lyber-core 0.9.6.2.3 → 1.3.0

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 DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- MTk4OWM3ZjU4MzBjMWM4MWNkNjE5YjEzYjhiNmQ3NGZiNWU5MDkxNw==
5
- data.tar.gz: !binary |-
6
- MzdiOTUzNGVkYzhmZTBiMzE1MzdiZTFiZmU5ZjYyNzQ2NWY2OTBkMg==
7
- SHA512:
8
- metadata.gz: !binary |-
9
- ZTQwMjNkYTBmN2RjYmQ1ODg2ODNhZDRlNzRmMGU0N2E4ZTZkZDYwY2E2NWQw
10
- ZDY0YmNlNGU4MWM2MTdjMWY2ODZhNGE4ODc2ZDMxYmY5NjFkMDI3NGE4ZDY2
11
- OTJhMDkxODM0Mzc2ZTc2Y2U1NGM0MDEzMmE4MzIxMjk2NWFhMWU=
12
- data.tar.gz: !binary |-
13
- N2NjOGRkZjM5ZDE3OTgzMDYwMTgwMjBkZjdiYjZjMTRhZDZhOTgwNmM4MjEx
14
- ZDI2NmQ3MzMxOTUwMTdjZTNiNjk4MTdiNTkzNTBhMjNlZmM2NDFjY2VhMTY5
15
- ZDZkM2MyZjExNTNjMjRkY2Y2OTk3MDUzZWQxY2Q5ZTUwNmE1YmQ=
data/lib/dor/base.rb DELETED
@@ -1,18 +0,0 @@
1
-
2
- module Dor
3
-
4
- class Base < ActiveFedora::Base
5
- def initialize(attrs = {})
6
- unless attrs[:pid]
7
- attrs = attrs.merge!({:pid=>Dor::SuriService.mint_id})
8
- @new_object=true
9
- else
10
- @new_object = attrs[:new_object] == false ? false : true
11
- end
12
- @inner_object = Fedora::FedoraObject.new(attrs)
13
- @datastreams = {}
14
- configure_defined_datastreams
15
- end
16
- end
17
-
18
- end
@@ -1,28 +0,0 @@
1
- require 'net/https'
2
- require 'active_fedora'
3
-
4
- module Dor
5
- class SuriService
6
-
7
- # If Dor::MINT_SURI_IDS is set to ture, then this method
8
- # Returns ID_NAMESPACE:id_from_suri
9
- # Throws an exception if there were any problems
10
- def self.mint_id
11
- unless(Dor::MINT_SURI_IDS)
12
- return Fedora::Repository.instance.nextid
13
- end
14
-
15
- #Post with no body
16
- id = LyberCore::Connection.post("#{SURI_URL}/suri2/namespaces/#{ID_NAMESPACE}/identifiers", nil,
17
- :auth_user => Dor::SURI_USER, :auth_password => Dor::SURI_PASSWORD)
18
-
19
- return "#{Dor::ID_NAMESPACE}:#{id.strip}"
20
-
21
- rescue Exception => e
22
- Rails.logger.error("Unable to mint id from suri: #{e.to_s}")
23
- raise e
24
- end
25
-
26
-
27
- end
28
- end
@@ -1,112 +0,0 @@
1
-
2
- module Dor
3
-
4
- # Methods to create and update workflow
5
- #
6
- # ==== Required Constants
7
- # - Dor::CREATE_WORKFLOW : true or false. Can be used to turn of workflow in a particular environment, like development
8
- # - Dor::WF_URI : The URI to the workflow service. An example URI is 'http://lyberservices-dev.stanford.edu/workflow'
9
- module WorkflowService
10
-
11
- # Creates a workflow for a given object in the repository. If this particular workflow for this objects exists,
12
- # it will replace the old workflow with wf_xml passed to this method.
13
- # Returns true on success. Caller must handle any exceptions
14
- #
15
- # == Parameters
16
- # - <b>repo</b> - The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
17
- # - <b>druid</b> - The id of the object
18
- # - <b>workflow_name</b> - The name of the workflow you want to create
19
- # - <b>wf_xml</b> - The xml that represents the workflow
20
- #
21
- def WorkflowService.create_workflow(repo, druid, workflow_name, wf_xml)
22
- return true unless(Dor::CREATE_WORKFLOW)
23
-
24
- full_uri = ''
25
- full_uri << Dor::WF_URI << '/' << repo << '/objects/' << druid << '/workflows/' << workflow_name
26
-
27
- # On success, an empty body is sent
28
- LyberCore::Connection.put(full_uri, wf_xml){|response| true}
29
- end
30
-
31
- # Updates the status of one step in a workflow.
32
- # Returns true on success. Caller must handle any exceptions
33
- #
34
- # == Required Parameters
35
- # - <b>repo</b> - The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
36
- # - <b>druid</b> - The id of the object
37
- # - <b>workflow_name</b> - The name of the workflow
38
- # - <b>status</b> - The status that you want to set. Typical statuses are 'waiting', 'completed', 'error', but could be any string
39
- #
40
- # == Optional Parameters
41
- # - <b>elapsed</b> - The number of seconds it took to complete this step. Can have a decimal. Is set to 0 if not passed in.
42
- # - <b>lifecycle</b> - Bookeeping label for this particular workflow step. Examples are: 'registered', 'shelved'
43
- #
44
- # == Http Call
45
- # The method does an HTTP PUT to the URL defined in Dor::WF_URI. As an example:
46
- # PUT "/dor/objects/pid:123/workflows/GoogleScannedWF/convert"
47
- # <process name=\"convert\" status=\"completed\" />"
48
- def WorkflowService.update_workflow_status(repo, druid, workflow, process, status, elapsed = 0, lifecycle = nil, note = nil)
49
- return true unless(Dor::CREATE_WORKFLOW)
50
-
51
- uri = ''
52
- uri << Dor::WF_URI << '/' << repo << '/objects/' << druid << '/workflows/' << workflow << '/' << process
53
- process_xml = '<process name="'+ process + '" status="' + status + '" '
54
- process_xml << 'elapsed="' + elapsed.to_s + '" '
55
- process_xml << 'lifecycle="' + lifecycle + '" ' if(lifecycle)
56
- process_xml << 'note="' + note + '" ' if(note)
57
- process_xml << '/>'
58
-
59
- # On success, an empty body is sent
60
- LyberCore::Connection.put(uri, process_xml) {|response| true}
61
- end
62
-
63
- #
64
- # Retrieves the process status of the given workflow for the given object identifier
65
- #
66
- def WorkflowService.get_workflow_status(repo, druid, workflow, process)
67
- uri = ''
68
- uri << Dor::WF_URI << '/' << repo << '/objects/' << druid << '/workflows/' << workflow
69
- workflow_md = LyberCore::Connection.get(uri)
70
-
71
- doc = Nokogiri::XML(workflow_md)
72
- raise Exception.new("Unable to parse response:\n#{workflow_md}") if(doc.root.nil?)
73
-
74
- status = doc.root.at_xpath("//process[@name='#{process}']/@status").content
75
- return status
76
- end
77
-
78
- def WorkflowService.get_workflow_xml(repo, druid, workflow)
79
- uri = ''
80
- uri << Dor::WF_URI << '/' << repo << '/objects/' << druid << '/workflows/' << workflow
81
- workflow_md = LyberCore::Connection.get(uri)
82
- end
83
-
84
- # Updates the status of one step in a workflow to error.
85
- # Returns true on success. Caller must handle any exceptions
86
- #
87
- # == Required Parameters
88
- # - <b>repo</b> - The repository the object resides in. The service recoginzes "dor" and "sdr" at the moment
89
- # - <b>druid</b> - The id of the object
90
- # - <b>workflow_name</b> - The name of the workflow
91
- # - <b>error_msg</b> - The error message. Ideally, this is a brief message describing the error
92
- #
93
- # == Optional Parameters
94
- # - <b>error_txt</b> - A slot to hold more information about the error, like a full stacktrace
95
- #
96
- # == Http Call
97
- # The method does an HTTP PUT to the URL defined in Dor::WF_URI. As an example:
98
- # PUT "/dor/objects/pid:123/workflows/GoogleScannedWF/convert"
99
- # <process name=\"convert\" status=\"error\" />"
100
- def WorkflowService.update_workflow_error_status(repo, druid, workflow, process, error_msg, error_txt = nil)
101
- uri = ''
102
- uri << Dor::WF_URI << '/' << repo << '/objects/' << druid << '/workflows/' << workflow << '/' << process
103
- process_xml = '<process name="'+ process + '" status="error" errorMessage="' + error_msg + '" '
104
- process_xml << 'errorText="' + error_txt + '" ' if(error_txt)
105
- process_xml << '/>'
106
-
107
- # On success, an empty body is sent
108
- LyberCore::Connection.put(uri, process_xml) {|response| true}
109
- end
110
-
111
- end
112
- end
@@ -1,126 +0,0 @@
1
- require 'rake/tasklib'
2
- require 'pony'
3
-
4
- module LyberCore
5
-
6
- # A rake task that will tag, build and publish your gem to the DLSS gemserver
7
- #
8
- # == Usage
9
- # Include the following two lines in your <tt>Rakefile</tt>:
10
- # require 'lyber_core/rake/dlss_release'
11
- # LyberCore::DlssRelease.new
12
- #
13
- # To build and release the gem, run the following AFTER pushing your code to the git repository on AFS:
14
- # rake dlss_release
15
- #
16
- # == Requirements
17
- # - You need <b>ONE</b> <tt>your-gemname.gemspec</tt> file in the root of your project. See the example in <tt>lyber-core.gemspec</tt> or look at http://yehudakatz.com/2010/04/02/using-gemspecs-as-intended/
18
- # - Inside the <tt>Gem::Specification</tt> block of the <tt>your-gemname.gemspec</tt> file, you must set the version number. For example
19
- # Gem::Specification.new do |s|
20
- # s.name = "your-gemname"
21
- # ...
22
- # s.version = "0.9.6"
23
- # ...
24
- # end
25
- # - You need to have access to the account on the DLSS gemserver, usually by adding your sunetid to the .k5login. You also need git installed.
26
- class DlssRelease < Rake::TaskLib
27
- # Name of the rake task. Defaults to :dlss_release
28
- attr_accessor :name
29
-
30
- # Name of the gem
31
- attr_accessor :gemname
32
-
33
- # Version of the gem being released
34
- attr_accessor :version
35
-
36
- def initialize(name=:dlss_release)
37
- @name = name
38
- @gemname = determine_gemname
39
- yield self if block_given?
40
- raise "Gemname must be set" if @gemname.nil?
41
- define
42
- end
43
-
44
- # Tries to parse the gemname from the prefix of the <tt>your-gemname.gemspec</tt> file.
45
- def determine_gemname
46
- files = Dir.glob("*.gemspec")
47
- raise "Unable to find project gemspec file.\nEither it doesn't exist or there are too many files ending in .gemspec" if(files.size != 1)
48
-
49
- files.first =~ /(.*)\.gemspec/
50
- $1
51
- end
52
-
53
- def send_release_announcement
54
- Pony.mail(:to => 'dlss-developers@lists.stanford.edu',
55
- :from => 'dlss-developers@lists.stanford.edu',
56
- :subject => "Release #{@version} of the #{@gemname} gem",
57
- :body => "The #{@gemname}-#{@version}.gem has been released to the DLSS gemserver",
58
- :via => :smtp,
59
- :via_options => {
60
- :address => 'smtp.stanford.edu',
61
- :port => '25',
62
- :enable_starttls_auto => true,
63
- :authentication => :plain, # :plain, :login, :cram_md5, no auth by default
64
- :domain => "localhost.localdomain" # the HELO domain provided by the client to the server
65
- }
66
- )
67
- end
68
-
69
- def define
70
- desc "Tag, build, and release DLSS specified gem"
71
- task @name do
72
- IO.foreach(File.join(Rake.original_dir, "#{@gemname}.gemspec")) do |line|
73
- if(line =~ /\.version.*=.*"(.*)"/)
74
- @version = $1
75
- break
76
- end
77
- end
78
-
79
- if(@version.nil?)
80
- raise "Unable to find version number in #{@gemname}.gemspec"
81
- end
82
- created_gem = "#{@gemname}-#{@version}.gem"
83
-
84
- puts "Make sure:"
85
- puts " 1) Version #{@version} of #{@gemname} has not been tagged and released previously"
86
- puts " 2) All of the tests pass"
87
- puts " 3) You've pushed the code to the git repository on AFS (usually 'git push origin master')"
88
- puts "Type 'yes' to continue if all of these statements are true"
89
-
90
- resp = STDIN.gets.chomp
91
- unless(resp =~ /yes/ )
92
- raise "Please complete the prerequisites"
93
- end
94
-
95
- puts "Releasing version #{@version} of the #{@gemname} gem"
96
-
97
- begin
98
- tags = `git tag`.split("\n")
99
- raise "tag v#{@version} already exists. Change the version number in the #{@gemname}.gemspec file" if tags.include?("v#{@version}")
100
-
101
- puts "...Tagging release"
102
- sh "git tag -a v#{@version} -m 'Gem version #{@version}'"
103
- sh "git push origin --tags"
104
-
105
- puts "...Building gem"
106
- sh "gem build #{@gemname}.gemspec"
107
-
108
- puts "...Publishing gem to sulair-rails-dev DLSS gemserver"
109
- sh "scp #{created_gem} webteam@sulair-rails-dev.stanford.edu:/var/www/html/gems"
110
- sh "ssh webteam@sulair-rails-dev.stanford.edu gem generate_index -d /var/www/html"
111
-
112
- puts "Done!!!!! A local copy of the gem is in the pkg directory"
113
- FileUtils.mkdir("pkg") unless File.exists?("pkg")
114
- FileUtils.mv("#{created_gem}", "pkg")
115
- rescue Exception => e
116
- FileUtils.rm("#{created_gem}") if(File.exists?("#{created_gem}"))
117
- raise e
118
- end
119
-
120
- puts "Sending release announcement to DLSS developers list"
121
- send_release_announcement
122
-
123
- end
124
- end
125
- end
126
- end
@@ -1,46 +0,0 @@
1
- require 'rubygems'
2
- require 'roxml'
3
-
4
- #<oai_dc:dc xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/"
5
- #xmlns:srw_dc="info:srw/schema/1/dc-schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
6
- #xsi:schemaLocation="http://www.openarchives.org/OAI/2.0/oai_dc/ http://cosimo.stanford.edu/standards/oai_dc/v2/oai_dc.xsd">
7
- # <dc:title>Life of Abraham Lincoln, sixteenth president of the United States: Containing his early
8
- #history and political career; together with the speeches, messages, proclamations and other official
9
- #documents illus. of his eventful administration</dc:title>
10
- # <dc:creator>Crosby, Frank.</dc:creator>
11
- # <dc:format>text</dc:format>
12
- # <dc:language>eng</dc:language>
13
- # <dc:subject>E457 .C94</dc:subject>
14
- # <dc:identifier>lccn:11030686</dc:identifier>
15
- # <dc:identifier>callseq:1</dc:identifier>
16
- # <dc:identifier>shelfseq:973.7111 .L731CR</dc:identifier>
17
- # <dc:identifier>catkey:1206382</dc:identifier>
18
- # <dc:identifier>barcode:36105005459602</dc:identifier>
19
- # <dc:identifier>uuid:ddcf5f1a-0331-4345-beca-e66f7db276eb</dc:identifier>
20
- # <dc:identifier>google:STANFORD_36105005459602</dc:identifier>
21
- # <dc:identifier>druid:ng786kn0371</dc:identifier>
22
- #</oai_dc:dc>
23
-
24
- class DublinCore
25
- include ROXML
26
- xml_namespaces \
27
- :oai_dc => "http://www.openarchives.org/OAI/2.0/oai_dc/",
28
- :dc => "http://purl.org/dc/elements/1.1/"
29
-
30
- xml_name :root => 'oai_dc:dc'
31
- xml_reader :title, :as => [], :from => 'dc:title'
32
- xml_reader :creator, :as => [], :from => 'dc:creator'
33
- xml_reader :subject, :as => [], :from => 'dc:subject'
34
- xml_reader :description, :as => [], :from => 'dc:description'
35
- xml_reader :publisher, :as => [], :from => 'dc:publisher'
36
- xml_reader :contributor, :as => [], :from => 'dc:contributor'
37
- xml_reader :date, :as => [], :from => 'dc:date'
38
- xml_reader :type, :as => [], :from => 'dc:type'
39
- xml_reader :format, :as => [], :from => 'dc:format'
40
- xml_reader :identifier, :as => [], :from => 'dc:identifier'
41
- xml_reader :source, :as => [], :from => 'dc:source'
42
- xml_reader :language, :as => [], :from => 'dc:language'
43
- xml_reader :relation, :as => [], :from => 'dc:relation'
44
- xml_reader :coverage, :as => [], :from => 'dc:coverage'
45
- xml_reader :rights, :as => [], :from => 'dc:rights'
46
- end
@@ -1,118 +0,0 @@
1
- require 'rubygems'
2
- require 'roxml'
3
-
4
- #<identityMetadata>
5
- # <objectId>druid:rt923jk342</objectId>
6
- # <objectType>item</objectType>
7
- # <objectLabel>google download barcode 36105049267078</objectLabel>
8
- # <objectCreator>DOR</objectCreator>
9
- # <citationTitle>Squirrels of North America</citationTitle>
10
- # <citationCreator>Eder, Tamara, 1974-</citationCreator>
11
- # <sourceId source="google">STANFORD_342837261527</sourceId>
12
- # <otherId name="barcode">342837261527</otherId>
13
- # <otherId name="catkey">129483625</otherId>
14
- # <otherId name="uuid">7f3da130-7b02-11de-8a39-0800200c9a66</otherId>
15
- # <agreementId>druid:yh72ms9133</agreementId>
16
- # <tag>Google Books : Phase 1</tag>
17
- # <tag>Google Books : Scan source STANFORD</tag>
18
- #</identityMetadata>
19
-
20
- class SourceId
21
- include ROXML
22
-
23
- xml_name :sourceId
24
- xml_accessor :source, :from => '@source'
25
- xml_accessor :value, :from => :content
26
- end
27
-
28
- class OtherId
29
- include ROXML
30
-
31
- xml_name :otherId
32
- xml_accessor :name, :from => '@name'
33
- xml_accessor :value, :from => :content
34
- end
35
-
36
- class Tag
37
- include ROXML
38
- xml_name :tag
39
- xml_accessor :value, :from => :content
40
- end
41
-
42
- class IdentityMetadata
43
- include ROXML
44
-
45
- xml_name :identityMetadata
46
- xml_accessor :objectId
47
- xml_accessor :objectType
48
- xml_accessor :objectAdminClass
49
- xml_accessor :objectLabel
50
- xml_accessor :objectCreator
51
- xml_accessor :citationTitle
52
- xml_accessor :citationCreator
53
- xml_accessor :sourceId, :as => SourceId
54
- xml_accessor :otherIds, :as => [OtherId]
55
- xml_accessor :agreementId
56
- xml_accessor :tags, :as => [Tag]
57
-
58
- # Add a new tag to the IdentityMetadata instance
59
- def add_tag(new_tag_value)
60
- # Make sure tag is not already present
61
- for tag in @tags do
62
- if (tag.value == new_tag_value )
63
- return
64
- end
65
- end
66
- tag = Tag.new
67
- tag.value = new_tag_value
68
- @tags << tag
69
- end
70
-
71
- # Return the OtherId object for the specified identier name
72
- def get_other_id(key)
73
- if (@otherIds != nil)
74
- for other_id in @otherIds do
75
- return other_id if (other_id.name == key)
76
- end
77
- end
78
- return nil
79
- end
80
-
81
- # Return the identifier value for the specified identier name
82
- def get_identifier_value(key)
83
- other_id = self.get_other_id(key)
84
- if (other_id != nil)
85
- return other_id.value
86
- end
87
- raise "No #{key} indentifier found for druid #{@objectId}"
88
- end
89
-
90
- # Add a new name,value pair to the set of identifiers
91
- def add_identifier(key, value)
92
- other_id = self.get_other_id(key)
93
- if (other_id != nil)
94
- other_id.value = value
95
- else
96
- other_id = OtherId.new
97
- other_id.name = key
98
- other_id.value = value
99
- if (@otherIds == nil)
100
- @otherIds = [other_id]
101
- else
102
- @otherIds << other_id
103
- end
104
- end
105
- end
106
-
107
- # Return an array of strings where each entry consists of name:value
108
- def get_id_pairs
109
- pairs=Array.new
110
- if (@otherIds != nil)
111
- @otherIds.each do |other_id|
112
- pairs << "#{other_id.name}:#{other_id.value}"
113
- end
114
- end
115
- return pairs
116
- end
117
-
118
- end