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, Itemizable::DIFF_QUERY

Constants included from Describable

Describable::DESC_MD_FORMATS

Instance Method Summary collapse

Methods included from Publishable

#build_rightsMetadata_datastream, #public_relationships, #public_xml, #publish_metadata, #publish_metadata_remotely

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, #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, #initialize, #method_missing, #normalize_tag, #normalize_tag_arr, #remove_other_Id, #remove_tag, #set_source_id, #split_tag_to_arr, #tags, #to_solr, #update_other_Id, #update_tag, #validate_and_normalize_tag

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



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/dor/models/embargoable.rb', line 52

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

Parameters:

  • release_agent (String) (defaults to: "unknown")

    name of the person, application or thing that released embargo



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# 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['events'].add_event("embargo", release_agent, "Embargo released")
end

#update_embargo(new_date) ⇒ Object



73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# File 'lib/dor/models/embargoable.rb', line 73

def update_embargo(new_date)
	if not .status == 'embargoed'
		raise 'You cannot change the embargo date of an item thant isnt embargoed.'
	end
	if new_date.past?
	  raise 'You cannot set the embargo date to a past date.'
	end
	updated=false
	self..ng_xml.search('//embargoReleaseDate').each do |node|
		node.content=new_date.beginning_of_day.utc.xmlschema
		updated=true
	end
	self..content=self..ng_xml.to_s
	self..save
	if not updated
		raise 'No release date in rights metadata, cannot proceed!'
	end
	self..ng_xml.xpath('//releaseDate').each do |node|
		node.content=new_date.beginning_of_day.utc.xmlschema
	end
	self..content=self..ng_xml.to_s
	self..save
end

#world_docObject



41
42
43
44
45
46
47
48
49
50
# File 'lib/dor/models/embargoable.rb', line 41

def world_doc
  builder = Nokogiri::XML::Builder.new do |xml|
    xml.access(:type => 'read') {
      xml.machine {
        xml.world
      }
    }
  end
  return builder.doc
end