dina 0.5.5.0 → 0.5.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dina/authentication/authentication.rb +4 -4
- data/lib/dina/models/agent/person.rb +1 -1
- data/lib/dina/models/base_model.rb +4 -0
- data/lib/dina/models/material_sample/collection.rb +2 -2
- data/lib/dina/models/object_store/derivative.rb +3 -2
- data/lib/dina/models/object_store/file.rb +13 -3
- data/lib/dina/models/object_store/object_store.rb +4 -0
- data/lib/dina/version.rb +1 -1
- data/lib/dina.rb +3 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4999fc970acb56ad2c4dcacb27124741d65c91b9dc00f13267b6da0f756ee3a9
|
4
|
+
data.tar.gz: 461e2ca77f1b4f4e7a675e42fc5f81008e967222211fb7ea4b0aa8435f869700
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2b3573481c0cfffd4fca4f32f8ff521ad357e7eb63598fc3d6ce77441d3a154c1b69bb382ef8473a0ce5525c8268042e4fd936bd203bc7970c720da320aba1b6
|
7
|
+
data.tar.gz: eabb87d0e292a17a4cd1769757c5de8e0862e3fc23aaeb81dcb1d3d5613f211e5937d42eddef28098872e195d8814431de9b33771e972ac6e5ab0a58e42ab84b
|
@@ -39,6 +39,10 @@ module Dina
|
|
39
39
|
@endpoint_url = options[:endpoint_url]
|
40
40
|
Keycloak.auth_server_url = options[:authorization_url]
|
41
41
|
Keycloak.realm = options[:realm]
|
42
|
+
|
43
|
+
if ::File.zero?(@token_store_file)
|
44
|
+
create_empty_token
|
45
|
+
end
|
42
46
|
end
|
43
47
|
|
44
48
|
# Gets, sets, and renews a Bearer access token as required
|
@@ -46,10 +50,6 @@ module Dina
|
|
46
50
|
#
|
47
51
|
# @return [String] the Bearer token
|
48
52
|
def self.header
|
49
|
-
if ::File.zero?(@token_store_file)
|
50
|
-
create_empty_token
|
51
|
-
end
|
52
|
-
|
53
53
|
if access_token.nil? || refresh_token.nil?
|
54
54
|
set_token
|
55
55
|
end
|
@@ -17,7 +17,7 @@ module Dina
|
|
17
17
|
has_many :identifiers, class_name: "Identifier"
|
18
18
|
|
19
19
|
validates_presence_of :familyNames, message: "familyNames is required"
|
20
|
-
validates_presence_of :displayName
|
20
|
+
validates_presence_of :displayName, message: "displayName is required"
|
21
21
|
|
22
22
|
def self.endpoint_path
|
23
23
|
"agent-api/"
|
@@ -23,6 +23,10 @@ module Dina
|
|
23
23
|
self.where("group.groupName": group).page(page).per(per)
|
24
24
|
end
|
25
25
|
|
26
|
+
def self.properties
|
27
|
+
self.schema.instance_values["properties"]
|
28
|
+
end
|
29
|
+
|
26
30
|
def initialize(params = {})
|
27
31
|
symbolized_params = params.transform_keys(&:to_sym)
|
28
32
|
params["id"] = SecureRandom.uuid if !symbolized_params[:id]
|
@@ -33,7 +33,7 @@ module Dina
|
|
33
33
|
# @param email [String] a name
|
34
34
|
# @return object [Object] a Collection object
|
35
35
|
def self.find_by_name(name)
|
36
|
-
where(name: name).all
|
36
|
+
where(name: name).all
|
37
37
|
end
|
38
38
|
|
39
39
|
# Finds a Collection object by code
|
@@ -41,7 +41,7 @@ module Dina
|
|
41
41
|
# @param code [String] a code
|
42
42
|
# @return object [Object] a Collection object
|
43
43
|
def self.find_by_code(code)
|
44
|
-
where(code: code).all
|
44
|
+
where(code: code).all
|
45
45
|
end
|
46
46
|
|
47
47
|
end
|
@@ -16,6 +16,7 @@ module Dina
|
|
16
16
|
belongs_to :ac_derived_from, shallow_path: true, class_name: "ObjectStore"
|
17
17
|
|
18
18
|
validates_presence_of :group, message: "group is required"
|
19
|
+
validates_presence_of :bucket, message: "bucket is required"
|
19
20
|
|
20
21
|
def self.endpoint_path
|
21
22
|
"objectstore-api/"
|
@@ -28,8 +29,8 @@ module Dina
|
|
28
29
|
private
|
29
30
|
|
30
31
|
def on_before_save
|
31
|
-
if self.bucket.nil?
|
32
|
-
self.bucket = self.group
|
32
|
+
if self.group && self.bucket.nil?
|
33
|
+
self.bucket = self.group.downcase
|
33
34
|
end
|
34
35
|
super
|
35
36
|
end
|
@@ -1,14 +1,23 @@
|
|
1
1
|
module Dina
|
2
|
-
class File
|
2
|
+
class File < BaseModel
|
3
3
|
attr_accessor :file_path, :group, :is_derivative, :id
|
4
4
|
|
5
|
+
def self.verify_ssl
|
6
|
+
begin
|
7
|
+
connection_options[:ssl][:verify]
|
8
|
+
rescue
|
9
|
+
true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
5
13
|
def self.find(group:, id:)
|
6
14
|
obj = self.new
|
7
15
|
obj.group = group
|
8
16
|
RestClient::Request.execute(
|
9
17
|
method: :get,
|
10
18
|
headers: { authorization: Dina::Authentication.header },
|
11
|
-
url: obj.url + "/#{id}"
|
19
|
+
url: obj.url + "/#{id}",
|
20
|
+
verify_ssl: verify_ssl
|
12
21
|
)
|
13
22
|
end
|
14
23
|
|
@@ -44,7 +53,8 @@ module Dina
|
|
44
53
|
payload: {
|
45
54
|
multipart: true,
|
46
55
|
file: file
|
47
|
-
}
|
56
|
+
},
|
57
|
+
verify_ssl: self.class.verify_ssl
|
48
58
|
)
|
49
59
|
json = JSON.parse(response, symbolize_names: true)
|
50
60
|
self.id = json[:uuid]
|
@@ -34,6 +34,7 @@ module Dina
|
|
34
34
|
has_many :derivatives, class_name: "Derivative"
|
35
35
|
|
36
36
|
validates_presence_of :group, message: "group is required"
|
37
|
+
validates_presence_of :bucket, message: "bucket is required"
|
37
38
|
validates_presence_of :dcFormat, message: "dcFormat is required"
|
38
39
|
validates_presence_of :dcType, message: "dcType is required"
|
39
40
|
validates_presence_of :xmpRightsUsageTerms, message: "xmpRightsUsageTerms is required"
|
@@ -63,6 +64,9 @@ module Dina
|
|
63
64
|
private
|
64
65
|
|
65
66
|
def on_before_save
|
67
|
+
if self.group && self.bucket.nil?
|
68
|
+
self.bucket = self.group.downcase
|
69
|
+
end
|
66
70
|
if !self.dcType.nil? && !self.class.accepted_types.include?(self.dcType)
|
67
71
|
raise PropertyValueInvalid, "#{self.class} is invalid. Accepted value for dcType is one of #{self.class.accepted_types.join(", ")}"
|
68
72
|
end
|
data/lib/dina/version.rb
CHANGED
data/lib/dina.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David P. Shorthouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|