dspace_rest_client 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dspace_rest_client.rb +3 -1
- data/lib/dspacerest/bitstream.rb +33 -32
- data/lib/dspacerest/builders/hash_builder.rb +16 -0
- data/lib/dspacerest/builders/model_builder.rb +61 -0
- data/lib/dspacerest/collection.rb +32 -23
- data/lib/dspacerest/community.rb +27 -19
- data/lib/dspacerest/item.rb +35 -42
- data/lib/dspacerest/metadata.rb +2 -2
- data/lib/dspacerest/policy.rb +41 -0
- data/lib/dspacerest/repositories/abstract_repository.rb +19 -11
- data/lib/dspacerest/repositories/bitstream_repository.rb +57 -48
- data/lib/dspacerest/repositories/collection_repository.rb +72 -63
- data/lib/dspacerest/repositories/community_repository.rb +71 -61
- data/lib/dspacerest/repositories/dspace_repository.rb +26 -26
- data/lib/dspacerest/repositories/item_repository.rb +75 -67
- data/lib/dspacerest/strategies/uploads/curl_strategy.rb +26 -26
- data/lib/dspacerest/strategies/uploads/rest_strategy.rb +16 -16
- metadata +4 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5beb7c52c728e6467bdbc68f0d8a7ca7fc6fa08c
|
4
|
+
data.tar.gz: 423f753535f47ec8f64fd9196ce47d32325ec856
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e132ad2bbdf9786150de16e123b38c5dac637e7373ae2b74d9017d3e4b403e0881443b715f00e003e1e0ee634d4ab41ccabeef7265d8c73a34adaa0b96d2c9b6
|
7
|
+
data.tar.gz: bcb42dcfb45d18da3370680147726536c4d48aed446905e5b5303c7498b49b253f92dc156ad1581635322f499fb2c5837ce81086626c12c9dedc612d74677eb5
|
data/lib/dspace_rest_client.rb
CHANGED
@@ -12,4 +12,6 @@ require File.dirname(__FILE__) + '/dspacerest/repositories/community_repository'
|
|
12
12
|
require File.dirname(__FILE__) + '/dspacerest/repositories/dspace_repository'
|
13
13
|
require File.dirname(__FILE__) + '/dspacerest/repositories/item_repository'
|
14
14
|
require File.dirname(__FILE__) + '/dspacerest/strategies/uploads/curl_strategy'
|
15
|
-
require File.dirname(__FILE__) + '/dspacerest/strategies/uploads/rest_strategy'
|
15
|
+
require File.dirname(__FILE__) + '/dspacerest/strategies/uploads/rest_strategy'
|
16
|
+
require File.dirname(__FILE__) + '/dspacerest/builders/hash_builder'
|
17
|
+
require File.dirname(__FILE__) + '/dspacerest/builders/model_builder'
|
data/lib/dspacerest/bitstream.rb
CHANGED
@@ -9,42 +9,43 @@ module DSpaceRest
|
|
9
9
|
:sequence_id, :policies
|
10
10
|
|
11
11
|
def initialize args
|
12
|
-
@id = args['id']
|
13
|
-
@name = args['name']
|
14
|
-
@type = args['type']
|
15
|
-
@link = args['link']
|
16
|
-
@bundle_name = args['bundleName']
|
17
|
-
@description = args['description']
|
18
|
-
@format = args['format']
|
19
|
-
@mime_type = args['mimeType']
|
20
|
-
@size_bytes = args['sizeBytes']
|
21
|
-
@parent_object = args['parentObject']
|
22
|
-
@retrieve_link = args['retrieveLink']
|
23
|
-
@check_sum = args['checkSum']
|
24
|
-
@sequence_id = args['sequenceId']
|
25
|
-
@policies = args['policies']
|
26
|
-
@expand = args['expand']
|
12
|
+
@id = args['id']
|
13
|
+
@name = args['name']
|
14
|
+
@type = args['type']
|
15
|
+
@link = args['link']
|
16
|
+
@bundle_name = args['bundleName']
|
17
|
+
@description = args['description']
|
18
|
+
@format = args['format']
|
19
|
+
@mime_type = args['mimeType']
|
20
|
+
@size_bytes = args['sizeBytes']
|
21
|
+
@parent_object = args['parentObject']
|
22
|
+
@retrieve_link = args['retrieveLink']
|
23
|
+
@check_sum = args['checkSum']
|
24
|
+
@sequence_id = args['sequenceId']
|
25
|
+
@policies = DSpaceRest::Builders::ModelBuilder.build_policies(args['policies'])
|
26
|
+
@expand = args['expand']
|
27
27
|
end
|
28
28
|
|
29
29
|
def to_h
|
30
|
-
h =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
30
|
+
h = {
|
31
|
+
id: @id,
|
32
|
+
name: @name,
|
33
|
+
type: @type,
|
34
|
+
link: @link,
|
35
|
+
bundleName: @bundle_name,
|
36
|
+
description: @description,
|
37
|
+
format: @format,
|
38
|
+
mimeType: @mime_type,
|
39
|
+
sizeBytes: @size_bytes,
|
40
|
+
parentObject: @parent_object,
|
41
|
+
retrieveLink: @retrieve_link,
|
42
|
+
checkSum: @check_sum,
|
43
|
+
sequenceId: @sequence_id,
|
44
|
+
policies: @policies,
|
45
|
+
expand: @expand
|
46
|
+
}
|
47
|
+
|
46
48
|
h
|
47
49
|
end
|
48
|
-
|
49
50
|
end
|
50
51
|
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module DSpaceRest
|
2
|
+
module Builders
|
3
|
+
module ModelBuilder
|
4
|
+
|
5
|
+
def self.build_communities(communities=[])
|
6
|
+
return communities if communities.nil?
|
7
|
+
colls = []
|
8
|
+
communities.each do |c|
|
9
|
+
colls << DSpaceRest::Community.new(c)
|
10
|
+
end
|
11
|
+
colls
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.build_collections(collections=[])
|
15
|
+
return collections if collections.nil?
|
16
|
+
colls = []
|
17
|
+
collections.each do |c|
|
18
|
+
colls << DSpaceRest::Collection.new(c)
|
19
|
+
end
|
20
|
+
colls
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.build_items(items=[])
|
24
|
+
return items if items.nil?
|
25
|
+
colls = []
|
26
|
+
items.each do |c|
|
27
|
+
colls << DSpaceRest::Item.new(c)
|
28
|
+
end
|
29
|
+
colls
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.build_bitstreams(bitstreams=[])
|
33
|
+
return bitstreams if bitstreams.nil?
|
34
|
+
colls = []
|
35
|
+
bitstreams.each do |c|
|
36
|
+
colls << DSpaceRest::Bitstream.new(c)
|
37
|
+
end
|
38
|
+
colls
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.build_metadatas(metadatas=[])
|
42
|
+
return metadatas if metadatas.nil?
|
43
|
+
colls = []
|
44
|
+
metadatas.each do |c|
|
45
|
+
colls << DSpaceRest::Metadata.new(c)
|
46
|
+
end
|
47
|
+
colls
|
48
|
+
end
|
49
|
+
|
50
|
+
def self.build_policies(policies=[])
|
51
|
+
return policies if policies.nil?
|
52
|
+
colls = []
|
53
|
+
policies.each do |c|
|
54
|
+
colls << DSpaceRest::Policy.new(c)
|
55
|
+
end
|
56
|
+
colls
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
@@ -6,7 +6,7 @@ module DSpaceRest
|
|
6
6
|
|
7
7
|
attr_reader :id, :handle, :type, :link, :parent_community,
|
8
8
|
:parent_community_list, :items,
|
9
|
-
:
|
9
|
+
:number_items, :expand
|
10
10
|
|
11
11
|
def initialize args
|
12
12
|
@id = args['id']
|
@@ -15,38 +15,47 @@ module DSpaceRest
|
|
15
15
|
@type = args['type']
|
16
16
|
@link = args['link']
|
17
17
|
@logo = args['logo']
|
18
|
-
@parent_community = args['parentCommunity']
|
19
|
-
@parent_community_list = args['parentCommunityList']
|
20
|
-
@items = args['items']
|
21
18
|
@license = args['license']
|
22
19
|
@copyright_text = args['copyrightText']
|
23
20
|
@introductory_text = args['introductoryText']
|
24
21
|
@short_description = args['shortDescription']
|
25
22
|
@sidebar_text = args['sidebarText']
|
26
|
-
@number_items = args['
|
23
|
+
@number_items = args['numberItems']
|
27
24
|
@expand = args['expand']
|
25
|
+
|
26
|
+
@parent_community = DSpaceRest::Community.new(args['parentCommunity']) unless args['parentCommunity'].nil?
|
27
|
+
@parent_community_list = DSpaceRest::Builders::ModelBuilder.build_communities(args['parentCommunityList'])
|
28
|
+
@items = DSpaceRest::Builders::ModelBuilder.build_items(args['items'])
|
28
29
|
end
|
29
30
|
|
30
31
|
def to_h
|
31
|
-
h =
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
32
|
+
h = {
|
33
|
+
id: @id,
|
34
|
+
name: @name,
|
35
|
+
handle: @handle,
|
36
|
+
type: @type,
|
37
|
+
link: @link,
|
38
|
+
logo: @logo,
|
39
|
+
parentCommunity: @parent_community,
|
40
|
+
parentCommunitList: @parent_community_list,
|
41
|
+
items: obj2hash(@items),
|
42
|
+
license: @license,
|
43
|
+
copyrightText: @copyright_text,
|
44
|
+
introductoryText: @introductory_text,
|
45
|
+
shortDescription: @short_description,
|
46
|
+
sidebarText: @sidebar_text,
|
47
|
+
numberItems: @number_items,
|
48
|
+
expand: @expand
|
49
|
+
}
|
50
|
+
|
48
51
|
h
|
49
52
|
end
|
50
53
|
|
54
|
+
private
|
55
|
+
|
56
|
+
def obj2hash(list)
|
57
|
+
DSpaceRest::Builders::HashBuilder.models2hash list
|
58
|
+
end
|
59
|
+
|
51
60
|
end
|
52
|
-
end
|
61
|
+
end
|
data/lib/dspacerest/community.rb
CHANGED
@@ -14,36 +14,44 @@ module DSpaceRest
|
|
14
14
|
@type = args['type']
|
15
15
|
@link = args['link']
|
16
16
|
@logo = args['logo']
|
17
|
-
@parent_community = args['parentCommunity']
|
17
|
+
@parent_community = DSpaceRest::Community.new(args['parentCommunity']) unless args['parentCommunity'].nil?
|
18
18
|
@copyright_text = args['copyrightText']
|
19
19
|
@introductory_text = args['introductoryText']
|
20
20
|
@short_description = args['shortDescription']
|
21
21
|
@sidebar_text = args['sidebarText']
|
22
22
|
@count_items = args['countItems']
|
23
|
-
@sub_communities = args['subcommunities']
|
24
|
-
@collections = args['collections']
|
23
|
+
@sub_communities = DSpaceRest::Builders::ModelBuilder.build_communities(args['subcommunities'])
|
24
|
+
@collections = DSpaceRest::Builders::ModelBuilder.build_collections(args['collections'])
|
25
25
|
@expand = args['expand']
|
26
26
|
end
|
27
27
|
|
28
28
|
def to_h
|
29
|
-
h =
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
29
|
+
h = {
|
30
|
+
id: @id,
|
31
|
+
name: @name,
|
32
|
+
handle: @handle,
|
33
|
+
type: @type,
|
34
|
+
link: @link,
|
35
|
+
logo: @logo,
|
36
|
+
parentCommunity: @parent_community,
|
37
|
+
subcommunities: obj2hash(@sub_communities),
|
38
|
+
collections: obj2hash(@collections),
|
39
|
+
copyrightText: @copyright_text,
|
40
|
+
introductoryText: @introductory_text,
|
41
|
+
shortDescription: @short_description,
|
42
|
+
sidebarText: @sidebar_text,
|
43
|
+
countItems: @count_items,
|
44
|
+
expand: @expand
|
45
|
+
}
|
46
|
+
|
45
47
|
h
|
46
48
|
end
|
47
49
|
|
50
|
+
private
|
51
|
+
|
52
|
+
def obj2hash(list)
|
53
|
+
DSpaceRest::Builders::HashBuilder.models2hash list
|
54
|
+
end
|
55
|
+
|
48
56
|
end
|
49
57
|
end
|
data/lib/dspacerest/item.rb
CHANGED
@@ -5,46 +5,44 @@ module DSpaceRest
|
|
5
5
|
|
6
6
|
attr_accessor :name, :archived, :withdrawn
|
7
7
|
|
8
|
-
attr_reader :id, :handle, :type, :link, :last_modified,
|
9
|
-
:
|
8
|
+
attr_reader :id, :handle, :type, :link, :last_modified, :parent_collection,
|
9
|
+
:parent_collection_list, :parent_community_list, :bit_streams,
|
10
10
|
:expand, :metadata
|
11
11
|
|
12
12
|
def initialize args
|
13
|
-
@id = args['id']
|
14
|
-
@name = args['name']
|
15
|
-
@handle = args['handle']
|
16
|
-
@type = args['type']
|
17
|
-
@link = args['link']
|
18
|
-
@last_modified = args['lastModified']
|
19
|
-
@parent_collection = args['parentCollection']
|
20
|
-
@parent_collection_list = args['parentCollectionList']
|
21
|
-
@parent_community_list = args['parentCommunityList']
|
22
|
-
@bit_streams = args['bitstreams']
|
23
|
-
@archived = args['archived']
|
24
|
-
@withdrawn = args['withdrawn']
|
25
|
-
@expand = args['expand']
|
26
|
-
@metadata = []
|
13
|
+
@id = args['id']
|
14
|
+
@name = args['name']
|
15
|
+
@handle = args['handle']
|
16
|
+
@type = args['type']
|
17
|
+
@link = args['link']
|
18
|
+
@last_modified = args['lastModified']
|
19
|
+
@parent_collection = DSpaceRest::Collection.new(args['parentCollection']) unless args['parentCollection'].nil?
|
20
|
+
@parent_collection_list = DSpaceRest::Builders::ModelBuilder.build_collections(args['parentCollectionList'])
|
21
|
+
@parent_community_list = DSpaceRest::Builders::ModelBuilder.build_communities(args['parentCommunityList'])
|
22
|
+
@bit_streams = DSpaceRest::Builders::ModelBuilder.build_bitstreams(args['bitstreams'])
|
23
|
+
@archived = args['archived']
|
24
|
+
@withdrawn = args['withdrawn']
|
25
|
+
@expand = args['expand']
|
26
|
+
@metadata = DSpaceRest::Builders::ModelBuilder.build_metadatas(args['metadata'])
|
27
27
|
end
|
28
28
|
|
29
29
|
def to_h
|
30
|
-
h =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
h["metadata"] = metadata2hash @metadata
|
47
|
-
end
|
30
|
+
h = {
|
31
|
+
id: @id,
|
32
|
+
name: @name,
|
33
|
+
handle: @handle,
|
34
|
+
type: @type,
|
35
|
+
link: @link,
|
36
|
+
lastModified: @last_modified,
|
37
|
+
parentCollection: @parent_collection.to_h,
|
38
|
+
parentCollectionList: obj2hash(@parent_collection_list),
|
39
|
+
parentCommunityList: obj2hash(@parent_community_list),
|
40
|
+
bitstreams: obj2hash(@bit_streams),
|
41
|
+
archived: @archived,
|
42
|
+
withdrawn: @withdrawn,
|
43
|
+
expand: @expand,
|
44
|
+
metadata: obj2hash(@metadata)
|
45
|
+
}
|
48
46
|
|
49
47
|
h
|
50
48
|
end
|
@@ -65,14 +63,9 @@ module DSpaceRest
|
|
65
63
|
|
66
64
|
private
|
67
65
|
|
68
|
-
def
|
69
|
-
|
70
|
-
@metadata.each do |m|
|
71
|
-
hash << m.to_h
|
72
|
-
end
|
73
|
-
|
74
|
-
hash
|
66
|
+
def obj2hash(list)
|
67
|
+
DSpaceRest::Builders::HashBuilder.models2hash list
|
75
68
|
end
|
76
69
|
|
77
70
|
end
|
78
|
-
end
|
71
|
+
end
|
data/lib/dspacerest/metadata.rb
CHANGED
@@ -6,11 +6,11 @@ module DSpaceRest
|
|
6
6
|
def initialize args
|
7
7
|
@key = args['key']
|
8
8
|
@value = args['value']
|
9
|
-
@language = args['language']
|
9
|
+
@language = args['language'] || nil
|
10
10
|
end
|
11
11
|
|
12
12
|
def to_h
|
13
|
-
|
13
|
+
{key: @key, value: @value, language: @language}
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
module DSpaceRest
|
2
|
+
class Policy
|
3
|
+
|
4
|
+
attr_reader :id, :action, :eperson_id, :group_id,
|
5
|
+
:resource_id, :resource_type, :rp_description,
|
6
|
+
:rp_name, :rp_type, :start_date, :end_date
|
7
|
+
|
8
|
+
def initialize args
|
9
|
+
@id = args['id']
|
10
|
+
@action = args['action']
|
11
|
+
@eperson_id = args['epersonId']
|
12
|
+
@group_id = args['groupId']
|
13
|
+
@resource_id = args['resourceId']
|
14
|
+
@resource_type = args['resourceType']
|
15
|
+
@rp_description = args['rpDescription']
|
16
|
+
@rp_name = args['rpName']
|
17
|
+
@rp_type = args['rpType']
|
18
|
+
@start_date = args['startDate']
|
19
|
+
@end_date = args['endDate']
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_h
|
23
|
+
h = {
|
24
|
+
id: @id,
|
25
|
+
action: @action,
|
26
|
+
epersonId: @eperson_id,
|
27
|
+
groupId: @group_id,
|
28
|
+
resourceId: @resource_id,
|
29
|
+
resourceType: @resource_type,
|
30
|
+
rpDescription: @rp_description,
|
31
|
+
rpName: @rp_name,
|
32
|
+
rpType: @rp_type,
|
33
|
+
startDate: @start_date,
|
34
|
+
endDate: @end_date
|
35
|
+
}
|
36
|
+
|
37
|
+
h
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
@@ -1,12 +1,20 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Repositories
|
3
|
-
class AbstractRepository
|
4
|
-
attr_reader :rest_client
|
5
|
-
|
6
|
-
def initialize(rest_client)
|
7
|
-
@rest_client = rest_client
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
module DSpaceRest
|
2
|
+
module Repositories
|
3
|
+
class AbstractRepository
|
4
|
+
attr_reader :rest_client
|
5
|
+
|
6
|
+
def initialize(rest_client)
|
7
|
+
@rest_client = rest_client
|
8
|
+
end
|
9
|
+
|
10
|
+
protected
|
11
|
+
|
12
|
+
def build_expand_uri(expand = nil)
|
13
|
+
if expandable_properties.include? expand
|
14
|
+
"expand=#{expand}"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
12
20
|
end
|
@@ -1,49 +1,58 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Repositories
|
3
|
-
class BitstreamRepository < AbstractRepository
|
4
|
-
|
5
|
-
# Bitstreams are files. They have a filename, size (in bytes), and a file format.
|
6
|
-
# Typically in DSpace, the Bitstream will the "full text" article, or some other media.
|
7
|
-
# Some files are the actual file that was uploaded (tagged with bundleName:ORIGINAL),
|
8
|
-
# others are DSpace-generated files that are derivatives or renditions, such as text-extraction, or thumbnails.
|
9
|
-
# You can download files/bitstreams.
|
10
|
-
# DSpace doesn't really limit the type of files that it takes in, so this could be PDF, JPG, audio, video, zip,
|
11
|
-
# or other.
|
12
|
-
# Also, the logo for a Collection or a Community, is also a Bitstream.
|
13
|
-
|
14
|
-
# √ GET /bitstreams - Return all bitstreams in DSpace.
|
15
|
-
# √ GET /bitstreams/{bitstream id} - Return bitstream.
|
16
|
-
# GET /bitstreams/{bitstream id}/policy - Return bitstream policies.
|
17
|
-
# √ GET /bitstreams/{bitstream id}/retrieve - Return data of bitstream.
|
18
|
-
# POST /bitstreams/{bitstream id}/policy - Add policy to item. You must post a ResourcePolicy
|
19
|
-
# PUT /bitstreams/{bitstream id}/data - Update data/file of bitstream. You must put the data
|
20
|
-
# √ PUT /bitstreams/{bitstream id} - Update metadata of bitstream. You must put a Bitstream, does not alter the file/data
|
21
|
-
# DELETE /bitstreams/{bitstream id} - Delete bitstream from DSpace.
|
22
|
-
# DELETE /bitstreams/{bitstream id}/policy/{policy_id} - Delete bitstream policy.
|
23
|
-
|
24
|
-
def get_bitstream_by_id(id)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
1
|
+
module DSpaceRest
|
2
|
+
module Repositories
|
3
|
+
class BitstreamRepository < AbstractRepository
|
4
|
+
|
5
|
+
# Bitstreams are files. They have a filename, size (in bytes), and a file format.
|
6
|
+
# Typically in DSpace, the Bitstream will the "full text" article, or some other media.
|
7
|
+
# Some files are the actual file that was uploaded (tagged with bundleName:ORIGINAL),
|
8
|
+
# others are DSpace-generated files that are derivatives or renditions, such as text-extraction, or thumbnails.
|
9
|
+
# You can download files/bitstreams.
|
10
|
+
# DSpace doesn't really limit the type of files that it takes in, so this could be PDF, JPG, audio, video, zip,
|
11
|
+
# or other.
|
12
|
+
# Also, the logo for a Collection or a Community, is also a Bitstream.
|
13
|
+
|
14
|
+
# √ GET /bitstreams - Return all bitstreams in DSpace.
|
15
|
+
# √ GET /bitstreams/{bitstream id} - Return bitstream.
|
16
|
+
# GET /bitstreams/{bitstream id}/policy - Return bitstream policies.
|
17
|
+
# √ GET /bitstreams/{bitstream id}/retrieve - Return data of bitstream.
|
18
|
+
# POST /bitstreams/{bitstream id}/policy - Add policy to item. You must post a ResourcePolicy
|
19
|
+
# PUT /bitstreams/{bitstream id}/data - Update data/file of bitstream. You must put the data
|
20
|
+
# √ PUT /bitstreams/{bitstream id} - Update metadata of bitstream. You must put a Bitstream, does not alter the file/data
|
21
|
+
# DELETE /bitstreams/{bitstream id} - Delete bitstream from DSpace.
|
22
|
+
# DELETE /bitstreams/{bitstream id}/policy/{policy_id} - Delete bitstream policy.
|
23
|
+
|
24
|
+
def get_bitstream_by_id(id, expand = nil)
|
25
|
+
expand_uri = build_expand_uri(expand)
|
26
|
+
response = rest_client["/bitstreams/#{id}?#{expand_uri}"].get
|
27
|
+
DSpaceRest::Bitstream.new(JSON.parse(response))
|
28
|
+
end
|
29
|
+
|
30
|
+
def get_all_bitstreams(expand = nil)
|
31
|
+
expand_uri = build_expand_uri(expand)
|
32
|
+
response = rest_client["/bitstreams?#{expand_uri}"].get
|
33
|
+
bit_streams = []
|
34
|
+
JSON.parse(response).each do |bits|
|
35
|
+
bit_streams << DSpaceRest::Bitstream.new(bits)
|
36
|
+
end
|
37
|
+
bit_streams
|
38
|
+
end
|
39
|
+
|
40
|
+
def retrieve_data(bitstream)
|
41
|
+
response = rest_client["/bitstreams/#{bitstream.id}/retrieve"].get
|
42
|
+
end
|
43
|
+
|
44
|
+
def update(bitstream)
|
45
|
+
valid_keys=['name', 'description', 'sequenceId']
|
46
|
+
form = JSON.generate(bitstream.to_h.select { |k, v| valid_keys.include? k })
|
47
|
+
response = rest_client["/bitstreams/#{bitstream.id}"].put form
|
48
|
+
end
|
49
|
+
|
50
|
+
private
|
51
|
+
|
52
|
+
def expandable_properties
|
53
|
+
["parent","policies","all"]
|
54
|
+
end
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
49
58
|
end
|
@@ -1,64 +1,73 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Repositories
|
3
|
-
class CollectionRepository < AbstractRepository
|
4
|
-
# Collections in DSpace are containers of Items
|
5
|
-
|
6
|
-
# √ GET /communities/{communityId}/collections - Returns array of collections of community.
|
7
|
-
# √ GET /collections - Return all collections of DSpace in array.
|
8
|
-
# √ GET /collections/{collectionId} - Return collection with id.
|
9
|
-
# √ GET /collections/{collectionId}/items - Return all items of collection.
|
10
|
-
# √ POST /communities/{communityId}/collections - Create new collections in community. You must post Collection.
|
11
|
-
# √ POST /collections/{collectionId}/items - Create posted item in collection. You must post an Item
|
12
|
-
# POST /collections/find-collection - Find collection by passed name.
|
13
|
-
# PUT /collections/{collectionId} - Update collection. You must put Collection.
|
14
|
-
# DELETE /collections/{collectionId} - Delete collection from DSpace.
|
15
|
-
# DELETE /collections/{collectionId}/items/{itemId} - Delete item in collection.
|
16
|
-
# DELETE /communities/{communityId}/collections/{collectionId} - Delete collection in community.
|
17
|
-
|
18
|
-
def get_collection_items(collection)
|
19
|
-
response = rest_client["/collections/#{collection.id}/items"].get
|
20
|
-
items = []
|
21
|
-
JSON.parse(response).each do |item|
|
22
|
-
items << DSpaceRest::Item.new(item)
|
23
|
-
end
|
24
|
-
items
|
25
|
-
end
|
26
|
-
|
27
|
-
def get_collection_by_id(id)
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
1
|
+
module DSpaceRest
|
2
|
+
module Repositories
|
3
|
+
class CollectionRepository < AbstractRepository
|
4
|
+
# Collections in DSpace are containers of Items
|
5
|
+
|
6
|
+
# √ GET /communities/{communityId}/collections - Returns array of collections of community.
|
7
|
+
# √ GET /collections - Return all collections of DSpace in array.
|
8
|
+
# √ GET /collections/{collectionId} - Return collection with id.
|
9
|
+
# √ GET /collections/{collectionId}/items - Return all items of collection.
|
10
|
+
# √ POST /communities/{communityId}/collections - Create new collections in community. You must post Collection.
|
11
|
+
# √ POST /collections/{collectionId}/items - Create posted item in collection. You must post an Item
|
12
|
+
# POST /collections/find-collection - Find collection by passed name.
|
13
|
+
# PUT /collections/{collectionId} - Update collection. You must put Collection.
|
14
|
+
# DELETE /collections/{collectionId} - Delete collection from DSpace.
|
15
|
+
# DELETE /collections/{collectionId}/items/{itemId} - Delete item in collection.
|
16
|
+
# DELETE /communities/{communityId}/collections/{collectionId} - Delete collection in community.
|
17
|
+
|
18
|
+
def get_collection_items(collection)
|
19
|
+
response = rest_client["/collections/#{collection.id}/items"].get
|
20
|
+
items = []
|
21
|
+
JSON.parse(response).each do |item|
|
22
|
+
items << DSpaceRest::Item.new(item)
|
23
|
+
end
|
24
|
+
items
|
25
|
+
end
|
26
|
+
|
27
|
+
def get_collection_by_id(id, expand = nil)
|
28
|
+
expand_uri = build_expand_uri(expand)
|
29
|
+
response = rest_client["/collections/#{id}?#{expand_uri}"].get
|
30
|
+
DSpaceRest::Collection.new(JSON.parse(response))
|
31
|
+
end
|
32
|
+
|
33
|
+
def get_all_collections(expand = nil)
|
34
|
+
expand_uri = build_expand_uri(expand)
|
35
|
+
response = rest_client["/collections?#{expand_uri}"].get
|
36
|
+
collections = []
|
37
|
+
JSON.parse(response).each do |coll|
|
38
|
+
collections << DSpaceRest::Collection.new(coll)
|
39
|
+
end
|
40
|
+
collections
|
41
|
+
end
|
42
|
+
|
43
|
+
def get_collections_of(community, expand = nil)
|
44
|
+
expand_uri = build_expand_uri(expand)
|
45
|
+
response = rest_client["/communities/#{community.id}/collections?#{expand_uri}"].get
|
46
|
+
collections = []
|
47
|
+
JSON.parse(response).each do |coll|
|
48
|
+
collections << DSpaceRest::Collection.new(coll)
|
49
|
+
end
|
50
|
+
collections
|
51
|
+
end
|
52
|
+
|
53
|
+
def create_collection_for(community, collection)
|
54
|
+
form = JSON.generate(collection.to_h)
|
55
|
+
response = rest_client["/communities/#{community.id}/collections"].post form
|
56
|
+
DSpaceRest::Collection.new(JSON.parse(response))
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_item_for(collection, item)
|
60
|
+
form = JSON.generate({"metadata" => item.to_h["metadata"]})
|
61
|
+
response = rest_client["/collections/#{collection.id}/items"].post form
|
62
|
+
DSpaceRest::Item.new(JSON.parse(response))
|
63
|
+
end
|
64
|
+
|
65
|
+
private
|
66
|
+
|
67
|
+
def expandable_properties
|
68
|
+
["parentCommunityList","parentCommunity","items","license","logo","all"]
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
64
73
|
end
|
@@ -1,62 +1,72 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Repositories
|
3
|
-
class CommunityRepository < AbstractRepository
|
4
|
-
# Communities in DSpace are used for organization and hierarchy, and are containers that hold sub-Communities and Collections.
|
5
|
-
|
6
|
-
# √ GET /communities - Returns array of all communities in DSpace.
|
7
|
-
# √ GET /communities/top-communities - Returns array of all top communities in DSpace
|
8
|
-
# √ GET /communities/{communityId} - Returns community
|
9
|
-
# √ GET /communities/{communityId}/communities - Returns array of subcommunities of community.
|
10
|
-
# √ POST /communities - Create new community at top level. You must post community.
|
11
|
-
# √ POST /communities/{communityId}/communities - Create new subcommunity in community. You must post Community.
|
12
|
-
# PUT /communities/{communityId} - Update community. You must put Community
|
13
|
-
# DELETE /communities/{communityId} - Delete community.
|
14
|
-
# DELETE /communities/{communityId}/communities/{communityId2} - Delete subcommunity in community.
|
15
|
-
|
16
|
-
def get_community_by_id(id)
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
communities
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
1
|
+
module DSpaceRest
|
2
|
+
module Repositories
|
3
|
+
class CommunityRepository < AbstractRepository
|
4
|
+
# Communities in DSpace are used for organization and hierarchy, and are containers that hold sub-Communities and Collections.
|
5
|
+
|
6
|
+
# √ GET /communities - Returns array of all communities in DSpace.
|
7
|
+
# √ GET /communities/top-communities - Returns array of all top communities in DSpace
|
8
|
+
# √ GET /communities/{communityId} - Returns community
|
9
|
+
# √ GET /communities/{communityId}/communities - Returns array of subcommunities of community.
|
10
|
+
# √ POST /communities - Create new community at top level. You must post community.
|
11
|
+
# √ POST /communities/{communityId}/communities - Create new subcommunity in community. You must post Community.
|
12
|
+
# PUT /communities/{communityId} - Update community. You must put Community
|
13
|
+
# DELETE /communities/{communityId} - Delete community.
|
14
|
+
# DELETE /communities/{communityId}/communities/{communityId2} - Delete subcommunity in community.
|
15
|
+
|
16
|
+
def get_community_by_id(id, expand = nil)
|
17
|
+
expand_uri = build_expand_uri(expand)
|
18
|
+
response = rest_client["/communities/#{id}?#{expand_uri}"].get
|
19
|
+
DSpaceRest::Community.new(JSON.parse(response))
|
20
|
+
end
|
21
|
+
|
22
|
+
def get_all_communities(expand = nil)
|
23
|
+
expand_uri = build_expand_uri(expand)
|
24
|
+
response = rest_client["/communities?#{expand_uri}"].get
|
25
|
+
communities = []
|
26
|
+
JSON.parse(response).each do |comm|
|
27
|
+
communities << DSpaceRest::Community.new(comm)
|
28
|
+
end
|
29
|
+
communities
|
30
|
+
end
|
31
|
+
|
32
|
+
def get_top_communities(expand = nil)
|
33
|
+
expand_uri = build_expand_uri(expand)
|
34
|
+
response = rest_client["/communities/top-communities?#{expand_uri}"].get
|
35
|
+
communities = []
|
36
|
+
JSON.parse(response).each do |comm|
|
37
|
+
communities << DSpaceRest::Community.new(comm)
|
38
|
+
end
|
39
|
+
communities
|
40
|
+
end
|
41
|
+
|
42
|
+
def get_subcommunities_of(community, expand = nil)
|
43
|
+
expand_uri = build_expand_uri(expand)
|
44
|
+
response = rest_client["/communities/#{community.id}/communities?#{expand_uri}"].get
|
45
|
+
communities = []
|
46
|
+
JSON.parse(response).each do |comm|
|
47
|
+
communities << DSpaceRest::Community.new(comm)
|
48
|
+
end
|
49
|
+
communities
|
50
|
+
end
|
51
|
+
|
52
|
+
def create_community(community)
|
53
|
+
form = JSON.generate(community.to_h)
|
54
|
+
response = rest_client["/communities"].post form
|
55
|
+
end
|
56
|
+
|
57
|
+
def create_subcommunity_of(community, subcommunity)
|
58
|
+
form = JSON.generate(subcommunity.to_h)
|
59
|
+
response = rest_client["/communities/#{community.id}/communities"].post form
|
60
|
+
|
61
|
+
DSpaceRest::Community.new(JSON.parse(response))
|
62
|
+
end
|
63
|
+
|
64
|
+
private
|
65
|
+
|
66
|
+
def expandable_properties
|
67
|
+
["parentCommunity","collections","subCommunities","logo","all"]
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
62
72
|
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Repositories
|
3
|
-
class DspaceRepository < AbstractRepository
|
4
|
-
|
5
|
-
def bitstream_repository
|
6
|
-
BitstreamRepository.new rest_client
|
7
|
-
end
|
8
|
-
|
9
|
-
def collection_repository
|
10
|
-
CollectionRepository.new rest_client
|
11
|
-
end
|
12
|
-
|
13
|
-
def community_repository
|
14
|
-
CommunityRepository.new rest_client
|
15
|
-
end
|
16
|
-
|
17
|
-
def item_repository
|
18
|
-
ItemRepository.new rest_client
|
19
|
-
end
|
20
|
-
|
21
|
-
def metadata_repository
|
22
|
-
MetadataRepository.new rest_client
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
26
|
-
end
|
1
|
+
module DSpaceRest
|
2
|
+
module Repositories
|
3
|
+
class DspaceRepository < AbstractRepository
|
4
|
+
|
5
|
+
def bitstream_repository
|
6
|
+
BitstreamRepository.new rest_client
|
7
|
+
end
|
8
|
+
|
9
|
+
def collection_repository
|
10
|
+
CollectionRepository.new rest_client
|
11
|
+
end
|
12
|
+
|
13
|
+
def community_repository
|
14
|
+
CommunityRepository.new rest_client
|
15
|
+
end
|
16
|
+
|
17
|
+
def item_repository
|
18
|
+
ItemRepository.new rest_client
|
19
|
+
end
|
20
|
+
|
21
|
+
def metadata_repository
|
22
|
+
MetadataRepository.new rest_client
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
@@ -1,68 +1,76 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Repositories
|
3
|
-
class ItemRepository < AbstractRepository
|
4
|
-
# Items in DSpace represent a "work" and combine metadata and files, known as Bitstreams
|
5
|
-
|
6
|
-
# √ GET /items - Return list of items.
|
7
|
-
# √ GET /items/{item id} - Return item.
|
8
|
-
# √ GET /items/{item id}/metadata - Return item metadata.
|
9
|
-
# √ GET /items/{item id}/bitstreams - Return item bitstreams.
|
10
|
-
# POST /items/find-by-metadata-field - Find items by metadata entry. You must post a MetadataEntry. DS-2501 - wrong SQL in REST /items/find-by-metadata-field CLOSED
|
11
|
-
# √ POST /items/{item id}/metadata - Add metadata to item. You must post an array of MetadataEntry
|
12
|
-
# √ POST /items/{item id}/bitstreams - Add bitstream to item. You must post a Bitstream
|
13
|
-
# √ PUT /items/{item id}/metadata - Update metadata in item. You must put a MetadataEntry
|
14
|
-
# √ DELETE /items/{item id} - Delete item.
|
15
|
-
# DELETE /items/{item id}/metadata - Clear item metadata.
|
16
|
-
# DELETE /items/{item id}/bitstreams/{bitstream id} - Delete item bitstream.
|
17
|
-
|
18
|
-
|
19
|
-
def get_all_items
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
1
|
+
module DSpaceRest
|
2
|
+
module Repositories
|
3
|
+
class ItemRepository < AbstractRepository
|
4
|
+
# Items in DSpace represent a "work" and combine metadata and files, known as Bitstreams
|
5
|
+
|
6
|
+
# √ GET /items - Return list of items.
|
7
|
+
# √ GET /items/{item id} - Return item.
|
8
|
+
# √ GET /items/{item id}/metadata - Return item metadata.
|
9
|
+
# √ GET /items/{item id}/bitstreams - Return item bitstreams.
|
10
|
+
# POST /items/find-by-metadata-field - Find items by metadata entry. You must post a MetadataEntry. DS-2501 - wrong SQL in REST /items/find-by-metadata-field CLOSED
|
11
|
+
# √ POST /items/{item id}/metadata - Add metadata to item. You must post an array of MetadataEntry
|
12
|
+
# √ POST /items/{item id}/bitstreams - Add bitstream to item. You must post a Bitstream
|
13
|
+
# √ PUT /items/{item id}/metadata - Update metadata in item. You must put a MetadataEntry
|
14
|
+
# √ DELETE /items/{item id} - Delete item.
|
15
|
+
# DELETE /items/{item id}/metadata - Clear item metadata.
|
16
|
+
# DELETE /items/{item id}/bitstreams/{bitstream id} - Delete item bitstream.
|
17
|
+
|
18
|
+
|
19
|
+
def get_all_items(expand = nil)
|
20
|
+
expand_uri = build_expand_uri(expand)
|
21
|
+
response = rest_client["/items?#{expand_uri}"].get
|
22
|
+
items = []
|
23
|
+
JSON.parse(response).each do |item|
|
24
|
+
items << DSpaceRest::Item.new(item)
|
25
|
+
end
|
26
|
+
items
|
27
|
+
end
|
28
|
+
|
29
|
+
def get_item_by_id(id, expand = nil)
|
30
|
+
expand_uri = build_expand_uri(expand)
|
31
|
+
response = rest_client["/items/#{id}?#{expand_uri}"].get
|
32
|
+
DSpaceRest::Item.new(JSON.parse(response))
|
33
|
+
end
|
34
|
+
|
35
|
+
def get_metadata_of(item)
|
36
|
+
response = rest_client["/items/#{item.id}/metadata"].get
|
37
|
+
metadata = []
|
38
|
+
JSON.parse(response).each do |m|
|
39
|
+
metadata << DSpaceRest::Metadata.new(m)
|
40
|
+
end
|
41
|
+
metadata
|
42
|
+
end
|
43
|
+
|
44
|
+
def get_bitstreams_of(item)
|
45
|
+
response = rest_client["/items/#{item.id}/bitstreams"].get
|
46
|
+
bitstreams = []
|
47
|
+
JSON.parse(response).each do |bits|
|
48
|
+
bitstreams << DSpaceRest::Bitstream.new(bits)
|
49
|
+
end
|
50
|
+
bitstreams
|
51
|
+
end
|
52
|
+
|
53
|
+
|
54
|
+
def create_metadata_for(item)
|
55
|
+
form = JSON.generate(self.to_h["metadata"])
|
56
|
+
response = rest_client["/items/#{item.id}/metadata"].put form
|
57
|
+
end
|
58
|
+
|
59
|
+
def create_bitstream_for(item, file, upload_strategy)
|
60
|
+
response = upload_strategy.upload("/items/#{item.id}/bitstreams", file)
|
61
|
+
DSpaceRest::Bitstream.new(JSON.parse(response))
|
62
|
+
end
|
63
|
+
|
64
|
+
def delete(item)
|
65
|
+
response = rest_client["/items/#{item.id}"].delete
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def expandable_properties
|
71
|
+
["metadata","parentCollection","parentCollectionList","parentCommunityList","bitstreams","all"]
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
68
76
|
end
|
@@ -1,27 +1,27 @@
|
|
1
|
-
#require 'curl'
|
2
|
-
|
3
|
-
module DSpaceRest
|
4
|
-
module Strategies
|
5
|
-
module Uploads
|
6
|
-
class CurlStrategy
|
7
|
-
|
8
|
-
def initialize(host_url, token)
|
9
|
-
@host_url = host_url
|
10
|
-
@token = token
|
11
|
-
end
|
12
|
-
|
13
|
-
def upload(endpoint, file)
|
14
|
-
c = Curl::Easy.new(@host_url.concat(endpoint))
|
15
|
-
c.headers['Accept'] = 'application/json'
|
16
|
-
c.headers['rest-dspace-token'] = @token
|
17
|
-
|
18
|
-
c.multipart_form_post = true
|
19
|
-
c.ssl_verify_peer = false
|
20
|
-
c.http_post(Curl::PostField.file('file', file))
|
21
|
-
|
22
|
-
c.body_str
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
1
|
+
#require 'curl'
|
2
|
+
|
3
|
+
module DSpaceRest
|
4
|
+
module Strategies
|
5
|
+
module Uploads
|
6
|
+
class CurlStrategy
|
7
|
+
|
8
|
+
def initialize(host_url, token)
|
9
|
+
@host_url = host_url
|
10
|
+
@token = token
|
11
|
+
end
|
12
|
+
|
13
|
+
def upload(endpoint, file)
|
14
|
+
c = Curl::Easy.new(@host_url.concat(endpoint))
|
15
|
+
c.headers['Accept'] = 'application/json'
|
16
|
+
c.headers['rest-dspace-token'] = @token
|
17
|
+
|
18
|
+
c.multipart_form_post = true
|
19
|
+
c.ssl_verify_peer = false
|
20
|
+
c.http_post(Curl::PostField.file('file', file))
|
21
|
+
|
22
|
+
c.body_str
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
27
|
end
|
@@ -1,17 +1,17 @@
|
|
1
|
-
module DSpaceRest
|
2
|
-
module Strategies
|
3
|
-
module Uploads
|
4
|
-
class RestStrategy
|
5
|
-
|
6
|
-
def initialize(rest_client)
|
7
|
-
@rest_client = rest_client
|
8
|
-
end
|
9
|
-
|
10
|
-
def upload(endpoint, file)
|
11
|
-
@rest_client[endpoint].post File.read(file)
|
12
|
-
end
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|
1
|
+
module DSpaceRest
|
2
|
+
module Strategies
|
3
|
+
module Uploads
|
4
|
+
class RestStrategy
|
5
|
+
|
6
|
+
def initialize(rest_client)
|
7
|
+
@rest_client = rest_client
|
8
|
+
end
|
9
|
+
|
10
|
+
def upload(endpoint, file)
|
11
|
+
@rest_client[endpoint].post File.read(file)
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
17
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dspace_rest_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mauricio Giacomini Girardello
|
@@ -55,10 +55,13 @@ files:
|
|
55
55
|
- lib/dspace_client.rb
|
56
56
|
- lib/dspace_rest_client.rb
|
57
57
|
- lib/dspacerest/bitstream.rb
|
58
|
+
- lib/dspacerest/builders/hash_builder.rb
|
59
|
+
- lib/dspacerest/builders/model_builder.rb
|
58
60
|
- lib/dspacerest/collection.rb
|
59
61
|
- lib/dspacerest/community.rb
|
60
62
|
- lib/dspacerest/item.rb
|
61
63
|
- lib/dspacerest/metadata.rb
|
64
|
+
- lib/dspacerest/policy.rb
|
62
65
|
- lib/dspacerest/repositories/abstract_repository.rb
|
63
66
|
- lib/dspacerest/repositories/bitstream_repository.rb
|
64
67
|
- lib/dspacerest/repositories/collection_repository.rb
|