dmp-dynamo_adapter 0.2.2 → 0.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/dmp/dmp_id_handler.rb +3 -1
- data/lib/dmp/dynamo_adapter.rb +13 -0
- data/lib/dmp/metadata_handler.rb +2 -0
- 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: 1ca8afd4ec83d2f0b665b3521e0bc9ebe7d1fbd051dea63676d9b4abaadc66ad
|
4
|
+
data.tar.gz: 8dbddd4cd81b89d25561948cf519a1fb27069d9aea10c9ca06956e74b4f7d243
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 28e8eb60875cc65bbbbc660a4df24a9848bedb784c20f6b5345686d39e8ceb49235b7e3e2703f37fa68e04317c24d5c06758291d4707987f82095b1d4ba70824
|
7
|
+
data.tar.gz: 6482832fe3c392bd302832bad1722f331890b0b3c4892c913fea2b33fb39f2678cfe4e6e9d8c80ca5cfd9ce7345760db41f93cf2bb7726cfcc0d7edd7728cc31
|
data/lib/dmp/dmp_id_handler.rb
CHANGED
@@ -16,8 +16,10 @@ module Dmp
|
|
16
16
|
# Preassign a DMP ID that will leater be sent to the DOI minting authority (EZID)
|
17
17
|
def preregister_dmp_id
|
18
18
|
dmp_id = ''
|
19
|
-
|
20
19
|
counter = 0
|
20
|
+
|
21
|
+
p 'PREREGISTER DMP ID:'
|
22
|
+
|
21
23
|
while dmp_id == '' && counter <= 10
|
22
24
|
prefix = "#{ENV['DMP_ID_SHOULDER']}.#{SecureRandom.hex(4).upcase}"
|
23
25
|
dmp_id = prefix if find_by_pk(p_key: Dmp::MetadataHandler.append_pk_prefix(dmp: dmp_id)).empty?
|
data/lib/dmp/dynamo_adapter.rb
CHANGED
@@ -105,16 +105,28 @@ 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
|
+
|
108
112
|
return { status: 500, error: result.fetch(:error, MSG_DEFAULT) } if result[:status] == 500
|
109
113
|
# Abort if found
|
110
114
|
return { status: 400, error: MSG_EXISTS } if result[:items].any?
|
111
115
|
|
112
116
|
# allocate a DMP ID
|
113
117
|
p_key = Dmp::DmpIdHandler.preregister_dmp_id
|
118
|
+
|
119
|
+
p "PRE REGISTERED DMP ID: #{p_key.inspect}"
|
120
|
+
|
114
121
|
return { status: 500, error: MSG_NO_DMP_ID } if p_key.nil?
|
115
122
|
|
116
123
|
# Add the DMPHub specific attributes and then save
|
117
124
|
json = Dmp::MetadataHandler.annotate_json(provenance: @provenance, json: json, p_key: p_key)
|
125
|
+
|
126
|
+
p "ANNOTATED:"
|
127
|
+
pp json
|
128
|
+
|
129
|
+
p "PUTTING ITEM:"
|
118
130
|
response = @client.put_item(
|
119
131
|
{
|
120
132
|
table_name: ENV['AWS_DYNAMO_TABLE_NAME'],
|
@@ -268,6 +280,7 @@ p "FINDING BY PROVENANCE ID: #{json['dmp_id']['identifier']}"
|
|
268
280
|
}
|
269
281
|
)
|
270
282
|
|
283
|
+
p "RESPONSE:"
|
271
284
|
pp response.data
|
272
285
|
|
273
286
|
return { status: 404, error: MSG_NOT_FOUND } if response.nil? || response[:Count] <= 0
|
data/lib/dmp/metadata_handler.rb
CHANGED
@@ -60,6 +60,8 @@ module Dmp
|
|
60
60
|
def annotate_json(provenance:, p_key:, json:)
|
61
61
|
return nil if provenance.nil? || p_key.nil? || json.nil?
|
62
62
|
|
63
|
+
p "ANNOTATING METADATA:"
|
64
|
+
|
63
65
|
# Fail if the :PK does not match the :dmp_id if the json has a :PK
|
64
66
|
id = Dmp::DmpIdHandler.dmp_id_to_pk(json: json.fetch('dmp_id', {}))
|
65
67
|
id = nil if id != p_key && !json['PK'].nil?
|