Organize a few rest paths
authorChristos KK Loverdos <loverdos@gmail.com>
Mon, 11 Jun 2012 08:51:03 +0000 (11:51 +0300)
committerChristos KK Loverdos <loverdos@gmail.com>
Mon, 11 Jun 2012 08:51:03 +0000 (11:51 +0300)
src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTActor.scala
src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTPaths.scala

index ec6dffd..3c76358 100644 (file)
@@ -193,22 +193,34 @@ class RESTActor private(_id: String) extends RoleableActor with Loggable {
           // /user/(.+)/state/?
           callRouter(GetUserStateRequest(userId, millis), responder)
 
-        case AdminPingAll() ⇒
+//        case AdminPingAllPath() ⇒
+//          withAdminCookieHelper { responder ⇒
+//            callRouter(PingAllRequest(), responder)
+//          }
+
+        case ResourcesPath() ⇒
           withAdminCookieHelper { responder ⇒
-            callRouter(PingAllRequest(), responder)
+            responder.complete(
+              stringResponse200("%s\n%s\n%s\n" .format(
+                  ResourceLocator.ResourceNames.AQUARIUM_PROPERTIES,
+                  ResourceLocator.ResourceNames.LOGBACK_XML,
+                  ResourceLocator.ResourceNames.POLICY_YAML),
+                TEXT_PLAIN
+              )
+            )
           }
 
-        case ResourcesAquariumProperties() ⇒
+        case ResourcesAquariumPropertiesPath() ⇒
           withAdminCookieHelper { responder ⇒
             resourceInfoResponse(uri, responder, ResourceLocator.Resources.AquariumPropertiesResource, TEXT_PLAIN)
           }
 
-        case ResourcesLogbackXML() ⇒
+        case ResourcesLogbackXMLPath() ⇒
           withAdminCookieHelper { responder ⇒
             resourceInfoResponse(uri, responder, ResourceLocator.Resources.LogbackXMLResource, TEXT_PLAIN)
           }
 
-        case ResourcesPolicyYAML() ⇒
+        case ResourcesPolicyYAMLPath() ⇒
           withAdminCookieHelper { responder ⇒
             resourceInfoResponse(uri, responder, ResourceLocator.Resources.PolicyYAMLResource, TEXT_PLAIN)
           }
index fc796c8..a4ff51d 100644 (file)
@@ -37,6 +37,8 @@ package gr.grnet.aquarium.actor
 package service
 package rest
 
+import gr.grnet.aquarium.ResourceLocator
+
 
 /**
  * Paths recognized and served by the REST API.
@@ -44,17 +46,21 @@ package rest
  * @author Christos KK Loverdos <loverdos@gmail.com>.
  */
 object RESTPaths {
-  final val ResourcesLogbackXML = "/resources/logback\\.xml".r
+  final val ResourcesPath = "/resources/?".r
+
+  private def fixREDot(s: String) = s.replaceAll("""\.""", """\\.""")
+  private def toResourcesPath(name: String) = "/resources/%s".format(fixREDot(name)).r
+  private def toEventPath(name: String) = "/%s/([^/]+)/?".format(name).r
 
-  final val ResourcesAquariumProperties = "/resources/aquarium\\.properties".r
+  final val ResourcesAquariumPropertiesPath = toResourcesPath(ResourceLocator.ResourceNames.AQUARIUM_PROPERTIES)
 
-  final val ResourcesPolicyYAML = "/resources/policy\\.yaml".r
+  final val ResourcesLogbackXMLPath = toResourcesPath(ResourceLocator.ResourceNames.LOGBACK_XML)
 
-  final val RolesAgreementsMap = "/resources/roles-agreements\\.map".r
+  final val ResourcesPolicyYAMLPath = toResourcesPath(ResourceLocator.ResourceNames.POLICY_YAML)
 
-  final val ResourceEventPath = "/rcevent/([^/]+)/?".r
+  final val ResourceEventPath = toEventPath("rcevent")
 
-  final val IMEventPath = "/imevent/([^/]+)/?".r
+  final val IMEventPath = toEventPath("imevent")
 
   /**
    * Use this URI path to query for the user balance. The parenthesized regular expression part
@@ -70,5 +76,5 @@ object RESTPaths {
   /**
    * Use this administrative URI path to ping all services used by Aquarium.
    */
-  final val AdminPingAll = "/admin/ping/all/?".r
+  final val AdminPingAllPath = "/admin/ping/all/?".r
 }
\ No newline at end of file