uc3-dmp-id 0.0.40 → 0.0.42
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uc3-dmp-id/creator.rb +7 -4
- data/lib/uc3-dmp-id/version.rb +1 -1
- 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: a0fef469bbcc71541818da66343150f5f8d836da7fea95e584814676504fc0ab
|
4
|
+
data.tar.gz: d33e5f4b658a3cc10af320a43712c39dc8876e94d463ca610b1c35f3845c8781
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2b2393f62e7a78df241ef998107817fe569c0de4362ca2e2451a471bb8e029717acad65dc48a4c12840885060110f750864d14a2d9ffaf3bd34f1eb78c59a05
|
7
|
+
data.tar.gz: 76b1ad4c83ebceccea8fdb0932615dfd930b306bfd604d240a39d42b21ffbcb694c17455d1596393f7ff71a00700c2b82c488d31739a07eca340d86c966b2c13
|
data/lib/uc3-dmp-id/creator.rb
CHANGED
@@ -19,16 +19,19 @@ module Uc3DmpId
|
|
19
19
|
raise DeleterError, MSG_DMP_FORBIDDEN unless provenance.is_a?(Hash) && !provenance['PK'].nil?
|
20
20
|
|
21
21
|
# Validate the incoming JSON first
|
22
|
-
|
22
|
+
json = Helper.parse_json(json: json)
|
23
|
+
errs = Validator.validate(mode: 'author', json: json)
|
23
24
|
raise CreatorError, errs.join(', ') if errs.is_a?(Array) && errs.any? && errs.first != Validator::MSG_VALID_JSON
|
24
25
|
|
25
26
|
# Fail if the provenance or owner affiliation are not defined
|
26
27
|
raise CreatorError, MSG_NO_PROVENANCE_OWNER if provenance.nil? || owner_org.nil?
|
27
28
|
raise CreatorError, MSG_NO_OWNER_ORG unless owner_org.is_a?(String) && !owner_org.strip.empty?
|
28
29
|
|
30
|
+
# TODO: Swap this out with the Finder search once the Dynamo indexes are working
|
29
31
|
# Try to find it first and Fail if found
|
30
|
-
result = Finder.by_json(json: json, debug: debug)
|
31
|
-
raise CreatorError, Uc3DmpId::MSG_DMP_EXISTS if result.is_a?(Hash)
|
32
|
+
# result = Finder.by_json(json: json, debug: debug)
|
33
|
+
# raise CreatorError, Uc3DmpId::MSG_DMP_EXISTS if result.is_a?(Hash)
|
34
|
+
raise CreatorError, Uc3DmpId::MSG_DMP_EXISTS unless json['PK'].nil?
|
32
35
|
|
33
36
|
p_key = _preregister_dmp_id(json: json, debug: debug)
|
34
37
|
raise CreatorError, MSG_UNABLE_TO_MINT if p_key.nil?
|
@@ -54,7 +57,7 @@ module Uc3DmpId
|
|
54
57
|
existing = json.fetch('dmp_id', {})
|
55
58
|
id = existing['identifier'].gsub(%r{https?://}, Helper::PK_DMP_PREFIX) if existing.is_a?(Hash) &&
|
56
59
|
!existing['identifier'].nil?
|
57
|
-
return id if existing['type'].downcase == 'doi' && !
|
60
|
+
return id if !id.nil? && existing['type'].downcase == 'doi' && !Finder.exists?(p_key: id)
|
58
61
|
|
59
62
|
dmp_id = ''
|
60
63
|
counter = 0
|
data/lib/uc3-dmp-id/version.rb
CHANGED