Module: Dor::Embargoable

Extended by:
ActiveSupport::Concern
Includes:
Publishable
Included in:
BasicItem
Defined in:
lib/dor/models/embargoable.rb

Constant Summary

Constants included from Itemizable

Itemizable::DIFF_FILENAME

Constants included from Describable

Describable::DESC_MD_FORMATS

Instance Method Summary collapse

Methods included from Publishable

#public_relationships, #public_xml, #publish_metadata, #publish_metadata_remotely

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_identifier, #add_related_item_node_for_collection, #build_descMetadata_datastream, #delete_identifier, #fetch_descMetadata_datastream, #generate_dublin_core, #generate_public_desc_md, get_collection_title, #metadata_format, #metadata_namespace, #remove_related_item_nodes_for_collections, #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, #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 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

#release_20_pct_vis_embargo(release_agent = 'unknown') ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/dor/models/embargoable.rb', line 42

def release_20_pct_vis_embargo(release_agent = 'unknown')
  # Set status to released
  embargo_md = datastreams['embargoMetadata']
  embargo_md.twenty_pct_status = 'released'

  # Remove all read acces nodes
  rights_xml = datastreams['rightsMetadata'].ng_xml
  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['rightsMetadata'].content_will_change!
  datastreams['events'].add_event('embargo', release_agent, '20% Visibility Embargo released')
end

#release_embargo(release_agent = 'unknown') ⇒ Object

Note:

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
# File 'lib/dor/models/embargoable.rb', line 18

def release_embargo(release_agent = 'unknown')
  # Set status to released
  embargo_md = datastreams['embargoMetadata']
  embargo_md.status = 'released'

  # Remove all read acces nodes
  rights_xml = datastreams['rightsMetadata'].ng_xml
  rights_xml.xpath("//rightsMetadata/access[@type='read']").each { |n| n.remove }

  # Replace rights <access> nodes with those from embargoMetadta
  release_access = embargo_md.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['rightsMetadata'].content_will_change!
  datastreams['events'].add_event('embargo', release_agent, 'Embargo released')
end

#update_embargo(new_date) ⇒ Object



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/dor/models/embargoable.rb', line 63

def update_embargo(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
  .ng_xml.search('//embargoReleaseDate').each do |node|
    node.content = new_date.beginning_of_day.utc.xmlschema
    updated = true
  end
  .content = .ng_xml.to_s
  .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
  .content = .ng_xml.to_s
  .save
end