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: <joh...@us...> - 2012-03-15 03:06:38
|
Revision: 118 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=118&view=rev Author: johnpage-09 Date: 2012-03-15 03:06:32 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.16 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-15 01:46:11 UTC (rev 117) +++ trunk/pom.xml 2012-03-15 03:06:32 UTC (rev 118) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.16-SNAPSHOT</version> + <version>1.0.16</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.16</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.16</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.16</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-15 01:46:17
|
Revision: 117 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=117&view=rev Author: johnpage-09 Date: 2012-03-15 01:46:11 +0000 (Thu, 15 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-15 01:46:02 UTC (rev 116) +++ trunk/pom.xml 2012-03-15 01:46:11 UTC (rev 117) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.15</version> + <version>1.0.16-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.15</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.15</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.15</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: <joh...@us...> - 2012-03-15 01:46:08
|
Revision: 116 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=116&view=rev Author: johnpage-09 Date: 2012-03-15 01:46:02 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.15 Added Paths: ----------- tags/ands-pid-client-1.0.15/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-15 01:45:41
|
Revision: 115 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=115&view=rev Author: johnpage-09 Date: 2012-03-15 01:45:35 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.15 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-15 01:23:28 UTC (rev 114) +++ trunk/pom.xml 2012-03-15 01:45:35 UTC (rev 115) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.15-SNAPSHOT</version> + <version>1.0.15</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.15</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.15</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.15</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-15 01:23:34
|
Revision: 114 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=114&view=rev Author: johnpage-09 Date: 2012-03-15 01:23:28 +0000 (Thu, 15 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-15 01:23:16 UTC (rev 113) +++ trunk/pom.xml 2012-03-15 01:23:28 UTC (rev 114) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.14</version> + <version>1.0.15-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.14</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.14</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.14</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: <joh...@us...> - 2012-03-15 01:23:22
|
Revision: 113 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=113&view=rev Author: johnpage-09 Date: 2012-03-15 01:23:16 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.14 Added Paths: ----------- tags/ands-pid-client-1.0.14/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-15 01:22:54
|
Revision: 112 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=112&view=rev Author: johnpage-09 Date: 2012-03-15 01:22:48 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.14 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-15 00:51:55 UTC (rev 111) +++ trunk/pom.xml 2012-03-15 01:22:48 UTC (rev 112) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.14-SNAPSHOT</version> + <version>1.0.14</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.14</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.14</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.14</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-15 00:52:01
|
Revision: 111 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=111&view=rev Author: johnpage-09 Date: 2012-03-15 00:51:55 +0000 (Thu, 15 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-15 00:51:45 UTC (rev 110) +++ trunk/pom.xml 2012-03-15 00:51:55 UTC (rev 111) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.13</version> + <version>1.0.14-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.13</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.13</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.13</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: <joh...@us...> - 2012-03-15 00:51:51
|
Revision: 110 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=110&view=rev Author: johnpage-09 Date: 2012-03-15 00:51:45 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] copy for tag ands-pid-client-1.0.13 Added Paths: ----------- tags/ands-pid-client-1.0.13/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-15 00:51:23
|
Revision: 109 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=109&view=rev Author: johnpage-09 Date: 2012-03-15 00:51:17 +0000 (Thu, 15 Mar 2012) Log Message: ----------- [maven-release-plugin] prepare release ands-pid-client-1.0.13 Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-14 05:52:31 UTC (rev 108) +++ trunk/pom.xml 2012-03-15 00:51:17 UTC (rev 109) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.13-SNAPSHOT</version> + <version>1.0.13</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.13</connection> + <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.13</developerConnection> + <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.13</url> </scm> <distributionManagement> <site> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-14 05:52:38
|
Revision: 108 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=108&view=rev Author: johnpage-09 Date: 2012-03-14 05:52:31 +0000 (Wed, 14 Mar 2012) Log Message: ----------- DMSTECH-2890: Updated POM with new release version Modified Paths: -------------- trunk/.classpath trunk/.project trunk/.settings/org.eclipse.jdt.core.prefs trunk/pom.xml Modified: trunk/.classpath =================================================================== --- trunk/.classpath 2012-03-14 03:12:21 UTC (rev 107) +++ trunk/.classpath 2012-03-14 05:52:31 UTC (rev 108) @@ -1,9 +1,10 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> <classpathentry kind="src" output="target/classes" path="src/main/java"/> - <classpathentry kind="src" path="src/main/resources"/> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"/> <classpathentry kind="src" output="target/test-classes" path="src/test/java"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/> + <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/> <classpathentry kind="output" path="target/classes"/> </classpath> Modified: trunk/.project =================================================================== --- trunk/.project 2012-03-14 03:12:21 UTC (rev 107) +++ trunk/.project 2012-03-14 05:52:31 UTC (rev 108) @@ -20,8 +20,14 @@ <arguments> </arguments> </buildCommand> + <buildCommand> + <name>org.eclipse.m2e.core.maven2Builder</name> + <arguments> + </arguments> + </buildCommand> </buildSpec> <natures> + <nature>org.eclipse.m2e.core.maven2Nature</nature> <nature>org.eclipse.jdt.core.javanature</nature> <nature>org.maven.ide.eclipse.maven2Nature</nature> <nature>org.eclipse.wst.common.project.facet.core.nature</nature> Modified: trunk/.settings/org.eclipse.jdt.core.prefs =================================================================== --- trunk/.settings/org.eclipse.jdt.core.prefs 2012-03-14 03:12:21 UTC (rev 107) +++ trunk/.settings/org.eclipse.jdt.core.prefs 2012-03-14 05:52:31 UTC (rev 108) @@ -1,7 +1,288 @@ -#Tue Feb 09 11:38:30 EST 2010 +#Fri Mar 09 10:08:03 EST 2012 eclipse.preferences.version=1 org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 org.eclipse.jdt.core.compiler.compliance=1.5 org.eclipse.jdt.core.compiler.problem.assertIdentifier=error org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning org.eclipse.jdt.core.compiler.source=1.5 +org.eclipse.jdt.core.formatter.align_type_members_on_columns=false +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_assignment=0 +org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 +org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 +org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 +org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 +org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 +org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 +org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 +org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 +org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 +org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 +org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_after_package=1 +org.eclipse.jdt.core.formatter.blank_lines_before_field=0 +org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 +org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 +org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 +org.eclipse.jdt.core.formatter.blank_lines_before_method=1 +org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 +org.eclipse.jdt.core.formatter.blank_lines_before_package=0 +org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 +org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 +org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line +org.eclipse.jdt.core.formatter.brace_position_for_block=next_line +org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=next_line +org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=next_line +org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=next_line +org.eclipse.jdt.core.formatter.brace_position_for_switch=next_line +org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=next_line +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false +org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false +org.eclipse.jdt.core.formatter.comment.format_block_comments=true +org.eclipse.jdt.core.formatter.comment.format_header=false +org.eclipse.jdt.core.formatter.comment.format_html=true +org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true +org.eclipse.jdt.core.formatter.comment.format_line_comments=true +org.eclipse.jdt.core.formatter.comment.format_source_code=true +org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true +org.eclipse.jdt.core.formatter.comment.indent_root_tags=true +org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert +org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert +org.eclipse.jdt.core.formatter.comment.line_length=120 +org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true +org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true +org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false +org.eclipse.jdt.core.formatter.compact_else_if=true +org.eclipse.jdt.core.formatter.continuation_indentation=2 +org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 +org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off +org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on +org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false +org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true +org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true +org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_empty_lines=false +org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true +org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true +org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false +org.eclipse.jdt.core.formatter.indentation.size=4 +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert +org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert +org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert +org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert +org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert +org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert +org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert +org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert +org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert +org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert +org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert +org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert +org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert +org.eclipse.jdt.core.formatter.join_lines_in_comments=true +org.eclipse.jdt.core.formatter.join_wrapped_lines=true +org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false +org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false +org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false +org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false +org.eclipse.jdt.core.formatter.lineSplit=120 +org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false +org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false +org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 +org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 +org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true +org.eclipse.jdt.core.formatter.tabulation.char=space +org.eclipse.jdt.core.formatter.tabulation.size=4 +org.eclipse.jdt.core.formatter.use_on_off_tags=false +org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false +org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true +org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true +org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-14 03:12:21 UTC (rev 107) +++ trunk/pom.xml 2012-03-14 05:52:31 UTC (rev 108) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.08-SNAPSHOT</version> + <version>1.0.13-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. See the Javadoc report for full details on usage.</description> <url>http://andspidclient.sourceforge.net/</url> @@ -162,7 +162,7 @@ <!-- Generate source jar as a build artifacts --> - <plugin> + <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-source-plugin</artifactId> <executions> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-14 03:12:27
|
Revision: 107 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=107&view=rev Author: johnpage-09 Date: 2012-03-14 03:12:21 +0000 (Wed, 14 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating URL associated with a Digital Object Identifier. Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-13 23:12:25 UTC (rev 106) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-14 03:12:21 UTC (rev 107) @@ -71,7 +71,7 @@ * <li>requestorIdentity.authDomain - mycomputer.edu.au</li> * </UL> * <p> - * You can then mint new DOIs using the {@link #mintDOI(String)} method. + * This class has methods for (a)minting DOIs, (b)updating DOIs, (c) activating and deactivating DOIs. * * </p> * Copyright 2010, CSIRO Australia All rights reserved. @@ -90,8 +90,7 @@ private static final Logger LOG = Logger.getLogger(AndsDoiClient.class.getName()); /** - * Constant that defines the name of properties file to be used. Both the Pid and Doi client share the same property - * file + * Constant that defines the name of properties file to be used. */ private static final String PROPERTIES_FILENAME = "/ands-doi-client.properties"; @@ -272,13 +271,23 @@ throws HttpException, IOException { + String queryString = null; + this.validateState(); // DOI should not be null this.validateParameters(updateMethodName, doi, updatedUrl); - String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { - getRequestorIdentity().getAppId(), doi }); + if (updatedUrl != null) + { + queryString = MessageFormat.format("app_id={0}&doi={1}&url={2}", new Object[] { + getRequestorIdentity().getAppId(), doi, updatedUrl }); + } + else + { + queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { getRequestorIdentity().getAppId(), + doi }); + } return executeMethod(queryString, updateMethodName, updateMetaData, updatedUrl, existingMetaDataXML); } @@ -318,7 +327,7 @@ } // DOI should not be null - this.validateParameters(methodName, doi, null); + this.validateParameters(methodName, doi); String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { getRequestorIdentity().getAppId(), doi }); @@ -346,7 +355,7 @@ this.validateState(); // DOI should not be null - this.validateParameters(doiMetadataRequest, doi, null); + this.validateParameters(doiMetadataRequest, doi); String queryString = MessageFormat.format("doi={0}", new Object[] { doi }); @@ -393,10 +402,12 @@ * Checks the arguments passed to the {@link #mintDOI(String)} and the * {@link #mintHandleByIndex(HandleType, int, String)} methods. * - * @param value - * the url of the data collection for which a DOI is required. * @param methodName - * the method that is being called on the DOI service + * the method that is being called on the DOI service call. + * @param doi + * for an update or get meta-data request service call. + * @param url + * for a mint DOI service call. * @throws IllegalStateException * thrown if the arguments provided to {@link #mintDOI(HandleType, String)} or to * {@link #mintHandleByIndex(HandleType, int, String)} are not valid. @@ -404,28 +415,27 @@ private void validateParameters(String... values) throws IllegalArgumentException { - if (values[0].equals("doi_mint.php") && StringUtils.isEmpty(values[1])) + if (mintMethodName.equals(values[0]) && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( - "The method mintDOI() can only be called if the arguement is non-empty:values={1}\n", + "The method to mint a DOI can only be called if the url value is a non-empty value:values={1}\n", new Object[] { values[1] })); } - if (((values[0].equals("doi_update.php")) || (values[0].equals("doi_xml.php"))) + if (((updateMethodName.equals(values[0])) || (values[0].equals(doiMetadataRequest))) && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( - "The method to update or request meta-data can only be called if the arguement is " - + "non-empty:values={1}\n", - new Object[] { values[1] })); + "The method to update or request meta-data can only be called if the DOI and updated url are " + + "non-empty values:values={1}, values={2}\n", new Object[] { values[1], values[2] })); } - if (((values[0].equals("doi_activate.php")) || (values[0].equals("doi_deactivate.php"))) + if (((activateDoi.equals(values[0])) || (deactivateDoi.equals(values[0]))) && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( - "The method to activate / deactivate () can only be called " - + "if the arguement is non-empty:values={1}\n", new Object[] { values[1] })); + "The method to activate / deactivate DOIs can only be called " + + "if the DOI is non-empty:values={1}\n", new Object[] { values[1] })); } } @@ -454,28 +464,29 @@ String metaDataXML = null; String requestType = getRequestType(methodName, updateMetaData); - LOG.debug("ExecuteMethod : Query String : ->" + queryString); - LOG.debug("ExecuteMethod : Method Name : ->" + methodName); + if (LOG.isDebugEnabled()) + { + LOG.debug("ExecuteMethod : Query String : ->" + queryString); + LOG.debug("ExecuteMethod : Method Name : ->" + methodName); + } HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, ""); url.setPath(url.getPath() + "/" + methodName); - if (methodName.equals("doi_mint.php")) + if (methodName.equals(mintMethodName)) { metaDataXML = this.getRequestorIdentity().generateMetaDataXMLFromDTO(); - LOG.debug("Metadata XML generated :->" + metaDataXML); } // Updates the meta-data xml with the parameters set in the DTO. - if (methodName.equals("doi_update.php") && (!StringUtils.isEmpty(existingMetaDataXML))) + if (methodName.equals(updateMethodName) && (!StringUtils.isEmpty(existingMetaDataXML))) { metaDataXML = this.getRequestorIdentity().updateMetaDataXMLFromDTO(existingMetaDataXML); - LOG.debug("**Updated Metadata XML :->" + metaDataXML); } - return doiRequest(url.toString(), metaDataXML, updateURL, requestType); + return doiRequest(url.toString(), metaDataXML, requestType); } /** @@ -490,7 +501,7 @@ private String getRequestType(String methodName, boolean updateMetaData) { - if (methodName.equals("doi_mint.php") || (updateMetaData)) + if (mintMethodName.equals(methodName) || (updateMetaData)) { return "POST"; } @@ -518,15 +529,16 @@ * @return * @throws IOException */ - private static AndsDoiResponse doiRequest(String serviceUrl, String metaDataXML, String updateURL, String requestType) + private static AndsDoiResponse doiRequest(String serviceUrl, String metaDataXML, String requestType) throws IOException { - LOG.debug("Method URL: " + serviceUrl); - LOG.debug("Metadata XML NULL ?: " + StringUtils.isEmpty(metaDataXML)); - LOG.debug("Update URL: " + updateURL); - LOG.debug("Request Type: " + requestType); + if (LOG.isDebugEnabled()) + { + LOG.debug("Method URL: " + serviceUrl); + LOG.debug("Metadata XML NULL ?: " + StringUtils.isEmpty(metaDataXML)); + LOG.debug("Request Type: " + requestType); + } AndsDoiResponse doiResponse = null; - String data = null; OutputStreamWriter wr = null; StringBuffer outputBuffer; @@ -545,16 +557,9 @@ if (metaDataXML != null) { - LOG.debug("Writing XML metadata to output stream..."); wr.write("xml=" + URLEncoder.encode(metaDataXML, "UTF-8")); } - - if (updateURL != null) - { - LOG.debug("Writing URL for update to output stream..."); - wr.write("url=" + URLEncoder.encode(updateURL, "UTF-8")); - } wr.flush(); } else @@ -566,7 +571,10 @@ doiResponse.setResponseCode(conn.getResponseCode()); doiResponse.setResponseMessage(conn.getResponseMessage()); - LOG.debug(conn.getResponseCode() + " - " + conn.getResponseMessage()); + if (LOG.isDebugEnabled()) + { + LOG.debug(conn.getResponseCode() + " - " + conn.getResponseMessage()); + } // Get the response outputBuffer = new StringBuffer(); @@ -596,7 +604,6 @@ String line; while ((line = rde.readLine()) != null) { - LOG.debug(line); outputBuffer.append(line); } rde.close(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-13 23:12:32
|
Revision: 106 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=106&view=rev Author: johnpage-09 Date: 2012-03-13 23:12:25 +0000 (Tue, 13 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating meta-data associated with a Digital Object Identifier. Modified Paths: -------------- trunk/DoiMetadataTemplate.xml trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java Modified: trunk/DoiMetadataTemplate.xml =================================================================== --- trunk/DoiMetadataTemplate.xml 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/DoiMetadataTemplate.xml 2012-03-13 23:12:25 UTC (rev 106) @@ -1,3 +1,20 @@ +<!-- + + 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. + +--> <resource xmlns="http://datacite.org/schema/kernel-2.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://datacite.org/schema/kernel-2.1 Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,3 +1,18 @@ +/** + * 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; import java.io.BufferedReader; @@ -29,6 +44,7 @@ import au.csiro.doiclient.business.AndsDoiIdentity; import au.csiro.doiclient.business.DoiDTO; +import au.csiro.pidclient.AndsPidClient.HandleType; @@ -79,10 +95,6 @@ */ private static final String PROPERTIES_FILENAME = "/ands-doi-client.properties"; - /** - * The name of the application, to be used by the HTTP client. - */ - private static String applicationName; /** * The name of the method (RESTful web service) to call when minting a DOI. @@ -126,52 +138,7 @@ */ private String doiServicePath; - /** - * The possible types of properties that can be associated with a handle. Each handle (DOI) can carry multiple (max - * of around 100) properties. - */ - public enum HandleType - { - /** - * A property with no associated value. - */ - EMPTY(""), - /** - * A property with a URL value. - */ - URL("URL"), - /** - * A property with a descriptive text value. - */ - DESC("DESC"); - /** - * The value of the enumeration understood by the ANDS DOI service. - */ - private final String value; - - HandleType(String value) - { - this.value = value; - } - - /** - * @return the value of the enumeration. - */ - public String value() - { - return this.value; - } - - /** - * @return whether this enumeration is empty. - */ - public boolean isEmpty() - { - return EMPTY.value().equals(this.value); - } - } - /** * Loads the specified properties file. */ @@ -182,7 +149,6 @@ try { props.load(is); - applicationName = props.getProperty("application.name"); mintMethodName = props.getProperty("method.mint"); updateMethodName = props.getProperty("method.update"); doiMetadataRequest = props.getProperty("method.doi"); @@ -206,8 +172,6 @@ /** * @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 appId @@ -231,8 +195,6 @@ /** * @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 @@ -278,7 +240,7 @@ String queryString = MessageFormat.format("app_id={0}&url={1}", new Object[] { getRequestorIdentity().getAppId(), url }); - return executeMethod(queryString, mintMethodName, true, null); + return executeMethod(queryString, mintMethodName, true, null, null); } @@ -290,10 +252,12 @@ * * @param doi * that needs to be updated. - * @param url + * @param updatedUrl * the url pointing to the landing page of the data collection. - * @param updateMetdaData + * @param updateMetaData * true if metadata update is required, false if not. + * @param existingMetaDataXML + * Metadata XML associated with the DOI. * @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. @@ -304,19 +268,19 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse updateDOI(String doi, String url, boolean updateMetdaData) throws HttpException, IOException + public AndsDoiResponse updateDOI(String doi, String updatedUrl, boolean updateMetaData, String existingMetaDataXML) + throws HttpException, IOException { this.validateState(); // DOI should not be null - this.validateParameters(updateMethodName, doi, url); + this.validateParameters(updateMethodName, doi, updatedUrl); String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { getRequestorIdentity().getAppId(), doi }); - - return executeMethod(queryString, updateMethodName, updateMetdaData, url); + return executeMethod(queryString, updateMethodName, updateMetaData, updatedUrl, existingMetaDataXML); } /** @@ -359,7 +323,7 @@ String queryString = MessageFormat.format("app_id={0}&doi={1}", new Object[] { getRequestorIdentity().getAppId(), doi }); - return executeMethod(queryString, methodName, false, null); + return executeMethod(queryString, methodName, false, null, null); } /** @@ -386,7 +350,7 @@ String queryString = MessageFormat.format("doi={0}", new Object[] { doi }); - return executeMethod(queryString, doiMetadataRequest, false, null); + return executeMethod(queryString, doiMetadataRequest, false, null, null); } @@ -473,7 +437,7 @@ * the query string to provide the POST call. * @param methodName * the method to call. - * @param updateMetdaData + * @param updateMetaData * flag indicating if the meta data needs to be generated. * @param updateURL * associated with a DOI that needs to be updated. @@ -483,12 +447,12 @@ * @throws HttpException * thrown when attempting to execute method call. */ - private AndsDoiResponse executeMethod(String queryString, String methodName, boolean updateMetdaData, - String updateURL) throws HttpException, IOException + private AndsDoiResponse executeMethod(String queryString, String methodName, boolean updateMetaData, + String updateURL, String existingMetaDataXML) throws HttpException, IOException { String metaDataXML = null; - String requestType = getRequestType(methodName); + String requestType = getRequestType(methodName, updateMetaData); LOG.debug("ExecuteMethod : Query String : ->" + queryString); LOG.debug("ExecuteMethod : Method Name : ->" + methodName); @@ -497,14 +461,20 @@ url.setPath(url.getPath() + "/" + methodName); - // Meta Data will need to be generated only if it is a call to MINT DOIs. - // It becomes optional for update calls. - if (updateMetdaData) + if (methodName.equals("doi_mint.php")) { - metaDataXML = this.getRequestorIdentity().toXML(methodName); + metaDataXML = this.getRequestorIdentity().generateMetaDataXMLFromDTO(); + LOG.debug("Metadata XML generated :->" + metaDataXML); } - LOG.debug("Metadata XML generated :->" + metaDataXML); + // Updates the meta-data xml with the parameters set in the DTO. + if (methodName.equals("doi_update.php") && (!StringUtils.isEmpty(existingMetaDataXML))) + { + metaDataXML = this.getRequestorIdentity().updateMetaDataXMLFromDTO(existingMetaDataXML); + LOG.debug("**Updated Metadata XML :->" + metaDataXML); + } + + return doiRequest(url.toString(), metaDataXML, updateURL, requestType); } @@ -513,14 +483,21 @@ * * @param methodName * call that is to be made to the DOI service. + * @param updateURL + * the URL to be updated. * @return requestType GET or POST. */ - private String getRequestType(String methodName) + private String getRequestType(String methodName, boolean updateMetaData) { - if ((methodName.equals("doi_mint.php")) || (methodName.equals("doi_update.php"))) + + if (methodName.equals("doi_mint.php") || (updateMetaData)) + { return "POST"; + } else + { return "GET"; + } } @@ -545,9 +522,12 @@ throws IOException { LOG.debug("Method URL: " + serviceUrl); + LOG.debug("Metadata XML NULL ?: " + StringUtils.isEmpty(metaDataXML)); + LOG.debug("Update URL: " + updateURL); LOG.debug("Request Type: " + requestType); AndsDoiResponse doiResponse = null; String data = null; + OutputStreamWriter wr = null; StringBuffer outputBuffer; URL url = new URL(serviceUrl); @@ -555,30 +535,33 @@ try { - // Send data - conn.setRequestMethod(requestType); - conn.setDoOutput(true); conn.setDoInput(true); - OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); + if (requestType.equals("POST")) + { + conn.setDoOutput(true); + wr = new OutputStreamWriter(conn.getOutputStream()); - // Construct data + // Construct data - if (metaDataXML != null) - { - System.out.println("Writing XML metadata to output stream..."); - data = "xml=" + URLEncoder.encode(metaDataXML, "UTF-8"); - wr.write(data); - } + if (metaDataXML != null) + { + LOG.debug("Writing XML metadata to output stream..."); + wr.write("xml=" + URLEncoder.encode(metaDataXML, "UTF-8")); - if (updateURL != null) + } + + if (updateURL != null) + { + LOG.debug("Writing URL for update to output stream..."); + wr.write("url=" + URLEncoder.encode(updateURL, "UTF-8")); + } + wr.flush(); + } + else { - System.out.println("Writing URL for update to output stream..."); - data = "url=" + updateURL; - wr.write(data); + conn.setDoOutput(false); } - wr.flush(); - doiResponse = new AndsDoiResponse(); doiResponse.setResponseCode(conn.getResponseCode()); doiResponse.setResponseMessage(conn.getResponseMessage()); @@ -593,7 +576,12 @@ { outputBuffer.append(line); } - wr.close(); + + if (wr != null) + { + wr.close(); + } + rd.close(); doiResponse.setResponseBody(outputBuffer.toString()); @@ -601,6 +589,7 @@ } catch (Exception e) { + e.printStackTrace(); // error occured outputBuffer = new StringBuffer(); BufferedReader rde = new BufferedReader(new InputStreamReader(conn.getErrorStream())); Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,3 +1,18 @@ +/** + * 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; @@ -32,6 +47,11 @@ * Digital Object Identifier returned by DOI service */ private String doi; + + /** + * Metadata xml returned by ANDs for a given DOI; + */ + private String metaData; /** * @@ -129,6 +149,17 @@ } /** + * ANDs has requested us to change the schema version to 2.1 for all meta-data sent to ANDs even though they send + * meta-data pertaining to version 2.2 in a GET Meta-data request. + * + * @return the metaData + */ + public String getMetaData() + { + return getResponseBody().replaceAll("2.2", "2.1"); + } + + /** * Extracts the DOI from the DOI service response body, if no DOI could be extracted from the response body then * null is returned */ Modified: trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,3 +1,18 @@ +/** + * 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.business; import java.io.IOException; @@ -147,12 +162,11 @@ * Formats the DOI meta-data information into a XML format that the ANDS Digital Object Identifier service * understands. * - * @param methodName - * the name of the method to be called for this particular DOI call. - * @return the meta data XML string representing the identity information of the digital object. + * @return String representation of the XML metadata. + * */ @SuppressWarnings(value = "all") - public String toXML(String methodName) + public String generateMetaDataXMLFromDTO() { String doiMetaDataXML = null; @@ -173,7 +187,33 @@ } + /** + * Updates the meta-data xml associated with the DOI. + * + * @param existingMetaDataXML + * existing metadata of the DOI. + * @return String representation of the updated XML metadata. + */ + public String updateMetaDataXMLFromDTO(String existingMetaDataXML) + { + String doiMetaDataXML = null; + try + { + doiMetaDataXML = DoiMetaDataGenerator.updateDoiMetaDataXML(getDoiDTO(), existingMetaDataXML); + } + catch (IOException e) + { + LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), e); + } + catch (JDOMException ex) + { + LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), ex); + } + + return doiMetaDataXML; + } + /* * (non-Javadoc) * @@ -231,5 +271,6 @@ return buffer.toString(); } + } Modified: trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,4 +1,19 @@ /** + * 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.business; @@ -13,7 +28,7 @@ * Copyright 2010, CSIRO Australia All rights reserved. * * @author John Page on 03/03/2012 - * @version $Revision$Date: + * @version $Revision$Date: $ */ public class DoiDTO implements Serializable { Modified: trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,3 +1,18 @@ +/** + * 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.io.IOException; @@ -96,8 +111,8 @@ * Namespace associated with the element * @param element * the element XPath that needs to be updated - * @param value - * the new value of the element + * @param values + * List of new values of the element * @throws JDOMException * when invalid XML parsing/access occurs */ @@ -110,6 +125,8 @@ Element baseElement = (Element) xPath.selectSingleNode(document); baseElement.setText(stripNonValidXMLCharacters(values.get(0))); + detachExistingNodes(xPath, document); + for (int counter = 1; counter < values.size(); counter++) { @@ -124,7 +141,23 @@ grandParent.addContent(1, clonedParentElement); } + } + /** + * Removes all elements following the first element + * + * @param xPath + * @param document + * @throws JDOMException + */ + private static void detachExistingNodes(XPath xPath, Document document) throws JDOMException + { + List<Element> selectNodes = xPath.selectNodes(document); + for (int counter = 1; counter < selectNodes.size(); counter++) + { + Element element = (Element) selectNodes.get(counter); + element.getParentElement().detach(); + } } /** @@ -308,8 +341,8 @@ * * @param document * the existing XML document to update - * @param nameSpaces - * a Hashtable of XML Namespaces associated with the element + * @param nameSpace + * the namespace associated with the element * @param element * the element XPath that needs to be added * @param values @@ -350,8 +383,8 @@ * * @param document * the existing XML document to update - * @param nameSpaces - * a Hashtable of XML Namespaces associated with the element + * @param nameSpace + * an xml namespace associated with the element * @param element * the element XPath that needs to be added * @param value Modified: trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,10 +1,26 @@ /** + * 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.io.IOException; +import org.apache.commons.lang.StringUtils; import org.jdom.Document; import org.jdom.JDOMException; @@ -18,7 +34,7 @@ * Copyright 2010, CSIRO Australia All rights reserved. * * @author John Page on 03/03/2011 - * @version $Revision$Date: + * @version $Revision$Date: $ */ public class DoiMetaDataGenerator { @@ -54,7 +70,7 @@ private static final String NAME_SPACE = "xsi"; /** - * Create a String representation of a DOIMetaData XML document from an DoiDTO bean. + * Create a String representation of a DOIMetaData XML document from an DoiDTO bean using a template. * * @param doiDto * the bean representation of an OPAL record to be converted to a VOResource XML document @@ -80,6 +96,55 @@ return ConverterUtils.outputTheXml(document); } + /** + * Updates a String representation of a DOIMetaData XML document from an DoiDTO bean using an existing metadata + * document. + * + * @param doiDto + * the bean representation of an OPAL record to be converted to a VOResource XML document + * @return a String representation of the DOIMetaData XML + * @throws IOException + * if the XML Document access fails + * @throws JDOMException + * when invalid XML parsing/access occurs + */ + public static String updateDoiMetaDataXML(DoiDTO doiDto, String metaDataDocument) throws IOException, + JDOMException + { + + Document document = ConverterUtils.xmlToDoc(metaDataDocument); + + if ((doiDto.getCreators() != null) && (doiDto.getCreators().size() > 0)) + { + ConverterUtils.updateElementValues(document, NAME_SPACE, CREATOR_NAME_XPATH, doiDto.getCreators()); + } + + if (!StringUtils.isEmpty(doiDto.getTitle())) + { + ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.TITLE_NAME_XPATH, + doiDto.getTitle()); + } + + if (!StringUtils.isEmpty(doiDto.getPublisher())) + { + ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.PUBLISHER_NAME_XPATH, + doiDto.getPublisher()); + } + + if (!StringUtils.isEmpty(doiDto.getPublicationYear())) + { + ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.PUBLICATIONYEAR_NAME_XPATH, + doiDto.getPublicationYear()); + } + + if (!StringUtils.isEmpty(doiDto.getIdentifier())) + { + ConverterUtils.updateElementValue(document, NAME_SPACE, IDENTIFIER_NAME_XPATH, doiDto.getIdentifier()); + } + + return ConverterUtils.outputTheXml(document); + } + /** * Sets the DOI value returned by the mint call and generates the meta-data xml. Modified: trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2012-03-13 00:40:14 UTC (rev 105) +++ trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2012-03-13 23:12:25 UTC (rev 106) @@ -1,3 +1,18 @@ +/** + * 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.util.ArrayList; @@ -24,11 +39,6 @@ { /** - * DTO with values to be set up in the metadata xml. - */ - private DoiDTO doiDTO; - - /** * Constant giving the xpath of the creator name */ private static final String CREATOR_NAME_XPATH = "/xsi:resource/xsi:creators/xsi:creator/xsi:creatorName"; @@ -42,8 +52,6 @@ protected void setUp() throws Exception { super.setUp(); - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); } @@ -53,8 +61,9 @@ * @param doiDTO * DTO with the values for the DOIMetaDataTemplate. */ - private void populateDummydoiDTO(DoiDTO doiDTO) + private DoiDTO populateDummydoiDTO() { + DoiDTO doiDTO = new DoiDTO(); List<String> creators = new ArrayList<String>(); creators.add(0, "Smith,John"); creators.add(1, "Green,Matt"); @@ -68,6 +77,8 @@ doiDTO.setPublicationYear("2001"); doiDTO.setPublisher("CSIRO"); + return doiDTO; + } /* (non-Javadoc) @@ -86,7 +97,7 @@ */ public final void testCreateDoiMetaDataXML() throws Exception { - String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(doiDTO); + String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(populateDummydoiDTO()); assertNotNull(doiMetaDataXML); Document document = ConverterUtils.xmlToDoc(doiMetaDataXML); @@ -102,15 +113,15 @@ /** - * Tests the updation of the Identifier + * Tests the updation of the identifier * * @throws Exception */ - public final void testUpdateDOI() throws Exception + public final void testUpdateIdentifier() throws Exception { String doi = "10.5072/08/4F5838BF44E5A"; - String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(doiDTO); + String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(populateDummydoiDTO()); assertNotNull(doiMetaDataXML); String updatedMetaData = DoiMetaDataGenerator.updateDOI(doi, doiMetaDataXML); @@ -127,4 +138,36 @@ assertEquals("identifier", ((Element) nodes.get(0)).getName()); assertEquals("10.5072/08/4F5838BF44E5A", ((Element) nodes.get(0)).getText()); } + + /** + * Tests the updation of the creator names. + * + * @throws Exception + */ + public final void testUpdateCreatorNames() throws Exception + { + + DoiDTO dto = populateDummydoiDTO(); + String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(dto); + String doi = "10.5072/08/4F5838BF44E5A"; + + List<String> creators = dto.getCreators(); + creators.remove(3); + creators.remove(4); + + dto.setCreators(creators); + + String updatedMetaData = DoiMetaDataGenerator.updateDoiMetaDataXML(dto, doiMetaDataXML); + assertNotNull(updatedMetaData); + System.out.println("Meta-Data : \n" + updatedMetaData); + + Document document = ConverterUtils.xmlToDoc(updatedMetaData); + XPath xPath = XPath.newInstance(CREATOR_NAME_XPATH); + xPath.addNamespace("xsi", document.getRootElement().getNamespaceURI()); + List nodes = xPath.selectNodes(document); + + assertEquals(4, nodes.size()); + + assertEquals("creatorName", ((Element) nodes.get(0)).getName()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <rit...@us...> - 2012-03-13 00:40:21
|
Revision: 105 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=105&view=rev Author: ritacsiro Date: 2012-03-13 00:40:14 +0000 (Tue, 13 Mar 2012) Log Message: ----------- modified comment Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java Modified: trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-09 02:26:54 UTC (rev 104) +++ trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-13 00:40:14 UTC (rev 105) @@ -14,7 +14,6 @@ * * Copyright 2010, CSIRO Australia All rights reserved. * - * @author Robert Bridle on 08/02/2010 * @author John Page on 03/03/2012 * * @version $Revision$Date: $ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-09 02:27:01
|
Revision: 104 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=104&view=rev Author: johnpage-09 Date: 2012-03-09 02:26:54 +0000 (Fri, 09 Mar 2012) Log Message: ----------- DMSTECH-2891: Updated JavaDoc for one of the methods. Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-09 02:10:56 UTC (rev 103) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-09 02:26:54 UTC (rev 104) @@ -322,15 +322,17 @@ /** * Responsible for Activating / Deactivating a DOI. * <p> - * DOI being updated must belong to the client requesting the update. The update service point allows clients to - * update their DOIs in 3 ways. Clients can update the URL only, metadata only, or both the URL and metadata + * Deactivates metadata associated with a DOI. A DOI\x92s metadata is active by default. Deactivating a DOI\x92s metadata + * prevents the metadata from being returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint. * + * Activates deactivated metadata associated with a given DOI. A DOI\x92s metadata is active by default, and can only + * by activated if it has previously been deactivated. Activating a DOI\x92s metadata allows the metadata to be + * returned by the public \x91Request Metadata Associated with DOI\x92 service endpoint. + * * @param doi - * that needs to be updated. - * @param url - * the url pointing to the landing page of the data collection. - * @param updateMetdaData - * true if metadata update is required, false if not. + * that needs to be activated/ deactivated. + * @param activate + * boolean flag indicating whether to activate or deactivate. * @return AndsDoiResponse {@link AndsDoiResponse} Response object holding the components of the response. * @throws IllegalStateException * thrown if the parameters need to call the ANDS DOI service have not been provided. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-08 22:34:47
|
Revision: 102 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=102&view=rev Author: johnpage-09 Date: 2012-03-08 22:34:41 +0000 (Thu, 08 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating the DOI element in the metadata xml. Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-08 05:15:50 UTC (rev 101) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-08 22:34:41 UTC (rev 102) @@ -538,11 +538,7 @@ HttpURLConnection conn = (HttpURLConnection) url.openConnection(); try { - if (metadata != null) - { - } - // Send data conn.setRequestMethod(requestType); conn.setDoOutput(true); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-08 05:15:57
|
Revision: 101 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=101&view=rev Author: johnpage-09 Date: 2012-03-08 05:15:50 +0000 (Thu, 08 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating the DOI element in the metadata xml. Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-08 04:39:03 UTC (rev 100) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-08 05:15:50 UTC (rev 101) @@ -294,7 +294,7 @@ /** - * Responsible for the Updating a DOI. + * 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 @@ -346,7 +346,7 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse requestMetaDatatDOI(String doi) throws HttpException, IOException + public AndsDoiResponse requestMetaDataOfDOI(String doi) throws HttpException, IOException { this.validateState(); Modified: trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java 2012-03-08 04:39:03 UTC (rev 100) +++ trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java 2012-03-08 05:15:50 UTC (rev 101) @@ -4,8 +4,6 @@ package au.csiro.doiclient.utils; import java.io.IOException; -import java.util.Iterator; -import java.util.List; import org.jdom.Document; import org.jdom.JDOMException; @@ -28,6 +26,12 @@ /** * Constant giving the xpath of the creator name */ + private static final String IDENTIFIER_NAME_XPATH = "/xsi:resource/xsi:identifier"; + + + /** + * Constant giving the xpath of the creator name + */ private static final String CREATOR_NAME_XPATH = "/xsi:resource/xsi:creators/xsi:creator/xsi:creatorName"; /** @@ -64,8 +68,6 @@ { Document document = ConverterUtils.getXmlDocument("DoiMetadataTemplate.xml"); - // ConverterUtils.addElementValue(document, NAME_SPACE, CREATOR_NAME_XPATH, doiDto.getCreators().get(0)); - ConverterUtils.updateElementValues(document, NAME_SPACE, CREATOR_NAME_XPATH, doiDto.getCreators()); ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.TITLE_NAME_XPATH, @@ -78,30 +80,29 @@ return ConverterUtils.outputTheXml(document); } + /** + * Sets the DOI value returned by the mint call and generates the meta-data xml. * - * @param doiDto - * @param document + * @param doi + * The Digital Object Identifier that needs to be set into the xml. + * @param xmlDocument + * XML document that neews to be updated. + * @throws IOException + * if the XML Document access fails * @throws JDOMException + * when invalid XML parsing/access occurs */ - private static void updateCreatorNames(DoiDTO doiDto, Document document) throws JDOMException + public static String updateDOI(String doi, String xmlDocument) throws JDOMException, IOException { + Document document = ConverterUtils.xmlToDoc(xmlDocument); + ConverterUtils.updateElementValue(document, NAME_SPACE, IDENTIFIER_NAME_XPATH, doi); - List<String> creators = doiDto.getCreators(); - int counter = 1; - for (Iterator<String> iterator = creators.iterator(); iterator.hasNext();) - { - String creatorName = (String) iterator.next(); - String xPath = DoiMetaDataGenerator.CREATOR_NAME_XPATH + "[" + counter + "]"; - ConverterUtils.updateElementValue(document, NAME_SPACE, xPath, creatorName); + return ConverterUtils.outputTheXml(document); - counter++; + } - } - } - - } Modified: trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2012-03-08 04:39:03 UTC (rev 100) +++ trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2012-03-08 05:15:50 UTC (rev 101) @@ -33,6 +33,9 @@ */ private static final String CREATOR_NAME_XPATH = "/xsi:resource/xsi:creators/xsi:creator/xsi:creatorName"; + /** Constant giving the xpath of the identifier name **/ + private static final String IDENTIFIER_NAME_XPATH = "/xsi:resource/xsi:identifier"; + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @@ -98,4 +101,30 @@ } + /** + * Tests the updation of the Identifier + * + * @throws Exception + */ + public final void testUpdateDOI() throws Exception + { + String doi = "10.5072/08/4F5838BF44E5A"; + + String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(doiDTO); + assertNotNull(doiMetaDataXML); + + String updatedMetaData = DoiMetaDataGenerator.updateDOI(doi, doiMetaDataXML); + assertNotNull(updatedMetaData); + System.out.println("Meta-Data : \n" + updatedMetaData); + + Document document = ConverterUtils.xmlToDoc(updatedMetaData); + XPath xPath = XPath.newInstance(IDENTIFIER_NAME_XPATH); + xPath.addNamespace("xsi", document.getRootElement().getNamespaceURI()); + List nodes = xPath.selectNodes(document); + + assertEquals(1, nodes.size()); + + assertEquals("identifier", ((Element) nodes.get(0)).getName()); + assertEquals("10.5072/08/4F5838BF44E5A", ((Element) nodes.get(0)).getText()); + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-08 04:39:11
|
Revision: 100 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=100&view=rev Author: johnpage-09 Date: 2012-03-08 04:39:03 +0000 (Thu, 08 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating the meta-data associated with the Digital Object Identifier with multiple creator names. Modified Paths: -------------- trunk/DoiMetadataTemplate.xml trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java Removed Paths: ------------- trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java Modified: trunk/DoiMetadataTemplate.xml =================================================================== --- trunk/DoiMetadataTemplate.xml 2012-03-07 05:56:29 UTC (rev 99) +++ trunk/DoiMetadataTemplate.xml 2012-03-08 04:39:03 UTC (rev 100) @@ -1,31 +1,29 @@ -<resource xmlns="http://datacite.org/schema/kernel-2.1" -xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" -xsi:schemaLocation="http://datacite.org/schema/kernel-2.1 +<resource xmlns="http://datacite.org/schema/kernel-2.1" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://datacite.org/schema/kernel-2.1 http://schema.datacite.org/meta/kernel-2.1/metadata.xsd"> <identifier identifierType="DOI">10.2312/meyniana.2005.57.101</identifier> -<creators> -<creator> -<creatorName>Schimanski, Alexander</creatorName> -</creator> -<creator> -<creatorName>Stattegger, Karl</creatorName> -</creator> -</creators> -<titles> -<title>A conceptual sediment budget for the Great Barrier Reef</title> -</titles> -<publisher> + <creators> + <creator> + <creatorName>Schimanski, Alexander</creatorName> + </creator> + </creators> + <titles> + <title>A conceptual sediment budget for the Great Barrier Reef</title> + </titles> + <publisher> Institut für Geowissenschaften, Christian-Albrechts-Universität, Kiel </publisher> -<publicationYear>2005</publicationYear> -<subjects> -<subject subjectScheme="DDC">550 Earth sciences and geology</subject> -</subjects> -<resourceType resourceTypeGeneral="Text">Article</resourceType> -<formats> -<format>PDF</format> -</formats> -<descriptions> -<description descriptionType="Other">MEYNIANA; 57; 101-115; ISSN 0076-7689</description> -</descriptions> + <publicationYear>2005</publicationYear> + <subjects> + <subject subjectScheme="DDC">550 Earth sciences and geology</subject> + </subjects> + <resourceType resourceTypeGeneral="Text">Article</resourceType> + <formats> + <format>PDF</format> + </formats> + <descriptions> + <description descriptionType="Other">MEYNIANA; 57; 101-115; ISSN + 0076-7689</description> + </descriptions> </resource> \ No newline at end of file Modified: trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java 2012-03-07 05:56:29 UTC (rev 99) +++ trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java 2012-03-08 04:39:03 UTC (rev 100) @@ -18,19 +18,33 @@ public class DoiDTO implements Serializable { - /** - * - */ + /** Generated serial version **/ private static final long serialVersionUID = 5970619710155407372L; + /** A persistent identifier that identifies a resource. **/ + private String identifier; + + /** Title of the Digital Object **/ private String title; - private String shortName; - private String creator; - private List<String> contributors; + /** + * The main researchers involved working on the data, or the authors of the publication in priority order. May be a + * corporate/institutional or personal name. + **/ + private List<String> creators; + + /** Publication Year **/ private String publicationYear; + /** + * A holder of the data (including archives as appropriate) or institution which submitted the work. Any others may + * be listed as contributors. This property will be used to formulate the citation, so consider the prominence of + * the role. + **/ private String publisher; + + /** Subject **/ private String subject; - private String keywords; + + /** Primary language of the resource. Allowed values from: ISO 639-2/B, ISO 639-3 **/ private String language; /** @@ -49,54 +63,23 @@ { this.title = title; } + + /** - * @return the shortName + * @return the creators */ - public String getShortName() + public List<String> getCreators() { - return shortName; + return creators; } - + /** - * @param shortName - * the shortName to set + * @param creators the creators to set */ - public void setShortName(String shortName) + public void setCreators(List<String> creators) { - this.shortName = shortName; + this.creators = creators; } - /** - * @return the creator - */ - public String getCreator() - { - return creator; - } - - /** - * @param creator - * the creator to set - */ - public void setCreator(String creator) - { - this.creator = creator; - } - /** - * @return the contributors - */ - public List<String> getContributors() - { - return contributors; - } - - /** - * @param contributors - * the contributors to set - */ - public void setContributors(List<String> contributors) - { - this.contributors = contributors; - } /** * @return the subject @@ -114,23 +97,8 @@ { this.subject = subject; } - /** - * @return the keywords - */ - public String getKeywords() - { - return keywords; - } /** - * @param keywords - * the keywords to set - */ - public void setKeywords(String keywords) - { - this.keywords = keywords; - } - /** * @return the language */ public String getLanguage() @@ -181,4 +149,20 @@ this.publisher = publisher; } + /** + * @return the identifier + */ + public String getIdentifier() + { + return identifier; + } + + /** + * @param identifier the identifier to set + */ + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } + } Modified: trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-03-07 05:56:29 UTC (rev 99) +++ trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-03-08 04:39:03 UTC (rev 100) @@ -69,8 +69,8 @@ * * @param document * the existing XML document to update - * @param nameSpaces - * a Hashtable of XML Namespaces associated with the element + * @param nameSpace + * Namespace associated with the element * @param element * the element XPath that needs to be updated * @param value @@ -88,6 +88,46 @@ } /** + * Update an existing XML element within an XML document using XPath. + * + * @param document + * the existing XML document to update + * @param nameSpace + * Namespace associated with the element + * @param element + * the element XPath that needs to be updated + * @param value + * the new value of the element + * @throws JDOMException + * when invalid XML parsing/access occurs + */ + public static void updateElementValues(Document document, String nameSpace, String element, List<String> values) + throws JDOMException + { + + XPath xPath = XPath.newInstance(element); + xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI()); + Element baseElement = (Element) xPath.selectSingleNode(document); + baseElement.setText(stripNonValidXMLCharacters(values.get(0))); + + for (int counter = 1; counter < values.size(); counter++) + { + + // Clone the parent of the base element + Element parent = baseElement.getParentElement(); + Element clonedParentElement = (Element) parent.clone(); + Element childElement = (Element) clonedParentElement.getChildren().get(0); + childElement.setText(stripNonValidXMLCharacters(values.get(counter))); + + clonedParentElement.detach(); + Element grandParent = parent.getParentElement(); + grandParent.addContent(1, clonedParentElement); + } + + + } + + /** * Add list of children nodes to a parent node * * @param document Modified: trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java 2012-03-07 05:56:29 UTC (rev 99) +++ trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java 2012-03-08 04:39:03 UTC (rev 100) @@ -4,6 +4,8 @@ package au.csiro.doiclient.utils; import java.io.IOException; +import java.util.Iterator; +import java.util.List; import org.jdom.Document; import org.jdom.JDOMException; @@ -62,8 +64,10 @@ { Document document = ConverterUtils.getXmlDocument("DoiMetadataTemplate.xml"); - ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.CREATOR_NAME_XPATH, - doiDto.getCreator()); + // ConverterUtils.addElementValue(document, NAME_SPACE, CREATOR_NAME_XPATH, doiDto.getCreators().get(0)); + + ConverterUtils.updateElementValues(document, NAME_SPACE, CREATOR_NAME_XPATH, doiDto.getCreators()); + ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.TITLE_NAME_XPATH, doiDto.getTitle()); ConverterUtils.updateElementValue(document, NAME_SPACE, DoiMetaDataGenerator.PUBLISHER_NAME_XPATH, @@ -73,6 +77,29 @@ return ConverterUtils.outputTheXml(document); } + + /** + * + * @param doiDto + * @param document + * @throws JDOMException + */ + private static void updateCreatorNames(DoiDTO doiDto, Document document) throws JDOMException + { + + List<String> creators = doiDto.getCreators(); + int counter = 1; + for (Iterator<String> iterator = creators.iterator(); iterator.hasNext();) + { + String creatorName = (String) iterator.next(); + String xPath = DoiMetaDataGenerator.CREATOR_NAME_XPATH + "[" + counter + "]"; + ConverterUtils.updateElementValue(document, NAME_SPACE, xPath, creatorName); + + counter++; + + } + + } Deleted: trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 05:56:29 UTC (rev 99) +++ trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-08 04:39:03 UTC (rev 100) @@ -1,236 +0,0 @@ -package au.csiro.doiclient; - -import junit.framework.TestCase; -import au.csiro.doiclient.business.DoiDTO; - - -/** - * Test case for the ANDsDOIClient - * - * Copyright 2010, CSIRO Australia All rights reserved. - * - * @author John Page on 6/03/2012 - * @version $Revision: $ $Date: $ - */ - -public class TestAndsDoiClient extends TestCase -{ - - /** CSIRO requester info: values required for connecting to DOI Service */ - private static final String ANDS_HOST = "services.ands.org.au"; - private static final String ANDS_PATH = "/home/dois"; - private static final String APPID = "c3fa1cb72cce27b7b0b02c9377fb9a6910294e35"; - private static final String IDENTIFIER = "wron-repository-unit-tests"; - private static final String AUTHDOMAIN = "csiro.au"; - - /** DTO holding meta data information for the mint DOI call **/ - private DoiDTO doiDTO; - - - /** - * Test connection can be established with valid appId - * - * @throws Exception - */ - public final void testValidAppId() throws Exception - { - AndsDoiClient client = createDummyDoiClient(); - DoiDTO doiDTO = client.getRequestorIdentity().getDoiDTO(); - - assertNotNull(doiDTO); - - assertEquals("Smith,John", doiDTO.getCreator()); - - AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); - - assertNotNull(mintDOIResponse); - - // should succeed - assertEquals(200, mintDOIResponse.getResponseCode()); - } - - - /** - * Test connection cannot be established with invalid appId - * - * @throws Exception - */ - public final void testInvalidAppId() throws Exception - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - AndsDoiClient client = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID + "123", IDENTIFIER, - AUTHDOMAIN, doiDTO); - - AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); - - // should fail - assertEquals(415, mintDOIResponse.getResponseCode()); - assertEquals("Authentication Error", mintDOIResponse.getResponseMessage()); - - } - - /** - * Test minting a DOI - * - * @throws Exception - */ - public final void testMintDOI() throws Exception - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - AndsDoiClient client = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - - AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); - - assertEquals(200, mintDOIResponse.getResponseCode()); - - assertNotNull(mintDOIResponse.getDoi()); - - // ANDs DOI Test pre-fix will start with 10.5072 - assertTrue(mintDOIResponse.getDoi().startsWith("10.5072")); - System.out.println("testMintDOI: DOI response is :->" + mintDOIResponse.getResponseBody()); - - } - - /** - * Test minting a DOI - * - * @throws Exception - */ - public final void testDOIRequestMetaData() throws Exception - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - AndsDoiClient client = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - - AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); - - assertEquals(200, mintDOIResponse.getResponseCode()); - - assertNotNull(mintDOIResponse.getDoi()); - - // ANDs DOI Test pre-fix will start with 10.5072 - assertTrue(mintDOIResponse.getDoi().startsWith("10.5072")); - - AndsDoiResponse metadaDataDOIResponse = client.requestMetaDatatDOI(mintDOIResponse.getDoi()); - - System.out.println("testDOIRequestMetaData: DOI response is :->" + metadaDataDOIResponse.getResponseBody()); - - - } - - /** - * Test updating the URL associated with a DOI - * - * @throws Exception - */ - public final void XXtestUpdateDOIUrl() throws Exception - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - AndsDoiClient client = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - - AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); - - System.out.println("Minted DOI is :->" + mintDOIResponse.getDoi()); - - AndsDoiResponse updateDOIResponse = client.updateDOI(mintDOIResponse.getDoi(), - "http://www.csiro.au/en/Portals/Events.aspx", false); - - System.out.println("testUpdateDOIUrl: DOI response is :->" + updateDOIResponse.getResponseBody()); - - assertEquals(200, updateDOIResponse.getResponseCode()); - - assertEquals(mintDOIResponse.getDoi(), updateDOIResponse.getDoi()); - assertNotNull(updateDOIResponse.getDoi()); - - } - - /** - * Test updating the URL associated with a DOI - * - * @throws Exception - */ - public final void XXtestUpdateDOIMetaData() throws Exception - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - AndsDoiClient mintClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - - AndsDoiResponse mintDOIResponse = mintClient.mintDOI("http://csiro.au"); - - System.out.println("Minted DOI is :->" + mintDOIResponse.getDoi()); - - doiDTO.setCreator("Ponting,Ricky"); - - AndsDoiClient updateClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - AndsDoiResponse updateDOIResponse = updateClient.updateDOI(mintDOIResponse.getDoi(), null, true); - - System.out.println("testUpdateDOIMetaData: Updated DOI response is :->" + updateDOIResponse.getResponseBody()); - - assertEquals(200, updateDOIResponse.getResponseCode()); - - assertEquals(mintDOIResponse.getDoi(), updateDOIResponse.getDoi()); - assertNotNull(updateDOIResponse.getDoi()); - - } - - - /** - * Test updating the URL associated with a DOI - * - * @throws Exception - */ - public final void XXtestUpdateDOIUrlAndMetaData() throws Exception - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - AndsDoiClient mintClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - - AndsDoiResponse mintDOIResponse = mintClient.mintDOI("http://csiro.au"); - - System.out.println("Minted DOI is :->" + mintDOIResponse.getDoi()); - - // Make a change in the DTO that will get translated into the meta-data - doiDTO.setCreator("Clarke,Michael"); - AndsDoiClient updateClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - AndsDoiResponse updateDOIResponse = updateClient.updateDOI(mintDOIResponse.getDoi(), - "http://www.csiro.au/en/Portals/Education.aspx", true); - - System.out.println("testUpdateDOIMetaData: Updated DOI response is :->" + updateDOIResponse.getResponseBody()); - - assertEquals(200, updateDOIResponse.getResponseCode()); - - assertEquals(mintDOIResponse.getDoi(), updateDOIResponse.getDoi()); - assertNotNull(updateDOIResponse.getDoi()); - - } - - /** - * Create a ANDs Digital Identifier Client using CSIRO requester info - * - * @return a valid ANDDigital IdentiferIdentifierClient - */ - private AndsDoiClient createDummyDoiClient() - { - doiDTO = new DoiDTO(); - populateDummydoiDTO(doiDTO); - return new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); - } - - /** - * Creates a DTO with the DOI Meta Data information. - * - * @param doiDTO - */ - private void populateDummydoiDTO(DoiDTO doiDTO) - { - doiDTO.setCreator("Smith,John"); - doiDTO.setTitle("A conceptual sediment budget for the Vietnam Shelf"); - doiDTO.setKeywords("minerals"); - doiDTO.setPublicationYear("2001"); - doiDTO.setPublisher("CSIRO"); - - } -} Modified: trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2012-03-07 05:56:29 UTC (rev 99) +++ trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java 2012-03-08 04:39:03 UTC (rev 100) @@ -1,5 +1,14 @@ package au.csiro.doiclient.utils; + +import java.util.ArrayList; +import java.util.List; + import junit.framework.TestCase; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.xpath.XPath; + import au.csiro.doiclient.business.DoiDTO; /** @@ -14,8 +23,16 @@ public class TestDoiMetaDataGenerator extends TestCase { + /** + * DTO with values to be set up in the metadata xml. + */ private DoiDTO doiDTO; + /** + * Constant giving the xpath of the creator name + */ + private static final String CREATOR_NAME_XPATH = "/xsi:resource/xsi:creators/xsi:creator/xsi:creatorName"; + /* (non-Javadoc) * @see junit.framework.TestCase#setUp() */ @@ -27,11 +44,24 @@ } + /** + * Populates a DTO with values that will passed on the DOIMetaDataTemplate. + * + * @param doiDTO + * DTO with the values for the DOIMetaDataTemplate. + */ private void populateDummydoiDTO(DoiDTO doiDTO) { - doiDTO.setCreator("Smith, John"); + List<String> creators = new ArrayList<String>(); + creators.add(0, "Smith,John"); + creators.add(1, "Green,Matt"); + creators.add(2, "Chapman,Alison"); + creators.add(3, "Gandhi,Rahul"); + creators.add(4, "Dravid,Rahul"); + creators.add(5, "Phillips,David"); + + doiDTO.setCreators(creators); doiDTO.setTitle("A conceptual sediment budget for the Vietnam Shelf"); - doiDTO.setKeywords("minerals"); doiDTO.setPublicationYear("2001"); doiDTO.setPublisher("CSIRO"); @@ -47,7 +77,7 @@ /** - * Test generation of DoiMetaData XML + * Tests the generation of DoiMetaData XML for multiple creatorNames. * * @throws Exception */ @@ -56,5 +86,16 @@ String doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(doiDTO); assertNotNull(doiMetaDataXML); + Document document = ConverterUtils.xmlToDoc(doiMetaDataXML); + XPath xPath = XPath.newInstance(CREATOR_NAME_XPATH); + xPath.addNamespace("xsi", document.getRootElement().getNamespaceURI()); + List nodes = xPath.selectNodes(document); + + assertEquals(6, nodes.size()); + + assertEquals("creatorName", ((Element) nodes.get(0)).getName()); + assertEquals("Phillips,David", ((Element) nodes.get(0)).getText()); } + + } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-07 05:56:36
|
Revision: 99 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=99&view=rev Author: johnpage-09 Date: 2012-03-07 05:56:29 +0000 (Wed, 07 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality to request DOI meta-data from ANDs. https://jira.csiro.au/browse/DMSTECH-2890 Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/main/resources/ands-doi-client.properties trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 05:05:38 UTC (rev 98) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 05:56:29 UTC (rev 99) @@ -95,10 +95,9 @@ private static String updateMethodName; /** - * The name of the method (RESTful web service) to call when associating a new value into the index of an existing - * handle. + * The name of the method (RESTful web service) to call when requesting the metadata associated with a DOI. */ - private static String addValueByIndexMethodName; + private static String doiMetadataRequest; /** * The name of the method (RESTful web service) to call when modifying an existing handle. @@ -195,7 +194,7 @@ applicationName = props.getProperty("application.name"); mintMethodName = props.getProperty("method.mint"); updateMethodName = props.getProperty("method.update"); - addValueByIndexMethodName = props.getProperty("method.addValueByIndex"); + doiMetadataRequest = props.getProperty("method.doi"); modifyValueByIndexMethodName = props.getProperty("method.modifyValueByIndex"); deleteValueByIndexMethodName = props.getProperty("method.deleteValueByIndex"); listHandlesMethodName = props.getProperty("method.listHandles"); @@ -331,7 +330,36 @@ return executeMethod(queryString, updateMethodName, updateMetdaData, url); } + /** + * Responsible for requesting the meta-data for a given DOI. + * <p> + * + * @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 requestMetaDatatDOI(String doi) throws HttpException, IOException + { + this.validateState(); + + // DOI should not be null + this.validateParameters(doiMetadataRequest, doi, null); + + String queryString = MessageFormat.format("DOI={0}", new Object[] { doi }); + + return executeMethod(queryString, doiMetadataRequest, false, null); + + } + + /** * Checks that this class is in a valid state to call the ANDS DOI service. * * @throws IllegalStateException @@ -388,7 +416,7 @@ new Object[] { values[1] })); } - if (values[0].equals("update") && StringUtils.isEmpty(values[1])) + if (((values[0].equals("update")) || (values[0].equals("doi"))) && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( "The method updateDOI() can only be called if the arguement is non-empty:values={1}\n", @@ -419,14 +447,15 @@ { String metaDataXML = null; + String requestType = getRequestType(methodName); LOG.debug("ExecuteMethod : Query String : ->" + queryString); LOG.debug("ExecuteMethod : Method Name : ->" + methodName); HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, ""); - url.setPath(url.getPath() + "/" + getMethodName(methodName)); + // Meta Data will need to be generated only if it is a call to MINT DOIs. // It becomes optional for update calls. if (updateMetdaData) @@ -435,8 +464,22 @@ } LOG.debug("Metadata XML generated :->" + metaDataXML); + return doiRequest(url.toString(), metaDataXML, updateURL, requestType); + } - return postDOIRequest(url.toString(), metaDataXML, updateURL); + /** + * Returns the Request Type : GET or POST + * + * @param methodName + * call that is to be made to the DOI service. + * @return requestType GET or POST. + */ + private String getRequestType(String methodName) + { + if ((methodName.equals("mint")) || (methodName.equals("update"))) + return "POST"; + else + return "GET"; } /** @@ -457,6 +500,10 @@ { return "doi_update.php"; } + else if (operation.equals("doi")) + { + return "doi_xml.php"; + } return null; } @@ -473,10 +520,13 @@ * @param metadata * an XML fragment that details the meta data of the document for which the DOI is queried. * @param updateURL + * URL for the DOI that needs to be updated. + * @param requestType + * POST or GET * @return * @throws IOException */ - private static AndsDoiResponse postDOIRequest(String serviceUrl, String metadata, String updateURL) + private static AndsDoiResponse doiRequest(String serviceUrl, String metadata, String updateURL, String requestType) throws IOException { LOG.debug("Post method URL: " + serviceUrl); @@ -494,7 +544,7 @@ } // Send data - conn.setRequestMethod("POST"); + conn.setRequestMethod(requestType); conn.setDoOutput(true); conn.setDoInput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); @@ -694,4 +744,5 @@ } + } Modified: trunk/src/main/resources/ands-doi-client.properties =================================================================== --- trunk/src/main/resources/ands-doi-client.properties 2012-03-07 05:05:38 UTC (rev 98) +++ trunk/src/main/resources/ands-doi-client.properties 2012-03-07 05:56:29 UTC (rev 99) @@ -18,10 +18,10 @@ application.name=${pom.name} application.version=${pom.version} -# RESTful ANDS Digital Idenfier Service web service URIs +# RESTful ANDS Digital Identifier Service web service URIs method.mint=mint method.update=update -method.addValueByIndex=addValueByIndex +method.doi=doi method.modifyValueByIndex=modifyValueByIndex method.deleteValueByIndex=deleteValueByIndex method.listHandles=listHandles Modified: trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 05:05:38 UTC (rev 98) +++ trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 05:56:29 UTC (rev 99) @@ -93,7 +93,33 @@ } + /** + * Test minting a DOI + * + * @throws Exception + */ + public final void testDOIRequestMetaData() throws Exception + { + doiDTO = new DoiDTO(); + populateDummydoiDTO(doiDTO); + AndsDoiClient client = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); + AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); + + assertEquals(200, mintDOIResponse.getResponseCode()); + + assertNotNull(mintDOIResponse.getDoi()); + + // ANDs DOI Test pre-fix will start with 10.5072 + assertTrue(mintDOIResponse.getDoi().startsWith("10.5072")); + + AndsDoiResponse metadaDataDOIResponse = client.requestMetaDatatDOI(mintDOIResponse.getDoi()); + + System.out.println("testDOIRequestMetaData: DOI response is :->" + metadaDataDOIResponse.getResponseBody()); + + + } + /** * Test updating the URL associated with a DOI * This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-07 05:05:45
|
Revision: 98 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=98&view=rev Author: johnpage-09 Date: 2012-03-07 05:05:38 +0000 (Wed, 07 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating a DOI. https://jira.csiro.au/browse/DMSTECH-2890 Modified Paths: -------------- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 03:21:57 UTC (rev 97) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 05:05:38 UTC (rev 98) @@ -289,7 +289,8 @@ String queryString = MessageFormat.format("app_id={0}&url={1}", new Object[] { getRequestorIdentity().getAppId(), url }); - return executeMethod(queryString, mintMethodName, true); + + return executeMethod(queryString, mintMethodName, true, null); } @@ -323,11 +324,11 @@ // DOI should not be null this.validateParameters(updateMethodName, doi, url); - String queryString = MessageFormat.format("app_id={0}&url={1}&DOI={2}", new Object[] { - getRequestorIdentity().getAppId(), url, doi }); + String queryString = MessageFormat.format("app_id={0}&DOI={1}", new Object[] { + getRequestorIdentity().getAppId(), doi }); - return executeMethod(queryString, updateMethodName, updateMetdaData); + return executeMethod(queryString, updateMethodName, updateMetdaData, url); } /** @@ -405,14 +406,16 @@ * the method to call. * @param updateMetdaData * flag indicating if the meta data needs to be generated. + * @param updateURL + * associated with a DOI that needs to be updated. * @return a formatted XML response. * @throws IOException * thrown when attempting to read response. * @throws HttpException * thrown when attempting to execute method call. */ - private AndsDoiResponse executeMethod(String queryString, String methodName, boolean updateMetdaData) - throws HttpException, IOException + private AndsDoiResponse executeMethod(String queryString, String methodName, boolean updateMetdaData, + String updateURL) throws HttpException, IOException { String metaDataXML = null; @@ -422,40 +425,40 @@ HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, ""); - url.setPath(url.getPath() + "/" + getPhPMethod(methodName)); + url.setPath(url.getPath() + "/" + getMethodName(methodName)); // Meta Data will need to be generated only if it is a call to MINT DOIs. - // It becomes optional for Update calls. + // It becomes optional for update calls. if (updateMetdaData) { metaDataXML = this.getRequestorIdentity().toXML(methodName); } - LOG.debug("Metadata XML generated " + metaDataXML); + LOG.debug("Metadata XML generated :->" + metaDataXML); - return postDOIRequest(url.toString(), metaDataXML); + return postDOIRequest(url.toString(), metaDataXML, updateURL); } /** * - * Returns the php method name that needs to be invoked on the DOI service to complete the call. + * Returns the method name that needs to be invoked on the DOI service to complete the call. * - * @param methodName + * @param operation * to be called - * @return php method name + * @return method name */ - private String getPhPMethod(String methodName) + private String getMethodName(String operation) { - if (methodName.equals("mint")) + if (operation.equals("mint")) { return "doi_mint.php"; } - else if (methodName.equals("update")) + else if (operation.equals("update")) { return "doi_update.php"; } - return ""; + return null; } @@ -469,14 +472,14 @@ * the URI of the RESTful ANDS Digital Object Identifier web service. * @param metadata * an XML fragment that details the meta data of the document for which the DOI is queried. + * @param updateURL * @return * @throws IOException */ - private static AndsDoiResponse postDOIRequest(String serviceUrl, String metadata) throws IOException + private static AndsDoiResponse postDOIRequest(String serviceUrl, String metadata, String updateURL) + throws IOException { LOG.debug("Post method URL: " + serviceUrl); - - LOG.debug("Metadata XML: " + metadata); AndsDoiResponse doiResponse = null; String data = null; @@ -487,22 +490,29 @@ { if (metadata != null) { - // Construct data - data = "xml=" + URLEncoder.encode(metadata, "UTF-8"); + } // Send data - conn.setRequestMethod("POST"); conn.setDoOutput(true); conn.setDoInput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); - if (data != null) + // Construct data + + if (metadata != null) { + data = "xml=" + URLEncoder.encode(metadata, "UTF-8"); wr.write(data); } + if (updateURL != null) + { + data = "url=" + updateURL; + wr.write(data); + } + wr.flush(); doiResponse = new AndsDoiResponse(); Modified: trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 03:21:57 UTC (rev 97) +++ trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 05:05:38 UTC (rev 98) @@ -87,8 +87,10 @@ assertNotNull(mintDOIResponse.getDoi()); + // ANDs DOI Test pre-fix will start with 10.5072 + assertTrue(mintDOIResponse.getDoi().startsWith("10.5072")); + System.out.println("testMintDOI: DOI response is :->" + mintDOIResponse.getResponseBody()); - } @@ -97,7 +99,7 @@ * * @throws Exception */ - public final void XXtestUpdateDOIURL() throws Exception + public final void XXtestUpdateDOIUrl() throws Exception { doiDTO = new DoiDTO(); populateDummydoiDTO(doiDTO); @@ -110,7 +112,7 @@ AndsDoiResponse updateDOIResponse = client.updateDOI(mintDOIResponse.getDoi(), "http://www.csiro.au/en/Portals/Events.aspx", false); - System.out.println("Updated DOI response is :->" + updateDOIResponse.getResponseBody()); + System.out.println("testUpdateDOIUrl: DOI response is :->" + updateDOIResponse.getResponseBody()); assertEquals(200, updateDOIResponse.getResponseCode()); @@ -119,8 +121,67 @@ } + /** + * Test updating the URL associated with a DOI + * + * @throws Exception + */ + public final void XXtestUpdateDOIMetaData() throws Exception + { + doiDTO = new DoiDTO(); + populateDummydoiDTO(doiDTO); + AndsDoiClient mintClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); + + AndsDoiResponse mintDOIResponse = mintClient.mintDOI("http://csiro.au"); + + System.out.println("Minted DOI is :->" + mintDOIResponse.getDoi()); + + doiDTO.setCreator("Ponting,Ricky"); + + AndsDoiClient updateClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); + AndsDoiResponse updateDOIResponse = updateClient.updateDOI(mintDOIResponse.getDoi(), null, true); + + System.out.println("testUpdateDOIMetaData: Updated DOI response is :->" + updateDOIResponse.getResponseBody()); + + assertEquals(200, updateDOIResponse.getResponseCode()); + + assertEquals(mintDOIResponse.getDoi(), updateDOIResponse.getDoi()); + assertNotNull(updateDOIResponse.getDoi()); + + } + /** + * Test updating the URL associated with a DOI + * + * @throws Exception + */ + public final void XXtestUpdateDOIUrlAndMetaData() throws Exception + { + doiDTO = new DoiDTO(); + populateDummydoiDTO(doiDTO); + AndsDoiClient mintClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); + + AndsDoiResponse mintDOIResponse = mintClient.mintDOI("http://csiro.au"); + + System.out.println("Minted DOI is :->" + mintDOIResponse.getDoi()); + + // Make a change in the DTO that will get translated into the meta-data + doiDTO.setCreator("Clarke,Michael"); + AndsDoiClient updateClient = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); + AndsDoiResponse updateDOIResponse = updateClient.updateDOI(mintDOIResponse.getDoi(), + "http://www.csiro.au/en/Portals/Education.aspx", true); + + System.out.println("testUpdateDOIMetaData: Updated DOI response is :->" + updateDOIResponse.getResponseBody()); + + assertEquals(200, updateDOIResponse.getResponseCode()); + + assertEquals(mintDOIResponse.getDoi(), updateDOIResponse.getDoi()); + assertNotNull(updateDOIResponse.getDoi()); + + } + + /** * Create a ANDs Digital Identifier Client using CSIRO requester info * * @return a valid ANDDigital IdentiferIdentifierClient This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-07 03:22:04
|
Revision: 97 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=97&view=rev Author: johnpage-09 Date: 2012-03-07 03:21:57 +0000 (Wed, 07 Mar 2012) Log Message: ----------- DMSTECH-2890: Functionality for updating a previously minted DOI. https://jira.csiro.au/browse/DMSTECH-2890 Modified Paths: -------------- trunk/pom.xml trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java trunk/src/main/resources/ands-doi-client.properties trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2012-03-07 00:48:43 UTC (rev 96) +++ trunk/pom.xml 2012-03-07 03:21:57 UTC (rev 97) @@ -74,6 +74,8 @@ <id>release-sonatype</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <!-- sonatype.org repository for staging releases --> </repository> + + <snapshotRepository> <id>snapshots</id> <url>http://junk-yf:8085/nexus/content/repositories/snapshots</url> @@ -358,33 +360,58 @@ --> <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <scope>test</scope> - </dependency> - <dependency> - <groupId>commons-httpclient</groupId> - <artifactId>commons-httpclient</artifactId> - <version>3.1</version> - </dependency> - <dependency> - <groupId>log4j</groupId> - <artifactId>log4j</artifactId> - <version>1.2.15</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - <version>2.4</version> - </dependency> - <dependency> - <groupId>org.jdom</groupId> - <artifactId>jdom</artifactId> - <version>1.1.2</version> - </dependency> - </dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>commons-httpclient</groupId> + <artifactId>commons-httpclient</artifactId> + <version>3.1</version> + </dependency> + <dependency> + <groupId>log4j</groupId> + <artifactId>log4j</artifactId> + <version>1.2.15</version> + <exclusions> + <exclusion> + <groupId>com.sun.jmx</groupId> + <artifactId>jmxri</artifactId> + </exclusion> + <exclusion> + <groupId>com.sun.jdmk</groupId> + <artifactId>jmxtools</artifactId> + </exclusion> + <exclusion> + <groupId>javax.jms</groupId> + <artifactId>jms</artifactId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>commons-lang</groupId> + <artifactId>commons-lang</artifactId> + <version>2.4</version> + </dependency> + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + <version>1.1.2</version> + <!-- http://jira.codehaus.org/browse/JAXEN-217 --> + <exclusions> + <exclusion> + <groupId>maven-plugins</groupId> + <artifactId>maven-cobertura-plugin</artifactId> + </exclusion> + <exclusion> + <groupId>maven-plugins</groupId> + <artifactId>maven-findbugs-plugin</artifactId> + </exclusion> + </exclusions> + </dependency> +</dependencies> <reporting> <plugins> <plugin> Modified: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 00:48:43 UTC (rev 96) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 03:21:57 UTC (rev 97) @@ -18,13 +18,8 @@ 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.HttpStatus; import org.apache.commons.httpclient.HttpsURL; -import org.apache.commons.httpclient.methods.PostMethod; -import org.apache.commons.httpclient.methods.RequestEntity; -import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.w3c.dom.Document; @@ -90,14 +85,14 @@ private static String applicationName; /** - * The name of the method (RESTful web service) to call when minting a new handle. + * The name of the method (RESTful web service) to call when minting a DOI. */ private static String mintMethodName; /** - * The name of the method (RESTful web service) to call when associating a new value with an existing handle. + * The name of the method (RESTful web service) to call when updating a DOI. */ - private static String addValueMethodName; + private static String updateMethodName; /** * The name of the method (RESTful web service) to call when associating a new value into the index of an existing @@ -199,7 +194,7 @@ props.load(is); applicationName = props.getProperty("application.name"); mintMethodName = props.getProperty("method.mint"); - addValueMethodName = props.getProperty("method.addValue"); + updateMethodName = props.getProperty("method.update"); addValueByIndexMethodName = props.getProperty("method.addValueByIndex"); modifyValueByIndexMethodName = props.getProperty("method.modifyValueByIndex"); deleteValueByIndexMethodName = props.getProperty("method.deleteValueByIndex"); @@ -272,7 +267,7 @@ * owner is created from the {@link AndsDoiIdentity#getIdentifier()} and {@link AndsDoiIdentity#getIdentifier()} * values. * - * @param value + * @param url * 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 @@ -284,20 +279,57 @@ * @throws HttpException * thrown when attempting to execute method call. */ - public AndsDoiResponse mintDOI(String value) throws IllegalStateException, IllegalArgumentException, + public AndsDoiResponse mintDOI(String url) throws IllegalStateException, IllegalArgumentException, HttpException, IOException { this.validateState(); - this.validateMintHandleArguments(value); + // URL for which the DOI is to be minted should not be null. + this.validateParameters(mintMethodName, url); String queryString = MessageFormat.format("app_id={0}&url={1}", new Object[] { - getRequestorIdentity().getAppId(), value }); - return executeMethod(queryString, mintMethodName); + getRequestorIdentity().getAppId(), url }); + return executeMethod(queryString, mintMethodName, true); } + /** + * 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 url + * the url pointing to the landing page of the data collection. + * @param updateMetdaData + * true if metadata update is required, false if not. + * @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 url, boolean updateMetdaData) throws HttpException, IOException + { + this.validateState(); + + // DOI should not be null + this.validateParameters(updateMethodName, doi, url); + + String queryString = MessageFormat.format("app_id={0}&url={1}&DOI={2}", new Object[] { + getRequestorIdentity().getAppId(), url, doi }); + + + return executeMethod(queryString, updateMethodName, updateMetdaData); + } + /** * Checks that this class is in a valid state to call the ANDS DOI service. * @@ -338,20 +370,30 @@ * {@link #mintHandleByIndex(HandleType, int, String)} methods. * * @param value - * the url of the data collection for which a DOi is required. + * the url of the data collection for which a DOI is required. + * @param methodName + * the method that is being called on the DOI service * @throws IllegalStateException * thrown if the arguments provided to {@link #mintDOI(HandleType, String)} or to * {@link #mintHandleByIndex(HandleType, int, String)} are not valid. */ - private void validateMintHandleArguments(String value) throws IllegalArgumentException + private void validateParameters(String... values) throws IllegalArgumentException { - if (StringUtils.isEmpty(value)) + if (values[0].equals("mint") && StringUtils.isEmpty(values[1])) { throw new IllegalArgumentException(MessageFormat.format( - "The method mintHandle() can only be called if both arguments are empty " - + "or both arguments are not empty:value={1}\n", new Object[] { value })); + "The method mintDOI() can only be called if the arguement is non-empty:values={1}\n", + new Object[] { values[1] })); } + + if (values[0].equals("update") && StringUtils.isEmpty(values[1])) + { + throw new IllegalArgumentException(MessageFormat.format( + "The method updateDOI() can only be called if the arguement is non-empty:values={1}\n", + new Object[] { values[1] })); + } + } /** @@ -361,15 +403,20 @@ * the query string to provide the POST call. * @param methodName * the method to call. + * @param updateMetdaData + * flag indicating if the meta data needs to be generated. * @return a formatted XML response. * @throws IOException * thrown when attempting to read response. * @throws HttpException * thrown when attempting to execute method call. */ - private AndsDoiResponse executeMethod(String queryString, String methodName) throws HttpException, IOException + private AndsDoiResponse executeMethod(String queryString, String methodName, boolean updateMetdaData) + throws HttpException, IOException { + String metaDataXML = null; + LOG.debug("ExecuteMethod : Query String : ->" + queryString); LOG.debug("ExecuteMethod : Method Name : ->" + methodName); @@ -377,7 +424,12 @@ url.setPath(url.getPath() + "/" + getPhPMethod(methodName)); - String metaDataXML = this.getRequestorIdentity().toXML(methodName); + // Meta Data will need to be generated only if it is a call to MINT DOIs. + // It becomes optional for Update calls. + if (updateMetdaData) + { + metaDataXML = this.getRequestorIdentity().toXML(methodName); + } LOG.debug("Metadata XML generated " + metaDataXML); @@ -386,6 +438,8 @@ /** * + * Returns the php method name that needs to be invoked on the DOI service to complete the call. + * * @param methodName * to be called * @return php method name @@ -396,78 +450,16 @@ { return "doi_mint.php"; } + else if (methodName.equals("update")) + { + return "doi_update.php"; + } return ""; } - /** - * 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 - * fragment that identifies the caller. - * - * @param postMethodURL - * the URI of the RESTful ANDS Digital Object Identifier web service. - * @param metaDataXML - * an XML fragment that details the meta data of the document for which the DOI is queried. - * @return a formatted XML response. - * @throws IOException - * thrown when attempting to read response. - * @throws HttpException - * thrown when attempting to execute method call. - */ - private String executePostMethod(String postMethodURL, String metaDataXML) throws HttpException, IOException - { - LOG.debug("Post method URL: " + postMethodURL); - LOG.debug("Metadata XML: " + metaDataXML); - HttpClient client = new HttpClient(); - client.getParams().setParameter("http.useragent", applicationName); - client.getParams().setParameter("Content-Type", "text/xml"); - client.getParams().setParameter("Content-Encoding", "UTF-8"); - PostMethod method = new PostMethod(postMethodURL); - - BufferedReader br = null; - StringBuffer strBuf = new StringBuffer(); - - try - { - RequestEntity entity = new StringRequestEntity(metaDataXML, "text/xml", "UTF-8"); - client.getParams().setParameter("Content-Length", entity.getContentLength()); - method.setRequestEntity(entity); - - int returnCode = client.executeMethod(method); - LOG.debug("HTTP return code from service " + returnCode); - - if (returnCode == HttpStatus.SC_NOT_IMPLEMENTED) - { - LOG.error("The post method is not implemented by this URI"); - // still consume the response body - method.getResponseBodyAsString(); - } - else - { - br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); - String readLine; - while (((readLine = br.readLine()) != null)) - { - LOG.debug(readLine); - strBuf.append(readLine); - } - } - } - finally - { - if (br != null) - { - br.close(); - } - method.releaseConnection(); - } - - return strBuf.toString(); - } - /** * 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 @@ -486,14 +478,18 @@ LOG.debug("Metadata XML: " + metadata); AndsDoiResponse doiResponse = null; + String data = null; StringBuffer outputBuffer; URL url = new URL(serviceUrl); HttpURLConnection conn = (HttpURLConnection) url.openConnection(); try { - // Construct data - String data = "xml=" + URLEncoder.encode(metadata, "UTF-8"); + if (metadata != null) + { + // Construct data + data = "xml=" + URLEncoder.encode(metadata, "UTF-8"); + } // Send data @@ -501,7 +497,12 @@ conn.setDoOutput(true); conn.setDoInput(true); OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); - wr.write(data); + + if (data != null) + { + wr.write(data); + } + wr.flush(); doiResponse = new AndsDoiResponse(); @@ -682,4 +683,5 @@ this.requestorIdentity = requestorIdentity; } + } Modified: trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-07 00:48:43 UTC (rev 96) +++ trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-07 03:21:57 UTC (rev 97) @@ -48,7 +48,7 @@ private static final Logger LOG = Logger.getLogger(AndsDoiIdentity.class.getName()); /** - * + * Default constructor */ public AndsDoiIdentity() { @@ -145,7 +145,7 @@ /** - * Formats the DOI metadata information into a XML format that the ANDS Digital Object Identifier service + * Formats the DOI meta-data information into a XML format that the ANDS Digital Object Identifier service * understands. * * @param methodName @@ -157,21 +157,18 @@ { String doiMetaDataXML = null; - if (methodName.equals("mint")) + try { - try - { - doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(getDoiDTO()); - } - catch (IOException e) - { - LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), e); - } - catch (JDOMException ex) - { - LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), ex); - } + doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(getDoiDTO()); } + catch (IOException e) + { + LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), e); + } + catch (JDOMException ex) + { + LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), ex); + } return doiMetaDataXML; Modified: trunk/src/main/resources/ands-doi-client.properties =================================================================== --- trunk/src/main/resources/ands-doi-client.properties 2012-03-07 00:48:43 UTC (rev 96) +++ trunk/src/main/resources/ands-doi-client.properties 2012-03-07 03:21:57 UTC (rev 97) @@ -18,9 +18,9 @@ application.name=${pom.name} application.version=${pom.version} -# RESTful ANDS Persistent Identifier web service URIs +# RESTful ANDS Digital Idenfier Service web service URIs method.mint=mint -method.addValue=addValue +method.update=update method.addValueByIndex=addValueByIndex method.modifyValueByIndex=modifyValueByIndex method.deleteValueByIndex=deleteValueByIndex Modified: trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java =================================================================== --- trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 00:48:43 UTC (rev 96) +++ trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java 2012-03-07 03:21:57 UTC (rev 97) @@ -26,25 +26,8 @@ /** DTO holding meta data information for the mint DOI call **/ private DoiDTO doiDTO; - /** - * - */ - protected void setUp() throws Exception - { - super.setUp(); - } - /** - * - */ - protected void tearDown() throws Exception - { - super.tearDown(); - } - - - /** * Test connection can be established with valid appId * * @throws Exception @@ -88,7 +71,7 @@ } /** - * Test connection cannot be established with invalid appId + * Test minting a DOI * * @throws Exception */ @@ -104,10 +87,38 @@ assertNotNull(mintDOIResponse.getDoi()); + + } + /** + * Test updating the URL associated with a DOI + * + * @throws Exception + */ + public final void XXtestUpdateDOIURL() throws Exception + { + doiDTO = new DoiDTO(); + populateDummydoiDTO(doiDTO); + AndsDoiClient client = new AndsDoiClient(ANDS_HOST, ANDS_PATH, APPID, IDENTIFIER, AUTHDOMAIN, doiDTO); + AndsDoiResponse mintDOIResponse = client.mintDOI("http://csiro.au"); + + System.out.println("Minted DOI is :->" + mintDOIResponse.getDoi()); + + AndsDoiResponse updateDOIResponse = client.updateDOI(mintDOIResponse.getDoi(), + "http://www.csiro.au/en/Portals/Events.aspx", false); + + System.out.println("Updated DOI response is :->" + updateDOIResponse.getResponseBody()); + + assertEquals(200, updateDOIResponse.getResponseCode()); + + assertEquals(mintDOIResponse.getDoi(), updateDOIResponse.getDoi()); + assertNotNull(updateDOIResponse.getDoi()); + + } + /** * Create a ANDs Digital Identifier Client using CSIRO requester info This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-07 00:48:49
|
Revision: 96 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=96&view=rev Author: johnpage-09 Date: 2012-03-07 00:48:43 +0000 (Wed, 07 Mar 2012) Log Message: ----------- DMSTECH-2822: Functionality for minting Digital Object Idenfiers from the ANDs DOI service. https://jira.csiro.au/browse/DMSTECH-2822 Removed Paths: ------------- trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java Deleted: trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java 2012-03-07 00:47:36 UTC (rev 95) +++ trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java 2012-03-07 00:48:43 UTC (rev 96) @@ -1,203 +0,0 @@ -package au.csiro.doiclient; - - -/********************************************************************** - Copyright 2011 The Australian National University - 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. - ***********************************************************************/ -import java.io.BufferedReader; -import java.io.FileInputStream; -import java.io.FileReader; -import java.io.InputStreamReader; -import java.io.OutputStreamWriter; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLEncoder; -import java.util.HashMap; -import java.util.Scanner; - -import org.xml.sax.ErrorHandler; -import org.xml.sax.SAXException; -import org.xml.sax.SAXParseException; - -class MockDOIMintClient -{ - - // Location of the DOI Service - private static final String DOIServicePoint = "http://services.ands.org.au/home/dois/"; - - // DOI Application ID (supplied by ANDS) - private static final String DOIApplicationID = "c3fa1cb72cce27b7b0b02c9377fb9a6910294e35-123"; - - // Suffices for certain services - private static final String DOIMintServiceSuffix = "doi_mint.php?app_id=<app_id>&url=<url>"; - private static final String DOIUpdateServiceSuffix = "doi_update.php?app_id=<app_id>&DOI=<doi_id>"; - private static final String DOIMetadataRequestServiceSuffix = "doi_xml.php?app_id=<app_id>&DOI=<doi_id>"; - - static String xml = "<resource xmlns=\"http://datacite.org/schema/kernel-2.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://datacite.org/schema/kernel-2.1 http://schema.datacite.org/meta/kernel-2.1/metadata.xsd\">" - + "<identifier identifierType=\"DOI\">10.1594/WDCC/CCSRNIES_SRES_B2</identifier>" - + "<creators>" - + "<creator>" - + "<creatorName>John, Smith</creatorName>" - + "</creator>" - + "</creators>" - + "<titles>" - + " <title>Test DOI service</title>" - + "<title titleType=\"Subtitle\">A survey</title>" - + "</titles>" - + "<publisher>CSIRO</publisher>" + "<publicationYear>2004</publicationYear>" + "</resource>"; - - public static void main(String[] args) throws Exception - { - - // Build up the URL for us to mint at - String url_of_data = "http://test.ands.org.au/robots.txt"; - String datacite_xml_fragment_file = "C:\\temp\\test_datacite_metadata.txt"; - String mint_service_url = DOIServicePoint + DOIMintServiceSuffix; - - // Replace the required fields - HashMap<String, String> url_replacement_values = new HashMap<String, String>(); - url_replacement_values.put("app_id", DOIApplicationID); - url_replacement_values.put("url", url_of_data); - - mint_service_url = replaceURLFields(mint_service_url, url_replacement_values); - - System.out.println("Read XML from " + datacite_xml_fragment_file); - System.out.println("Sending query data to" + mint_service_url); - System.out.println("Output:"); - - String response_string = postDOIRequest(mint_service_url, loadXMLFromFile(datacite_xml_fragment_file)); - - System.out.println(response_string); - - } - - private static String postDOIRequest(String serviceUrl, String contents) throws Exception - { - - URL url = new URL(serviceUrl); - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - try - { - // Construct data - String data = "xml=" + URLEncoder.encode(contents, "UTF-8"); - - // Send data - - conn.setRequestMethod("POST"); - conn.setDoOutput(true); - conn.setDoInput(true); - OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); - wr.write(data); - wr.flush(); - - System.out.println(conn.getResponseCode() + " - " + conn.getResponseMessage()); - - // Get the response - StringBuffer outputBuffer = new StringBuffer(); - BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); - String line; - while ((line = rd.readLine()) != null) - { - outputBuffer.append(line); - } - wr.close(); - rd.close(); - - return outputBuffer.toString(); - } - catch (Exception e) - { - // error occured - BufferedReader rde = new BufferedReader(new InputStreamReader(conn.getErrorStream())); - String line; - while ((line = rde.readLine()) != null) - { - System.out.println(line); - } - rde.close(); - } - finally - { - } - - return ""; - - } - - private static String loadXMLFromFile(String filename) throws Exception - { - - FileInputStream fis = new FileInputStream(filename); - InputStreamReader in = new InputStreamReader(fis, "UTF-8"); - Scanner s = null; - StringBuffer xml_buffer = new StringBuffer(); - try - { - s = new Scanner(new BufferedReader(new FileReader(filename))); - s.useDelimiter(System.getProperty("line.separator")); - while (s.hasNext()) - { - xml_buffer.append(s.next() + System.getProperty("line.separator")); - } - } - finally - { - if (s != null) - { - s.close(); - } - } - - return xml_buffer.toString(); - - // return xml; - } - - private static String replaceURLFields(String input_string, HashMap<String, String> replacements_map) - { - String return_url = input_string; - for (String key : replacements_map.keySet()) - { - return_url = return_url.replaceAll("\\<" + key + "\\>", replacements_map.get(key)); - } - - /* - * // sanity check if (return_url.matches(".*\\<.*\\>.*")) { // should throw an exception // Service Point URL - * contains fields which are still incomplete? } - */ - - return return_url; - - } - -} - -class SimpleErrorHandler implements ErrorHandler -{ - public void warning(SAXParseException e) throws SAXException - { - System.out.println(e.getMessage()); - } - - public void error(SAXParseException e) throws SAXException - { - System.out.println(e.getMessage()); - } - - public void fatalError(SAXParseException e) throws SAXException - { - System.out.println(e.getMessage()); - } -} - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-07 00:47:43
|
Revision: 95 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=95&view=rev Author: johnpage-09 Date: 2012-03-07 00:47:36 +0000 (Wed, 07 Mar 2012) Log Message: ----------- DMSTECH-2822: Functionality for minting Digital Object Idenfiers from the ANDs DOI service. https://jira.csiro.au/browse/DMSTECH-2822 Copyright information Added Paths: ----------- trunk/src/main/java/au/csiro/doiclient/utils/package.html Added: trunk/src/main/java/au/csiro/doiclient/utils/package.html =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/package.html (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/utils/package.html 2012-03-07 00:47:36 UTC (rev 95) @@ -0,0 +1,30 @@ +<!-- + + 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. + +--> + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<title>au.csiro.doiclient.utils package</title> +</head> +<body bgcolor="white"> + +Support classes for the ANDS DOI client library. + + +</body> +</html> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <joh...@us...> - 2012-03-07 00:26:55
|
Revision: 94 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=94&view=rev Author: johnpage-09 Date: 2012-03-07 00:26:47 +0000 (Wed, 07 Mar 2012) Log Message: ----------- DMSTECH-2822: Functionality for minting Digital Object Idenfiers from the ANDs DOI service. https://jira.csiro.au/browse/DMSTECH-2822 Modified Paths: -------------- trunk/pom.xml trunk/src/test/java/au/csiro/pidclient/TestAndsPidClient.java Added Paths: ----------- trunk/DoiMetadataTemplate.xml trunk/src/main/java/au/csiro/doiclient/ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java trunk/src/main/java/au/csiro/doiclient/business/ trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java trunk/src/main/java/au/csiro/doiclient/business/package.html trunk/src/main/java/au/csiro/doiclient/package.html trunk/src/main/java/au/csiro/doiclient/utils/ trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java trunk/src/main/java/au/csiro/doiclient/utils/DoiMetaDataGenerator.java trunk/src/main/resources/ands-doi-client.properties trunk/src/test/java/au/csiro/doiclient/ trunk/src/test/java/au/csiro/doiclient/TestAndsDoiClient.java trunk/src/test/java/au/csiro/doiclient/utils/ trunk/src/test/java/au/csiro/doiclient/utils/TestDoiMetaDataGenerator.java Added: trunk/DoiMetadataTemplate.xml =================================================================== --- trunk/DoiMetadataTemplate.xml (rev 0) +++ trunk/DoiMetadataTemplate.xml 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,31 @@ +<resource xmlns="http://datacite.org/schema/kernel-2.1" +xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" +xsi:schemaLocation="http://datacite.org/schema/kernel-2.1 +http://schema.datacite.org/meta/kernel-2.1/metadata.xsd"> +<identifier identifierType="DOI">10.2312/meyniana.2005.57.101</identifier> +<creators> +<creator> +<creatorName>Schimanski, Alexander</creatorName> +</creator> +<creator> +<creatorName>Stattegger, Karl</creatorName> +</creator> +</creators> +<titles> +<title>A conceptual sediment budget for the Great Barrier Reef</title> +</titles> +<publisher> +Institut für Geowissenschaften, Christian-Albrechts-Universität, Kiel +</publisher> +<publicationYear>2005</publicationYear> +<subjects> +<subject subjectScheme="DDC">550 Earth sciences and geology</subject> +</subjects> +<resourceType resourceTypeGeneral="Text">Article</resourceType> +<formats> +<format>PDF</format> +</formats> +<descriptions> +<description descriptionType="Other">MEYNIANA; 57; 101-115; ISSN 0076-7689</description> +</descriptions> +</resource> \ No newline at end of file Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-09-01 23:28:47 UTC (rev 93) +++ trunk/pom.xml 2012-03-07 00:26:47 UTC (rev 94) @@ -379,6 +379,11 @@ <artifactId>commons-lang</artifactId> <version>2.4</version> </dependency> + <dependency> + <groupId>org.jdom</groupId> + <artifactId>jdom</artifactId> + <version>1.1.2</version> + </dependency> </dependencies> <reporting> <plugins> @@ -488,5 +493,12 @@ <organization>CSIRO</organization> <timezone>+11</timezone> </developer> + <developer> + <id>pag06d</id> + <name>John Page</name> + <email>joh...@us...</email> + <organization>CSIRO</organization> + <timezone>+11</timezone> + </developer> </developers> </project> Added: trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiClient.java 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,685 @@ +package au.csiro.doiclient; + +import java.io.BufferedReader; +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.HttpStatus; +import org.apache.commons.httpclient.HttpsURL; +import org.apache.commons.httpclient.methods.PostMethod; +import org.apache.commons.httpclient.methods.RequestEntity; +import org.apache.commons.httpclient.methods.StringRequestEntity; +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; + + + + +/** + * 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 + * <a href="http://www.ands.org.au/">Australian National Data Service</a>. You will need to register with ANDS to be + * able to use the service. + * <p> + * <b>Usage:</b> + * </p> + * <p> + * Create a new instance of the class using either the empty constructor and then calling the four setters, or using the + * constructors. This should be compatible with use as a singleton bean in Spring or other DI (dependency injection) + * frameworks. Example: + * </p> + * <UL> + * <li>pidServiceHost - test.ands.org.au</li> + * <li>pidServicePort - 8443</li> + * <li>pidServicePath - /pids</li> + * <li>requestorIdentity.appId - 5d9a4da3580c528ba98d8e6f088dab93f680dd6b</li> + * <li>requestorIdentity.identifier - scott</li> + * <li>requestorIdentity.authDomain - mycomputer.edu.au</li> + * </UL> + * <p> + * You can then mint new DOIs using the {@link #mintDOI(String)} method. + * + * </p> + * Copyright 2010, CSIRO Australia All rights reserved. + * + * @author Robert Bridle on 05/02/2010 + * @author John Page on 03/03/2012 + * @version $Revision: $Date: $ + */ +public class AndsDoiClient +{ + + + /** + * Constant that defines the logger to be used. + */ + private static final Logger LOG = Logger.getLogger(AndsDoiClient.class.getName()); + + /** + * Constant that defines the name of properties file to be used. Both the Pid and Doi client share the same property + * file + */ + private static final String PROPERTIES_FILENAME = "/ands-doi-client.properties"; + + /** + * The name of the application, to be used by the HTTP client. + */ + private static String applicationName; + + /** + * The name of the method (RESTful web service) to call when minting a new handle. + */ + private static String mintMethodName; + + /** + * The name of the method (RESTful web service) to call when associating a new value with an existing handle. + */ + private static String addValueMethodName; + + /** + * The name of the method (RESTful web service) to call when associating a new value into the index of an existing + * handle. + */ + private static String addValueByIndexMethodName; + + /** + * The name of the method (RESTful web service) to call when modifying an existing handle. + */ + private static String modifyValueByIndexMethodName; + + /** + * The name of the method (RESTful web service) to call when deleting an existing handle value. + */ + private static String deleteValueByIndexMethodName; + + /** + * The name of the method (RESTful web service) to call when listing the handles owned by the requestor. + */ + private static String listHandlesMethodName; + + /** + * The name of the method (RESTful web service) to call when retrieving the values associated with a handle. + */ + private static String getHandleMethodName; + + /** + * Represents the identity information of the caller. + */ + private AndsDoiIdentity requestorIdentity; + + /** + * The ANDS Digital Object Identifier host name. + */ + private String doiServiceHost; + + + /** + * The ANDS Digital Object Identifier path name (web application context name). + */ + private String doiServicePath; + + /** + * The possible types of properties that can be associated with a handle. Each handle (DOI) can carry multiple (max + * of around 100) properties. + */ + public enum HandleType + { + /** + * A property with no associated value. + */ + EMPTY(""), + /** + * A property with a URL value. + */ + URL("URL"), + /** + * A property with a descriptive text value. + */ + DESC("DESC"); + + /** + * The value of the enumeration understood by the ANDS DOI service. + */ + private final String value; + + HandleType(String value) + { + this.value = value; + } + + /** + * @return the value of the enumeration. + */ + public String value() + { + return this.value; + } + + /** + * @return whether this enumeration is empty. + */ + public boolean isEmpty() + { + return EMPTY.value().equals(this.value); + } + } + + /** + * Loads the specified properties file. + */ + private static void loadProperties() + { + InputStream is = AndsDoiResponse.class.getResourceAsStream(PROPERTIES_FILENAME); + Properties props = new Properties(); + try + { + props.load(is); + applicationName = props.getProperty("application.name"); + mintMethodName = props.getProperty("method.mint"); + addValueMethodName = props.getProperty("method.addValue"); + addValueByIndexMethodName = props.getProperty("method.addValueByIndex"); + modifyValueByIndexMethodName = props.getProperty("method.modifyValueByIndex"); + deleteValueByIndexMethodName = props.getProperty("method.deleteValueByIndex"); + listHandlesMethodName = props.getProperty("method.listHandles"); + getHandleMethodName = props.getProperty("method.getHandle"); + } + catch (IOException e) + { + LOG.error("Could not load properties file: " + PROPERTIES_FILENAME, e); + } + } + + /** + * Default constructor. You will still need to supply the configuration data via the public setters. + */ + public AndsDoiClient() + { + this(null, null, null, null, null, null); + } + + /** + * @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 appId + * the unique Id provided to the caller upon IP registration with the ANDS Digital Object Identifier + * service. + * @param identifier + * the identifier or name of the repository calling the service. + * @param authDomain + * the domain of the organisation calling the service. + * @param doiDTO + * a DTO with the meta data info. + * + */ + public AndsDoiClient(String doiServiceHost, String doiServicePath, String appId, + String identifier, String authDomain, DoiDTO doiDTO) + { + this(doiServiceHost, doiServicePath, new AndsDoiIdentity(appId, identifier, authDomain, doiDTO)); + } + + + /** + * @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, String doiServicePath, + AndsDoiIdentity requestorIdentity) + { + this.setDoiServiceHost(doiServiceHost); + this.setDoiServicePath(doiServicePath); + this.setRequestorIdentity(requestorIdentity); + loadProperties(); + } + + /** + * 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 value + * 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 mintDOI(String value) throws IllegalStateException, IllegalArgumentException, + HttpException, IOException + { + this.validateState(); + + this.validateMintHandleArguments(value); + + String queryString = MessageFormat.format("app_id={0}&url={1}", new Object[] { + getRequestorIdentity().getAppId(), value }); + return executeMethod(queryString, mintMethodName); + } + + + + /** + * Checks that this class is in a valid state to call the ANDS DOI service. + * + * @throws IllegalStateException + * thrown if the parameters need to call the ANDS DOI service have not been provided. + */ + private void validateState() throws IllegalStateException + { + StringBuffer errorMsg = new StringBuffer(); + if (StringUtils.isEmpty(this.getDoiServiceHost())) + { + errorMsg.append("The host name of the ANDS DOI service has not been provided. e.g. test.org.au\n"); + } + if (getRequestorIdentity() == null || StringUtils.isEmpty(this.getRequestorIdentity().getAppId())) + { + errorMsg.append("The appID of the caller has not been provided. " + + "e.g. unique Id provided by ANDS upon IP registration.\n"); + } + if (getRequestorIdentity() == null || StringUtils.isEmpty(this.getRequestorIdentity().getIdentifier())) + { + errorMsg.append("The identifier of the caller has not been provided. " + + "e.g. identifier or name of the repository calling the service.\n"); + } + if (getRequestorIdentity() == null || StringUtils.isEmpty(this.getRequestorIdentity().getAuthDomain())) + { + errorMsg.append("The authDomain of the caller has not been provided. " + + "e.g. the domain of the organisation calling the service."); + } + // if we have error messages, throw the exception + if (errorMsg.length() != 0) + { + throw new IllegalStateException(errorMsg.toString()); + } + } + + /** + * Checks the arguments passed to the {@link #mintDOI(String)} and the + * {@link #mintHandleByIndex(HandleType, int, String)} methods. + * + * @param value + * the url of the data collection for which a DOi is required. + * @throws IllegalStateException + * thrown if the arguments provided to {@link #mintDOI(HandleType, String)} or to + * {@link #mintHandleByIndex(HandleType, int, String)} are not valid. + */ + private void validateMintHandleArguments(String value) throws IllegalArgumentException + { + + if (StringUtils.isEmpty(value)) + { + throw new IllegalArgumentException(MessageFormat.format( + "The method mintHandle() can only be called if both arguments are empty " + + "or both arguments are not empty:value={1}\n", new Object[] { value })); + } + } + + /** + * Constructs and executes an HTTP POST call. + * + * @param queryString + * the query string to provide the POST call. + * @param methodName + * the method to call. + * @return a formatted XML response. + * @throws IOException + * thrown when attempting to read response. + * @throws HttpException + * thrown when attempting to execute method call. + */ + private AndsDoiResponse executeMethod(String queryString, String methodName) throws HttpException, IOException + { + + LOG.debug("ExecuteMethod : Query String : ->" + queryString); + LOG.debug("ExecuteMethod : Method Name : ->" + methodName); + + HttpsURL url = new HttpsURL(this.getDoiServiceHost(), this.getDoiServicePath(), queryString, ""); + + url.setPath(url.getPath() + "/" + getPhPMethod(methodName)); + + String metaDataXML = this.getRequestorIdentity().toXML(methodName); + + LOG.debug("Metadata XML generated " + metaDataXML); + + return postDOIRequest(url.toString(), metaDataXML); + } + + /** + * + * @param methodName + * to be called + * @return php method name + */ + private String getPhPMethod(String methodName) + { + if (methodName.equals("mint")) + { + return "doi_mint.php"; + } + + return ""; + } + + /** + * 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 + * fragment that identifies the caller. + * + * @param postMethodURL + * the URI of the RESTful ANDS Digital Object Identifier web service. + * @param metaDataXML + * an XML fragment that details the meta data of the document for which the DOI is queried. + * @return a formatted XML response. + * @throws IOException + * thrown when attempting to read response. + * @throws HttpException + * thrown when attempting to execute method call. + */ + private String executePostMethod(String postMethodURL, String metaDataXML) throws HttpException, IOException + { + LOG.debug("Post method URL: " + postMethodURL); + LOG.debug("Metadata XML: " + metaDataXML); + + HttpClient client = new HttpClient(); + client.getParams().setParameter("http.useragent", applicationName); + client.getParams().setParameter("Content-Type", "text/xml"); + client.getParams().setParameter("Content-Encoding", "UTF-8"); + + PostMethod method = new PostMethod(postMethodURL); + + BufferedReader br = null; + StringBuffer strBuf = new StringBuffer(); + + try + { + RequestEntity entity = new StringRequestEntity(metaDataXML, "text/xml", "UTF-8"); + client.getParams().setParameter("Content-Length", entity.getContentLength()); + method.setRequestEntity(entity); + + int returnCode = client.executeMethod(method); + LOG.debug("HTTP return code from service " + returnCode); + + if (returnCode == HttpStatus.SC_NOT_IMPLEMENTED) + { + LOG.error("The post method is not implemented by this URI"); + // still consume the response body + method.getResponseBodyAsString(); + } + else + { + br = new BufferedReader(new InputStreamReader(method.getResponseBodyAsStream())); + String readLine; + while (((readLine = br.readLine()) != null)) + { + LOG.debug(readLine); + strBuf.append(readLine); + } + } + } + finally + { + if (br != null) + { + br.close(); + } + method.releaseConnection(); + } + + return strBuf.toString(); + } + + /** + * 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 + * fragment that identifies the caller. + * + * @param serviceUrl + * the URI of the RESTful ANDS Digital Object Identifier web service. + * @param metadata + * an XML fragment that details the meta data of the document for which the DOI is queried. + * @return + * @throws IOException + */ + private static AndsDoiResponse postDOIRequest(String serviceUrl, String metadata) throws IOException + { + LOG.debug("Post method URL: " + serviceUrl); + + LOG.debug("Metadata XML: " + metadata); + AndsDoiResponse doiResponse = null; + + StringBuffer outputBuffer; + URL url = new URL(serviceUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + try + { + // Construct data + String data = "xml=" + URLEncoder.encode(metadata, "UTF-8"); + + // Send data + + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setDoInput(true); + OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); + wr.write(data); + wr.flush(); + + doiResponse = new AndsDoiResponse(); + doiResponse.setResponseCode(conn.getResponseCode()); + doiResponse.setResponseMessage(conn.getResponseMessage()); + + LOG.debug(conn.getResponseCode() + " - " + conn.getResponseMessage()); + + // Get the response + outputBuffer = new StringBuffer(); + BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = rd.readLine()) != null) + { + outputBuffer.append(line); + } + wr.close(); + rd.close(); + + doiResponse.setResponseBody(outputBuffer.toString()); + return doiResponse; + } + catch (Exception e) + { + // error occured + outputBuffer = new StringBuffer(); + BufferedReader rde = new BufferedReader(new InputStreamReader(conn.getErrorStream())); + String line; + while ((line = rde.readLine()) != null) + { + LOG.debug(line); + outputBuffer.append(line); + } + rde.close(); + } + finally + { + } + doiResponse.setResponseBody(outputBuffer.toString()); + return doiResponse; + + } + + /** + * 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 + */ + public String getDoiServiceHost() + { + return doiServiceHost; + } + + /** + * Set the ANDS Digital Object Identifier host name. + * + * @param pidServiceHost + * the ANDS Digital Object Identifier host name to set + */ + public void setDoiServiceHost(String pidServiceHost) + { + this.doiServiceHost = pidServiceHost; + } + + + /** + * Retrieve the current ANDS Digital Object Identifier path name (web application context name) + * + * @return the ANDS Digital Object Identifier path name + */ + public String getDoiServicePath() + { + return doiServicePath; + } + + /** + * Set the current ANDS Digital Object Identifier path name (web application context name) + * + * @param pidServicePath + * the ANDS Digital Object Identifier path name to set + */ + public void setDoiServicePath(String pidServicePath) + { + this.doiServicePath = pidServicePath; + } + + /** + * Retrieve the identity information of the calling application/organisation. + * + * @return the identity of the caller + */ + public AndsDoiIdentity getRequestorIdentity() + { + return requestorIdentity; + } + + /** + * Set the identity information of the calling application/organisation. + * + * @param requestorIdentity + * the identity object to set + */ + public void setRequestorIdentity(AndsDoiIdentity requestorIdentity) + { + this.requestorIdentity = requestorIdentity; + } + +} Added: trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/AndsDoiResponse.java 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,152 @@ +package au.csiro.doiclient; + + +/** + * Represents an ANDS Digital Object Identifier service response. + * + * Copyright 2010, CSIRO Australia All rights reserved. + * + * @author John Page on 06/03/2012 + * + * @version $Revision: $ $Date: $ + */ +public class AndsDoiResponse +{ + + /** + * Code returned by the DOI service + */ + private int responseCode; + + /** + * Message returned by the DOI service + */ + private String responseMessage; + + /** + * Response Body returned by the DOI service + */ + private String responseBody; + + /** + * Digital Object Identifier returned by DOI service + */ + private String doi; + + /** + * + * + * @param responseCode + * Code returned by the DOI service + * @param responseMessage + * Message returned by the DOI service + * @param responseBody + * Response Body returned by the DOI + */ + public AndsDoiResponse(int responseCode, String responseMessage, String responseBody) + { + super(); + this.responseCode = responseCode; + this.responseMessage = responseMessage; + this.responseBody = responseBody; + } + + /** + * Default constructor + */ + public AndsDoiResponse() + { + + } + + /** + * @return the responseCode + */ + public int getResponseCode() + { + return responseCode; + } + + /** + * @param responseCode + * the responseCode to set + */ + public void setResponseCode(int responseCode) + { + this.responseCode = responseCode; + } + + /** + * @return the responseMessage + */ + public String getResponseMessage() + { + return responseMessage; + } + + /** + * @param responseMessage + * the responseMessage to set + */ + public void setResponseMessage(String responseMessage) + { + this.responseMessage = responseMessage; + } + + /** + * @return the responseBody + */ + public String getResponseBody() + { + return responseBody; + } + + /** + * @param responseBody + * the responseBody to set + */ + public void setResponseBody(String responseBody) + { + this.responseBody = responseBody; + } + + /** + * @return the doi + */ + public String getDoi() + { + extractDOI(); + return doi; + } + + /** + * @param doi + * the Digital Object Identifier to set + */ + public void setDoi(String doi) + { + this.doi = doi; + } + + /** + * Extracts the DOI from the DOI service response body, if no DOI could be extracted from the response body then + * null is returned + */ + private void extractDOI() + { + doi = null; + if (getResponseCode() == 200) + { + int startIndex = getResponseBody().indexOf("DOI"); + int endIndex = getResponseBody().indexOf("was"); + + if (startIndex > 0 && endIndex > 0) + { + doi = getResponseBody().substring(startIndex + 3, endIndex).trim(); + } + } + } + + +} + Added: trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/MockDOIMintClient.java 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,203 @@ +package au.csiro.doiclient; + + +/********************************************************************** + Copyright 2011 The Australian National University + 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. + ***********************************************************************/ +import java.io.BufferedReader; +import java.io.FileInputStream; +import java.io.FileReader; +import java.io.InputStreamReader; +import java.io.OutputStreamWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLEncoder; +import java.util.HashMap; +import java.util.Scanner; + +import org.xml.sax.ErrorHandler; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; + +class MockDOIMintClient +{ + + // Location of the DOI Service + private static final String DOIServicePoint = "http://services.ands.org.au/home/dois/"; + + // DOI Application ID (supplied by ANDS) + private static final String DOIApplicationID = "c3fa1cb72cce27b7b0b02c9377fb9a6910294e35-123"; + + // Suffices for certain services + private static final String DOIMintServiceSuffix = "doi_mint.php?app_id=<app_id>&url=<url>"; + private static final String DOIUpdateServiceSuffix = "doi_update.php?app_id=<app_id>&DOI=<doi_id>"; + private static final String DOIMetadataRequestServiceSuffix = "doi_xml.php?app_id=<app_id>&DOI=<doi_id>"; + + static String xml = "<resource xmlns=\"http://datacite.org/schema/kernel-2.1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://datacite.org/schema/kernel-2.1 http://schema.datacite.org/meta/kernel-2.1/metadata.xsd\">" + + "<identifier identifierType=\"DOI\">10.1594/WDCC/CCSRNIES_SRES_B2</identifier>" + + "<creators>" + + "<creator>" + + "<creatorName>John, Smith</creatorName>" + + "</creator>" + + "</creators>" + + "<titles>" + + " <title>Test DOI service</title>" + + "<title titleType=\"Subtitle\">A survey</title>" + + "</titles>" + + "<publisher>CSIRO</publisher>" + "<publicationYear>2004</publicationYear>" + "</resource>"; + + public static void main(String[] args) throws Exception + { + + // Build up the URL for us to mint at + String url_of_data = "http://test.ands.org.au/robots.txt"; + String datacite_xml_fragment_file = "C:\\temp\\test_datacite_metadata.txt"; + String mint_service_url = DOIServicePoint + DOIMintServiceSuffix; + + // Replace the required fields + HashMap<String, String> url_replacement_values = new HashMap<String, String>(); + url_replacement_values.put("app_id", DOIApplicationID); + url_replacement_values.put("url", url_of_data); + + mint_service_url = replaceURLFields(mint_service_url, url_replacement_values); + + System.out.println("Read XML from " + datacite_xml_fragment_file); + System.out.println("Sending query data to" + mint_service_url); + System.out.println("Output:"); + + String response_string = postDOIRequest(mint_service_url, loadXMLFromFile(datacite_xml_fragment_file)); + + System.out.println(response_string); + + } + + private static String postDOIRequest(String serviceUrl, String contents) throws Exception + { + + URL url = new URL(serviceUrl); + HttpURLConnection conn = (HttpURLConnection) url.openConnection(); + try + { + // Construct data + String data = "xml=" + URLEncoder.encode(contents, "UTF-8"); + + // Send data + + conn.setRequestMethod("POST"); + conn.setDoOutput(true); + conn.setDoInput(true); + OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream()); + wr.write(data); + wr.flush(); + + System.out.println(conn.getResponseCode() + " - " + conn.getResponseMessage()); + + // Get the response + StringBuffer outputBuffer = new StringBuffer(); + BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream())); + String line; + while ((line = rd.readLine()) != null) + { + outputBuffer.append(line); + } + wr.close(); + rd.close(); + + return outputBuffer.toString(); + } + catch (Exception e) + { + // error occured + BufferedReader rde = new BufferedReader(new InputStreamReader(conn.getErrorStream())); + String line; + while ((line = rde.readLine()) != null) + { + System.out.println(line); + } + rde.close(); + } + finally + { + } + + return ""; + + } + + private static String loadXMLFromFile(String filename) throws Exception + { + + FileInputStream fis = new FileInputStream(filename); + InputStreamReader in = new InputStreamReader(fis, "UTF-8"); + Scanner s = null; + StringBuffer xml_buffer = new StringBuffer(); + try + { + s = new Scanner(new BufferedReader(new FileReader(filename))); + s.useDelimiter(System.getProperty("line.separator")); + while (s.hasNext()) + { + xml_buffer.append(s.next() + System.getProperty("line.separator")); + } + } + finally + { + if (s != null) + { + s.close(); + } + } + + return xml_buffer.toString(); + + // return xml; + } + + private static String replaceURLFields(String input_string, HashMap<String, String> replacements_map) + { + String return_url = input_string; + for (String key : replacements_map.keySet()) + { + return_url = return_url.replaceAll("\\<" + key + "\\>", replacements_map.get(key)); + } + + /* + * // sanity check if (return_url.matches(".*\\<.*\\>.*")) { // should throw an exception // Service Point URL + * contains fields which are still incomplete? } + */ + + return return_url; + + } + +} + +class SimpleErrorHandler implements ErrorHandler +{ + public void warning(SAXParseException e) throws SAXException + { + System.out.println(e.getMessage()); + } + + public void error(SAXParseException e) throws SAXException + { + System.out.println(e.getMessage()); + } + + public void fatalError(SAXParseException e) throws SAXException + { + System.out.println(e.getMessage()); + } +} + Added: trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/business/AndsDoiIdentity.java 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,239 @@ +package au.csiro.doiclient.business; + +import java.io.IOException; + +import org.apache.log4j.Logger; +import org.jdom.JDOMException; + +import au.csiro.doiclient.utils.DoiMetaDataGenerator; + + + +/** + * Represents the identify information required when calling the ANDS Digital Object Identifier service. + * + * Copyright 2010, CSIRO Australia All rights reserved. + * + * @author Robert Bridle on 08/02/2010 + * @author John Page on 03/03/2012 + * + * @version $Revision: $Date: $ + */ +public class AndsDoiIdentity +{ + /** + * The unique Id provided to the caller upon IP registration with the ANDS Digital Object Identifier service. + */ + private String appId; + + /** + * The identifier or name of the repository calling the service. + */ + private String identifier; + + /** + * The domain of the organisation calling the service. + */ + private String authDomain; + + /** + * The creator of the Digital Object + */ + private DoiDTO doiDTO; + + + /** + * Constant that defines the logger to be used. + */ + private static final Logger LOG = Logger.getLogger(AndsDoiIdentity.class.getName()); + + /** + * + */ + public AndsDoiIdentity() + { + } + + /** + * Constructor + * + * @param appId + * the unique Id provided to the caller upon IP registration with the ANDS Digital Object Identifier + * service. + * @param identifier + * the identifier or name of the repository calling the service. + * @param authDomain + * the domain of the organisation calling the service. + */ + @SuppressWarnings(value = "all") + public AndsDoiIdentity(String appId, String identifier, String authDomain, DoiDTO doiDTO) + { + this.setAppId(appId); + this.setIdentifier(identifier); + this.setAuthDomain(authDomain); + this.setDoiDTO(doiDTO); + + } + + /** + * @return the appId + */ + public String getAppId() + { + return escape(appId); + } + + /** + * @param appId + * the appId to set + */ + public void setAppId(String appId) + { + this.appId = appId; + } + + /** + * @return the identifier + */ + public String getIdentifier() + { + return escape(identifier); + } + + /** + * @param identifier + * the identifier to set + */ + public void setIdentifier(String identifier) + { + this.identifier = identifier; + } + + /** + * @return the authDomain + */ + public String getAuthDomain() + { + return escape(authDomain); + } + + /** + * @param authDomain + * the authDomain to set + */ + public void setAuthDomain(String authDomain) + { + this.authDomain = authDomain; + } + + /** + * @return the doiDTO + */ + public DoiDTO getDoiDTO() + { + return doiDTO; + } + + /** + * @param doiDTO + * the doiDTO to set + */ + public void setDoiDTO(DoiDTO doiDTO) + { + this.doiDTO = doiDTO; + } + + + /** + * Formats the DOI metadata information into a XML format that the ANDS Digital Object Identifier service + * understands. + * + * @param methodName + * the name of the method to be called for this particular DOI call. + * @return the meta data XML string representing the identity information of the digital object. + */ + @SuppressWarnings(value = "all") + public String toXML(String methodName) + { + String doiMetaDataXML = null; + + if (methodName.equals("mint")) + { + try + { + doiMetaDataXML = DoiMetaDataGenerator.createDoiMetaDataXML(getDoiDTO()); + } + catch (IOException e) + { + LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), e); + } + catch (JDOMException ex) + { + LOG.error("Error in generating DOI Metadata for " + getDoiDTO().getTitle(), ex); + } + } + + return doiMetaDataXML; + + } + + + /* + * (non-Javadoc) + * + * @see java.lang.Object#toString() + */ + @Override + public String toString() + { + return "RequestorIdentity [appId=" + appId + ", authDomain=" + authDomain + ", identifier=" + identifier + "]"; + } + + /** + * Escape reserved characters, assumes UTF-8 or UTF-16 as encoding. + * + * @param in + * the String whose reserved characters we want to remove. + * @return the in String, stripped of reserved characters. + */ + public String escape(String in) + { + if (in == null) + { + return in; + } + + StringBuffer buffer = new StringBuffer(); + for (int i = 0; i < in.length(); i++) + { + char c = in.charAt(i); + if (c == '<') + { + buffer.append("<"); + } + else if (c == '>') + { + buffer.append(">"); + } + else if (c == '&') + { + buffer.append("&"); + } + else if (c == '"') + { + buffer.append("""); + } + else if (c == '\'') + { + buffer.append("'"); + } + else + { + buffer.append(c); + } + } + return buffer.toString(); + } + +} + Added: trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/business/DoiDTO.java 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,184 @@ +/** + * + */ +package au.csiro.doiclient.business; + +import java.io.Serializable; +import java.util.List; + +/** + * Class representing an DOI Data Transfer Object. This class is serializable, so that it can easily be shared between + * libraries. + * + * Copyright 2010, CSIRO Australia All rights reserved. + * + * @author John Page on 03/03/2012 + * @version $Revision: $Date: + */ +public class DoiDTO implements Serializable +{ + + /** + * + */ + private static final long serialVersionUID = 5970619710155407372L; + + private String title; + private String shortName; + private String creator; + private List<String> contributors; + private String publicationYear; + private String publisher; + private String subject; + private String keywords; + private String language; + + /** + * @return the title + */ + public String getTitle() + { + return title; + } + + /** + * @param title + * the title to set + */ + public void setTitle(String title) + { + this.title = title; + } + /** + * @return the shortName + */ + public String getShortName() + { + return shortName; + } + + /** + * @param shortName + * the shortName to set + */ + public void setShortName(String shortName) + { + this.shortName = shortName; + } + /** + * @return the creator + */ + public String getCreator() + { + return creator; + } + + /** + * @param creator + * the creator to set + */ + public void setCreator(String creator) + { + this.creator = creator; + } + /** + * @return the contributors + */ + public List<String> getContributors() + { + return contributors; + } + + /** + * @param contributors + * the contributors to set + */ + public void setContributors(List<String> contributors) + { + this.contributors = contributors; + } + + /** + * @return the subject + */ + public String getSubject() + { + return subject; + } + + /** + * @param subject + * the subject to set + */ + public void setSubject(String subject) + { + this.subject = subject; + } + /** + * @return the keywords + */ + public String getKeywords() + { + return keywords; + } + + /** + * @param keywords + * the keywords to set + */ + public void setKeywords(String keywords) + { + this.keywords = keywords; + } + /** + * @return the language + */ + public String getLanguage() + { + return language; + } + + /** + * @param language + * the language to set + */ + public void setLanguage(String language) + { + this.language = language; + } + + /** + * @return the publicationYear + */ + public String getPublicationYear() + { + return publicationYear; + } + + /** + * @param publicationYear + * the publicationYear to set + */ + public void setPublicationYear(String publicationYear) + { + this.publicationYear = publicationYear; + } + + /** + * @return the publisher + */ + public String getPublisher() + { + return publisher; + } + + /** + * @param publisher + * the publisher to set + */ + public void setPublisher(String publisher) + { + this.publisher = publisher; + } + +} Added: trunk/src/main/java/au/csiro/doiclient/business/package.html =================================================================== --- trunk/src/main/java/au/csiro/doiclient/business/package.html (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/business/package.html 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,30 @@ +<!-- + + 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. + +--> + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<title>au.csiro.doiclient.business package</title> +</head> +<body bgcolor="white"> + +Support classes for the ANDS DOI client library. + + +</body> +</html> Added: trunk/src/main/java/au/csiro/doiclient/package.html =================================================================== --- trunk/src/main/java/au/csiro/doiclient/package.html (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/package.html 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,36 @@ +<!-- + + 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. + +--> + +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN"> +<html> +<head> +<title>au.csiro.doiclient package</title> +</head> +<body bgcolor="white"> +<p> +Provides a simple interface to use the +<a href="http://ands.org.au/services/cite-my-data.html">Digital IDentifier Service</a> +provided by the +<a href="http://www.ands.org.au/">Australian National Data Service</a>. You will need to +register with ANDS to be able to use the service, both for an app key but also each IP address +which will call the service. +</p><p> +The primary interface can be found in {@see au.csiro.doiclient.AndsdoiClient } +</p> +</body> +</html> \ No newline at end of file Added: trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java =================================================================== --- trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java (rev 0) +++ trunk/src/main/java/au/csiro/doiclient/utils/ConverterUtils.java 2012-03-07 00:26:47 UTC (rev 94) @@ -0,0 +1,375 @@ +package au.csiro.doiclient.utils; + +import java.io.IOException; +import java.io.StringReader; +import java.io.StringWriter; +import java.util.Hashtable; +import java.util.List; + +import org.jdom.Document; +import org.jdom.Element; +import org.jdom.JDOMException; +import org.jdom.Namespace; +import org.jdom.input.SAXBuilder; +import org.jdom.output.Format; +import org.jdom.output.XMLOutputter; +import org.jdom.xpath.XPath; + + +/** + * Generic XML conversion utility. This can be used to take a supplied XML document, and make modifications to the + * textual data. + * + * Copyright 2010, CSIRO Australia All rights reserved. + * + * @author Martin Pienaar on 22/07/2010 + * @version $Revision: 7327 $ $Date: 2010-07-22 10:35:12 +1000 (Thu, 22 Jul 2010) $ + */ +public class ConverterUtils +{ + + /** + * Generate an XML document from a file location string. + * + * @param xmlFile + * the location of the XML file + * @return an XML document + * @throws IOException + * when the xmlFile is not accessible + * @throws JDOMException + * when the xmlFile is not valid + */ + public static Document getXmlDocument(String xmlFile) throws IOException, JDOMException + { + SAXBuilder builder = new SAXBuilder(); + return builder.build(xmlFile); + } + + /** + * Convert the string of XML to a JDOM document. + * + * @param xml + * The XML string to be converted. + * @return The document + * @throws JDOMException + * If the XML is not valid or the conversion otherwise fails + * @throws IOException + * If the string cannot be read. + */ + public static Document xmlToDoc(String xml) throws JDOMException, IOException + { + SAXBuilder builder = new SAXBuilder(); + StringReader reader = new StringReader(xml); + Document rifCsDoc = builder.build(reader); + return rifCsDoc; + } + + /** + * Update an existing XML element within an XML document using XPath. + * + * @param document + * the existing XML document to update + * @param nameSpaces + * a Hashtable of XML Namespaces associated with the element + * @param element + * the element XPath that needs to be updated + * @param value + * the new value of the element + * @throws JDOMException + * when invalid XML parsing/access occurs + */ + public static void updateElementValue(Document document, String nameSpace, String element, + String value) throws JDOMException + { + XPath xPath = XPath.newInstance(element); + xPath.addNamespace(nameSpace, document.getRootElement().getNamespaceURI()); + Element theElement = (Element) xPath.selectSingleNode(document); + theElement.setText(stripNonValidXMLCharacters(value)); + } + + /** + * Add list of children nodes to a parent node + * + * @param document + * the existing XML document to update + * @param parent + * the parent XPath + * @param childrenElements + * children elements to be added + * @param nameSpaces + * one or more XML Namespaces associated with the XML document + * @throws JDOMException + * when invalid XML parsing/access occurs + */ + @SuppressWarnings("unchecked") + public static void addChildrenToNode(Document document, String parent, List<Element> childrenElements, + Namespace... nameSpaces) throws JDOMException + { + Element parentNode = getElement(document, parent, nameSpaces); + List<Element> existingChildrenList = parentNode.getChildren(); + existingChildrenList.addAll(childrenElements); + } + + /** + * Add list of children nodes to the start of the child list for a parent node + * + * @param document + * the existing XML document to update + * @param parent + * the parent XPath + * @param childrenElements + * children elements to be added + * @param nameSpaces + * one or more XML Namespaces associated with the XML document + * @throws JDOMException + * when invalid XML parsing/access occurs + */ + @SuppressWarnings("unchecked") + public static void insertChildrenToNode(Document document, String parent, List<Element> childrenElements, + Namespace... nameSpaces) throws JDOMException + { + Element parentNode = getElement(document, parent, nameSpaces); + List<Element> existingChildrenList = parentNode.getChildren(); + existingChildrenList.addAll(0, childrenElements); + } + + /** + * Get element from an XML document. + * + * @param document + * the existing XML document to update + * @param element + * the element XPath that needs to be added + * @param nameSpaces + * one or more XML Namespaces associated with the XML document + * @return the element specified by the XPath element, null otherwise. + * @throws JDOMException + * when invalid XML parsing/access occurs + */ + public static Element getElement(Document document, String element, Namespace... nameSpaces) throws JDOMException + { + XPath xPath = XPath.newInstance(element); + for (int i = 0; i < nameSpaces.length; i++) + { + xPath.addNamespace(nameSpaces[i]); + } + return (Element) xPath.selectSingleNode(document); + } + + /** + * Add a new element containing text to the parent node. + * + * @param parent + * The node to which the element is being added. + * @param elementName + * The name of the new element. + * @param nameSpaceUri + * The UIR of the new node's namespace. + * @param text + * The text content of the new node + */ + public static void addTextElement(Element parent, String elementName, String nameSpaceUri, String text) + { + Element description = new Element(elementName, nameSpaceUri); + description.setText(text); + parent.addContent(description); + } + + /** + * Add a new element containing text to the parent node, allows namespace prefix. + * + * @param parent + * The node to which the element is being added. + * @param elementName + * The name of the new element. + * @param nameSpacePrefix + * The prefix of the new node's namespace. + * @param nameSpaceUri + * The UIR of the new node's namespace. + * @param text + * The text content of the new node + */ + public static void addTextElement(Element parent, String elementName, String nameSpacePrefix, String nameSpaceUri, + String text) + { + Element description = new Element(elementName, nameSpacePrefix, nameSpaceUri); + description.setText(text); + parent.addContent(description); + } + + /** + * Add a new element containing text to the parent node. + * + * @param parent + *... [truncated message content] |
From: <csi...@us...> - 2010-09-01 23:28:53
|
Revision: 93 http://andspidclient.svn.sourceforge.net/andspidclient/?rev=93&view=rev Author: csirobuilduser Date: 2010-09-01 23:28:47 +0000 (Wed, 01 Sep 2010) Log Message: ----------- [maven-release-plugin] prepare for next development iteration Modified Paths: -------------- trunk/pom.xml Modified: trunk/pom.xml =================================================================== --- trunk/pom.xml 2010-09-01 23:28:37 UTC (rev 92) +++ trunk/pom.xml 2010-09-01 23:28:47 UTC (rev 93) @@ -52,7 +52,7 @@ <groupId>net.sourceforge.andspidclient</groupId> <artifactId>ands-pid-client</artifactId> <packaging>jar</packaging> - <version>1.0.07</version> + <version>1.0.08-SNAPSHOT</version> <name>ands-pid-client</name> <description>A generic client library for accessing the ANDS Persistent Identifier service. 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.07</connection> - <developerConnection>scm:svn:https://andspidclient.svn.sourceforge.net/svnroot/andspidclient/tags/ands-pid-client-1.0.07</developerConnection> - <url>http://andspidclient.svn.sourceforge.net/viewvc/andspidclient/tags/ands-pid-client-1.0.07</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. |