diff --git a/app/services/dspace_service.rb b/app/services/dspace_service.rb index be6f81b16dd88884b5219b939ab252cf00f4ca60..57dd5bb5f32b7b58e3da500e3107bebda702661d 100644 --- a/app/services/dspace_service.rb +++ b/app/services/dspace_service.rb @@ -6,47 +6,10 @@ class DspaceService @dspace_client = dspace_client end - def self.create_dspace_client(url = 'https://demo.dspace.org/rest', auth_token=nil) + def self.create_dspace_client(url = Rails.application.secrets.dspace_rest_url, auth_token=nil) @@clients[url] ||= DspaceClient.new(url, auth_token) end - # def get_all_communities - # community_repository = @dspace_client.repository.community_repository - # all_communities = community_repository.get_all_communities("subCommunities") - # - # setores = [] - # all_communities.each do |community| - # unless community.sub_communities.empty? - # setores << build_setor(community) - # end - # end - # setores - # end - # - # def get_community_by_id(id) - # community_repository = @dspace_client.repository.community_repository - # - # community = community_repository.get_community_by_id(id, "subCommunities") - # build_setor(community, community.sub_communities) - # end - # - # def get_subcommunity_by_id(id) - # community_repository = @dspace_client.repository.community_repository - # collection_repository = @dspace_client.repository.collection_repository - # - # community = community_repository.get_community_by_id(id,"parentCommunity") - # disciplinas = build_disciplinas(collection_repository.get_collections_of(community)) - # build_departamento(community, disciplinas) - # end - # - # def get_collection_by_id(id) - # collection_repository = @dspace_client.repository.collection_repository - # - # collection = collection_repository.get_collection_by_id(id, "parentCommunityList") - # items = collection_repository.get_collection_items(collection) - # build_disciplina(collection, items) - # end - def get_object_by_id(id) item_repository = @dspace_client.repository.item_repository @@ -120,48 +83,6 @@ class DspaceService private - # def build_community(community, subcommunities=[]) - # Setor.new({ - # id: community.id, - # name: community.name, - # introductory_text: community.introductory_text, - # departamentos: subcommunities - # }) - # end - # - # def build_subcommunities(community, collections=[]) - # Departamento.new({ - # id: community.id, - # name: community.name, - # introductory_text: community.introductory_text, - # setor: community.parent_community, - # disciplinas: collections - # }) - # end - # - # def build_collection(collection, items=[]) - # Disciplina.new({ - # id: collection.id, - # name: collection.name, - # introductory_text: collection.introductory_text, - # details_url: collection.short_description, - # departamento: collection.parent_community_list[0], - # setor: collection.parent_community_list[1], - # # TODO: real professor - # professor: Professor.new({id: 1, name: "Prof Joao"}), - # items: items - # }) - # end - # - # def build_collections(collections) - # disciplinas = [] - # - # collections.each do |c| - # disciplinas << build_disciplina(c) - # end - # disciplinas - # end - def build_object(item, metadata={}) item.new({ id: item.id, @@ -184,7 +105,7 @@ class DspaceService id: bitstream.id, name: bitstream.name, description: bitstream.description, - retrieve_link: Rails.application.secrets.dspace_url + bitstream.retrieve_link, + retrieve_link: Rails.application.secrets.dspace_rest_url + bitstream.retrieve_link, size_bytes: bitstream.size_bytes }) end diff --git a/config/dspace.yml b/config/dspace.yml new file mode 100644 index 0000000000000000000000000000000000000000..f50b219d83c1e995f85ad2aeda0b844b6985e4d3 --- /dev/null +++ b/config/dspace.yml @@ -0,0 +1,8 @@ +development: + dspace_rest_url: https://portalmecdev.c3sl.ufpr.br:8443/rest + +test: + dspace_rest_url: https://portalmecdev.c3sl.ufpr.br:8443/rest + +production: + dspace_rest_url: https://portalmecdev.c3sl.ufpr.br:8443/rest