idok-commit AT lists.psi.ch
Subject: Commit emails of the iDok project
List archive
[idok-commit] idok commit r254 - in trunk/java/ch/idok/service/server: admin/rest rest
Chronological Thread
- From: "AFS account Florian Huebner" <huebner AT savannah.psi.ch>
- To: idok-commit AT lists.psi.ch
- Subject: [idok-commit] idok commit r254 - in trunk/java/ch/idok/service/server: admin/rest rest
- Date: Thu, 25 Sep 2008 16:50:40 +0200
- List-archive: <https://lists.web.psi.ch/pipermail/idok-commit/>
- List-id: Commit emails of the iDok project <idok-commit.lists.psi.ch>
Author: huebner
Date: Thu Sep 25 16:50:40 2008
New Revision: 254
Log:
Implemented configurable base URI for hrefs in ReST response entities
Modified:
trunk/java/ch/idok/service/server/admin/rest/RestAdminServiceResource.java
trunk/java/ch/idok/service/server/rest/RestServer.java
Modified:
trunk/java/ch/idok/service/server/admin/rest/RestAdminServiceResource.java
==============================================================================
---
trunk/java/ch/idok/service/server/admin/rest/RestAdminServiceResource.java
(original)
+++
trunk/java/ch/idok/service/server/admin/rest/RestAdminServiceResource.java
Thu Sep 25 16:50:40 2008
@@ -4,6 +4,7 @@
import java.io.FileOutputStream;
import java.io.FileReader;
import java.io.InputStream;
+import java.net.URI;
import java.security.AccessControlException;
import java.util.logging.Level;
import java.util.logging.Logger;
@@ -19,6 +20,7 @@
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
+import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
import javax.ws.rs.core.Response.Status;
@@ -56,10 +58,16 @@
*/
@Context
SecurityContext securityContext;
+
+ /**
+ * Base URI used for hrefs in the response entity
+ */
+ static String baseURI;
static public void init(RestServer server) throws DmsException {
adapter = PermissionAdapterFactory.getAdapter();
logger = server.getLogger();
+ baseURI = server.getBaseURI();
}
@GET
@@ -502,17 +510,16 @@
}
private Object getSchemaURI(String project, String repository, String
schema) {
- return
uriInfo.getBaseUriBuilder().path(this.getClass()).path(project)
+ return
UriBuilder.fromUri(baseURI).path(this.getClass()).path(project)
.path(repository).path("schema").path(schema).toString();
}
private String getProjectURI(String project) {
- return
uriInfo.getBaseUriBuilder().path(this.getClass()).path(project)
+ return
UriBuilder.fromUri(baseURI).path(this.getClass()).path(project)
.toString();
}
-
private String getRepositoryURI(String project, String repository) {
- return
uriInfo.getBaseUriBuilder().path(this.getClass()).path(project)
+ return
UriBuilder.fromUri(baseURI).path(this.getClass()).path(project)
.path(repository).toString();
}
Modified: trunk/java/ch/idok/service/server/rest/RestServer.java
==============================================================================
--- trunk/java/ch/idok/service/server/rest/RestServer.java (original)
+++ trunk/java/ch/idok/service/server/rest/RestServer.java Thu Sep 25
16:50:40 2008
@@ -124,4 +124,17 @@
logger.info("REST server stopped");
}
+ /**
+ * @return Base URI to be used for hrefs in the response entity
+ * @throws DmsException
+ */
+ public String getBaseURI() throws DmsException {
+ String uri = System.getProperty("ch.idok.service.rest.baseURI");
+ if (uri != null)
+ return uri;
+ else
+ throw new DmsException(ErrorType.MISSING_PROPERTY, null,
+ "Property ch.idok.service.rest.baseURI not set", null);
+ }
+
}
- [idok-commit] idok commit r254 - in trunk/java/ch/idok/service/server: admin/rest rest, AFS account Florian Huebner, 09/25/2008
Archive powered by MHonArc 2.6.19.