lib/cul-fedora/item.rb in cul-fedora-0.8.5 vs lib/cul-fedora/item.rb in cul-fedora-0.8.6

- old
+ new

@@ -6,10 +6,11 @@ attr_reader :server, :pid include Open3 URI_TO_PID = 'info:fedora/' + MAX_LIST_MEMBERS_PER_REQUEST = 500 def <=>(other) pid <=> other.pid end @@ -67,16 +68,31 @@ end def listMembers() begin - result = Nokogiri::XML(request(:method => "/objects", :sdef => "methods/ldpd:sdef.Aggregator", :request => "listMembers", :format => "", :max => "", :start => "")) + i = 1 + size = getSize + items = [] + while (i <= size) + result = Nokogiri::XML(request(:method => "/objects", :sdef => "methods/ldpd:sdef.Aggregator", :request => "listMembers", :format => "sparql", :max => MAX_LIST_MEMBERS_PER_REQUEST, :start => (i - 1))) - result.css("sparql>results>result>member").collect do |result_node| - @server.item(result_node.attributes["uri"].value) + result.css("sparql>results>result>member").collect do |result_node| + items << @server.item(result_node.attributes["uri"].value) + end + i = i + MAX_LIST_MEMBERS_PER_REQUEST end + return items rescue [] + end + end + + def getSize() + begin + request(:method => "/objects", :sdef => "methods/ldpd:sdef.Aggregator", :request => "getSize").to_i + rescue + -1 end end def describedBy begin