dor-services 5.0.2 → 5.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f18cae14cad4e7d46c99fd2805fb8517ef0d4020
4
- data.tar.gz: 853c360a25789be6c4d541e20ddd5f875bf9aaca
3
+ metadata.gz: 220d7103c61a4210c39dd0a7d7f92f08c1fc3b16
4
+ data.tar.gz: 7ed5456b52b9d10a701b36a3c82e02189589e806
5
5
  SHA512:
6
- metadata.gz: 06e4ded70b6d91f0751240b1b122260c6ac0d7994405e9e37b2192e83655235ad807d377a80114449ef3db79741b3d4084cc373d88bee1a495670fbed16822ac
7
- data.tar.gz: 1624211169fdcfb9f7da970bb614a0f5e3d9704f9e551acde3d497c4f22b178f8c5a8c92c7aade636cf10c4fdf03387aba196b2d178029a4d8688ff90da665c0
6
+ metadata.gz: c419b64ebe780589176fa5bd7a9b77bc4b8dbade3899710e9984af0d42469327bfa62efda0d7565e9f59a9792ba82238f9e4a59d4410865c5871bbaa84c488a7
7
+ data.tar.gz: 074921fed0d04103962f77d87e96d39235ff693a04c7d439b0f76e906f8977a8f47a9c71b37e43607164bfdebc5bffdded6f622b026811329bc36e7685222f03
@@ -37,8 +37,8 @@ Dor::Config.configure do
37
37
  local_document_cache_root '/purl/document_cache'
38
38
  end
39
39
 
40
- gsearch.url 'https://dor-dev.stanford.edu/solr/gsearch'
41
- solrizer.url 'https://dor-dev.stanford.edu/solr'
40
+ gsearch.url 'https://sul-dor-dev.stanford.edu/solr/gsearch'
41
+ solrizer.url 'https://sul-dor-dev.stanford.edu/solr'
42
42
  workflow.url 'https://lyberservices-dev.stanford.edu/workflow/'
43
43
  dor_services.url 'https://dorAdmin:dorAdmin@sul-lyberservices-dev.stanford.edu/dor/v1'
44
44
 
@@ -9,8 +9,8 @@ Dor::Config.configure do
9
9
 
10
10
  ssl do
11
11
  cert_file File.join(cert_dir,"robots-dor-dev.crt")
12
- key_file File.join(cert_dir,"robots-dor-dev.key")
13
- key_pass ''
12
+ key_file File.join(cert_dir,"robots-dor-dev.key")
13
+ key_pass ''
14
14
  end
15
15
 
16
16
  suri do
@@ -22,7 +22,7 @@ Dor::Config.configure do
22
22
  end
23
23
 
24
24
  metadata do
25
- exist.url 'http://server/exist/rest/'
25
+ exist.url 'http://server/exist/rest/'
26
26
  catalog.url 'http://lyberservices-prod.stanford.edu/catalog/mods'
27
27
  end
28
28
 
@@ -37,24 +37,24 @@ Dor::Config.configure do
37
37
  local_document_cache_root '/purl'
38
38
  end
39
39
 
40
- gsearch.url 'https://host/solr/gsearch'
41
- solrizer.url 'https://host/solr'
42
- workflow.url 'https://host/workflow/'
40
+ gsearch.url 'https://host/solr/gsearch'
41
+ solrizer.url 'https://host/solr'
42
+ workflow.url 'https://host/workflow/'
43
43
  dor_services.url 'https://host/dor/v1'
44
44
 
45
45
  cleanup do
46
46
  local_workspace_root '/dor/workspace'
47
- local_export_home '/dor/export'
47
+ local_export_home '/dor/export'
48
48
  end
49
49
 
50
50
  sdr do
51
51
  local_workspace_root '/dor/workspace'
52
- local_export_home '/dor/export'
52
+ local_export_home '/dor/export'
53
53
  datastreams do
54
- contentMetadata 'required'
55
- descMetadata 'required'
56
- identityMetadata 'required'
57
- provenanceMetadata 'required'
54
+ contentMetadata 'required'
55
+ descMetadata 'required'
56
+ identityMetadata 'required'
57
+ provenanceMetadata 'required'
58
58
  relationshipMetadata 'required'
59
59
  rightsMetadata 'optional'
60
60
  sourceMetadata 'optional'
@@ -63,4 +63,4 @@ Dor::Config.configure do
63
63
 
64
64
  accessioning_robot_sleep_time 30
65
65
 
66
- end
66
+ end
@@ -9,7 +9,7 @@ module Dor
9
9
  end
10
10
 
11
11
  def initiate_apo_workflow(name)
12
- self.initialize_workflow(name, 'dor', !self.new_object?)
12
+ self.initialize_workflow(name, !self.new_object?)
13
13
  end
14
14
 
15
15
  # Returns the default lane_id from the item's APO. Will return 'default' if the item does not have
@@ -209,14 +209,14 @@ module Dor
209
209
  # It will set the priorty of the new workflow to the current_priority if it is > 0
210
210
  # It will set lane_id from the item's APO default workflow lane
211
211
  # @param [String] name of the workflow to be initialized
212
- # @param [String] repo name of the repository to create workflow for
213
212
  # @param [Boolean] create_ds create a 'workflows' datastream in Fedora for the object
214
- def initialize_workflow(name, repo='dor', create_ds=true, priority=0)
213
+ # @param [Integer] priority the workflow's priority level
214
+ def initialize_workflow(name, create_ds=true, priority=0)
215
215
  priority = workflows.current_priority if priority == 0
216
216
  opts = { :create_ds => create_ds }
217
217
  opts[:priority] = priority if(priority > 0)
218
218
  opts[:lane_id] = default_workflow_lane
219
- Dor::WorkflowService.create_workflow(repo, self.pid, name, Dor::WorkflowObject.initial_workflow(name), opts)
219
+ Dor::WorkflowService.create_workflow(Dor::WorkflowObject.initial_repo(name), self.pid, name, Dor::WorkflowObject.initial_workflow(name), opts)
220
220
  end
221
221
 
222
222
 
@@ -1,3 +1,6 @@
1
+ require 'open-uri'
2
+ require 'retries'
3
+
1
4
  module Dor
2
5
  module Releasable
3
6
  extend ActiveSupport::Concern
@@ -8,7 +11,7 @@ module Dor
8
11
  #@return [String] The XML release node as a string, with ReleaseDigest as the root document
9
12
  def generate_release_xml
10
13
  builder = Nokogiri::XML::Builder.new do |xml|
