You can subscribe to this list here.
2010 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(69) |
Jul
(3) |
Aug
(11) |
Sep
(4) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2012 |
Jan
|
Feb
|
Mar
(54) |
Apr
|
May
(14) |
Jun
(3) |
Jul
(4) |
Aug
(7) |
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
2016 |
Jan
|
Feb
(8) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(5) |
Nov
|
Dec
|
2018 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
(10) |
Dec
(9) |
2019 |
Jan
|
Feb
(5) |
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <jav...@us...> - 2012-07-30 07:46:10
|
Revision: 169 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=169&view=rev Author: javinovich Date: 2012-07-30 07:46:04 +0000 (Mon, 30 Jul 2012) Log Message: ----------- DMSTECH-3819: - Implementing AndsDoiResponse.toString() Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-07-30 06:18:57 UTC (rev 168) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-07-30 07:46:04 UTC (rev 169) @@ -146,5 +146,23 @@ } + /* (non-Javadoc) + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + StringBuilder builder = new StringBuilder(); + builder.append("AndsDoiResponse ["); + if (doi != null) + builder.append("doi=").append(doi).append(", "); + builder.append("success=").append(success).append(", "); + if (message != null) + builder.append("\nmessage=").append(message); + builder.append("\n]"); + return builder.toString(); + } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jav...@us...> - 2012-07-30 06:19:04
|
Revision: 168 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=168&view=rev Author: javinovich Date: 2012-07-30 06:18:57 +0000 (Mon, 30 Jul 2012) Log Message: ----------- DMSTECH-3819: - New methods need a '/' at the end. Modified Paths: -------------- trunk/src/main/resources/ands-doi-client.properties Modified: trunk/src/main/resources/ands-doi-client.properties =================================================================== --- trunk/src/main/resources/ands-doi-client.properties 2012-07-30 06:07:47 UTC (rev 167) +++ trunk/src/main/resources/ands-doi-client.properties 2012-07-30 06:18:57 UTC (rev 168) @@ -19,8 +19,8 @@ application.version=${pom.version} # RESTful ANDS Digital Identifier Service web service URIs -method.mint=mint.xml -method.update=update.xml -method.doi=xml.xml -method.activate=activate.xml -method.deactivate=deactivate.xml +method.mint=mint.xml/ +method.update=update.xml/ +method.doi=xml.xml/ +method.activate=activate.xml/ +method.deactivate=deactivate.xml/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <jav...@us...> - 2012-07-30 06:07:54
|
Revision: 167 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=167&view=rev Author: javinovich Date: 2012-07-30 06:07:47 +0000 (Mon, 30 Jul 2012) Log Message: ----------- DMSTECH-3819: - Renamed DOI service methods to comply with new endpoints as described in https://www.google.com/url?q=http://ands.org.au/resource/cite-my-data-tech-doco-v1_1.pdf&sa=U&ei=LRQWUOayO6X8mAXl1oGABg&ved=0CAUQFjAA&client=internal-uds-cse&usg=AFQjCNEC4jQ_IDN9PLSdFbrlSPdcKDkOmQ - Added debug parameter to DOI service methods Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/main/resources/ands-doi-client.properties Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-06-01 01:11:09 UTC (rev 166) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-07-30 06:07:47 UTC (rev 167) @@ -109,17 +109,17 @@ /** * The name of the method (RESTful web service) to call when requesting the metadata associated with a DOI. */ - private static String doiMetadataRequest; + private static String doiMetadataRequestMethodName; /** * The name of the method (RESTful web service) to call when activating a DOI. */ - private static String activateDoi; + private static String activateDoiMethodName; /** * The name of the method (RESTful web service) to call when deactivating a DOI. */ - private static String deactivateDoi; + private static String deactivateDoiMethodName; /** * The path to the DOI meta-data template. @@ -163,9 +163,9 @@ applicationVersion = props.getProperty("application.version"); mintMethodName = props.getProperty("method.mint"); updateMethodName = props.getProperty("method.update"); - doiMetadataRequest = props.getProperty("method.doi"); - activateDoi = props.getProperty("method.activate"); - deactivateDoi = props.getProperty("method.deactivate"); + doiMetadataRequestMethodName = props.getProperty("method.doi"); + activateDoiMethodName = props.getProperty("method.activate"); + deactivateDoiMethodName = props.getProperty("method.deactivate"); } catch (IOException e) { @@ -266,6 +266,9 @@ * the url pointing to the landing page of the data collection. * @param doiDTO * doiDTO with the values for the meta-data update. + * @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 * @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. @@ -276,7 +279,7 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse mintDOI(String url, DoiDTO doiDTO) throws IllegalStateException, IllegalArgumentException, + public AndsDoiResponse mintDOI(String url, DoiDTO doiDTO, boolean... debug) throws IllegalStateException, IllegalArgumentException, HttpException, IOException { this.validateState(); @@ -288,6 +291,7 @@ params.put("app_id", getRequestorIdentity().getAppId()); params.put("url", url); + setDebug(params, debug); return executeMethod(params, mintMethodName, null, doiDTO); } @@ -305,6 +309,11 @@ * that needs to be updated. * @param updatedUrl * the url pointing to the landing page of the data collection. + * @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 * @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. @@ -315,10 +324,10 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse updateDOI(String doi, String updatedUrl) + public AndsDoiResponse updateDOI(String doi, String updatedUrl, boolean... debug) throws HttpException, IOException { - return this.updateDOI(doi, updatedUrl, null); + return this.updateDOI(doi, updatedUrl, null, debug); } @@ -334,6 +343,11 @@ * that needs to be updated. * @param doiDTO * doiDTO with the values for the meta-data update. + * @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 * @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. @@ -344,10 +358,10 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse updateDOI(String doi, DoiDTO doiDTO) + public AndsDoiResponse updateDOI(String doi, DoiDTO doiDTO, boolean... debug) throws HttpException, IOException { - return this.updateDOI(doi, null, doiDTO); + return this.updateDOI(doi, null, doiDTO, debug); } /** @@ -364,6 +378,11 @@ * the url pointing to the landing page of the data collection. * @param doiDTO * doiDTO with the values for the meta-data update. + * @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 * @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. @@ -374,7 +393,7 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse updateDOI(String doi, String updatedUrl, DoiDTO doiDTO) + public AndsDoiResponse updateDOI(String doi, String updatedUrl, DoiDTO doiDTO, boolean...debug) throws HttpException, IOException { this.validateState(); @@ -392,6 +411,7 @@ params.put("url", updatedUrl); } + setDebug(params, debug); AndsDoiResponse existingMetaDataXML = requestMetaDataOfDOI(doi); return executeMethod(params, updateMethodName, @@ -410,6 +430,11 @@ * * @param doi * that needs to be activated/ deactivated. + * @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 * @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. @@ -420,9 +445,9 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse activateDOI(String doi) throws HttpException, IOException + public AndsDoiResponse activateDOI(String doi, boolean...debug) throws HttpException, IOException { - String methodName = activateDoi; + String methodName = activateDoiMethodName; // DOI should not be null this.validateParameters(methodName, doi); @@ -431,9 +456,29 @@ params.put("app_id", getRequestorIdentity().getAppId()); params.put("doi", doi); + + setDebug(params, debug); return executeMethod(params, methodName, null, null); } + + /** + * Adds "debug" key to params according to the value of debug parameter + * + * false => debug="false" will be passed + * true => debug="true" will be passed + * If ommitted no debug flag will be added to request + * + * @param params The list of parameters + * @param debug the optional flag + */ + private void setDebug(Map<String, String> params, boolean... debug) + { + if(debug.length > 0) + { + params.put("debug", debug[0] ? "true":"false"); + } + } /** * Responsible for Deactivating a DOI. @@ -446,7 +491,10 @@ * @param doi * that needs to be activated/ deactivated. * @param activate - * boolean flag indicating whether to activate or deactivate. + * 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 + * * @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. @@ -457,9 +505,9 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse deActivateDOI(String doi) throws HttpException, IOException + public AndsDoiResponse deActivateDOI(String doi, boolean... debug) throws HttpException, IOException { - String methodName = deactivateDoi; + String methodName = deactivateDoiMethodName; // DOI should not be null this.validateParameters(methodName, doi); @@ -468,6 +516,7 @@ params.put("app_id", getRequestorIdentity().getAppId()); params.put("doi", doi); + setDebug(params, debug); return executeMethod(params, methodName, null, null); } @@ -481,6 +530,11 @@ * @param encodeParams * whether to URL encode the input parameters or not. Use false if the input parameters * are already URL encoded. + * @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 * @throws IllegalStateException * thrown if the parameters need to call the ANDS DOI service have not been provided. * @throws IllegalArgumentException @@ -490,13 +544,13 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse requestMetaDataOfDOI(String doi, boolean encodeParams) throws HttpException, IOException + public AndsDoiResponse requestMetaDataOfDOI(String doi, boolean encodeParams, boolean ...debug) throws HttpException, IOException { if (encodeParams) { doi = URLEncoder.encode(doi, "UTF-8"); } - return requestMetaDataOfDOI(doi); + return requestMetaDataOfDOI(doi, debug); } /** @@ -506,6 +560,9 @@ * * @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 * @throws IllegalStateException * thrown if the parameters need to call the ANDS DOI service have not been provided. * @throws IllegalArgumentException @@ -515,18 +572,19 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse requestMetaDataOfDOI(String doi) throws HttpException, IOException + public AndsDoiResponse requestMetaDataOfDOI(String doi, boolean... debug) throws HttpException, IOException { this.validateState(); // DOI should not be null - this.validateParameters(doiMetadataRequest, doi); + this.validateParameters(doiMetadataRequestMethodName, doi); Map<String,String> params = new HashMap<String,String>(); params.put("doi", doi); + setDebug(params, debug); - return executeMethod(params, doiMetadataRequest, null, null); + return executeMethod(params, doiMetadataRequestMethodName, null, null); } @@ -584,7 +642,7 @@ new Object[] { values[1] })); } - if (((updateMethodName.equals(values[0])) || (values[0].equals(doiMetadataRequest))) + if (((updateMethodName.equals(values[0])) || (values[0].equals(doiMetadataRequestMethodName))) && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( @@ -592,7 +650,7 @@ + "non-empty values:values={1}, values={2}\n", new Object[] { values[1], values[2] })); } - if (((activateDoi.equals(values[0])) || (deactivateDoi.equals(values[0]))) + if (((activateDoiMethodName.equals(values[0])) || (deactivateDoiMethodName.equals(values[0]))) && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( Modified: trunk/src/main/resources/ands-doi-client.properties =================================================================== --- trunk/src/main/resources/ands-doi-client.properties 2012-06-01 01:11:09 UTC (rev 166) +++ trunk/src/main/resources/ands-doi-client.properties 2012-07-30 06:07:47 UTC (rev 167) @@ -19,8 +19,8 @@ application.version=${pom.version} # RESTful ANDS Digital Identifier Service web service URIs -method.mint=doi_mint.php -method.update=doi_update.php -method.doi=doi_xml.php -method.activate=doi_activate.php -method.deactivate=doi_deactivate.php +method.mint=mint.xml +method.update=update.xml +method.doi=xml.xml +method.activate=activate.xml +method.deactivate=deactivate.xml This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-06-01 01:11:15
|
Revision: 166 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=166&view=rev Author: csirobuilduser Date: 2012-06-01 01:11:09 +0000 (Fri, 01 Jun 2012) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-06-01 01:10:59 UTC (rev 165) +++ trunk/pom.xml 2012-06-01 01:11:09 UTC (rev 166) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.29</version> + <version>1.0.30-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.29</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.29</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.29</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-06-01 01:11:05
|
Revision: 165 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=165&view=rev Author: csirobuilduser Date: 2012-06-01 01:10:59 +0000 (Fri, 01 Jun 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.29 Added Paths: ----------- tags/ands-pid-client-1.0.29/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-06-01 01:10:36
|
Revision: 164 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=164&view=rev Author: csirobuilduser Date: 2012-06-01 01:10:30 +0000 (Fri, 01 Jun 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.29 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-29 08:00:05 UTC (rev 163) +++ trunk/pom.xml 2012-06-01 01:10:30 UTC (rev 164) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.29-SNAPSHOT</version> + <version>1.0.29</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.29</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.29</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.29</url> </scm> <distributionManagement> <site> 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: <csi...@us...> - 2012-05-16 03:06:20
|
Revision: 162 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=162&view=rev Author: csirobuilduser Date: 2012-05-16 03:06:14 +0000 (Wed, 16 May 2012) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-16 03:06:03 UTC (rev 161) +++ trunk/pom.xml 2012-05-16 03:06:14 UTC (rev 162) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.28</version> + <version>1.0.29-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.28</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.28</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.28</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-05-16 03:06:09
|
Revision: 161 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=161&view=rev Author: csirobuilduser Date: 2012-05-16 03:06:03 +0000 (Wed, 16 May 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.28 Added Paths: ----------- tags/ands-pid-client-1.0.28/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-05-16 03:05:41
|
Revision: 160 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=160&view=rev Author: csirobuilduser Date: 2012-05-16 03:05:35 +0000 (Wed, 16 May 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.28 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-16 02:30:49 UTC (rev 159) +++ trunk/pom.xml 2012-05-16 03:05:35 UTC (rev 160) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.28-SNAPSHOT</version> + <version>1.0.28</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.28</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.28</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.28</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sbe...@us...> - 2012-05-16 02:30:56
|
Revision: 159 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=159&view=rev Author: sbearcsiro Date: 2012-05-16 02:30:49 +0000 (Wed, 16 May 2012) Log Message: ----------- - Add filtering for properties files. Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-16 02:29:41 UTC (rev 158) +++ trunk/pom.xml 2012-05-16 02:30:49 UTC (rev 159) @@ -113,6 +113,22 @@ </mailingLists> <build> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + <includes> + <include>**/*.properties</include> + </includes> + </resource> + <resource> + <directory>src/main/resources</directory> + <filtering>false</filtering> + <excludes> + <exclude>**/*.properties</exclude> + </excludes> + </resource> + </resources> <plugins> <plugin> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sbe...@us...> - 2012-05-16 02:29:48
|
Revision: 158 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=158&view=rev Author: sbearcsiro Date: 2012-05-16 02:29:41 +0000 (Wed, 16 May 2012) Log Message: ----------- - Add app name and version for ANDS DOI Client User-Agent string Modified Paths: -------------- trunk/src/main/resources/ands-doi-client.properties Modified: trunk/src/main/resources/ands-doi-client.properties =================================================================== --- trunk/src/main/resources/ands-doi-client.properties 2012-05-16 02:29:06 UTC (rev 157) +++ trunk/src/main/resources/ands-doi-client.properties 2012-05-16 02:29:41 UTC (rev 158) @@ -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. @@ -14,6 +14,10 @@ # limitations under the License. # +# application.properties +application.name=${pom.name} +application.version=${pom.version} + # RESTful ANDS Digital Identifier Service web service URIs method.mint=doi_mint.php method.update=doi_update.php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sbe...@us...> - 2012-05-16 02:29:12
|
Revision: 157 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=157&view=rev Author: sbearcsiro Date: 2012-05-16 02:29:06 +0000 (Wed, 16 May 2012) Log Message: ----------- - Fix FindBugs - Fix Content-Encoding Header incorrectly specifying a charset - Add charset to Content-Type header - Use charset from response when decoding response from ANDS Modified Paths: -------------- trunk/src/main/java/au/csiro/pidclient/AndsPidClient.java Modified: trunk/src/main/java/au/csiro/pidclient/AndsPidClient.java =================================================================== --- trunk/src/main/java/au/csiro/pidclient/AndsPidClient.java 2012-05-16 02:26:29 UTC (rev 156) +++ trunk/src/main/java/au/csiro/pidclient/AndsPidClient.java 2012-05-16 02:29:06 UTC (rev 157) @@ -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. @@ -13,7 +13,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ - package au.csiro.pidclient; import java.io.BufferedReader; @@ -51,7 +50,7 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; -import au.csiro.pidclient.AndsPidClient.HandleType; +import au.csiro.doiclient.utils.HttpUtil; import au.csiro.pidclient.business.AndsPidIdentity; import au.csiro.pidclient.business.AndsPidResponseProperty; @@ -236,6 +235,20 @@ { LOG.error("Could not load properties file: " + PROPERTIES_FILENAME, e); } + finally + { + if (is != null) + { + try + { + is.close(); + } + catch (IOException e) + { + LOG.error("Could not close properties", e); + } + } + } } /** @@ -939,8 +952,7 @@ HttpClient client = new HttpClient(); client.getParams().setParameter("http.useragent", applicationName); - client.getParams().setParameter("Content-Type", "text/xml"); - client.getParams().setParameter("Content-Encoding", "UTF-8"); + client.getParams().setParameter("Content-Type", "text/xml; charset=UTF-8"); PostMethod method = new PostMethod(postMethodURL); @@ -962,7 +974,8 @@ } else { - br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); + br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream(), + HttpUtil.getCharsetFromResponse(method))); String readLine; while (((readLine = br.readLine()) != null)) { @@ -1256,7 +1269,7 @@ throw new IllegalArgumentException(MessageFormat.format( "The method mintHandle() can only be called if both arguments are empty " + "or both arguments are not empty:\n type= {0}\n value={1}\n", new Object[] { - (type == null) ? null : type.value(), value })); + type.value(), value })); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sbe...@us...> - 2012-05-16 02:26:35
|
Revision: 156 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=156&view=rev Author: sbearcsiro Date: 2012-05-16 02:26:29 +0000 (Wed, 16 May 2012) Log Message: ----------- - Fix FindBugs Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java Modified: trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-05-16 02:25:34 UTC (rev 155) +++ trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-05-16 02:26:29 UTC (rev 156) @@ -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. @@ -21,6 +21,7 @@ import java.io.StringWriter; import java.util.Hashtable; import java.util.List; +import java.util.Map; import org.jdom.Document; import org.jdom.Element; @@ -156,6 +157,7 @@ */ private static void detachExistingNodes(XPath xPath, Document document) throws JDOMException { + @SuppressWarnings("unchecked") List<Element> selectNodes = xPath.selectNodes(document); for (int counter = 1; counter < selectNodes.size(); counter++) { @@ -425,9 +427,9 @@ { Namespace namespaces[] = new Namespace[namespaceMap.size()]; int i = 0; - for (String prefix : namespaceMap.keySet()) + for (Map.Entry<String, String> prefixEntry : namespaceMap.entrySet()) { - Namespace ns = Namespace.getNamespace(prefix, namespaceMap.get(prefix)); + Namespace ns = Namespace.getNamespace(prefixEntry.getKey(), prefixEntry.getValue()); namespaces[i++] = ns; } return namespaces; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sbe...@us...> - 2012-05-16 02:25:41
|
Revision: 155 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=155&view=rev Author: sbearcsiro Date: 2012-05-16 02:25:34 +0000 (Wed, 16 May 2012) Log Message: ----------- - Fix things found by FindBugs - Update HTTP client library to use Apache HTTP Client since it's a dependency anyway - Set user agent - Extract charset from response message - Remove unused methods Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java Added Paths: ----------- trunk/src/main/java/au/csiro/doiclient/utils/HttpUtil.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-05-16 02:18:58 UTC (rev 154) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-05-16 02:25:34 UTC (rev 155) @@ -19,32 +19,25 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.URL; import java.net.URLEncoder; import java.text.MessageFormat; import java.util.Properties; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathConstants; -import javax.xml.xpath.XPathExpression; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - +import org.apache.commons.httpclient.HttpClient; import org.apache.commons.httpclient.HttpException; +import org.apache.commons.httpclient.HttpMethod; +import org.apache.commons.httpclient.HttpURL; import org.apache.commons.httpclient.HttpsURL; +import org.apache.commons.httpclient.NameValuePair; +import org.apache.commons.httpclient.methods.GetMethod; +import org.apache.commons.httpclient.methods.PostMethod; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.w3c.dom.Document; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; import au.csiro.doiclient.business.AndsDoiIdentity; import au.csiro.doiclient.business.DoiDTO; import au.csiro.doiclient.utils.DoiMetaDataGenerator; +import au.csiro.doiclient.utils.HttpUtil; import au.csiro.pidclient.AndsPidClient.HandleType; /** @@ -82,7 +75,7 @@ /** * Constant that defines the logger to be used. */ - private static final Logger LOG = Logger.getLogger(AndsDoiClient.class.getName()); + public static final Logger LOG = Logger.getLogger(AndsDoiClient.class.getName()); /** * Constant that defines the name of properties file to be used. @@ -90,6 +83,16 @@ private static final String PROPERTIES_FILENAME = "/ands-doi-client.properties"; /** + * The application name to use in the user agent header + */ + private static String applicationName; + + /** + * The application version to use in the user agent header + */ + private static String applicationVersion; + + /** * The name of the method (RESTful web service) to call when minting a DOI. */ private static String mintMethodName; @@ -145,13 +148,15 @@ /** * Loads the specified properties file. */ - private static void loadProperties() + static { InputStream is = AndsDoiResponse.class.getResourceAsStream(PROPERTIES_FILENAME); Properties props = new Properties(); try { props.load(is); + applicationName = props.getProperty("application.name"); + applicationVersion = props.getProperty("application.version"); mintMethodName = props.getProperty("method.mint"); updateMethodName = props.getProperty("method.update"); doiMetadataRequest = props.getProperty("method.doi"); @@ -162,6 +167,20 @@ { LOG.error("Could not load properties file: " + PROPERTIES_FILENAME, e); } + finally + { + try + { + if (is != null) + { + is.close(); + } + } + catch (IOException e) + { + LOG.error(e); + } + } } /** @@ -208,7 +227,6 @@ this.setDoiServiceHost(doiServiceHost); this.setDoiServicePath(doiServicePath); this.setRequestorIdentity(requestorIdentity); - loadProperties(); } /** @@ -228,7 +246,6 @@ this.setDoiServicePort(doiServicePort); this.setDoiServicePath(doiServicePath); this.setRequestorIdentity(requestorIdentity); - loadProperties(); } /** @@ -809,8 +826,8 @@ LOG.debug("ExecuteMethod : Method Name : ->" + methodName); } - HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePort(), this.getDoiServicePath(), queryString); - //HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, ""); + HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePort(), this.getDoiServicePath(), + queryString); url.setPath(url.getPath() + "/" + methodName); @@ -826,7 +843,7 @@ } - return doiRequest(url.toString(), metaDataXML, requestType); + return doiRequest(url, metaDataXML, requestType); } /** @@ -867,8 +884,8 @@ * @return * @throws IOException */ - private static AndsDoiResponse doiRequest(String serviceUrl, String metaDataXML, String requestType) - throws IOException + private static AndsDoiResponse doiRequest(HttpURL serviceUrl, String metaDataXML, String requestType) + throws HttpException, IOException { if (LOG.isDebugEnabled()) { @@ -877,44 +894,44 @@ LOG.debug("Request Type: " + requestType); } AndsDoiResponse doiResponse = null; - OutputStreamWriter wr = null; BufferedReader rd = null; StringBuffer outputBuffer; - URL url = new URL(serviceUrl); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - try + HttpMethod method; + + if (requestType.equals("POST")) { - - conn.setDoInput(true); - if (requestType.equals("POST")) + PostMethod post = new PostMethod(serviceUrl.toString()); + if (metaDataXML != null) { - conn.setDoOutput(true); - wr = new OutputStreamWriter(conn.getOutputStream()); - - // Construct data - - if (metaDataXML != null) - { - wr.write("xml=" + URLEncoder.encode(metaDataXML, "UTF-8")); - - } - wr.flush(); + post.setRequestBody(new NameValuePair[] { new NameValuePair("xml", metaDataXML) }); } - else - { - conn.setDoOutput(false); - } - + post.setRequestHeader("Content-Type", PostMethod.FORM_URL_ENCODED_CONTENT_TYPE+"; charset=UTF-8"); + + method = post; + } + else + { + method = new GetMethod(serviceUrl.toString()); + } + + method.setRequestHeader("User-Agent", applicationName + "/" + applicationVersion); + + try + { + HttpClient client = new HttpClient(); + client.executeMethod(method); if (LOG.isDebugEnabled()) { - LOG.debug(conn.getResponseCode() + " - " + conn.getResponseMessage()); + LOG.debug(method.getStatusCode() + " - " + method.getStatusText()); } // Get the response outputBuffer = new StringBuffer(); - rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); + + rd = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream(), + HttpUtil.getCharsetFromResponse(method))); String line; while ((line = rd.readLine()) != null) { @@ -922,38 +939,26 @@ } doiResponse = new AndsDoiResponse(); doiResponse.setMessage(outputBuffer.toString()); - setResponseFlag(conn.getResponseCode(), doiResponse); - + setResponseFlag(method.getStatusCode(), doiResponse); } - catch (Exception e) - { - - // error occured - doiResponse = new AndsDoiResponse(); - outputBuffer = new StringBuffer(); - outputBuffer.append(conn.getResponseMessage() + "\n"); - BufferedReader rde = new BufferedReader(new InputStreamReader(conn.getErrorStream())); - String line; - while ((line = rde.readLine()) != null) - { - outputBuffer.append(line); - } - - doiResponse.setSuccess(false); - doiResponse.setMessage(outputBuffer.toString()); - rde.close(); - } finally { - if (wr != null) + if (rd != null) { - wr.close(); + try + { + rd.close(); + } + catch (IOException e) + { + LOG.error(e); + } } - if (rd != null) + + if (method != null) { - rd.close(); + method.releaseConnection(); } - } return doiResponse; @@ -986,11 +991,7 @@ } break; case 415: - doiResponse.setSuccess(false); - break; case 500: - doiResponse.setSuccess(false); - break; default: doiResponse.setSuccess(false); break; @@ -998,77 +999,6 @@ } /** - * Parses an XML document which contains an ANDS DOI service response for a node that specifies whether the service - * call was successful. - * - * @param doc - * an XML document of the ANDS DOI service response. - * @return whether the response represents a success - * @throws XPathExpressionException - * thrown when attempting to execute XPath on XML response. - * @throws ParserConfigurationException - * thrown when attempting to convert response to an XML document. - * @throws SAXException - * thrown when attempting to convert response to an XML document. - * @throws IOException - * thrown when attempting to read response. - */ - @SuppressWarnings(value = "all") - private boolean parseForSuccess(Document doc) throws XPathExpressionException, ParserConfigurationException, - SAXException, IOException - { - XPathFactory factory = XPathFactory.newInstance(); - XPath xpath = factory.newXPath(); - - // whether <response type="success"> was returned - XPathExpression expr = xpath.compile("//response[@type]"); - Object result = expr.evaluate(doc, XPathConstants.NODESET); - NodeList nodes = (NodeList) result; - for (int i = 0; i < nodes.getLength(); i++) - { - for (int j = 0; j < nodes.item(i).getAttributes().getLength(); j++) - { - Node node = (Node) nodes.item(i).getAttributes().item(j); - return "success".equals(node.getNodeValue()); - } - } - return false; - } - - /** - * Parses an XML document which contains an ANDS DOI service response for a node that specifies what the response - * message is. - * - * @param doc - * an XML document of the ANDS DOI service response. - * @return the response message - * @throws XPathExpressionException - * thrown when attempting to execute XPath on XML response. - * @throws ParserConfigurationException - * thrown when attempting to convert response to an XML document. - * @throws SAXException - * thrown when attempting to convert response to an XML document. - * @throws IOException - * thrown when attempting to read response. - */ - @SuppressWarnings(value = "all") - private String parseForMessage(Document doc) throws XPathExpressionException, ParserConfigurationException, - SAXException, IOException - { - XPathFactory factory = XPathFactory.newInstance(); - XPath xpath = factory.newXPath(); - - XPathExpression expr = xpath.compile("//response/message"); - Object result = expr.evaluate(doc, XPathConstants.NODESET); - NodeList nodes = (NodeList) result; - for (int i = 0; i < nodes.getLength(); i++) - { - return nodes.item(i).getTextContent(); - } - return null; - } - - /** * Retrieve the current ANDS Digital Object Identifier host name * * @return the ANDS Digital Object Identifier host name Added: trunk/src/main/java/au/csiro/doiclient/utils/HttpUtil.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/HttpUtil.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/utils/HttpUtil.java 2012-05-16 02:25:34 UTC (rev 155) @@ -0,0 +1,98 @@ +/** + * 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. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package au.csiro.doiclient.utils; + +import java.nio.charset.Charset; +import java.nio.charset.IllegalCharsetNameException; + +import org.apache.commons.httpclient.Header; +import org.apache.commons.httpclient.HttpMethod; + +import au.csiro.doiclient.AndsDoiClient; + +/** + * Http Utils + * + * Copyright 2012, CSIRO Australia + * All rights reserved. + * + * @author Simon Bear on 15/05/2012 + * @version $Revision$ $Date$ + */ +public class HttpUtil +{ + + /** + * Reads the response headers and finds the character set encoding used in the + * response. + * + * @param method The HTTP Method that has been executed + * @return The Charset used in the response + */ + public static Charset getCharsetFromResponse(HttpMethod method) + { + Charset cs = null; + Header contentType = method.getResponseHeader("Content-Type"); + if (contentType.getElements().length > 0) + { + String value = contentType.getValue(); + int index = value.indexOf(';'); + + if (index > -1 && index != value.length()) + { + String charset = value.substring(index+1).trim(); + index = charset.indexOf('='); + if (index > -1 && index != charset.length()) + { + String name = charset.substring(index+1).trim(); + try + { + if (Charset.isSupported(name)) + { + cs = Charset.forName(name); + } + else + { + AndsDoiClient.LOG.warn("Charset " + name + " not available"); + } + } + catch (IllegalCharsetNameException e) + { + AndsDoiClient.LOG.warn("Charset " + name + " not available"); + } + } + } + } + + if (cs == null) + { + // if no charset available + // then fall back to HTTP 1.1. default + if (Charset.isSupported("ISO-8859-1")) + { + cs = Charset.forName("ISO-8859-1"); + } + else + { + // use platform default if nothing else and hope for the best, i suppose. + AndsDoiClient.LOG.warn("Using default charset"); + cs = Charset.defaultCharset(); + } + } + return cs; + } + +} Property changes on: trunk/src/main/java/au/csiro/doiclient/utils/HttpUtil.java ___________________________________________________________________ Added: svn:keywords + Author Revision Date Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sbe...@us...> - 2012-05-16 02:19:05
|
Revision: 154 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=154&view=rev Author: sbearcsiro Date: 2012-05-16 02:18:58 +0000 (Wed, 16 May 2012) Log Message: ----------- Fix replace 2.2 with 2.1 regex Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-05-14 04:54:43 UTC (rev 153) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-05-16 02:18:58 UTC (rev 154) @@ -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. @@ -100,7 +100,7 @@ { if (getMessage() != null) { - return getMessage().replaceAll("2.2", "2.1"); + return getMessage().replaceAll("2\\.2", "2.1"); } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-05-14 04:54:49
|
Revision: 153 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=153&view=rev Author: csirobuilduser Date: 2012-05-14 04:54:43 +0000 (Mon, 14 May 2012) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-14 04:54:31 UTC (rev 152) +++ trunk/pom.xml 2012-05-14 04:54:43 UTC (rev 153) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.27</version> + <version>1.0.28-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.27</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.27</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.27</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-05-14 04:54:37
|
Revision: 152 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=152&view=rev Author: csirobuilduser Date: 2012-05-14 04:54:31 +0000 (Mon, 14 May 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.27 Added Paths: ----------- tags/ands-pid-client-1.0.27/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-05-14 04:54:03
|
Revision: 151 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=151&view=rev Author: csirobuilduser Date: 2012-05-14 04:53:56 +0000 (Mon, 14 May 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.27 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-05-14 01:36:00 UTC (rev 150) +++ trunk/pom.xml 2012-05-14 04:53:56 UTC (rev 151) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.27-SNAPSHOT</version> + <version>1.0.27</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.27</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.27</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.27</url> </scm> <distributionManagement> <site> 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: <csi...@us...> - 2012-03-26 23:49:42
|
Revision: 149 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=149&view=rev Author: csirobuilduser Date: 2012-03-26 23:49:36 +0000 (Mon, 26 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-26 23:49:24 UTC (rev 148) +++ trunk/pom.xml 2012-03-26 23:49:36 UTC (rev 149) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.26</version> + <version>1.0.27-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.26</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.26</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.26</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-03-26 23:49:30
|
Revision: 148 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=148&view=rev Author: csirobuilduser Date: 2012-03-26 23:49:24 +0000 (Mon, 26 Mar 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.26 Added Paths: ----------- tags/ands-pid-client-1.0.26/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <csi...@us...> - 2012-03-26 23:49:03
|
Revision: 147 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=147&view=rev Author: csirobuilduser Date: 2012-03-26 23:48:56 +0000 (Mon, 26 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.26 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-22 05:52:37 UTC (rev 146) +++ trunk/pom.xml 2012-03-26 23:48:56 UTC (rev 147) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.26-SNAPSHOT</version> + <version>1.0.26</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.26</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.26</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.26</url> </scm> <distributionManagement> <site> 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: <csi...@us...> - 2012-03-20 06:14:43
|
Revision: 145 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=145&view=rev Author: csirobuilduser Date: 2012-03-20 06:14:37 +0000 (Tue, 20 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-20 06:14:27 UTC (rev 144) +++ trunk/pom.xml 2012-03-20 06:14:37 UTC (rev 145) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.25</version> + <version>1.0.26-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier and the DOI services. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -61,9 +61,9 @@ <url>https://sourceforge.net/apps/trac/andspidclient/</url> </issueManagement> <scm> - <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.25</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.25</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.25</url> + <connection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/trunk/</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/trunk</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |