import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import javax.ws.rs.core.MultivaluedHashMap;
import org.collectionspace.services.client.IClientQueryParams;
import org.collectionspace.services.client.IQueryManager;
import org.collectionspace.services.common.ServiceMain;
import org.collectionspace.services.common.ServiceMessages;
import org.collectionspace.services.common.StoredValuesUriTemplate;
+import org.collectionspace.services.common.UriInfoWrapper;
import org.collectionspace.services.common.UriTemplateFactory;
import org.collectionspace.services.common.UriTemplateRegistry;
import org.collectionspace.services.common.UriTemplateRegistryKey;
@Path("{csid}/sync")
public byte[] synchronize(
@Context Request request,
- @Context UriInfo ui,
+ @Context UriInfo uriInfo,
@PathParam("csid") String identifier) {
+ uriInfo = new UriInfoWrapper(uriInfo);
byte[] result;
boolean neededSync = false;
PoxPayloadOut payloadOut = null;
//
synchronized(AuthorityResource.class) {
try {
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
/*
* Make sure this authority service supports synchronization
*/
@Override
public byte[] get(
@Context Request request,
- @Context UriInfo ui,
+ @Context UriInfo uriInfo,
@PathParam("csid") String specifier) {
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
Specifier spec = Specifier.getSpecifier(specifier, "getAuthority", "GET");
@GET
@Produces("application/xml")
public AbstractCommonList getAuthorityList(@Context UriInfo uriInfo) { //FIXME - REM 5/3/2012 - This is not reachable from the JAX-RS dispatcher. Instead the equivalent method in ResourceBase is getting called.
+ uriInfo = new UriInfoWrapper(uriInfo);
AbstractCommonList result = null;
try {
@Path("{csid}")
public Response deleteAuthority(
@Context Request request,
- @Context UriInfo ui,
+ @Context UriInfo uriInfo,
@PathParam("csid") String specifier) {
+ uriInfo = new UriInfoWrapper(uriInfo);
+
if (logger.isDebugEnabled()) {
logger.debug("deleteAuthority with specifier=" + specifier);
}
try {
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
Specifier spec = Specifier.getSpecifier(specifier, "getAuthority", "GET");
@Context UriInfo uriInfo,
@PathParam("csid") String parentIdentifier, // Either a CSID or a URN form -e.g., a8ad38ec-1d7d-4bf2-bd31 or urn:cspace:name(bugsbunny)
String xmlPayload) {
+ uriInfo = new UriInfoWrapper(uriInfo);
Response result = null;
try {
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier,
@PathParam("transition") String transition) {
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
@Context ResourceMap resourceMap,
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier) {
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx =
@Produces("application/xml")
public AbstractCommonList getAuthorityItemList(@PathParam("csid") String authorityIdentifier,
@Context UriInfo uriInfo) {
+ uriInfo = new UriInfoWrapper(uriInfo);
AbstractCommonList result = null;
try {
@PathParam("itemcsid") String itemSpecifier,
@Context UriTemplateRegistry uriTemplateRegistry,
@Context UriInfo uriInfo) {
+ uriInfo = new UriInfoWrapper(uriInfo);
AuthorityRefDocList authRefDocList = null;
try {
authRefDocList = getReferencingObjects(null, parentSpecifier, itemSpecifier, uriTemplateRegistry, uriInfo);
String itemspecifier,
UriTemplateRegistry uriTemplateRegistry,
UriInfo uriInfo) throws Exception {
+ uriInfo = new UriInfoWrapper(uriInfo);
AuthorityRefDocList authRefDocList = null;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
String parentcsid = lookupParentCSID(ctx, parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", uriInfo);
String itemcsid = lookupItemCSID(ctx, itemspecifier, parentcsid, "getReferencingObjects(item)", "GET_ITEM_REF_OBJS");
-
- // RESTEasy returns a read-only set of query params, so we need to make a read-write copy of them
- MultivaluedHashMap<String, String> tmpQueryParams = new MultivaluedHashMap<String, String>();
- tmpQueryParams.putAll(queryParams);
- // Set the original query params to the new copy
- queryParams = tmpQueryParams;
- // Update the service context with the new copy
- ctx.setQueryParams(queryParams);
// Remove the "type" property from the query params
List<String> serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
@PathParam("csid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier,
@Context UriInfo uriInfo) {
+ uriInfo = new UriInfoWrapper(uriInfo);
AuthorityRefList authRefList = null;
try {
@Context UriInfo uriInfo,
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier) {
+ uriInfo = new UriInfoWrapper(uriInfo);
byte[] result;
boolean neededSync = false;
PoxPayloadOut payloadOut = null;
@PathParam("csid") String parentSpecifier,
@PathParam("itemcsid") String itemSpecifier,
String xmlPayload) {
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
@Context UriInfo uriInfo,
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier) {
+ uriInfo = new UriInfoWrapper(uriInfo);
Response result = null;
ensureCSID(parentIdentifier, ServiceMessages.DELETE_FAILED, "AuthorityItem.parentcsid");
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier,
@Context UriInfo uriInfo) throws Exception {
+ uriInfo = new UriInfoWrapper(uriInfo);
String result = null;
try {
--- /dev/null
+package org.collectionspace.services.common;
+
+import java.net.URI;
+import java.util.List;
+
+import javax.ws.rs.core.MultivaluedHashMap;
+import javax.ws.rs.core.MultivaluedMap;
+import javax.ws.rs.core.PathSegment;
+import javax.ws.rs.core.UriBuilder;
+import javax.ws.rs.core.UriInfo;
+
+/**
+ *
+ * @author remillet
+ *
+ * The older versions of RESTEasy allowed us to modify the query parameters passed into us from the UriInfo class. There
+ * are many places in the existing code that rely on changes to the query parameters. But more recent versions of RESTEasy
+ * pass us a read-only copy of the query parameters. Therefore, this wrapper class allows us to provide the existing code
+ * a read-write copy of the query parameters.
+ *
+ */
+public class UriInfoWrapper implements UriInfo {
+ //
+ // Construct the UriInfoWrapper from a UriInfo instance
+ //
+ public UriInfoWrapper(UriInfo uriInfo) {
+ this.uriInfo = uriInfo;
+ // RESTEasy returns a read-only set of query params, so we need to make a read-write copy of them
+ queryParams.putAll(uriInfo.getQueryParameters());
+ }
+
+ private UriInfo uriInfo;
+ private MultivaluedHashMap<String, String> queryParams = new MultivaluedHashMap<String, String>();
+
+ @Override
+ public URI getAbsolutePath() {
+ return uriInfo.getAbsolutePath();
+ }
+
+ @Override
+ public UriBuilder getAbsolutePathBuilder() {
+ return uriInfo.getAbsolutePathBuilder();
+ }
+
+ @Override
+ public URI getBaseUri() {
+ return uriInfo.getBaseUri();
+ }
+
+ @Override
+ public UriBuilder getBaseUriBuilder() {
+ return uriInfo.getBaseUriBuilder();
+ }
+
+ @Override
+ public List<Object> getMatchedResources() {
+ return uriInfo.getMatchedResources();
+ }
+
+ @Override
+ public List<String> getMatchedURIs() {
+ return uriInfo.getMatchedURIs();
+ }
+
+ @Override
+ public List<String> getMatchedURIs(boolean arg0) {
+ return uriInfo.getMatchedURIs(arg0);
+ }
+
+ @Override
+ public String getPath() {
+ return uriInfo.getPath();
+ }
+
+ @Override
+ public String getPath(boolean arg0) {
+ return uriInfo.getPath();
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getPathParameters() {
+ return uriInfo.getPathParameters();
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getPathParameters(boolean arg0) {
+ return uriInfo.getPathParameters(arg0);
+ }
+
+ @Override
+ public List<PathSegment> getPathSegments() {
+ return uriInfo.getPathSegments();
+ }
+
+ @Override
+ public List<PathSegment> getPathSegments(boolean arg0) {
+ return uriInfo.getPathSegments(arg0);
+ }
+
+ @Override
+ public MultivaluedMap<String, String> getQueryParameters() {
+ return this.queryParams;
+ }
+
+ /**
+ * Not implemented.
+ *
+ */
+ @Override
+ public MultivaluedMap<String, String> getQueryParameters(boolean arg0) {
+ throw new java.lang.UnsupportedOperationException();
+ }
+
+ @Override
+ public URI getRequestUri() {
+ return uriInfo.getRequestUri();
+ }
+
+ @Override
+ public UriBuilder getRequestUriBuilder() {
+ return uriInfo.getRequestUriBuilder();
+ }
+
+ @Override
+ public URI relativize(URI arg0) {
+ return uriInfo.relativize(arg0);
+ }
+
+ @Override
+ public URI resolve(URI arg0) {
+ return uriInfo.resolve(arg0);
+ }
+
+}