From: Christos KK Loverdos Date: Mon, 11 Jun 2012 08:51:03 +0000 (+0300) Subject: Organize a few rest paths X-Git-Url: https://code.grnet.gr/git/aquarium/commitdiff_plain/f6638ff1448da0cb9e1e5b0ef2fb756c166b581d Organize a few rest paths --- diff --git a/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTActor.scala b/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTActor.scala index ec6dffd..3c76358 100644 --- a/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTActor.scala +++ b/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTActor.scala @@ -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) } diff --git a/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTPaths.scala b/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTPaths.scala index fc796c8..a4ff51d 100644 --- a/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTPaths.scala +++ b/src/main/scala/gr/grnet/aquarium/actor/service/rest/RESTPaths.scala @@ -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 . */ 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