dmp-dynamo_adapter 0.2.3 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dmp/dynamo_adapter.rb +5 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be57979b11b7ac8a35b820835768a0d3118b54dc82134ba099c24d338858d603
|
4
|
+
data.tar.gz: 4a4e3804862bce06a1aec7cf91b0b7164c2ad3a256ce4e57fb2a7e869dcdaaee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69d866715074b1b34444b30cc64489af45b10ca90f5aa27d079dba2f4bfac17feaac7e74fc60a8837465fb4a67c801dbdf762665d40408fd8938c204a53d2628
|
7
|
+
data.tar.gz: 53e24074d088a3d5a5d1232257679b6018a221d7c140fe5a91e012ba409d78383035e588e344fdcf5111bd970fe639851e785c32b170e348af15d02e0547bfe8
|
data/lib/dmp/dynamo_adapter.rb
CHANGED
@@ -105,13 +105,9 @@ p "FINDING BY PK: PK - #{p_key.inspect} / SK - #{s_key.inspect}"
|
|
105
105
|
|
106
106
|
# Try to find it first
|
107
107
|
result = find_by_json(json: json)
|
108
|
-
|
109
|
-
p "RESULT:"
|
110
|
-
pp result
|
111
|
-
|
112
108
|
return { status: 500, error: result.fetch(:error, MSG_DEFAULT) } if result[:status] == 500
|
113
109
|
# Abort if found
|
114
|
-
return { status: 400, error: MSG_EXISTS } if result
|
110
|
+
return { status: 400, error: MSG_EXISTS } if result.fetch(:items, []).any?
|
115
111
|
|
116
112
|
# allocate a DMP ID
|
117
113
|
p_key = Dmp::DmpIdHandler.preregister_dmp_id
|
@@ -274,7 +270,7 @@ p "FINDING BY PROVENANCE ID: #{json['dmp_id']['identifier']}"
|
|
274
270
|
},
|
275
271
|
filter_expression: 'SK = :version',
|
276
272
|
expression_attribute_values: {
|
277
|
-
':
|
273
|
+
':version': Dmp::MetadataHandler::LATEST_VERSION
|
278
274
|
},
|
279
275
|
return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
|
280
276
|
}
|
@@ -283,11 +279,11 @@ p "FINDING BY PROVENANCE ID: #{json['dmp_id']['identifier']}"
|
|
283
279
|
p "RESPONSE:"
|
284
280
|
pp response.data
|
285
281
|
|
286
|
-
return { status: 404, error: MSG_NOT_FOUND } if response.nil? || response[:
|
282
|
+
return { status: 404, error: MSG_NOT_FOUND } if response.nil? || response[:count] <= 0
|
287
283
|
|
288
284
|
# If we got a hit, fetch the DMP and return it.
|
289
|
-
find_by_pk(p_key: response.fetch(:
|
290
|
-
s_key: response.fetch(:
|
285
|
+
find_by_pk(p_key: response.fetch(:last_evaluated_key, {})[:hash_key_element],
|
286
|
+
s_key: response.fetch(:last_evaluated_key, {})[:range_key_element])
|
291
287
|
rescue Aws::Errors::ServiceError => e
|
292
288
|
{ status: 500, error: "#{MSG_DEFAULT} - #{e.message}" }
|
293
289
|
end
|