Module: Dor::Embargoable
- Extended by:
- ActiveSupport::Concern
- Includes:
- Publishable
- Included in:
- Item
- Defined in:
- lib/dor/models/embargoable.rb
Constant Summary
Constants included from Itemizable
Constants included from Describable
Instance Method Summary collapse
- #release_20_pct_vis_embargo(release_agent = 'unknown') ⇒ Object
-
#release_embargo(release_agent = 'unknown') ⇒ Object
Manipulates datastreams in the object when embargo is lifted: Sets embargo status to released in embargoMetadata Modifies rightsMetadata to remove embargoReleaseDate and updates/adds access from embargoMetadata/releaseAccess.
- #update_embargo(new_date) ⇒ Object
Methods included from Publishable
#encoded_thumb, #public_relationships, #public_xml, #publish_metadata, #publish_metadata_remotely, #publish_notify_on_success, #thumb, #thumb_url
Methods included from Rightsable
#build_rightsMetadata_datastream, #world_doc
Methods included from Itemizable
#clear_diff_cache, #get_content_diff
Methods included from Describable
#add_access_conditions, #add_collection_reference, #add_constituent_relations, #add_related_item_node_for_collection, #build_descMetadata_datastream, #fetch_descMetadata_datastream, #generate_dublin_core, #generate_public_desc_md, get_collection_title, #remove_related_item_nodes_for_collections, #set_desc_metadata_using_label, #stanford_mods, #to_solr
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
#adapt_to_cmodel, #add_other_Id, #add_tag, #content_type_tag, #druid_regex, #get_related_obj_display_title, #identity_metadata_source, #initialize, #normalize_tag, #normalize_tag_arr, #pid_regex, #remove_druid_prefix, #remove_other_Id, #remove_tag, #source_id, #source_id=, #split_tag_to_arr, #tags, #to_solr, #update_other_Id, #update_tag, #validate_and_normalize_tag, #validate_tag_format
Methods included from Eventable
Methods included from SolrDocHelper
Instance Method Details
#release_20_pct_vis_embargo(release_agent = 'unknown') ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dor/models/embargoable.rb', line 43 def (release_agent = 'unknown') # Set status to released = datastreams['embargoMetadata'] .twenty_pct_status = 'released' # Remove all read acces nodes rights_md = datastreams['rightsMetadata'] rights_xml = rights_md.ng_xml rights_md.ng_xml_will_change! rights_xml.xpath("//rightsMetadata/access[@type='read']").each { |n| n.remove } # Replace rights <access> nodes with 1 machine/world node access_sibling = rights_xml.at_xpath('//rightsMetadata/access[last()]') if access_sibling access_sibling.add_next_sibling(world_doc.root.clone) else rights_xml.root.add_child(world_doc.root.clone) end datastreams['events'].add_event('embargo', release_agent, '20% Visibility Embargo released') end |
#release_embargo(release_agent = 'unknown') ⇒ Object
The caller should save the object to fedora to commit the changes
Manipulates datastreams in the object when embargo is lifted: Sets embargo status to released in embargoMetadata Modifies rightsMetadata to remove embargoReleaseDate and updates/adds access from embargoMetadata/releaseAccess
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/dor/models/embargoable.rb', line 18 def (release_agent = 'unknown') # Set status to released = datastreams['embargoMetadata'] .status = 'released' # Remove all read acces nodes rights_md = datastreams['rightsMetadata'] rights_xml = rights_md.ng_xml rights_md.ng_xml_will_change! rights_xml.xpath("//rightsMetadata/access[@type='read']").each { |n| n.remove } # Replace rights <access> nodes with those from embargoMetadta release_access = .release_access_node release_access.xpath('//releaseAccess/access').each do |new_access| access_sibling = rights_xml.at_xpath('//rightsMetadata/access[last()]') if access_sibling access_sibling.add_next_sibling(new_access.clone) else rights_xml.root.add_child(new_access.clone) end end datastreams['events'].add_event('embargo', release_agent, 'Embargo released') end |
#update_embargo(new_date) ⇒ Object
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/dor/models/embargoable.rb', line 65 def (new_date) if .status != 'embargoed' raise ArgumentError, 'You cannot change the embargo date of an item that is not embargoed.' end if new_date.past? raise ArgumentError, 'You cannot set the embargo date to a past date.' end updated = false rightsMetadata.ng_xml.search('//embargoReleaseDate').each do |node| node.content = new_date.beginning_of_day.utc.xmlschema updated = true end rightsMetadata.ng_xml_will_change! rightsMetadata.save raise 'No release date in rights metadata, cannot proceed!' unless updated .ng_xml.xpath('//releaseDate').each do |node| node.content = new_date.beginning_of_day.utc.xmlschema end .ng_xml_will_change! .save end |