Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: DSpace/DSpace
...
head fork: DSpace/DSpace
Checking mergeability… Don't worry, you can still create the pull request.
  • 2 commits
  • 3 files changed
  • 0 commit comments
  • 1 contributor
Commits on Feb 12, 2014
@mwoodiupui mwoodiupui Implement EZID_PATH and use it 057b310
Commits on Apr 02, 2014
@mwoodiupui mwoodiupui Merge pull request #492 from mwoodiupui/DS-1909
[DS-1909] EZID IdentifierProvider broken by recent change to EZID service
fb61ed0
View
63 dspace-api/src/main/java/org/dspace/identifier/ezid/EZIDRequest.java
@@ -38,9 +38,9 @@
{
private static final Logger log = LoggerFactory.getLogger(EZIDRequest.class);
- private static final String ID_PATH = "/ezid/id/" + DOI.SCHEME;
+ private static final String ID_PATH = "/id/" + DOI.SCHEME;
- private static final String SHOULDER_PATH = "/ezid/shoulder/" + DOI.SCHEME;
+ private static final String SHOULDER_PATH = "/shoulder/" + DOI.SCHEME;
private static final String UTF_8 = "UTF-8";
@@ -52,6 +52,8 @@
private final String host;
+ private final String path;
+
private final String authority;
/**
@@ -64,7 +66,9 @@
* @param username an EZID user identity.
* @param password user's password, or {@code null} for none.
* @throws URISyntaxException if host or authority is bad.
+ * @deprecated since 4.1
*/
+ @Deprecated
EZIDRequest(String scheme, String host, String authority, String username, String password)
throws URISyntaxException
{
@@ -72,6 +76,49 @@
this.host = host;
+ this.path = "ezid";
+
+ if (authority.charAt(authority.length()-1) == '/')
+ {
+ this.authority = authority.substring(0, authority.length()-1);
+ }
+ else
+ {
+ this.authority = authority;
+ }
+
+ client = new DefaultHttpClient();
+ if (null != username)
+ {
+ URI uri = new URI(scheme, host, path, null);
+ client.getCredentialsProvider().setCredentials(
+ new AuthScope(uri.getHost(), uri.getPort()),
+ new UsernamePasswordCredentials(username, password));
+ }
+ }
+
+ /**
+ * Prepare a context for requests concerning a specific identifier or
+ * authority prefix.
+ *
+ * @param scheme URL scheme for access to the EZID service.
+ * @param host Host name for access to the EZID service.
+ * @param path Local-path to the EZID service.
+ * @param authority DOI authority prefix, e.g. "10.5072/FK2".
+ * @param username an EZID user identity.
+ * @param password user's password, or {@code null} for none.
+ * @throws URISyntaxException if host or authority is bad.
+ */
+ EZIDRequest(String scheme, String host, String path,
+ String authority, String username, String password)
+ throws URISyntaxException
+ {
+ this.scheme = scheme;
+
+ this.host = host;
+
+ this.path = path;
+
if (authority.charAt(authority.length()-1) == '/')
{
this.authority = authority.substring(0, authority.length()-1);
@@ -84,7 +131,7 @@
client = new DefaultHttpClient();
if (null != username)
{
- URI uri = new URI(scheme, host, null, null);
+ URI uri = new URI(scheme, host, path, null);
client.getCredentialsProvider().setCredentials(
new AuthScope(uri.getHost(), uri.getPort()),
new UsernamePasswordCredentials(username, password));
@@ -103,7 +150,7 @@ public EZIDResponse lookup(String name)
{
// GET path
HttpGet request;
- URI uri = new URI(scheme, host, ID_PATH + authority + name, null);
+ URI uri = new URI(scheme, host, path + ID_PATH + authority + name, null);
log.debug("EZID lookup {}", uri.toASCIIString());
request = new HttpGet(uri);
HttpResponse response = client.execute(request);
@@ -123,7 +170,7 @@ public EZIDResponse create(String name, Map<String, String> metadata)
{
// PUT path [+metadata]
HttpPut request;
- URI uri = new URI(scheme, host, ID_PATH + authority + '/' + name, null);
+ URI uri = new URI(scheme, host, path + ID_PATH + authority + '/' + name, null);
log.debug("EZID create {}", uri.toASCIIString());
request = new HttpPut(uri);
if (null != metadata)
@@ -148,7 +195,7 @@ public EZIDResponse mint(Map<String, String> metadata)
{
// POST path [+metadata]
HttpPost request;
- URI uri = new URI(scheme, host, SHOULDER_PATH + authority, null);
+ URI uri = new URI(scheme, host, path + SHOULDER_PATH + authority, null);
log.debug("EZID mint {}", uri.toASCIIString());
request = new HttpPost(uri);
if (null != metadata)
@@ -176,7 +223,7 @@ public EZIDResponse modify(String name, Map<String, String> metadata)
}
// POST path +metadata
HttpPost request;
- URI uri = new URI(scheme, host, ID_PATH + authority + name, null);
+ URI uri = new URI(scheme, host, path + ID_PATH + authority + name, null);
log.debug("EZID modify {}", uri.toASCIIString());
request = new HttpPost(uri);
request.setEntity(new StringEntity(formatMetadata(metadata), UTF_8));
@@ -192,7 +239,7 @@ public EZIDResponse delete(String name)
{
// DELETE path
HttpDelete request;
- URI uri = new URI(scheme, host, ID_PATH + authority + name, null);
+ URI uri = new URI(scheme, host, path + ID_PATH + authority + name, null);
log.debug("EZID delete {}", uri.toASCIIString());
request = new HttpDelete(uri);
HttpResponse response = client.execute(request);
View
17 dspace-api/src/main/java/org/dspace/identifier/ezid/EZIDRequestFactory.java
@@ -31,6 +31,7 @@
{
private static String EZID_SCHEME;
private static String EZID_HOST;
+ private static String EZID_PATH;
/**
* Configure an EZID request.
@@ -43,11 +44,12 @@
public EZIDRequest getInstance(String authority, String username, String password)
throws URISyntaxException
{
- return new EZIDRequest(EZID_SCHEME, EZID_HOST, authority, username, password);
+ return new EZIDRequest(EZID_SCHEME, EZID_HOST, EZID_PATH,
+ authority, username, password);
}
/**
- * @param aEZID_SCHEME the EZID URL scheme to set
+ * @param aEZID_SCHEME the EZID URL scheme to set.
*/
@Required
public static void setEZID_SCHEME(String aEZID_SCHEME)
@@ -56,11 +58,20 @@ public static void setEZID_SCHEME(String aEZID_SCHEME)
}
/**
- * @param aEZID_HOST the EZID host to set
+ * @param aEZID_HOST the EZID host to set.
*/
@Required
public static void setEZID_HOST(String aEZID_HOST)
{
EZID_HOST = aEZID_HOST;
}
+
+ /**
+ * @param aEZID_PATH the local path to the EZID API.
+ */
+ @Required
+ public static void setEZID_PATH(String aEZID_PATH)
+ {
+ EZID_PATH = aEZID_PATH;
+ }
}
View
3  dspace/config/spring/api/identifier-service.xml
@@ -77,7 +77,8 @@
<property name='requestFactory'>
<bean class='org.dspace.identifier.ezid.EZIDRequestFactory'>
<property name='EZID_SCHEME' value='https'/>
- <property name='EZID_HOST' value='n2t.net'/>
+ <property name='EZID_HOST' value='ezid.cdlib.org'/>
+ <property name='EZID_PATH' value=''/>
</bean>
</property>
<property name='crosswalk'>

No commit comments for this range

Something went wrong with that request. Please try again.