|
From: <joh...@us...> - 2012-03-08 22:34:47
|
Revision: 102
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=102&view=rev
Author: johnpage-09
Date: 2012-03-08 22:34:41 +0000 (Thu, 08 Mar 2012)
Log Message:
-----------
DMSTECH-2890: Functionality for updating the DOI element in the metadata xml.
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-08 05:15:50 UTC (rev 101)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-08 22:34:41 UTC (rev 102)
@@ -538,11 +538,7 @@
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
try
{
- if (metadata != null)
- {
- }
-
// Send data
conn.setRequestMethod(requestType);
conn.setDoOutput(true);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joh...@us...> - 2012-03-09 02:27:01
|
Revision: 104
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=104&view=rev
Author: johnpage-09
Date: 2012-03-09 02:26:54 +0000 (Fri, 09 Mar 2012)
Log Message:
-----------
DMSTECH-2891: Updated JavaDoc for one of the methods.
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-09 02:10:56 UTC (rev 103)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-09 02:26:54 UTC (rev 104)
@@ -322,15 +322,17 @@
/**
* Responsible for Activating / Deactivating a DOI.
* <p>
- * DOI being updated must belong to the client requesting the update. The update service point allows clients to
- * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
+ * Deactivates metadata associated with a DOI. A DOI\x92s metadata is active by default. Deactivating a DOI\x92s metadata
+ * prevents the metadata from being returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
*
+ * Activates deactivated metadata associated with a given DOI. A DOI\x92s metadata is active by default, and can only
+ * by activated if it has previously been deactivated. Activating a DOI\x92s metadata allows the metadata to be
+ * returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
+ *
* @param doi
- * that needs to be updated.
- * @param url
- * the url pointing to the landing page of the data collection.
- * @param updateMetdaData
- * true if metadata update is required, false if not.
+ * that needs to be activated/ deactivated.
+ * @param activate
+ * boolean flag indicating whether to activate or deactivate.
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <joh...@us...> - 2012-03-14 03:12:27
|
Revision: 107
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=107&view=rev
Author: johnpage-09
Date: 2012-03-14 03:12:21 +0000 (Wed, 14 Mar 2012)
Log Message:
-----------
DMSTECH-2890: Functionality for updating URL associated with a Digital Object Identifier.
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-13 23:12:25 UTC (rev 106)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-14 03:12:21 UTC (rev 107)
@@ -71,7 +71,7 @@
* <li>requestorIdentity.authDomain - mycomputer.edu.au</li>
* </UL>
* <p>
- * You can then mint new DOIs using the {@link #mintDOI(String)} method.
+ * This class has methods for (a)minting DOIs, (b)updating DOIs, (c) activating and deactivating DOIs.
*
* </p>
* Copyright 2010, CSIRO Australia All rights reserved.
@@ -90,8 +90,7 @@
private static final Logger LOG = Logger.getLogger(AndsDoiClient.class.getName());
/**
- * Constant that defines the name of properties file to be used. Both the Pid and Doi client share the same property
- * file
+ * Constant that defines the name of properties file to be used.
*/
private static final String PROPERTIES_FILENAME = "/ands-doi-client.properties";
@@ -272,13 +271,23 @@
throws HttpException, IOException
{
+ String queryString = null;
+
this.validateState();
// DOI should not be null
this.validateParameters(updateMethodName, doi, updatedUrl);
- String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
- getRequestorIdentity().getAppId(), doi });
+ if (updatedUrl != null)
+ {
+ queryString = MessageFormat.format("app_id={0}&doi={1}&url={2}", new Object[] {
+ getRequestorIdentity().getAppId(), doi, updatedUrl });
+ }
+ else
+ {
+ queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { getRequestorIdentity().getAppId(),
+ doi });
+ }
return executeMethod(queryString, updateMethodName, updateMetaData, updatedUrl, existingMetaDataXML);
}
@@ -318,7 +327,7 @@
}
// DOI should not be null
- this.validateParameters(methodName, doi, null);
+ this.validateParameters(methodName, doi);
String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
getRequestorIdentity().getAppId(), doi });
@@ -346,7 +355,7 @@
this.validateState();
// DOI should not be null
- this.validateParameters(doiMetadataRequest, doi, null);
+ this.validateParameters(doiMetadataRequest, doi);
String queryString = MessageFormat.format("doi={0}", new Object[] { doi });
@@ -393,10 +402,12 @@
* Checks the arguments passed to the {@link #mintDOI(String)} and the
* {@link #mintHandleByIndex(HandleType, int, String)} methods.
*
- * @param value
- * the url of the data collection for which a DOI is required.
* @param methodName
- * the method that is being called on the DOI service
+ * the method that is being called on the DOI service call.
+ * @param doi
+ * for an update or get meta-data request service call.
+ * @param url
+ * for a mint DOI service call.
* @throws IllegalStateException
* thrown if the arguments provided to {@link #mintDOI(HandleType, String)} or to
* {@link #mintHandleByIndex(HandleType, int, String)} are not valid.
@@ -404,28 +415,27 @@
private void validateParameters(String... values) throws IllegalArgumentException
{
- if (values[0].equals("doi_mint.php") && StringUtils.isEmpty(values[1]))
+ if (mintMethodName.equals(values[0]) && StringUtils.isEmpty(values[1]))
{
throw new IllegalArgumentException(MessageFormat.format(
- "The method mintDOI() can only be called if the arguement is non-empty:values={1}\n",
+ "The method to mint a DOI can only be called if the url value is a non-empty value:values={1}\n",
new Object[] { values[1] }));
}
- if (((values[0].equals("doi_update.php")) || (values[0].equals("doi_xml.php")))
+ if (((updateMethodName.equals(values[0])) || (values[0].equals(doiMetadataRequest)))
&& StringUtils.isEmpty(values[1]))
{
throw new IllegalArgumentException(MessageFormat.format(
- "The method to update or request meta-data can only be called if the arguement is "
- + "non-empty:values={1}\n",
- new Object[] { values[1] }));
+ "The method to update or request meta-data can only be called if the DOI and updated url are "
+ + "non-empty values:values={1}, values={2}\n", new Object[] { values[1], values[2] }));
}
- if (((values[0].equals("doi_activate.php")) || (values[0].equals("doi_deactivate.php")))
+ if (((activateDoi.equals(values[0])) || (deactivateDoi.equals(values[0])))
&& StringUtils.isEmpty(values[1]))
{
throw new IllegalArgumentException(MessageFormat.format(
- "The method to activate / deactivate () can only be called "
- + "if the arguement is non-empty:values={1}\n", new Object[] { values[1] }));
+ "The method to activate / deactivate DOIs can only be called "
+ + "if the DOI is non-empty:values={1}\n", new Object[] { values[1] }));
}
}
@@ -454,28 +464,29 @@
String metaDataXML = null;
String requestType = getRequestType(methodName, updateMetaData);
- LOG.debug("ExecuteMethod : Query String : ->" + queryString);
- LOG.debug("ExecuteMethod : Method Name : ->" + methodName);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("ExecuteMethod : Query String : ->" + queryString);
+ LOG.debug("ExecuteMethod : Method Name : ->" + methodName);
+ }
HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, "");
url.setPath(url.getPath() + "/" + methodName);
- if (methodName.equals("doi_mint.php"))
+ if (methodName.equals(mintMethodName))
{
metaDataXML = this.getRequestorIdentity().generateMetaDataXMLFromDTO();
- LOG.debug("Metadata XML generated :->" + metaDataXML);
}
// Updates the meta-data xml with the parameters set in the DTO.
- if (methodName.equals("doi_update.php") && (!StringUtils.isEmpty(existingMetaDataXML)))
+ if (methodName.equals(updateMethodName) && (!StringUtils.isEmpty(existingMetaDataXML)))
{
metaDataXML = this.getRequestorIdentity().updateMetaDataXMLFromDTO(existingMetaDataXML);
- LOG.debug("**Updated Metadata XML :->" + metaDataXML);
}
- return doiRequest(url.toString(), metaDataXML, updateURL, requestType);
+ return doiRequest(url.toString(), metaDataXML, requestType);
}
/**
@@ -490,7 +501,7 @@
private String getRequestType(String methodName, boolean updateMetaData)
{
- if (methodName.equals("doi_mint.php") || (updateMetaData))
+ if (mintMethodName.equals(methodName) || (updateMetaData))
{
return "POST";
}
@@ -518,15 +529,16 @@
* @return
* @throws IOException
*/
- private static AndsDoiResponse doiRequest(String serviceUrl, String metaDataXML, String updateURL, String requestType)
+ private static AndsDoiResponse doiRequest(String serviceUrl, String metaDataXML, String requestType)
throws IOException
{
- LOG.debug("Method URL: " + serviceUrl);
- LOG.debug("Metadata XML NULL ?: " + StringUtils.isEmpty(metaDataXML));
- LOG.debug("Update URL: " + updateURL);
- LOG.debug("Request Type: " + requestType);
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug("Method URL: " + serviceUrl);
+ LOG.debug("Metadata XML NULL ?: " + StringUtils.isEmpty(metaDataXML));
+ LOG.debug("Request Type: " + requestType);
+ }
AndsDoiResponse doiResponse = null;
- String data = null;
OutputStreamWriter wr = null;
StringBuffer outputBuffer;
@@ -545,16 +557,9 @@
if (metaDataXML != null)
{
- LOG.debug("Writing XML metadata to output stream...");
wr.write("xml=" + URLEncoder.encode(metaDataXML, "UTF-8"));
}
-
- if (updateURL != null)
- {
- LOG.debug("Writing URL for update to output stream...");
- wr.write("url=" + URLEncoder.encode(updateURL, "UTF-8"));
- }
wr.flush();
}
else
@@ -566,7 +571,10 @@
doiResponse.setResponseCode(conn.getResponseCode());
doiResponse.setResponseMessage(conn.getResponseMessage());
- LOG.debug(conn.getResponseCode() + " - " + conn.getResponseMessage());
+ if (LOG.isDebugEnabled())
+ {
+ LOG.debug(conn.getResponseCode() + " - " + conn.getResponseMessage());
+ }
// Get the response
outputBuffer = new StringBuffer();
@@ -596,7 +604,6 @@
String line;
while ((line = rde.readLine()) != null)
{
- LOG.debug(line);
outputBuffer.append(line);
}
rde.close();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <rit...@us...> - 2012-03-22 05:52:44
|
Revision: 146
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=146&view=rev
Author: ritacsiro
Date: 2012-03-22 05:52:37 +0000 (Thu, 22 Mar 2012)
Log Message:
-----------
DMSTECH-2890 update DOI.
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-20 06:14:37 UTC (rev 145)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-22 05:52:37 UTC (rev 146)
@@ -82,8 +82,6 @@
*/
public class AndsDoiClient
{
-
-
/**
* Constant that defines the logger to be used.
*/
@@ -94,7 +92,6 @@
*/
private static final String PROPERTIES_FILENAME = "/ands-doi-client.properties";
-
/**
* The name of the method (RESTful web service) to call when minting a DOI.
*/
@@ -135,14 +132,12 @@
*/
private String doiServiceHost;
-
/**
* The ANDS Digital Object Identifier path name (web application context name).
*/
private String doiServicePath;
-
/**
* Loads the specified properties file.
*/
@@ -248,6 +243,57 @@
return executeMethod(queryString, mintMethodName, null, null, doiDTO);
}
+ /**
+ * Responsible for the updating a DOI.
+ * <p>
+ * DOI being updated must belong to the client requesting the update. The update service point allows clients to
+ * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
+ *
+ * @param doi
+ * that needs to be updated.
+ * @param updatedUrl
+ * the url pointing to the landing page of the data collection.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
+ public AndsDoiResponse updateDOI(String doi, String updatedUrl)
+ throws HttpException, IOException
+ {
+ return this.updateDOI(doi, updatedUrl, null);
+ }
+
+ /**
+ * Responsible for the updating a DOI.
+ * <p>
+ * DOI being updated must belong to the client requesting the update. The update service point allows clients to
+ * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
+ *
+ * @param doi
+ * that needs to be updated.
+ * @param doiDTO
+ * doiDTO with the values for the meta-data update.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
+ public AndsDoiResponse updateDOI(String doi, DoiDTO doiDTO)
+ throws HttpException, IOException
+ {
+ return this.updateDOI(doi, null, doiDTO);
+ }
/**
* Responsible for the updating a DOI.
@@ -466,7 +512,6 @@
"The method to activate / deactivate DOIs can only be called "
+ "if the DOI is non-empty:values={1}\n", new Object[] { values[1] }));
}
-
}
/**
@@ -542,8 +587,6 @@
}
}
-
-
/**
* Calls a POST method of the ANDS Digital Object identifier service in a RESTful web service manner. The query
* string of the URI defines the type of operation that is to be performed. The request body contains an XML
@@ -651,7 +694,6 @@
}
return doiResponse;
-
}
/**
@@ -764,8 +806,6 @@
return null;
}
-
-
/**
* Retrieve the current ANDS Digital Object Identifier host name
*
@@ -787,7 +827,6 @@
this.doiServiceHost = pidServiceHost;
}
-
/**
* Retrieve the current ANDS Digital Object Identifier path name (web application context name)
*
@@ -830,9 +869,6 @@
this.requestorIdentity = requestorIdentity;
}
-
-
-
/**
* @return the metadataTemplatePath
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2012-05-14 01:36:08
|
Revision: 150
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=150&view=rev
Author: sbearcsiro
Date: 2012-05-14 01:36:00 +0000 (Mon, 14 May 2012)
Log Message:
-----------
DMSTECH-3236 Save Data Admin Review choice, Create Approval Task, Update Publishing
- Fix adding HTTP status code description into response message.
- Add option to URL Encode query string parameters.
- Add option to set HTTPS port.
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-26 23:49:36 UTC (rev 149)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-05-14 01:36:00 UTC (rev 150)
@@ -1,5 +1,5 @@
/**
- * Copyright 2012, CSIRO Australia.
+ * Copyright 2010, CSIRO Australia.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -47,9 +47,6 @@
import au.csiro.doiclient.utils.DoiMetaDataGenerator;
import au.csiro.pidclient.AndsPidClient.HandleType;
-
-
-
/**
* This is the main interface to the ANDS DOI Client library. It allows the caller to interact with the <a
* href="http://www.ands.org.au/services/doi-m2m-identifiers.html">Digital Object IDentifier Service</a> provided by the
@@ -131,6 +128,13 @@
* The ANDS Digital Object Identifier host name.
*/
private String doiServiceHost;
+
+ /**
+ * The ANDS Digital Object Identifier port number.
+ *
+ * Defaults to the default HTTPS port (443)
+ */
+ private int doiServicePort = 443;
/**
* The ANDS Digital Object Identifier path name (web application context name).
@@ -206,6 +210,26 @@
this.setRequestorIdentity(requestorIdentity);
loadProperties();
}
+
+ /**
+ * @param doiServiceHost
+ * the ANDS Digital Object Identifier host name.
+ * @param doiServicePort
+ * the ANDS Digital Object Identifier port number.
+ * @param doiServicePath
+ * the ANDS Digital Object Identifier path name (web application context name).
+ * @param requestorIdentity
+ * represents the identity information of the caller {@link AndsDoiIdentity}.
+ */
+ public AndsDoiClient(String doiServiceHost, int doiServicePort, String doiServicePath,
+ AndsDoiIdentity requestorIdentity)
+ {
+ this.setDoiServiceHost(doiServiceHost);
+ this.setDoiServicePort(doiServicePort);
+ this.setDoiServicePath(doiServicePath);
+ this.setRequestorIdentity(requestorIdentity);
+ loadProperties();
+ }
/**
* Responsible for the creation of a DOI.
@@ -219,6 +243,9 @@
* the url pointing to the landing page of the data collection.
* @param doiDTO
* doiDTO with the values for the meta-data update.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
+ * are already URL encoded.
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -229,6 +256,40 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
+ public AndsDoiResponse mintDOI(String url, DoiDTO doiDTO, boolean encodeParams) throws IllegalStateException, IllegalArgumentException,
+ HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ url = URLEncoder.encode(url, "UTF-8");
+ }
+ return mintDOI(url, doiDTO);
+ }
+
+ /**
+ * Responsible for the creation of a DOI.
+ * <p>
+ * If the value arguments are both empty, a handle with no values is created. The handle is assigned to an owner,
+ * specified by the {@link AndsDoiIdentity#getAppId()} value. If the owner is not known to the handle system, an
+ * owner is created from the {@link AndsDoiIdentity#getIdentifier()} and {@link AndsDoiIdentity#getIdentifier()}
+ * values.
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param url
+ * the url pointing to the landing page of the data collection.
+ * @param doiDTO
+ * doiDTO with the values for the meta-data update.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
public AndsDoiResponse mintDOI(String url, DoiDTO doiDTO) throws IllegalStateException, IllegalArgumentException,
HttpException, IOException
{
@@ -238,9 +299,9 @@
this.validateParameters(mintMethodName, url);
String queryString = MessageFormat.format("app_id={0}&url={1}", new Object[] {
- getRequestorIdentity().getAppId(), url });
+ URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"), url });
- return executeMethod(queryString, mintMethodName, null, null, doiDTO);
+ return executeMethod(queryString, mintMethodName, null, doiDTO);
}
/**
@@ -253,6 +314,8 @@
* that needs to be updated.
* @param updatedUrl
* the url pointing to the landing page of the data collection.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -263,6 +326,39 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
+ public AndsDoiResponse updateDOI(String doi, String updatedUrl, boolean encodeParams)
+ throws HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ doi = URLEncoder.encode(doi, "UTF-8");
+ updatedUrl = URLEncoder.encode(updatedUrl, "UTF-8");
+ }
+ return updateDOI(doi, updatedUrl);
+ }
+
+ /**
+ * Responsible for the updating a DOI.
+ * <p>
+ * DOI being updated must belong to the client requesting the update. The update service point allows clients to
+ * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param doi
+ * that needs to be updated.
+ * @param updatedUrl
+ * the url pointing to the landing page of the data collection.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
public AndsDoiResponse updateDOI(String doi, String updatedUrl)
throws HttpException, IOException
{
@@ -279,6 +375,8 @@
* that needs to be updated.
* @param doiDTO
* doiDTO with the values for the meta-data update.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -289,6 +387,38 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
+ public AndsDoiResponse updateDOI(String doi, DoiDTO doiDTO, boolean encodeParams)
+ throws HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ doi = URLEncoder.encode(doi, "UTF-8");
+ }
+ return updateDOI(doi, doiDTO);
+ }
+
+ /**
+ * Responsible for the updating a DOI.
+ * <p>
+ * DOI being updated must belong to the client requesting the update. The update service point allows clients to
+ * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param doi
+ * that needs to be updated.
+ * @param doiDTO
+ * doiDTO with the values for the meta-data update.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
public AndsDoiResponse updateDOI(String doi, DoiDTO doiDTO)
throws HttpException, IOException
{
@@ -307,6 +437,8 @@
* the url pointing to the landing page of the data collection.
* @param doiDTO
* doiDTO with the values for the meta-data update.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -317,6 +449,41 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
+ public AndsDoiResponse updateDOI(String doi, String updatedUrl, DoiDTO doiDTO, boolean encodeParams)
+ throws HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ doi = URLEncoder.encode(doi, "UTF-8");
+ updatedUrl = URLEncoder.encode(updatedUrl, "UTF-8");
+ }
+ return updateDOI(doi, updatedUrl, doiDTO);
+ }
+
+ /**
+ * Responsible for the updating a DOI.
+ * <p>
+ * DOI being updated must belong to the client requesting the update. The update service point allows clients to
+ * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param doi
+ * that needs to be updated.
+ * @param updatedUrl
+ * the url pointing to the landing page of the data collection.
+ * @param doiDTO
+ * doiDTO with the values for the meta-data update.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
public AndsDoiResponse updateDOI(String doi, String updatedUrl, DoiDTO doiDTO)
throws HttpException, IOException
{
@@ -331,17 +498,20 @@
if (updatedUrl != null)
{
queryString = MessageFormat.format("app_id={0}&doi={1}&url={2}", new Object[] {
- getRequestorIdentity().getAppId(), doi, updatedUrl });
+ URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"),
+ doi,
+ updatedUrl});
}
else
{
- queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { getRequestorIdentity().getAppId(),
+ queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
+ URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"),
doi });
}
AndsDoiResponse existingMetaDataXML = requestMetaDataOfDOI(doi);
- return executeMethod(queryString, updateMethodName, updatedUrl,
+ return executeMethod(queryString, updateMethodName,
existingMetaDataXML.getMetaData(), doiDTO);
}
@@ -355,9 +525,42 @@
* returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
*
* @param doi
+ * that needs to be activated.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
+ * are already URL encoded.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
+ public AndsDoiResponse activateDOI(String doi, boolean encodeParams) throws HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ doi = URLEncoder.encode(doi, "UTF-8");
+ }
+
+ return activateDOI(doi);
+ }
+
+ /**
+ * Responsible for Activating a DOI.
+ * <p>
+ *
+ * Activates deactivated metadata associated with a given DOI. A DOI\x92s metadata is active by default, and can only
+ * by activated if it has previously been deactivated. Activating a DOI\x92s metadata allows the metadata to be
+ * returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param doi
* that needs to be activated/ deactivated.
- * @param activate
- * boolean flag indicating whether to activate or deactivate.
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -376,9 +579,9 @@
this.validateParameters(methodName, doi);
String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
- getRequestorIdentity().getAppId(), doi });
+ URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"), doi});
- return executeMethod(queryString, methodName, null, null, null);
+ return executeMethod(queryString, methodName, null, null);
}
/**
@@ -390,6 +593,38 @@
*
* @param doi
* that needs to be activated/ deactivated.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
+ * are already URL encoded.
+ * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
+ public AndsDoiResponse deActivateDOI(String doi, boolean encodeParams) throws HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ doi = URLEncoder.encode(doi, "UTF-8");
+ }
+ return deActivateDOI(doi);
+ }
+
+ /**
+ * Responsible for Deactivating a DOI.
+ * <p>
+ * Deactivates metadata associated with a DOI. A DOI\x92s metadata is active by default. Deactivating a DOI\x92s metadata
+ * prevents the metadata from being returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param doi
+ * that needs to be activated/ deactivated.
* @param activate
* boolean flag indicating whether to activate or deactivate.
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
@@ -410,9 +645,9 @@
this.validateParameters(methodName, doi);
String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
- getRequestorIdentity().getAppId(), doi });
+ URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"), doi});
- return executeMethod(queryString, methodName, null, null, null);
+ return executeMethod(queryString, methodName, null, null);
}
/**
@@ -421,6 +656,9 @@
*
* @param doi
* DOI for which the meta-data is requested.
+ * @param encodeParams
+ * whether to URL encode the input parameters or not. Use false if the input parameters
+ * are already URL encoded.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
* @throws IllegalArgumentException
@@ -430,6 +668,31 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
+ public AndsDoiResponse requestMetaDataOfDOI(String doi, boolean encodeParams) throws HttpException, IOException
+ {
+ if (encodeParams)
+ {
+ doi = URLEncoder.encode(doi, "UTF-8");
+ }
+ return requestMetaDataOfDOI(doi);
+ }
+
+ /**
+ * Responsible for requesting the meta-data for a given DOI.
+ * <p>
+ * String arguments should already be URL encoded when calling this method.
+ *
+ * @param doi
+ * DOI for which the meta-data is requested.
+ * @throws IllegalStateException
+ * thrown if the parameters need to call the ANDS DOI service have not been provided.
+ * @throws IllegalArgumentException
+ * thrown when method is called with invalid arguments.
+ * @throws IOException
+ * thrown when attempting to read response.
+ * @throws HttpException
+ * thrown when attempting to execute method call.
+ */
public AndsDoiResponse requestMetaDataOfDOI(String doi) throws HttpException, IOException
{
this.validateState();
@@ -439,7 +702,7 @@
String queryString = MessageFormat.format("doi={0}", new Object[] { doi });
- return executeMethod(queryString, doiMetadataRequest, null, null, null);
+ return executeMethod(queryString, doiMetadataRequest, null, null);
}
@@ -533,7 +796,7 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
- private AndsDoiResponse executeMethod(String queryString, String methodName, String updateURL,
+ private AndsDoiResponse executeMethod(String queryString, String methodName,
String existingMetaDataXML, DoiDTO doiDTO) throws HttpException, IOException
{
@@ -546,7 +809,8 @@
LOG.debug("ExecuteMethod : Method Name : ->" + methodName);
}
- HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, "");
+ HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePort(), this.getDoiServicePath(), queryString);
+ //HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, "");
url.setPath(url.getPath() + "/" + methodName);
@@ -650,7 +914,6 @@
// Get the response
outputBuffer = new StringBuffer();
- outputBuffer.append(conn.getResponseMessage() + "\n");
rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
String line;
while ((line = rd.readLine()) != null)
@@ -712,9 +975,8 @@
switch (responseCode)
{
case 200:
- if (doiResponse.getMessage().contains("OK")
- && ((doiResponse.getMessage().contains("successfully")) || doiResponse.getMessage().contains(
- "<?xml version=")))
+ if ((doiResponse.getMessage().contains("successfully"))
+ || doiResponse.getMessage().contains("<?xml version="))
{
doiResponse.setSuccess(true);
}
@@ -826,8 +1088,28 @@
{
this.doiServiceHost = pidServiceHost;
}
+
+ /**
+ * Retrieve the ANDS Digital Object Identifier port number.
+ *
+ * @return the doiServicePort the ANDS Digital Object Identifier port number
+ */
+ public int getDoiServicePort()
+ {
+ return doiServicePort;
+ }
/**
+ * Set the ANDS Digital Object Identifier port number.
+ *
+ * @param doiServicePort the ANDS Digital Object Identifier port number to set
+ */
+ public void setDoiServicePort(int doiServicePort)
+ {
+ this.doiServicePort = doiServicePort;
+ }
+
+ /**
* Retrieve the current ANDS Digital Object Identifier path name (web application context name)
*
* @return the ANDS Digital Object Identifier path name
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <sbe...@us...> - 2012-05-29 08:00:16
|
Revision: 163
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=163&view=rev
Author: sbearcsiro
Date: 2012-05-29 08:00:05 +0000 (Tue, 29 May 2012)
Log Message:
-----------
DMSTECH-3519
- Fix broken url encoding in doi client
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-05-16 03:06:14 UTC (rev 162)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-05-29 08:00:05 UTC (rev 163)
@@ -21,6 +21,10 @@
import java.io.InputStreamReader;
import java.net.URLEncoder;
import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.Properties;
import org.apache.commons.httpclient.HttpClient;
@@ -247,41 +251,6 @@
this.setDoiServicePath(doiServicePath);
this.setRequestorIdentity(requestorIdentity);
}
-
- /**
- * Responsible for the creation of a DOI.
- * <p>
- * If the value arguments are both empty, a handle with no values is created. The handle is assigned to an owner,
- * specified by the {@link AndsDoiIdentity#getAppId()} value. If the owner is not known to the handle system, an
- * owner is created from the {@link AndsDoiIdentity#getIdentifier()} and {@link AndsDoiIdentity#getIdentifier()}
- * values.
- *
- * @param url
- * the url pointing to the landing page of the data collection.
- * @param doiDTO
- * doiDTO with the values for the meta-data update.
- * @param encodeParams
- * whether to URL encode the input parameters or not. Use false if the input parameters
- * are already URL encoded.
- * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
- * @throws IllegalStateException
- * thrown if the parameters need to call the ANDS DOI service have not been provided.
- * @throws IllegalArgumentException
- * thrown when method is called with invalid arguments.
- * @throws IOException
- * thrown when attempting to read response.
- * @throws HttpException
- * thrown when attempting to execute method call.
- */
- public AndsDoiResponse mintDOI(String url, DoiDTO doiDTO, boolean encodeParams) throws IllegalStateException, IllegalArgumentException,
- HttpException, IOException
- {
- if (encodeParams)
- {
- url = URLEncoder.encode(url, "UTF-8");
- }
- return mintDOI(url, doiDTO);
- }
/**
* Responsible for the creation of a DOI.
@@ -314,45 +283,15 @@
// URL for which the DOI is to be minted should not be null.
this.validateParameters(mintMethodName, url);
+
+ Map<String,String> params = new HashMap<String,String>();
+
+ params.put("app_id", getRequestorIdentity().getAppId());
+ params.put("url", url);
- String queryString = MessageFormat.format("app_id={0}&url={1}", new Object[] {
- URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"), url });
-
- return executeMethod(queryString, mintMethodName, null, doiDTO);
+ return executeMethod(params, mintMethodName, null, doiDTO);
}
- /**
- * Responsible for the updating a DOI.
- * <p>
- * DOI being updated must belong to the client requesting the update. The update service point allows clients to
- * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
- *
- * @param doi
- * that needs to be updated.
- * @param updatedUrl
- * the url pointing to the landing page of the data collection.
- * @param encodeParams
- * whether to URL encode the input parameters or not. Use false if the input parameters
- * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
- * @throws IllegalStateException
- * thrown if the parameters need to call the ANDS DOI service have not been provided.
- * @throws IllegalArgumentException
- * thrown when method is called with invalid arguments.
- * @throws IOException
- * thrown when attempting to read response.
- * @throws HttpException
- * thrown when attempting to execute method call.
- */
- public AndsDoiResponse updateDOI(String doi, String updatedUrl, boolean encodeParams)
- throws HttpException, IOException
- {
- if (encodeParams)
- {
- doi = URLEncoder.encode(doi, "UTF-8");
- updatedUrl = URLEncoder.encode(updatedUrl, "UTF-8");
- }
- return updateDOI(doi, updatedUrl);
- }
/**
* Responsible for the updating a DOI.
@@ -382,37 +321,6 @@
return this.updateDOI(doi, updatedUrl, null);
}
- /**
- * Responsible for the updating a DOI.
- * <p>
- * DOI being updated must belong to the client requesting the update. The update service point allows clients to
- * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
- *
- * @param doi
- * that needs to be updated.
- * @param doiDTO
- * doiDTO with the values for the meta-data update.
- * @param encodeParams
- * whether to URL encode the input parameters or not. Use false if the input parameters
- * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
- * @throws IllegalStateException
- * thrown if the parameters need to call the ANDS DOI service have not been provided.
- * @throws IllegalArgumentException
- * thrown when method is called with invalid arguments.
- * @throws IOException
- * thrown when attempting to read response.
- * @throws HttpException
- * thrown when attempting to execute method call.
- */
- public AndsDoiResponse updateDOI(String doi, DoiDTO doiDTO, boolean encodeParams)
- throws HttpException, IOException
- {
- if (encodeParams)
- {
- doi = URLEncoder.encode(doi, "UTF-8");
- }
- return updateDOI(doi, doiDTO);
- }
/**
* Responsible for the updating a DOI.
@@ -441,41 +349,6 @@
{
return this.updateDOI(doi, null, doiDTO);
}
-
- /**
- * Responsible for the updating a DOI.
- * <p>
- * DOI being updated must belong to the client requesting the update. The update service point allows clients to
- * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata
- *
- * @param doi
- * that needs to be updated.
- * @param updatedUrl
- * the url pointing to the landing page of the data collection.
- * @param doiDTO
- * doiDTO with the values for the meta-data update.
- * @param encodeParams
- * whether to URL encode the input parameters or not. Use false if the input parameters
- * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
- * @throws IllegalStateException
- * thrown if the parameters need to call the ANDS DOI service have not been provided.
- * @throws IllegalArgumentException
- * thrown when method is called with invalid arguments.
- * @throws IOException
- * thrown when attempting to read response.
- * @throws HttpException
- * thrown when attempting to execute method call.
- */
- public AndsDoiResponse updateDOI(String doi, String updatedUrl, DoiDTO doiDTO, boolean encodeParams)
- throws HttpException, IOException
- {
- if (encodeParams)
- {
- doi = URLEncoder.encode(doi, "UTF-8");
- updatedUrl = URLEncoder.encode(updatedUrl, "UTF-8");
- }
- return updateDOI(doi, updatedUrl, doiDTO);
- }
/**
* Responsible for the updating a DOI.
@@ -504,67 +377,26 @@
public AndsDoiResponse updateDOI(String doi, String updatedUrl, DoiDTO doiDTO)
throws HttpException, IOException
{
-
- String queryString = null;
-
this.validateState();
// DOI should not be null
this.validateParameters(updateMethodName, doi, updatedUrl);
+ Map<String,String> params = new HashMap<String,String>();
+
+ params.put("app_id", getRequestorIdentity().getAppId());
+ params.put("doi", doi);
+
if (updatedUrl != null)
{
- queryString = MessageFormat.format("app_id={0}&doi={1}&url={2}", new Object[] {
- URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"),
- doi,
- updatedUrl});
+ params.put("url", updatedUrl);
}
- else
- {
- queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
- URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"),
- doi });
- }
AndsDoiResponse existingMetaDataXML = requestMetaDataOfDOI(doi);
- return executeMethod(queryString, updateMethodName,
+ return executeMethod(params, updateMethodName,
existingMetaDataXML.getMetaData(), doiDTO);
}
-
-
- /**
- * Responsible for Activating a DOI.
- * <p>
- *
- * Activates deactivated metadata associated with a given DOI. A DOI\x92s metadata is active by default, and can only
- * by activated if it has previously been deactivated. Activating a DOI\x92s metadata allows the metadata to be
- * returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
- *
- * @param doi
- * that needs to be activated.
- * @param encodeParams
- * whether to URL encode the input parameters or not. Use false if the input parameters
- * are already URL encoded.
- * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
- * @throws IllegalStateException
- * thrown if the parameters need to call the ANDS DOI service have not been provided.
- * @throws IllegalArgumentException
- * thrown when method is called with invalid arguments.
- * @throws IOException
- * thrown when attempting to read response.
- * @throws HttpException
- * thrown when attempting to execute method call.
- */
- public AndsDoiResponse activateDOI(String doi, boolean encodeParams) throws HttpException, IOException
- {
- if (encodeParams)
- {
- doi = URLEncoder.encode(doi, "UTF-8");
- }
-
- return activateDOI(doi);
- }
/**
* Responsible for Activating a DOI.
@@ -595,42 +427,13 @@
// DOI should not be null
this.validateParameters(methodName, doi);
- String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
- URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"), doi});
+ Map<String,String> params = new HashMap<String,String>();
+
+ params.put("app_id", getRequestorIdentity().getAppId());
+ params.put("doi", doi);
- return executeMethod(queryString, methodName, null, null);
+ return executeMethod(params, methodName, null, null);
}
-
- /**
- * Responsible for Deactivating a DOI.
- * <p>
- * Deactivates metadata associated with a DOI. A DOI\x92s metadata is active by default. Deactivating a DOI\x92s metadata
- * prevents the metadata from being returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint.
- *
- *
- * @param doi
- * that needs to be activated/ deactivated.
- * @param encodeParams
- * whether to URL encode the input parameters or not. Use false if the input parameters
- * are already URL encoded.
- * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
- * @throws IllegalStateException
- * thrown if the parameters need to call the ANDS DOI service have not been provided.
- * @throws IllegalArgumentException
- * thrown when method is called with invalid arguments.
- * @throws IOException
- * thrown when attempting to read response.
- * @throws HttpException
- * thrown when attempting to execute method call.
- */
- public AndsDoiResponse deActivateDOI(String doi, boolean encodeParams) throws HttpException, IOException
- {
- if (encodeParams)
- {
- doi = URLEncoder.encode(doi, "UTF-8");
- }
- return deActivateDOI(doi);
- }
/**
* Responsible for Deactivating a DOI.
@@ -660,11 +463,13 @@
// DOI should not be null
this.validateParameters(methodName, doi);
+
+ Map<String,String> params = new HashMap<String,String>();
+
+ params.put("app_id", getRequestorIdentity().getAppId());
+ params.put("doi", doi);
- String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] {
- URLEncoder.encode(getRequestorIdentity().getAppId(), "UTF-8"), doi});
-
- return executeMethod(queryString, methodName, null, null);
+ return executeMethod(params, methodName, null, null);
}
/**
@@ -716,10 +521,12 @@
// DOI should not be null
this.validateParameters(doiMetadataRequest, doi);
+
+ Map<String,String> params = new HashMap<String,String>();
- String queryString = MessageFormat.format("doi={0}", new Object[] { doi });
+ params.put("doi", doi);
- return executeMethod(queryString, doiMetadataRequest, null, null);
+ return executeMethod(params, doiMetadataRequest, null, null);
}
@@ -797,7 +604,7 @@
/**
* Constructs and executes an HTTP POST call.
*
- * @param queryString
+ * @param queryStringParams
* the query string to provide the POST call.
* @param methodName
* the method to call.
@@ -813,7 +620,7 @@
* @throws HttpException
* thrown when attempting to execute method call.
*/
- private AndsDoiResponse executeMethod(String queryString, String methodName,
+ private AndsDoiResponse executeMethod(Map<String,String> queryStringParams, String methodName,
String existingMetaDataXML, DoiDTO doiDTO) throws HttpException, IOException
{
@@ -822,15 +629,25 @@
if (LOG.isDebugEnabled())
{
- LOG.debug("ExecuteMethod : Query String : ->" + queryString);
+ LOG.debug("ExecuteMethod : Query String : ->" + queryStringParams);
LOG.debug("ExecuteMethod : Method Name : ->" + methodName);
}
- HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePort(), this.getDoiServicePath(),
- queryString);
+ HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePort(), this.getDoiServicePath());
+
url.setPath(url.getPath() + "/" + methodName);
+
+ ArrayList<String> keys = new ArrayList<String>(queryStringParams.size());
+ ArrayList<String> values = new ArrayList<String>(queryStringParams.size());
+
+ for (Entry<String,String> entry : queryStringParams.entrySet())
+ {
+ keys.add(entry.getKey());
+ values.add(entry.getValue());
+ }
+
+ url.setQuery(keys.toArray(new String[keys.size()]), values.toArray(new String[values.size()]));
-
if (methodName.equals(mintMethodName))
{
metaDataXML = DoiMetaDataGenerator.generateMetaDataXMLFromDTO(doiDTO);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <jav...@us...> - 2012-08-03 03:11:26
|
Revision: 172
http://andspidclient.svn.sourceforge.net/andspidclient/?rev=172&view=rev
Author: javinovich
Date: 2012-08-03 03:11:20 +0000 (Fri, 03 Aug 2012)
Log Message:
-----------
DMSTECH-3819:
- Update javadoc as per DAPCRU-152 Review
Modified Paths:
--------------
trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java
===================================================================
--- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-08-02 02:17:06 UTC (rev 171)
+++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-08-03 03:11:20 UTC (rev 172)
@@ -290,6 +290,7 @@
* @param debug
* Optional parameter. Activates debug flag for WS call false => debug=false will be passed true =>
* debug=true will be passed If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -335,6 +336,7 @@
* false => debug=false will be passed
* true => debug=true will be passed
* If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -369,6 +371,7 @@
* false => debug=false will be passed
* true => debug=true will be passed
* If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -406,6 +409,7 @@
* false => debug=false will be passed
* true => debug=true will be passed
* If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -458,6 +462,7 @@
* false => debug=false will be passed
* true => debug=true will be passed
* If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -514,10 +519,13 @@
* @param doi
* that needs to be activated/ deactivated.
* @param activate
- * boolean flag indicating whether to activate or deactivate. * @param debug Optional parameter.
- * Activates debug flag for WS call false => debug=false will be passed true => debug=true will be passed
+ * boolean flag indicating whether to activate or deactivate.
+ * @param debug Optional parameter.
+ * Activates debug flag for WS call
+ * false => debug=false will be passed
+ * true => debug=true will be passed
* If ommitted no debug flag will be added to request
- *
+ * See {@link AndsDoiClient} general documentation for details
* @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response.
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
@@ -557,7 +565,8 @@
* Optional parameter. Activates debug flag for WS call
* false => debug=false will be passed
* true => debug=true will be passed
- * If ommitted no debug flag will be added to request
+ * If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
* @throws IllegalArgumentException
@@ -584,8 +593,12 @@
* @param doi
* DOI for which the meta-data is requested.
* @param debug
- * Optional parameter. Activates debug flag for WS call false => debug=false will be passed true =>
- * debug=true will be passed If ommitted no debug flag will be added to request
+ * Optional parameter.
+ * Activates debug flag for WS call
+ * false => debug=false will be passed
+ * true => debug=true will be passed
+ * If ommitted no debug flag will be added to request
+ * See {@link AndsDoiClient} general documentation for details
* @throws IllegalStateException
* thrown if the parameters need to call the ANDS DOI service have not been provided.
* @throws IllegalArgumentException
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|