From 519755a1119674c37c4246d34599a13fc41007bd Mon Sep 17 00:00:00 2001 From: Aron Roberts Date: Wed, 22 Apr 2009 22:31:59 +0000 Subject: [PATCH] CSPACE-88: Revamped VersionResource to PingResource, which better reflects the nature of this service - a ping or echo service. (Returning a global version number for the application isn't currently meaningful, as Patrick pointed out.) Service now also responds on requests for both 'ping' and 'echo' path elements. --- .../services/HelloworldNuxeoApplication.java | 2 +- .../hello/services/PingResource.java | 64 +++++++++++++++++++ .../hello/services/VersionResource.java | 44 ------------- 3 files changed, 65 insertions(+), 45 deletions(-) create mode 100755 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java delete mode 100755 HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/VersionResource.java diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java index c9dd1273c..1a0e2cc93 100644 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java +++ b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/HelloworldNuxeoApplication.java @@ -12,7 +12,7 @@ public class HelloworldNuxeoApplication extends Application { public HelloworldNuxeoApplication() { singletons.add(new CollectionObjectResource()); singletons.add(new DomainIdentifierResource()); - singletons.add(new VersionResource()); + singletons.add(new PingResource()); } @Override diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java new file mode 100755 index 000000000..2d389127d --- /dev/null +++ b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/PingResource.java @@ -0,0 +1,64 @@ +package org.collectionspace.hello.services; + +/** + * PingResource + * + * Service that returns a brief "ping"-type response. + * Allows clients to test basic connectivity. + * + * @author $Author: aron $ + * @version $Revision: 547 $ + * @version $Date: 2009-01-30 12:48:42 -0800 (Fri, 30 Jan 2009) $ + * + */ + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; + +@Path("") +@Produces("text/plain") +public class PingResource { + + // Paths relative to the root path, defined above. + final static String ECHO_RELATIVE_PATH = "echo"; + final static String PING_RELATIVE_PATH = "ping"; + + // Ping or echo message to return. + final static String SERVICE_NAME = "CollectionSpace"; + final static String SERVICE_PING_MESSAGE = + "The " + SERVICE_NAME + " system is alive and listening.\n"; + + ///////////////////////////////////////////////////////////////// + /** + * Class constructor (no argument). + */ + public PingResource() { + // do nothing + } + + ///////////////////////////////////////////////////////////////// + /** + * Returns a brief "ping"-type message. + * + * @return A brief "ping"-type message. + */ + @Path(PING_RELATIVE_PATH) + @GET + public String getPing() { + return SERVICE_PING_MESSAGE; + } + + ///////////////////////////////////////////////////////////////// + /** + * Returns a brief "ping"-type message. Allows this message to be retrieved + * from an "echo" URI, as well as a "ping" URI. + * + * @return A brief "ping"-type message. + */ + @Path(ECHO_RELATIVE_PATH) + @GET + public String getEcho() { + return getPing(); + } +} diff --git a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/VersionResource.java b/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/VersionResource.java deleted file mode 100755 index c6fb56aad..000000000 --- a/HelloWorld/HelloWorldNuxeoService/src/main/java/org/collectionspace/hello/services/VersionResource.java +++ /dev/null @@ -1,44 +0,0 @@ -package org.collectionspace.hello.services; - -/** - *

- * Service that returns the overall version of CollectionSpace services. - * Can also be called as a "ping"-type service to test basic connectivity. - *

- * - * @author $Author: aron $ - * @version $Revision: 547 $ - * @version $Date: 2009-01-30 12:48:42 -0800 (Fri, 30 Jan 2009) $ - * - */ - -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; - -@Path("/version") -@Produces("text/plain") -public class VersionResource { - - final static String CO_VERSION = "0.1"; - - ///////////////////////////////////////////////////////////////// - /** - * Class constructor (no argument). - */ - public VersionResource() { - // do nothing - } - - ///////////////////////////////////////////////////////////////// - /** - * Returns the version of the CollectionSpace system. - * - * @return The version of the CollectionSpace system. - */ - @GET - public String getVersion() { - return CO_VERSION; - } - -} -- 2.47.3