dmp-dynamo_adapter 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 482c56531b1bce877f93b66efbdc8aefc4b2c120b5d81eb3713035dfb546149d
4
- data.tar.gz: bd9680232b0bbfcf92bdeec0b56ec62f335ccefb52acb9d902fc02e00e73659c
3
+ metadata.gz: 1ca8afd4ec83d2f0b665b3521e0bc9ebe7d1fbd051dea63676d9b4abaadc66ad
4
+ data.tar.gz: 8dbddd4cd81b89d25561948cf519a1fb27069d9aea10c9ca06956e74b4f7d243
5
5
  SHA512:
6
- metadata.gz: 4a2e6307f60b392621225539e2065633a64859b8dbc60bc83fa1cb559b6960d5f581eace2ada534bbce85d5bf009502642f9065e27fff683d57f967298fe415e
7
- data.tar.gz: dfd6fdaaf576d91b96fcdb37a7ce6f060a66f8d7ae4511205f08106259eecb6104a65f024cbe4c3ebc07e9221e83c266b627caeef7bc0827fb6f85524d6b082e
6
+ metadata.gz: 28e8eb60875cc65bbbbc660a4df24a9848bedb784c20f6b5345686d39e8ceb49235b7e3e2703f37fa68e04317c24d5c06758291d4707987f82095b1d4ba70824
7
+ data.tar.gz: 6482832fe3c392bd302832bad1722f331890b0b3c4892c913fea2b33fb39f2678cfe4e6e9d8c80ca5cfd9ce7345760db41f93cf2bb7726cfcc0d7edd7728cc31
@@ -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?
@@ -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
@@ -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?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dmp-dynamo_adapter
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - briri