dor-services 4.22.3 → 4.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/bin/dor-indexer +19 -20
- data/bin/dor-indexerd +2 -3
- data/config/certs/robots-dor-dev.crt +29 -0
- data/config/certs/robots-dor-dev.key +27 -0
- data/config/dev_console_env.rb +77 -0
- data/lib/dor-services.rb +3 -3
- data/lib/dor/config.rb +15 -15
- data/lib/dor/datastreams/administrative_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/content_metadata_ds.rb +181 -225
- data/lib/dor/datastreams/datastream_spec_solrizer.rb +1 -1
- data/lib/dor/datastreams/default_object_rights_ds.rb +8 -10
- data/lib/dor/datastreams/desc_metadata_ds.rb +35 -34
- data/lib/dor/datastreams/embargo_metadata_ds.rb +7 -7
- data/lib/dor/datastreams/events_ds.rb +11 -11
- data/lib/dor/datastreams/geo_metadata_ds.rb +86 -86
- data/lib/dor/datastreams/identity_metadata_ds.rb +19 -19
- data/lib/dor/datastreams/role_metadata_ds.rb +3 -3
- data/lib/dor/datastreams/simple_dublin_core_ds.rb +13 -13
- data/lib/dor/datastreams/version_metadata_ds.rb +5 -5
- data/lib/dor/datastreams/workflow_definition_ds.rb +21 -21
- data/lib/dor/migrations/identifiable/assert_adminPolicy.rb +1 -1
- data/lib/dor/migrations/identifiable/fix_model_assertions.rb +1 -1
- data/lib/dor/migrations/identifiable/record_remediation.rb +2 -2
- data/lib/dor/migrations/identifiable/uriify_augmented_contentlocation_refs.rb +1 -1
- data/lib/dor/migrations/identifiable/uriify_contentlocation_refs.rb +1 -1
- data/lib/dor/migrations/processable/unify_workflows.rb +4 -4
- data/lib/dor/migrations/versionable/add_missing_version_md.rb +1 -1
- data/lib/dor/models/admin_policy_object.rb +1 -1
- data/lib/dor/models/assembleable.rb +5 -5
- data/lib/dor/models/contentable.rb +27 -27
- data/lib/dor/models/describable.rb +168 -179
- data/lib/dor/models/discoverable.rb +13 -13
- data/lib/dor/models/editable.rb +55 -55
- data/lib/dor/models/embargoable.rb +26 -26
- data/lib/dor/models/eventable.rb +3 -3
- data/lib/dor/models/geoable.rb +8 -8
- data/lib/dor/models/governable.rb +14 -14
- data/lib/dor/models/identifiable.rb +117 -143
- data/lib/dor/models/item.rb +2 -2
- data/lib/dor/models/itemizable.rb +9 -9
- data/lib/dor/models/presentable.rb +8 -8
- data/lib/dor/models/preservable.rb +4 -4
- data/lib/dor/models/processable.rb +22 -23
- data/lib/dor/models/releaseable.rb +26 -26
- data/lib/dor/models/shelvable.rb +14 -14
- data/lib/dor/models/upgradable.rb +13 -13
- data/lib/dor/models/versionable.rb +2 -2
- data/lib/dor/models/workflow_object.rb +4 -4
- data/lib/dor/services/cleanup_reset_service.rb +27 -27
- data/lib/dor/services/cleanup_service.rb +4 -7
- data/lib/dor/services/digital_stacks_service.rb +10 -10
- data/lib/dor/services/merge_service.rb +1 -1
- data/lib/dor/services/metadata_handlers/mdtoolkit_handler.rb +2 -2
- data/lib/dor/services/metadata_service.rb +20 -20
- data/lib/dor/services/registration_service.rb +27 -27
- data/lib/dor/services/reset_workspace_service.rb +15 -15
- data/lib/dor/services/sdr_ingest_service.rb +6 -6
- data/lib/dor/services/search_service.rb +2 -2
- data/lib/dor/services/suri_service.rb +5 -5
- data/lib/dor/services/technical_metadata_service.rb +2 -3
- data/lib/dor/utils/ng_tidy.rb +9 -9
- data/lib/dor/utils/predicate_patch.rb +1 -1
- data/lib/dor/utils/solr_doc_helper.rb +2 -2
- data/lib/dor/version.rb +1 -1
- data/lib/dor/workflow/document.rb +19 -19
- data/lib/dor/workflow/graph.rb +36 -36
- data/lib/dor/workflow/process.rb +12 -12
- data/lib/tasks/dor.rake +1 -1
- data/lib/tasks/rdoc.rake +3 -3
- metadata +6 -3
@@ -1,7 +1,7 @@
|
|
1
1
|
module Dor
|
2
|
-
class IdentityMetadataDS < ActiveFedora::OmDatastream
|
2
|
+
class IdentityMetadataDS < ActiveFedora::OmDatastream
|
3
3
|
include SolrDocHelper
|
4
|
-
|
4
|
+
|
5
5
|
set_terminology do |t|
|
6
6
|
t.root(:path=>"identityMetadata")
|
7
7
|
t.objectId :index_as => [:searchable]
|
@@ -18,36 +18,36 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
18
18
|
t.objectCreator :index_as => [:searchable, :facetable]
|
19
19
|
t.adminPolicy :index_as => [:not_searchable]
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
define_template :value do |builder,name,value,attrs|
|
23
23
|
builder.send(name.to_sym, value, attrs)
|
24
24
|
end
|
25
|
-
|
25
|
+
|
26
26
|
def self.xml_template
|
27
27
|
Nokogiri::XML('<identityMetadata/>')
|
28
28
|
end #self.xml_template
|
29
|
-
|
30
|
-
def add_value(name, value, attrs={})
|
29
|
+
|
30
|
+
def add_value(name, value, attrs = {})
|
31
31
|
add_child_node(ng_xml.root, :value, name, value, attrs)
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
def objectId
|
35
|
-
|
35
|
+
find_by_terms(:objectId).text
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
def sourceId
|
39
|
-
node =
|
39
|
+
node = find_by_terms(:sourceId).first
|
40
40
|
node ? [node['source'],node.text].join(':') : nil
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
def sourceId=(value)
|
44
|
-
node =
|
44
|
+
node = find_by_terms(:sourceId).first
|
45
45
|
unless value.present?
|
46
46
|
node.remove unless node.nil?
|
47
47
|
nil
|
48
48
|
else
|
49
49
|
(source,val) = value.split(/:/,2)
|
50
|
-
unless source.present?
|
50
|
+
unless source.present? && value.present?
|
51
51
|
raise ArgumentError, "Source ID must follow the format namespace:value"
|
52
52
|
end
|
53
53
|
node = ng_xml.root.add_child('<sourceId/>').first if node.nil?
|
@@ -58,13 +58,13 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
58
58
|
end
|
59
59
|
def tags()
|
60
60
|
result=[]
|
61
|
-
|
61
|
+
ng_xml.search('//tag').each do |node|
|
62
62
|
result << node.content
|
63
63
|
end
|
64
64
|
result
|
65
65
|
end
|
66
66
|
def otherId(type = nil)
|
67
|
-
result =
|
67
|
+
result = find_by_terms(:otherId).to_a
|
68
68
|
if type.nil?
|
69
69
|
result.collect { |n| [n['name'],n.text].join(':') }
|
70
70
|
else
|
@@ -79,8 +79,8 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
79
79
|
node.content = val
|
80
80
|
node
|
81
81
|
end
|
82
|
-
|
83
|
-
def to_solr(solr_doc=Hash.new, *args)
|
82
|
+
|
83
|
+
def to_solr(solr_doc = Hash.new, *args)
|
84
84
|
super(solr_doc, *args)
|
85
85
|
if digital_object.respond_to?(:profile)
|
86
86
|
digital_object.profile.each_pair do |property,value|
|
@@ -99,8 +99,8 @@ class IdentityMetadataDS < ActiveFedora::OmDatastream
|
|
99
99
|
add_solr_value(solr_doc, "identifier", qid, :string, [:searchable])
|
100
100
|
add_solr_value(solr_doc, "#{name}_id", id, :string, [:searchable])
|
101
101
|
}
|
102
|
-
|
103
|
-
|
102
|
+
|
103
|
+
find_by_terms(:tag).each { |tag|
|
104
104
|
(top,rest) = tag.text.split(/:/,2)
|
105
105
|
unless rest.nil?
|
106
106
|
add_solr_value(solr_doc, "#{top.downcase.strip.gsub(/\s/,'_')}_tag", rest.strip, :string, [:searchable, :facetable])
|
@@ -34,8 +34,8 @@ class RoleMetadataDS < ActiveFedora::OmDatastream
|
|
34
34
|
end
|
35
35
|
|
36
36
|
|
37
|
-
def to_solr(solr_doc=Hash.new, *args)
|
38
|
-
|
37
|
+
def to_solr(solr_doc = Hash.new, *args)
|
38
|
+
find_by_xpath('/roleMetadata/role/*').each do |actor|
|
39
39
|
role_type = actor.parent['type']
|
40
40
|
val = [actor.at_xpath('identifier/@type'),actor.at_xpath('identifier/text()')].join ':'
|
41
41
|
add_solr_value(solr_doc, "apo_role_#{actor.name}_#{role_type}", val, :string, [:searchable, :facetable])
|
@@ -48,4 +48,4 @@ class RoleMetadataDS < ActiveFedora::OmDatastream
|
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
51
|
-
end
|
51
|
+
end
|
@@ -1,44 +1,44 @@
|
|
1
|
-
class SimpleDublinCoreDs < ActiveFedora::OmDatastream
|
2
|
-
|
1
|
+
class SimpleDublinCoreDs < ActiveFedora::OmDatastream
|
2
|
+
|
3
3
|
set_terminology do |t|
|
4
4
|
t.root(:path=>"dc", :xmlns=>"http://www.openarchives.org/OAI/2.0/oai_dc/", :schema=>"http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd", :namespace_prefix => 'oai_dc', :index_as => [:not_searchable])
|
5
5
|
t.title(:index_as=>[:searchable, :displayable, :facetable], :xmlns => "http://purl.org/dc/elements/1.1/", :namespace_prefix => 'dc')
|
6
6
|
t.creator(:index_as=>[:searchable, :displayable, :facetable], :xmlns => "http://purl.org/dc/elements/1.1/", :namespace_prefix => 'dc')
|
7
7
|
t.identifier(:index_as=>[:searchable, :displayable], :xmlns => "http://purl.org/dc/elements/1.1/", :namespace_prefix => 'dc')
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
def self.xml_template
|
11
11
|
builder = Nokogiri::XML::Builder.new do |xml|
|
12
|
-
xml.dc(:xmlns=>"http://www.openarchives.org/OAI/2.0/oai_dc/",
|
12
|
+
xml.dc(:xmlns=>"http://www.openarchives.org/OAI/2.0/oai_dc/",
|
13
13
|
'xmlns:dc'=>'http://purl.org/dc/elements/1.1/') {
|
14
14
|
xml['dc'].title
|
15
15
|
xml['dc'].creator
|
16
16
|
xml['dc'].identifier
|
17
|
-
}
|
17
|
+
}
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
builder.doc
|
21
21
|
end
|
22
|
-
|
23
|
-
def to_solr(solr_doc=Hash.new, *args)
|
22
|
+
|
23
|
+
def to_solr(solr_doc = Hash.new, *args)
|
24
24
|
# There are a whole bunch of namespace-related things that can go
|
25
25
|
# wrong with this terminology. Until it's fixed in OM, ignore them all.
|
26
26
|
begin
|
27
27
|
doc = super solr_doc, *args
|
28
28
|
|
29
|
-
add_solr_value(doc, 'dc_title',
|
30
|
-
add_solr_value(doc, 'dc_creator',
|
31
|
-
|
29
|
+
add_solr_value(doc, 'dc_title', title.first, :string, [:sortable])
|
30
|
+
add_solr_value(doc, 'dc_creator', creator.first, :string, [:sortable])
|
31
|
+
|
32
32
|
identifiers = {}
|
33
33
|
|
34
|
-
|
34
|
+
identifier.each { |i| ns, val = i.split(":"); identifiers[ns] ||= val }
|
35
35
|
|
36
36
|
identifiers.each do |ns, val|
|
37
37
|
add_solr_value(doc, "dc_identifier_#{ns}", val, :string, [:sortable])
|
38
38
|
end
|
39
39
|
|
40
40
|
return doc
|
41
|
-
rescue
|
41
|
+
rescue
|
42
42
|
solr_doc
|
43
43
|
end
|
44
44
|
end
|
@@ -70,7 +70,7 @@ module Dor
|
|
70
70
|
}
|
71
71
|
}
|
72
72
|
end
|
73
|
-
|
73
|
+
builder.doc
|
74
74
|
end
|
75
75
|
|
76
76
|
def ensure_non_versionable
|
@@ -167,7 +167,7 @@ module Dor
|
|
167
167
|
end
|
168
168
|
|
169
169
|
def tag_for_version(versionId)
|
170
|
-
nodes=
|
170
|
+
nodes=ng_xml.search('//version[@versionId=\''+versionId+'\']')
|
171
171
|
if nodes.length == 1
|
172
172
|
nodes.first['tag'].to_s
|
173
173
|
else
|
@@ -177,8 +177,8 @@ module Dor
|
|
177
177
|
|
178
178
|
# @return [String] The description for the specified version, or empty string if there is no description
|
179
179
|
def description_for_version(versionId)
|
180
|
-
nodes=
|
181
|
-
if nodes.length == 1
|
180
|
+
nodes=ng_xml.search('//version[@versionId=\''+versionId+'\']')
|
181
|
+
if nodes.length == 1 && nodes.first.at_xpath('description')
|
182
182
|
nodes.first.at_xpath('description').content.to_s
|
183
183
|
else
|
184
184
|
''
|
@@ -230,4 +230,4 @@ module Dor
|
|
230
230
|
end
|
231
231
|
|
232
232
|
end
|
233
|
-
end
|
233
|
+
end
|
@@ -1,12 +1,12 @@
|
|
1
1
|
module Dor
|
2
|
-
class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
2
|
+
class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
3
3
|
include SolrDocHelper
|
4
|
-
|
4
|
+
|
5
5
|
set_terminology do |t|
|
6
6
|
t.root(:path => "workflow-def", :index_as => [:not_searchable])
|
7
7
|
t.process(:index_as => [:not_searchable])
|
8
8
|
end
|
9
|
-
|
9
|
+
|
10
10
|
define_template :process do |builder,workflow,attrs|
|
11
11
|
prereqs = attrs.delete('prerequisite')
|
12
12
|
if prereqs.is_a?(String)
|
@@ -20,11 +20,11 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
20
20
|
prereq_name = repo
|
21
21
|
repo = nil
|
22
22
|
end
|
23
|
-
if (repo == workflow.repo
|
23
|
+
if (repo == workflow.repo && wf = workflow.name)
|
24
24
|
repo = nil
|
25
25
|
wf = nil
|
26
26
|
end
|
27
|
-
attrs = (repo.nil?
|
27
|
+
attrs = (repo.nil? && wf.nil?) ? {} : { :repository => repo, :workflow => wf }
|
28
28
|
node.prereq(attrs) { node.text prereq_name }
|
29
29
|
end
|
30
30
|
end
|
@@ -33,25 +33,25 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
33
33
|
def self.xml_template
|
34
34
|
Nokogiri::XML('<workflow-def/>')
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def add_process(attributes)
|
38
38
|
add_child_node(ng_xml.at_xpath('/workflow-def'), :process, self, attributes)
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def graph(parent = nil)
|
42
|
-
Workflow::Graph.from_processes(
|
42
|
+
Workflow::Graph.from_processes(repo, name, processes, parent)
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
def processes
|
46
46
|
ng_xml.xpath('/workflow-def/process').collect do |node|
|
47
|
-
Workflow::Process.new(
|
47
|
+
Workflow::Process.new(repo, name, node)
|
48
48
|
end.sort { |a,b| (a.sequence || 0) <=> (b.sequence || 0) }
|
49
49
|
end
|
50
50
|
|
51
51
|
def name
|
52
52
|
ng_xml.at_xpath('/workflow-def/@id').to_s
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
def repo
|
56
56
|
ng_xml.at_xpath('/workflow-def/@repository').to_s
|
57
57
|
end
|
@@ -63,17 +63,17 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
63
63
|
processes.each { |process| result[process.name] = process.to_hash }
|
64
64
|
result
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def configuration=(hash)
|
68
68
|
self.ng_xml = Nokogiri::XML(%{<workflow-def id="#{hash['name']}" repository="#{hash['repository']}"/>})
|
69
69
|
i = 0
|
70
|
-
hash.each_pair do |k,v|
|
70
|
+
hash.each_pair do |k,v|
|
71
71
|
if v.is_a?(Hash)
|
72
72
|
add_process(v.merge({:name => k, :sequence => i+=1}))
|
73
73
|
end
|
74
74
|
end
|
75
75
|
end
|
76
|
-
|
76
|
+
|
77
77
|
# Creates the xml used by Dor::WorkflowService.create_workflow
|
78
78
|
# @return [String] An object's initial workflow as defined by the <workflow-def> in content
|
79
79
|
def initial_workflow
|
@@ -95,19 +95,19 @@ class WorkflowDefinitionDs < ActiveFedora::OmDatastream
|
|
95
95
|
}
|
96
96
|
Nokogiri::XML(doc.to_xml) { |x| x.noblanks }.to_xml { |config| config.no_declaration }
|
97
97
|
end
|
98
|
-
|
99
|
-
def to_solr(solr_doc=Hash.new,*args)
|
98
|
+
|
99
|
+
def to_solr(solr_doc = Hash.new,*args)
|
100
100
|
super(solr_doc,*args)
|
101
|
-
add_solr_value(solr_doc, "workflow_name",
|
101
|
+
add_solr_value(solr_doc, "workflow_name", name, :symbol, [:searchable])
|
102
102
|
processes.each do |p|
|
103
103
|
add_solr_value(solr_doc, "process", "#{p.name}|#{p.label}", :symbol, [:displayable])
|
104
104
|
end
|
105
105
|
solr_doc
|
106
106
|
end
|
107
|
-
|
107
|
+
|
108
108
|
def to_yaml
|
109
|
-
YAML.dump(
|
109
|
+
YAML.dump(configuration)
|
110
110
|
end
|
111
|
-
|
111
|
+
|
112
|
+
end
|
112
113
|
end
|
113
|
-
end
|
@@ -4,7 +4,7 @@ Dor::Identifiable.on_upgrade '3.6.1', 'Assert correct models' do |obj|
|
|
4
4
|
obj.remove_relationship :has_model, 'info:fedora/hydra:commonMetadata'
|
5
5
|
applied = true
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
unless obj.relationships.predicates.any? { |p| p.to_s == 'info:fedora/fedora-system:def/model#hasModel' }
|
9
9
|
obj.assert_content_model
|
10
10
|
applied = true
|
@@ -5,11 +5,11 @@ Dor::Processable.on_upgrade '3.5.0', 'Replace individual *WF datastreams with un
|
|
5
5
|
obj.workflows.content
|
6
6
|
run = true
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
# Remove individual *WF datastreams
|
10
|
-
obj.datastreams.each_pair do |dsid,ds|
|
11
|
-
if ds.controlGroup == 'E'
|
12
|
-
ds.delete
|
10
|
+
obj.datastreams.each_pair do |dsid,ds|
|
11
|
+
if ds.controlGroup == 'E' && dsid =~ /WF$/
|
12
|
+
ds.delete
|
13
13
|
run = true
|
14
14
|
end
|
15
15
|
end
|
@@ -1,14 +1,14 @@
|
|
1
1
|
module Dor
|
2
2
|
module Assembleable
|
3
|
-
|
4
|
-
def initialize_workspace(source=nil)
|
3
|
+
|
4
|
+
def initialize_workspace(source = nil)
|
5
5
|
if(source.nil?)
|
6
|
-
druid = DruidTools::Druid.new(
|
6
|
+
druid = DruidTools::Druid.new(pid,Config.stacks.local_workspace_root)
|
7
7
|
druid.mkdir
|
8
8
|
else
|
9
|
-
druid = DruidTools::Druid.new(
|
9
|
+
druid = DruidTools::Druid.new(pid, Config.stacks.local_workspace_root)
|
10
10
|
druid.mkdir_with_final_link(source)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
14
|
-
end
|
14
|
+
end
|
@@ -3,17 +3,17 @@ module Dor
|
|
3
3
|
extend ActiveSupport::Concern
|
4
4
|
|
5
5
|
#add a file to a resource, not to be confused with add a resource to an object
|
6
|
-
def add_file file, resource, file_name, mime_type=nil,publish='no', shelve='no', preserve='no'
|
7
|
-
contentMD=
|
6
|
+
def add_file file, resource, file_name, mime_type = nil,publish = 'no', shelve = 'no', preserve = 'no'
|
7
|
+
contentMD=datastreams['contentMetadata']
|
8
8
|
xml=contentMD.ng_xml
|
9
9
|
#make sure the resource exists
|
10
10
|
if xml.search('//resource[@id=\''+resource+'\']').length == 0
|
11
11
|
raise 'resource doesnt exist.'
|
12
12
|
end
|
13
13
|
sftp=Net::SFTP.start(Config.content.content_server,Config.content.content_user,:auth_methods=>['publickey'])
|
14
|
-
druid_tools=DruidTools::Druid.new(
|
14
|
+
druid_tools=DruidTools::Druid.new(pid,Config.content.content_base_dir)
|
15
15
|
location=druid_tools.path(file_name)
|
16
|
-
oldlocation=location.gsub('/'+
|
16
|
+
oldlocation=location.gsub('/'+pid.gsub('druid:',''),'')
|
17
17
|
md5=Digest::MD5.file(file.path).hexdigest
|
18
18
|
sha1=Digest::SHA1.file(file.path).hexdigest
|
19
19
|
size=File.size?(file.path)
|
@@ -26,7 +26,7 @@ module Dor
|
|
26
26
|
raise 'The file '+file_name+' already exists!'
|
27
27
|
rescue Net::SFTP::StatusException
|
28
28
|
sftp.upload!(file.path,location)
|
29
|
-
|
29
|
+
contentMetadata.add_file file_hash,resource
|
30
30
|
end
|
31
31
|
rescue Net::SFTP::StatusException
|
32
32
|
#the directory layout doesnt match the new style, so use the old style.
|
@@ -36,7 +36,7 @@ module Dor
|
|
36
36
|
rescue Net::SFTP::StatusException
|
37
37
|
#the file doesnt already exist, which is good. Add it
|
38
38
|
sftp.upload!(file.path,oldlocation)
|
39
|
-
|
39
|
+
contentMetadata.add_file file_hash,resource
|
40
40
|
end
|
41
41
|
end
|
42
42
|
#can only arrive at this point if a non status exception occurred.
|
@@ -44,10 +44,10 @@ module Dor
|
|
44
44
|
|
45
45
|
def replace_file file,file_name
|
46
46
|
sftp=Net::SFTP.start(Config.content.content_server,Config.content.content_user,:auth_methods=>['publickey'])
|
47
|
-
item=Dor::Item.find(
|
48
|
-
druid_tools=DruidTools::Druid.new(
|
47
|
+
item=Dor::Item.find(pid)
|
48
|
+
druid_tools=DruidTools::Druid.new(pid,Config.content.content_base_dir)
|
49
49
|
location=druid_tools.path(file_name)
|
50
|
-
oldlocation=location.gsub('/'+
|
50
|
+
oldlocation=location.gsub('/'+pid.gsub('druid:',''),'')
|
51
51
|
|
52
52
|
md5=Digest::MD5.file(file.path).hexdigest
|
53
53
|
sha1=Digest::SHA1.file(file.path).hexdigest
|
@@ -66,7 +66,7 @@ module Dor
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def get_preserved_file file, version
|
69
|
-
preservation_server=Config.content.sdr_server+'/sdr/objects/'+
|
69
|
+
preservation_server=Config.content.sdr_server+'/sdr/objects/'+pid+"/content/"
|
70
70
|
file=URI.encode(file)
|
71
71
|
add=preservation_server+file+"?version="+version
|
72
72
|
uri = URI(add)
|
@@ -78,9 +78,9 @@ module Dor
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def get_file file
|
81
|
-
druid_tools=DruidTools::Druid.new(
|
81
|
+
druid_tools=DruidTools::Druid.new(pid,Config.content.content_base_dir)
|
82
82
|
location=druid_tools.path(file)
|
83
|
-
oldlocation=location.gsub('/'+file,'').gsub('/'+
|
83
|
+
oldlocation=location.gsub('/'+file,'').gsub('/'+pid.gsub('druid:',''),'')+'/'+file
|
84
84
|
sftp=Net::SFTP.start(Config.content.content_server,Config.content.content_user,:auth_methods=>['publickey'])
|
85
85
|
begin
|
86
86
|
data=sftp.download!(location)
|
@@ -89,9 +89,9 @@ module Dor
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
def remove_file filename
|
92
|
-
druid_tools=DruidTools::Druid.new(
|
92
|
+
druid_tools=DruidTools::Druid.new(pid,Config.content.content_base_dir)
|
93
93
|
location=druid_tools.path(filename)
|
94
|
-
oldlocation=location.gsub('/'+
|
94
|
+
oldlocation=location.gsub('/'+pid.gsub('druid:',''),'')
|
95
95
|
sftp=Net::SFTP.start(Config.content.content_server,Config.content.content_user,:auth_methods=>['publickey'])
|
96
96
|
begin
|
97
97
|
data=sftp.remove!(location)
|
@@ -102,37 +102,37 @@ module Dor
|
|
102
102
|
rescue Net::SFTP::StatusException
|
103
103
|
end
|
104
104
|
end
|
105
|
-
|
105
|
+
contentMetadata.remove_file filename
|
106
106
|
end
|
107
107
|
def rename_file old_name, new_name
|
108
|
-
druid_tools=DruidTools::Druid.new(
|
108
|
+
druid_tools=DruidTools::Druid.new(pid,Config.content.content_base_dir)
|
109
109
|
location=druid_tools.path(old_name)
|
110
|
-
oldlocation=location.gsub('/'+
|
110
|
+
oldlocation=location.gsub('/'+pid.gsub('druid:',''),'')
|
111
111
|
sftp=Net::SFTP.start(Config.content.content_server,Config.content.content_user,:auth_methods=>['publickey'])
|
112
112
|
begin
|
113
113
|
data=sftp.rename!(location,location.gsub(old_name,new_name))
|
114
114
|
rescue
|
115
115
|
data=sftp.rename!(oldlocation,oldlocation.gsub(old_name,new_name))
|
116
116
|
end
|
117
|
-
|
117
|
+
contentMetadata.rename_file(old_name, new_name)
|
118
118
|
end
|
119
119
|
def remove_resource resource_name
|
120
120
|
#run delete for all of the files in the resource
|
121
|
-
xml=
|
121
|
+
xml=contentMetadata.ng_xml
|
122
122
|
files=xml.search('//resource[@id=\''+resource_name+'\']/file').each do |file|
|
123
|
-
|
123
|
+
remove_file(file['id'])
|
124
124
|
end
|
125
125
|
#remove the resource record from the metadata and renumber the resource sequence
|
126
|
-
|
126
|
+
contentMetadata.remove_resource resource_name
|
127
127
|
end
|
128
128
|
#list files in the workspace
|
129
129
|
def list_files
|
130
130
|
filename='none'
|
131
131
|
files=[]
|
132
132
|
sftp=Net::SFTP.start(Config.content.content_server,Config.content.content_user,:auth_methods=>['publickey'])
|
133
|
-
druid_tools=DruidTools::Druid.new(
|
133
|
+
druid_tools=DruidTools::Druid.new(pid,Config.content.content_base_dir)
|
134
134
|
location=druid_tools.path(filename).gsub(filename,'')
|
135
|
-
oldlocation=location.gsub('/'+
|
135
|
+
oldlocation=location.gsub('/'+pid.gsub('druid:',''),'')
|
136
136
|
begin
|
137
137
|
sftp.dir.entries(location, "*") do |file|
|
138
138
|
files<<file.name
|
@@ -146,7 +146,7 @@ module Dor
|
|
146
146
|
return files
|
147
147
|
end
|
148
148
|
end
|
149
|
-
|
149
|
+
files
|
150
150
|
end
|
151
151
|
|
152
152
|
# Appends contentMetadata file resources from the source objects to this object
|
@@ -172,7 +172,7 @@ module Dor
|
|
172
172
|
secondary_file['id'] = new_secondary_file_name(secondary_file['id'], max_sequence)
|
173
173
|
|
174
174
|
if primary_cm.at_xpath("//file[@id = '#{secondary_file["id"]}']")
|
175
|
-
raise Dor::Exception.new "File '#{secondary_file['id']}' from secondary object #{src_pid} already exist in primary object: #{
|
175
|
+
raise Dor::Exception.new "File '#{secondary_file['id']}' from secondary object #{src_pid} already exist in primary object: #{pid}"
|
176
176
|
end
|
177
177
|
end
|
178
178
|
|
@@ -194,7 +194,7 @@ module Dor
|
|
194
194
|
resource_copy.first_element_child.add_previous_sibling attr_node
|
195
195
|
end
|
196
196
|
end
|
197
|
-
|
197
|
+
contentMetadata.content_will_change!
|
198
198
|
end
|
199
199
|
|
200
200
|
def new_secondary_file_name old_name, sequence_num
|
@@ -223,4 +223,4 @@ module Dor
|
|
223
223
|
add_tag "Decommissioned : #{tag}"
|
224
224
|
end
|
225
225
|
end
|
226
|
-
end
|
226
|
+
end
|