11
- xml.ReleaseDigest {
14
+ xml.ReleaseData {
12
15
  self.released_for.each do |project,released_value|
13
16
  xml.release(released_value["release"],:to=>project)
14
17
  end
@@ -52,6 +55,9 @@ module Dor
52
55
  end
53
56
 
54
57
  end
58
+
59
+ #See what the application is currently released for on Purl. If something is released in purl but not listed here, it needs to be added as a false
60
+ released_hash = self.add_tags_from_purl(released_hash)
55
61
 
56
62
  return released_hash
57
63
  end
@@ -254,7 +260,7 @@ module Dor
254
260
  #
255
261
  #@params tag [Boolean] True or false for the release node
256
262
  #@params attrs [hash] A hash of any attributes to be placed onto the tag
257
- # release tag example:
263
+ #@example
258
264
  # item.add_tag(true,:release,{:tag=>'Fitch : Batch2',:what=>'self',:to=>'Searchworks',:who=>'petucket'})
259
265
  def add_release_node(release, attrs={})
260
266
  identity_metadata_ds = self.identityMetadata
@@ -305,6 +311,86 @@ module Dor
305
311
  end
306
312
  return return_hash
307
313
  end
314
+
315
+ #Get a list of all release nodes found in a purl document
316
+ #
317
+ #@params druid [String]
318
+ #
319
+ #@raises [OpenURI::HTTPError]
320
+ #
321
+ #Fetches purl xml for a druid
322
+ #
323
+ #@return [Nokogiri::HTML::Document] the parsed xml for the druid or an empty document if no purl is found
324
+ def get_xml_from_purl
325
+ handler = Proc.new do |exception, attempt_number, total_delay|
326
+ #We assume a 404 means the document has never been published before and thus has no purl
327
+ #The strip is needed before the actual message is "404 "
328
+ return Nokogiri::HTML::Document.new if exception.message.strip == "404"
329
+ end
330
+
331
+ with_retries(:max_retries => 5, :base_sleep_seconds => 3, :max_sleep_seconds=> 5, :rescue => OpenURI::HTTPError, :handler => handler) {
332
+ #If you change the method used for opening the webpage, you can change the :rescue param to handle the new method's errors
333
+ return Nokogiri::HTML(open(self.form_purl_url))
334
+ }
335
+
336
+ end
337
+
338
+ #Since purl does not use the druid: prefix but much of dor does, use this function to strip the druid: if needed
339
+ #
340
+ #@return [String] the druid sans the druid: or if there was no druid: prefix, the entire string you passed
341
+ def remove_druid_prefix
342
+ druid_prefix = "druid:"
343
+ return self.id.split(druid_prefix)[1] if self.id.split(druid_prefix).size > 1
344
+ return druid
345
+ end
346
+
347
+ #Take the and create the entire purl url that will usable for the open method in open-uri, returns http
348
+ #
349
+ #params druid [String], the druid without or without the driud prefix
350
+ #
351
+ #return [String], the full url
352
+ def form_purl_url
353
+ prefix = "http://"
354
+ return prefix + Dor::Config.stacks.document_cache_host + "/#{self.remove_druid_prefix}.xml"
355
+ end
356
+
357
+ #Pull all release nodes from the public xml obtained via the purl query
358
+ #
359
+ #@params druid [Nokogiri::HTML::Document] The druid of the object you want
360
+ #
361
+ #@return [Array] An array containing all the release tags
362
+ def get_release_tags_from_purl_xml(doc)
363
+ nodes = doc.xpath("//html/body/publicobject/releasedata").children
364
+ #We only want the nodes with a name that isn't text
365
+ return_array = []
366
+ nodes.each do |n|
367
+ return_array << n.attr('to') if n.name != nil and n.name.downcase != "text"
368
+ end
369
+ return return_array.uniq
370
+ end
371
+
372
+ #Pull all release nodes from the public xml obtained via the purl query
373
+ #
374
+ #@return [Array] An array containing all the release tags
375
+ def get_release_tags_from_purl
376
+ xml = self.get_xml_from_purl
377
+ return self.get_release_tags_from_purl_xml(xml)
378
+ end
379
+
380
+ #This function calls purl and gets a list of all release tags currently in purl. It then compares to the list you have generated.
381
+ #Any tag that is on purl, but not in the newly generated list is added to the new list with a value of false.
382
+ #
383
+ #params new_tags [Hash] a hash of all new tags in the form of {Project => Boolean}, where Project is a string
384
+ #
385
+ #return [Hash], a hash in the same form as new_tags, with all missing tags not in new_tags, but in current_tag_names, added in with a Boolean value of false
386
+ def add_tags_from_purl(new_tags)
387
+ tags_currently_in_purl = self.get_release_tags_from_purl
388
+ missing_tags = tags_currently_in_purl.map(&:downcase) - new_tags.keys.map(&:downcase)
389
+ missing_tags.each do |missing_tag|
390
+ new_tags[missing_tag.capitalize] = false
391
+ end
392
+ return new_tags
393
+ end
308
394
 
309
395
  end
310
396
  end
@@ -33,7 +33,7 @@ module Dor
33
33
  if opts.has_key?(k)
34
34
  # During local development, Hydrus (or some other app running Fedora locally)
35
35
  # does not want this call to initialize the workflows datastream.
36
- initialize_workflow('versioningWF', 'dor', opts[k])
36
+ initialize_workflow('versioningWF', opts[k])
37
37
  else
38
38
  initialize_workflow('versioningWF')
39
39
  end
@@ -6,6 +6,7 @@ module Dor
6
6
  include SolrDocHelper
7
7
  include Governable
8
8
  @@xml_cache = {}
9
+ @@repo_cache = {}
9
10
 
10
11
  has_object_type 'workflow'
11
12
  has_metadata :name => "workflowDefinition", :type => Dor::WorkflowDefinitionDs, :label => 'Workflow Definition'
@@ -13,8 +14,8 @@ module Dor
13
14
  def self.find_by_name(name, opts={})
14
15
  Dor.find_all(%{#{Solrizer.solr_name "objectType", :facetable}:"#{self.object_type}" #{Solrizer.solr_name "workflow_name", :symbol}:"#{name}"}, opts).first
15
16
  end
16
-
17
- # Searches for the workflow definition object in DOR, then
17
+
18
+ # Searches for the workflow definition object in DOR, then
18
19
  # returns an object's initial workflow as defined in the worfklowDefinition datastream
19
20
  # It will cache the result for subsequent requests
20
21
  # @param [String] name the name of the workflow
@@ -22,19 +23,29 @@ module Dor
22
23
  def self.initial_workflow(name)
23
24
  return @@xml_cache[name] if(@@xml_cache.include?(name))
24
25
 
25
- wobj = self.find_by_name(name)
26
- wf_xml = wobj.generate_initial_workflow
27
- @@xml_cache[name] = wf_xml
26
+ self.find_and_cache_workflow_xml_and_repo name
27
+ @@xml_cache[name]
28
+ end
29
+
30
+ # Returns the repository attribute from the workflow definition
31
+ # It will cache the result for subsequent requests
32
+ # @param [String] name the name of the workflow
33
+ # @return [String] the initial workflow xml
34
+ def self.initial_repo(name)
35
+ return @@repo_cache[name] if(@@repo_cache.include?(name))
36
+
37
+ self.find_and_cache_workflow_xml_and_repo name
38
+ @@repo_cache[name]
28
39
  end
29
40
 
30
41
  def definition
31
42
  datastreams['workflowDefinition']
32
43
  end
33
-
44
+
34
45
  def graph *args
35
46
  self.definition.graph *args
36
47
  end
37
-
48
+
38
49
  def to_solr solr_doc=Hash.new, *args
39
50
  super solr_doc, *args
40
51
  client = Dor::WorkflowService.workflow_resource
@@ -50,5 +61,14 @@ module Dor
50
61
 
51
62
  alias_method :generate_intial_workflow, :generate_initial_workflow
52
63
 
64
+ # Searches DOR for the workflow definition object. It then caches the workflow repository and xml
65
+ # @param [String] naem the name of the workflow
66
+ def self.find_and_cache_workflow_xml_and_repo name
67
+ wobj = self.find_by_name(name)
68
+ wf_xml = wobj.generate_initial_workflow
69
+ @@repo_cache[name] = wobj.definition.repo
70
+ @@xml_cache[name] = wf_xml
71
+ end
72
+
53
73
  end
54
74
  end
@@ -105,7 +105,7 @@ module Dor
105
105
  workflow_priority = params[:workflow_priority] ? params[:workflow_priority].to_i : 0
106
106
 
107
107
  Array(params[:seed_datastream]).each { |datastream_name| new_item.build_datastream(datastream_name) }
108
- Array(params[:initiate_workflow]).each { |workflow_id| new_item.initialize_workflow(workflow_id, 'dor', !new_item.new_object?, workflow_priority)}
108
+ Array(params[:initiate_workflow]).each { |workflow_id| new_item.initialize_workflow(workflow_id, !new_item.new_object?, workflow_priority)}
109
109
 
110
110
  new_item.assert_content_model
111
111
 
@@ -36,7 +36,7 @@ module Dor
36
36
  bagger.create_tagfiles
37
37
  verify_bag_structure(bag_dir)
38
38
  # Now bootstrap SDR workflow. but do not create the workflows datastream
39
- dor_item.initialize_workflow('sdrIngestWF', 'sdr', false)
39
+ dor_item.initialize_workflow('sdrIngestWF', false)
40
40
  rescue Exception => e
41
41
  raise LyberCore::Exceptions::ItemError.new(druid, "Export failure", e)
42
42
  end
data/lib/dor/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Dor
2
- VERSION = '5.0.2'
2
+ VERSION = '5.1.0'
3
3
  end
@@ -15,6 +15,7 @@ module Workflow
15
15
  t.elapsed(:path=>{:attribute=>"elapsed"})
16
16
  t.lifecycle(:path=>{:attribute=>"lifecycle"})
17
17
  t.attempts(:path=>{:attribute=>"attempts"}, :index_as => [:not_searchable])
18
+ t.version(:path=>{:attribute=>"version"})
18
19
  }
19
20
  end
20
21
  @@definitions={}
@@ -30,9 +31,10 @@ module Workflow
30
31
  def priority
31
32
  processes.map {|proc| proc.priority.to_i }.detect(0) {|p| p > 0}
32
33
  end
33
-
34
+
35
+ # @return [Boolean] if any process node does not have version, returns true, false otherwise (all processes have version)
34
36
  def active?
35
- processes.any? { |proc| !proc.version }
37
+ ng_xml.at_xpath("/workflow/process[not(@version)]") ? true : false
36
38
  end
37
39
 
38
40
  def definition
@@ -66,7 +68,8 @@ module Workflow
66
68
  if ng_xml.search("/workflow/process").length == 0
67
69
  return []
68
70
  end
69
- @processes ||= if self.definition
71
+ @processes ||=
72
+ if self.definition
70
73
  self.definition.processes.collect do |process|
71
74
  node = ng_xml.at("/workflow/process[@name = '#{process.name}']")
72
75
  process.update!(node,self) unless node.nil?
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dor-services
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.2
4
+ version: 5.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Klein
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-03-09 00:00:00.000000000 Z
15
+ date: 2015-04-07 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: active-fedora
@@ -322,6 +322,20 @@ dependencies:
322
322
  - - '='
323
323
  - !ruby/object:Gem::Version
324
324
  version: 2.3.5
325
+ - !ruby/object:Gem::Dependency
326
+ name: retries
327
+ requirement: !ruby/object:Gem::Requirement
328
+ requirements:
329
+ - - ">="
330
+ - !ruby/object:Gem::Version
331
+ version: '0'
332
+ type: :runtime
333
+ prerelease: false
334
+ version_requirements: !ruby/object:Gem::Requirement
335
+ requirements:
336
+ - - ">="
337
+ - !ruby/object:Gem::Version
338
+ version: '0'
325
339
  - !ruby/object:Gem::Dependency
326
340
  name: dor-workflow-service
327
341
  requirement: !ruby/object:Gem::Requirement
@@ -348,14 +362,14 @@ dependencies:
348
362
  requirements:
349
363
  - - "~>"
350
364
  - !ruby/object:Gem::Version
351
- version: '0.3'
365
+ version: '0.4'
352
366
  type: :runtime
353
367
  prerelease: false
354
368
  version_requirements: !ruby/object:Gem::Requirement
355
369
  requirements:
356
370
  - - "~>"
357
371
  - !ruby/object:Gem::Version
358
- version: '0.3'
372
+ version: '0.4'
359
373
  - !ruby/object:Gem::Dependency
360
374
  name: lyber-utils
361
375
  requirement: !ruby/object:Gem::Requirement