dmp-dynamo_adapter 0.2.0 → 0.2.1
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 +11 -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: 4c4c901b97437913b47803234f1f6bd80dfe048e307c452ce80b174f465d6de2
|
4
|
+
data.tar.gz: f5583c6531e487250ba8ccb0acf7e600a9ca46f7e8fee702bbc35bc5085e7198
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11246b4c0a980ffd9b4b43b4e9566f1ed29dd4f6db4068a96539cbd5d615bae24a1d720efba00a1bbc54ed3c38fdfa2b0405fd69ce6f1c6a0e2cdd6b73cf4383
|
7
|
+
data.tar.gz: 9fa961d5cf6405334791cebb57713265dccf5856d8bb853cefa37f0d0a2ab2040dfc88d6678718fae15603c82253d37d26df59d721c69edce529076e5ce0557b
|
data/lib/dmp/dynamo_adapter.rb
CHANGED
@@ -70,9 +70,6 @@ p "FINDING BY PK: PK - #{p_key.inspect} / SK - #{s_key.inspect}"
|
|
70
70
|
return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
|
71
71
|
}
|
72
72
|
)
|
73
|
-
|
74
|
-
pp response.data
|
75
|
-
|
76
73
|
return { status: 404, error: MSG_NOT_FOUND } if response[:item].nil?
|
77
74
|
|
78
75
|
{ status: 200, items: [response[:item]] }
|
@@ -106,9 +103,6 @@ pp response.data
|
|
106
103
|
json = prepare_json(json: json)
|
107
104
|
return { status: 400, error: MSG_DEFAULT } if json.nil? || @provenance.nil?
|
108
105
|
|
109
|
-
p "FINDING BY JSON"
|
110
|
-
pp json
|
111
|
-
|
112
106
|
# Try to find it first
|
113
107
|
result = find_by_json(json: json)
|
114
108
|
return { status: 500, error: MSG_DEFAULT } if result[:status] == 500
|
@@ -128,7 +122,11 @@ pp json
|
|
128
122
|
return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
|
129
123
|
}
|
130
124
|
)
|
131
|
-
|
125
|
+
|
126
|
+
p 'CREATED!?'
|
127
|
+
pp response.data
|
128
|
+
|
129
|
+
{ status: 201, items: [response.data] }
|
132
130
|
rescue Aws::DynamoDB::Errors::DuplicateItemException
|
133
131
|
{ status: 405, error: MSG_EXISTS }
|
134
132
|
rescue Aws::Errors::ServiceError => e
|
@@ -269,10 +267,14 @@ p "FINDING BY PROVENANCE ID: #{json['dmp_id']['identifier']}"
|
|
269
267
|
return_consumed_capacity: @debug_mode ? 'TOTAL' : 'NONE'
|
270
268
|
}
|
271
269
|
)
|
272
|
-
|
270
|
+
|
271
|
+
pp response.data
|
272
|
+
|
273
|
+
return { status: 404, error: MSG_NOT_FOUND } if response.nil? || response[:Count] <= 0
|
273
274
|
|
274
275
|
# If we got a hit, fetch the DMP and return it.
|
275
|
-
find_by_pk(p_key: response.
|
276
|
+
find_by_pk(p_key: response.fetch(:LastEvaluatedKey, {})[:HashKeyElement],
|
277
|
+
s_key: response.fetch(:LastEvaluatedKey, {})[:RangeKeyElement])
|
276
278
|
rescue Aws::Errors::ServiceError => e
|
277
279
|
{ status: 500, error: "#{MSG_DEFAULT} - #{e.message}" }
|
278
280
|
end
|