Class: DSpaceRest::Repositories::BitstreamRepository

Inherits:
AbstractRepository show all
Defined in:
lib/dspacerest/repositories/bitstream_repository.rb

Instance Attribute Summary

Attributes inherited from AbstractRepository

#rest_client

Instance Method Summary collapse

Methods inherited from AbstractRepository

#initialize

Constructor Details

This class inherits a constructor from DSpaceRest::Repositories::AbstractRepository

Instance Method Details

#get_all_bitstreams(expand = nil) ⇒ Object



30
31
32
33
34
35
36
37
38
# File 'lib/dspacerest/repositories/bitstream_repository.rb', line 30

def get_all_bitstreams(expand = nil)
  expand_uri = build_expand_uri(expand)
  response = rest_client["/bitstreams?#{expand_uri}"].get
  bit_streams = []
  JSON.parse(response).each do |bits|
    bit_streams << DSpaceRest::Bitstream.new(bits)
  end
  bit_streams
end

#get_bitstream_by_id(id, expand = nil) ⇒ Object

√ GET /bitstreams - Return all bitstreams in DSpace. √ GET /bitstreams/id - Return bitstream. GET /bitstreams/id/policy - Return bitstream policies. √ GET /bitstreams/id/retrieve - Return data of bitstream. POST /bitstreams/id/policy - Add policy to item. You must post a ResourcePolicy PUT /bitstreams/id/data - Update data/file of bitstream. You must put the data √ PUT /bitstreams/id - Update metadata of bitstream. You must put a Bitstream, does not alter the file/data DELETE /bitstreams/id - Delete bitstream from DSpace. DELETE /bitstreams/id/policy/policy_id - Delete bitstream policy.



24
25
26
27
28
# File 'lib/dspacerest/repositories/bitstream_repository.rb', line 24

def get_bitstream_by_id(id, expand = nil)
  expand_uri = build_expand_uri(expand)
  response = rest_client["/bitstreams/#{id}?#{expand_uri}"].get
  DSpaceRest::Bitstream.new(JSON.parse(response))
end

#retrieve_data(bitstream) ⇒ Object



40
41
42
# File 'lib/dspacerest/repositories/bitstream_repository.rb', line 40

def retrieve_data(bitstream)
  response = rest_client["/bitstreams/#{bitstream.id}/retrieve"].get
end

#update(bitstream) ⇒ Object



44
45
46
47
48
# File 'lib/dspacerest/repositories/bitstream_repository.rb', line 44

def update(bitstream)
  valid_keys=[:name, :description, :sequenceId]
  form = JSON.generate(bitstream.to_h.select { |k, v| valid_keys.include? k })
  response = rest_client["/bitstreams/#{bitstream.id}"].put form
end