-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from hudmol/handles
Handles
- Loading branch information
Showing
13 changed files
with
221 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'http://rubygems.org' | ||
|
||
gem 'savon', '~> 2.11', '>= 2.11.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
GEM | ||
remote: http://rubygems.org/ | ||
specs: | ||
akami (1.3.1) | ||
gyoku (>= 0.4.0) | ||
nokogiri | ||
builder (3.2.3) | ||
gyoku (1.3.1) | ||
builder (>= 2.1.2) | ||
httpi (2.4.2) | ||
rack | ||
socksify | ||
mini_portile2 (2.1.0) | ||
nokogiri (1.6.8.1) | ||
mini_portile2 (~> 2.1.0) | ||
nokogiri (1.6.8.1-java) | ||
nori (2.6.0) | ||
rack (1.6.8) | ||
savon (2.11.1) | ||
akami (~> 1.2) | ||
builder (>= 2.1.2) | ||
gyoku (~> 1.2) | ||
httpi (~> 2.3) | ||
nokogiri (>= 1.4.0) | ||
nori (~> 2.4) | ||
wasabi (~> 3.4) | ||
socksify (1.7.1) | ||
wasabi (3.5.0) | ||
httpi (~> 2.0) | ||
nokogiri (>= 1.4.2) | ||
|
||
PLATFORMS | ||
java | ||
ruby | ||
|
||
DEPENDENCIES | ||
savon (~> 2.11, >= 2.11.1) | ||
|
||
BUNDLED WITH | ||
1.15.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/bin/bash | ||
|
||
BASEDIR=$(dirname "$0")/../ | ||
|
||
export GEM_HOME="$BASEDIR/gems" | ||
export GEM_PATH="$BASEDIR/gems" | ||
|
||
cd "$BASEDIR" | ||
|
||
java -cp bin/jruby-complete-9.1.0.0.jar org.jruby.Main -S gem install bundler | ||
|
||
java -cp bin/jruby-complete-9.1.0.0.jar org.jruby.Main gems/bin/bundle install |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
require 'bundler/setup' | ||
Bundler.require | ||
|
||
class ExporterApp | ||
|
||
POLL_INTERVAL = 60 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'savon' | ||
|
||
class HandleClient | ||
|
||
HANDLE_HOST = 'http://hdl.handle.net' | ||
|
||
def initialize(wsdl_url, user, credential, prefix, group, handle_base) | ||
@wsdl_url = wsdl_url | ||
@user = user | ||
@credential = credential | ||
@prefix = prefix | ||
@group = group | ||
@handle_base = handle_base | ||
|
||
# looks like the namespace stuff from the example code isn't required | ||
# leaving it commented for now in case it is needed later | ||
# @namespace = @prefix.sub(/.*?\//, '') + ':' | ||
|
||
@client = Savon.client(wsdl: @wsdl_url) | ||
end | ||
|
||
def create_handle(id, uri) | ||
# unless id.include?(@namespace) | ||
# raise "Handle prefix namespace '#{@namespace}' doesn't match namespace of id '#{id}'" | ||
# end | ||
# handle = [@prefix, id.sub(@namespace, '')].join('/') | ||
|
||
handle = [@prefix, id].join('/') | ||
|
||
response = @client.call(:create_batch_semantic, xml: soap_envelope(handle, uri)) | ||
|
||
unless response.success? | ||
raise "Failed to create handle for id '#{id}' with uri '#{uri}': #{response.to_xml.to_s}" | ||
end | ||
|
||
[HANDLE_HOST, handle].join('/') | ||
end | ||
|
||
private | ||
|
||
def soap_envelope(handle, uri) | ||
<<-EOT | ||
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> | ||
<env:Body> | ||
<tns:createBatchSemantic xmlns:tns="http://ws.ypls.its.yale.edu/"> | ||
<handlesToValues> | ||
<map> | ||
<entry> | ||
<key>#{handle.encode(:xml => :text)}</key> | ||
<value>#{@handle_base.encode(:xml => :text)}#{uri.encode(:xml => :text)}</value> | ||
</entry> | ||
</map> | ||
</handlesToValues> | ||
<group>#{@group.encode(:xml => :text)}</group> | ||
<user>#{@user.encode(:xml => :text)}</user> | ||
<credential>#{@credential.encode(:xml => :text)}</credential> | ||
</tns:createBatchSemantic> | ||
</env:Body> | ||
</env:Envelope> | ||
EOT | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters