Module: Dor::Publishable

Extended by:
ActiveSupport::Concern
Includes:
Describable, Governable, Identifiable, Itemizable, Presentable, Rightsable
Included in:
Collection, Embargoable, Set
Defined in:
lib/dor/models/publishable.rb

Constant Summary

Constants included from Presentable

Dor::Presentable::DC_NS

Constants included from Itemizable

Itemizable::DIFF_FILENAME, Itemizable::DIFF_QUERY

Constants included from Describable

Describable::DESC_MD_FORMATS

Instance Method Summary collapse

Methods included from Rightsable

#build_rightsMetadata_datastream, #world_doc

Methods included from Presentable

#add_metadata, #build_iiif_manifest, #iiif_presentation_manifest_needed?

Methods included from Itemizable

#clear_diff_cache, #get_content_diff

Methods included from Describable

#add_access_conditions, #add_collection_reference, #add_identifier, #build_descMetadata_datastream, #delete_identifier, #fetch_descMetadata_datastream, #generate_dublin_core, #generate_public_desc_md, get_collection_title, #metadata_format, #metadata_namespace, #set_desc_metadata_using_label, #stanford_mods, #to_solr, #update_title

Methods included from Governable

#add_collection, #can_manage_content?, #can_manage_desc_metadata?, #can_manage_embargo?, #can_manage_item?, #can_manage_rights?, #can_manage_system_metadata?, #can_view_content?, #can_view_metadata?, #default_workflow_lane, #groups_which_manage_content, #groups_which_manage_desc_metadata, #groups_which_manage_embargo, #groups_which_manage_item, #groups_which_manage_rights, #groups_which_manage_system_metadata, #groups_which_view_content, #groups_which_view_metadata, #initiate_apo_workflow, #intersect, #reapplyAdminPolicyObjectDefaults, #remove_collection, #reset_to_apo_default, #rights, #set_read_rights

Methods included from Identifiable

#add_other_Id, #add_tag, #content_type_tag, #get_related_obj_display_title, #identity_metadata_source, #initialize, #method_missing, #normalize_tag, #normalize_tag_arr, #remove_displayTypes, #remove_other_Id, #remove_tag, #set_source_id, #split_tag_to_arr, #tags, #to_solr, #update_other_Id, #update_tag, #validate_and_normalize_tag, #validate_tag_format

Methods included from Upgradable

add_upgrade_callback, included, run_upgrade_callbacks, #upgrade!

Methods included from Eventable

#add_event

Methods included from SolrDocHelper

#add_solr_value

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Dor::Identifiable

Instance Method Details

#public_relationshipsObject



13
14
15
16
17
18
19
20
21
22
23
# File 'lib/dor/models/publishable.rb', line 13

def public_relationships
  include_elements = ['fedora:isMemberOf','fedora:isMemberOfCollection']
  rels_doc = Nokogiri::XML(self.datastreams['RELS-EXT'].content)
  rels_doc.xpath('/rdf:RDF/rdf:Description/*', { 'rdf' => 'http://www.w3.org/1999/02/22-rdf-syntax-ns#' }).each do |rel|
    unless include_elements.include?([rel.namespace.prefix,rel.name].join(':'))
      rel.next_sibling.remove if rel.next_sibling.content.strip.empty?
      rel.remove
    end
  end
  rels_doc
end

#public_xmlxml

Generate the public .xml for a PURL page.

Returns:

  • (xml)

    The public xml for the item



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/dor/models/publishable.rb', line 28

def public_xml
  pub = Nokogiri::XML("<publicObject/>").root
  pub['id'] = pid
  pub['published'] = Time.now.xmlschema
  release_xml=Nokogiri(self.generate_release_xml).xpath('//release')

  im=self.datastreams['identityMetadata'].ng_xml.clone
  im.search('//release').each {|node| node.remove} # remove any <release> tags from public xml which have full history
  im.root.add_child(release_xml)

  pub.add_child(im.root) # add in modified identityMetadata datastream
  pub.add_child(self.datastreams['contentMetadata'].public_xml.root.clone)
  pub.add_child(self.datastreams['rightsMetadata'].ng_xml.root.clone)

  rels = public_relationships.root
  pub.add_child(rels.clone) unless rels.nil? # TODO: Should never be nil in practice; working around an ActiveFedora quirk for testing
  pub.add_child(self.generate_dublin_core.root.clone)
  @public_xml_doc = pub # save this for possible IIIF Presentation manifest
  pub.add_child(Nokogiri(self.generate_release_xml).root.clone) unless release_xml.children.size == 0 #If there are no release_tags, this prevents an empty <releaseData/> from being added
  #Note we cannot base this on if an individual object has release tags or not, because the collection may cause one to be generated for an item, so we need to calculate it and then look at the final result
  new_pub = Nokogiri::XML(pub.to_xml) { |x| x.noblanks }
  new_pub.encoding = 'UTF-8'
  new_pub.to_xml
end

#publish_metadataObject

Copies this object’s public_xml to the Purl document cache if it is world discoverable

otherwise, it prunes the object's metadata from the document cache


55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/dor/models/publishable.rb', line 55

def 
  rights = datastreams['rightsMetadata'].ng_xml.clone.remove_namespaces!
  if rights.at_xpath("//rightsMetadata/access[@type='discover']/machine/world")
    dc_xml = self.generate_dublin_core.to_xml {|config| config.no_declaration}
    DigitalStacksService.transfer_to_document_store(pid, dc_xml, 'dc')
    DigitalStacksService.transfer_to_document_store(pid, self.datastreams['identityMetadata'].to_xml, 'identityMetadata')
    DigitalStacksService.transfer_to_document_store(pid, self.datastreams['contentMetadata'].to_xml, 'contentMetadata')
    DigitalStacksService.transfer_to_document_store(pid, self.datastreams['rightsMetadata'].to_xml, 'rightsMetadata')
    DigitalStacksService.transfer_to_document_store(pid, public_xml, 'public')
    if self. == 'mods'
      DigitalStacksService.transfer_to_document_store(pid, self.generate_public_desc_md, 'mods')
    end
    if iiif_presentation_manifest_needed? @public_xml_doc
      DigitalStacksService.transfer_to_document_store(pid, build_iiif_manifest(@public_xml_doc), 'manifest')
    end
  else
    # Clear out the document cache for this item
    DigitalStacksService.prune_purl_dir pid
  end
end

#publish_metadata_remotelyObject

call the dor services app to have it publish the metadata



76
77
78
79
80
# File 'lib/dor/models/publishable.rb', line 76

def 
  dor_services = RestClient::Resource.new(Config.dor_services.url+"/v1/objects/#{pid}/publish")
  dor_services.post ''
  dor_services.url
end