From 2833e3ac75c6efc39c27625131e5a9e8e8859639 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Mon, 10 Sep 2012 08:43:11 -0700 Subject: [PATCH] CSPACE-5518: More changes to service context setup to support existing hierarchy creation code that was moved into the common base class. --- .../common/vocabulary/AuthorityResource.java | 98 ++++++++++--------- .../AbstractCollectionSpaceResourceImpl.java | 71 +++++--------- .../services/common/ResourceBase.java | 2 +- .../MultipartServiceContextFactory.java | 9 +- .../context/MultipartServiceContextImpl.java | 5 +- .../context/RemoteServiceContextFactory.java | 9 +- .../context/RemoteServiceContextImpl.java | 9 +- .../common/context/ServiceContextFactory.java | 5 +- .../AuthorityResourceWithContacts.java | 12 ++- .../services/media/MediaResource.java | 5 +- 10 files changed, 111 insertions(+), 114 deletions(-) diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index c8f304b5a..e7a862fd6 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -265,13 +265,16 @@ public abstract class AuthorityResource String shortIdentifier; } - protected String lookupParentCSID(String parentspecifier, String method, String op, MultivaluedMap queryParams) - throws Exception { - CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(parentspecifier, method, op, queryParams); - return tempResult.CSID; - } + protected String lookupParentCSID(String parentspecifier, String method, + String op, UriInfo uriInfo) throws Exception { + CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer( + parentspecifier, method, op, uriInfo); + return tempResult.CSID; + } - private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer(String parentspecifier, String method, String op, MultivaluedMap queryParams) + private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer(String parentspecifier, + String method, String op, + UriInfo uriInfo) throws Exception { CsidAndShortIdentifier result = new CsidAndShortIdentifier(); Specifier parentSpec = getSpecifier(parentspecifier, method, op); @@ -287,7 +290,7 @@ public abstract class AuthorityResource } else { parentShortIdentifier = parentSpec.value; String whereClause = buildWhereForAuthByName(parentSpec.value); - ServiceContext ctx = createServiceContext(getServiceName(), queryParams); + ServiceContext ctx = createServiceContext(getServiceName(), uriInfo); parentcsid = getRepositoryClient(ctx).findDocCSID(null, ctx, whereClause); //FIXME: REM - If the parent has been soft-deleted, should we be looking for the item? } result.CSID = parentcsid; @@ -422,10 +425,13 @@ public abstract class AuthorityResource */ @GET @Produces("application/xml") - public AbstractCommonList getAuthorityList(@Context UriInfo ui) { //FIXME - REM 5/3/2012 - This is not reachable from the JAX-RS dispatcher. Instead the equivalent method in ResourceBase is getting called. - try { - MultivaluedMap queryParams = ui.getQueryParameters(); - ServiceContext ctx = createServiceContext(ui); + 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. + AbstractCommonList result = null; + + try { + MultivaluedMap queryParams = uriInfo.getQueryParameters(); + ServiceContext ctx = createServiceContext(uriInfo); + DocumentHandler handler = createDocumentHandler(ctx); DocumentFilter myFilter = handler.getDocumentFilter(); // Need to make the default sort order for authority items @@ -441,13 +447,14 @@ public abstract class AuthorityResource myFilter.setWhereClause(authorityCommonSchemaName + ":refName='" + nameQ + "'"); } getRepositoryClient(ctx).getFiltered(ctx, handler); - return handler.getCommonPartList(); + result = handler.getCommonPartList(); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.GET_FAILED); } + + return result; } - /** * Update authority. * @@ -512,25 +519,30 @@ public abstract class AuthorityResource *************************************************************************/ @POST @Path("{csid}/items") - public Response createAuthorityItem(@Context ResourceMap resourceMap, @Context UriInfo ui, - @PathParam("csid") String specifier, String xmlPayload) { + public Response createAuthorityItem( + @Context ResourceMap resourceMap, + @Context UriInfo uriInfo, + @PathParam("csid") String specifier, + String xmlPayload) { + Response result = null; + try { PoxPayloadIn input = new PoxPayloadIn(xmlPayload); - ServiceContext ctx = createServiceContext(getItemServiceName(), input); - ctx.setResourceMap(resourceMap); - ctx.setUriInfo(ui); + ServiceContext ctx = createServiceContext(getItemServiceName(), input, resourceMap, uriInfo); // Note: must have the parentShortId, to do the create. CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(specifier, "createAuthorityItem", "CREATE_ITEM", null); - DocumentHandler handler = createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier); + DocumentHandler handler = + createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier); String itemcsid = getRepositoryClient(ctx).create(ctx, handler); UriBuilder path = UriBuilder.fromResource(resourceClass); path.path(parent.CSID + "/items/" + itemcsid); - Response response = Response.created(path.build()).build(); - return response; + result = Response.created(path.build()).build(); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.CREATE_FAILED); } + + return result; } @GET @@ -607,19 +619,18 @@ public abstract class AuthorityResource @Path("{csid}/items/{itemcsid}") public byte[] getAuthorityItem( @Context Request request, - @Context UriInfo ui, + @Context UriInfo uriInfo, @Context ResourceMap resourceMap, @PathParam("csid") String parentspecifier, @PathParam("itemcsid") String itemspecifier) { PoxPayloadOut result = null; try { - MultivaluedMap queryParams = ui.getQueryParameters(); - String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItem(parent)", "GET_ITEM", queryParams); + String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItem(parent)", "GET_ITEM", uriInfo); - RemoteServiceContext ctx = null; - ctx = (RemoteServiceContext) createServiceContext(getItemServiceName(), resourceMap, ui); + RemoteServiceContext ctx = + (RemoteServiceContext) createServiceContext(getItemServiceName(), resourceMap, uriInfo); - JaxRsContext jaxRsContext = new JaxRsContext(request, ui); // REM - Why are we setting this? Who is using the getter? + JaxRsContext jaxRsContext = new JaxRsContext(request, uriInfo); // REM - Why are we setting this? Who is using the getter? ctx.setJaxRsContext(jaxRsContext); // We omit the parentShortId, only needed when doing a create... @@ -690,22 +701,23 @@ public abstract class AuthorityResource @Path("{csid}/items") @Produces("application/xml") public AbstractCommonList getAuthorityItemList(@PathParam("csid") String specifier, - @Context UriInfo ui) { + @Context UriInfo uriInfo) { AbstractCommonList result = null; try { - MultivaluedMap queryParams = ui.getQueryParameters(); + ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); + MultivaluedMap queryParams = ctx.getQueryParams(); + String orderBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM); String termStatus = queryParams.getFirst(SEARCH_TYPE_TERMSTATUS); String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW); String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS); String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM); - ServiceContext ctx = createServiceContext(getItemServiceName(), queryParams); // For the wildcard case, parentcsid is null, but docHandler will deal with this. // We omit the parentShortId, only needed when doing a create... String parentcsid = PARENT_WILDCARD.equals(specifier) ? null : - lookupParentCSID(specifier, "getAuthorityItemList", "LIST", queryParams); + lookupParentCSID(specifier, "getAuthorityItemList", "LIST", uriInfo); DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, null); @@ -727,7 +739,7 @@ public abstract class AuthorityResource myFilter.appendWhereClause(tsClause, IQueryManager.SEARCH_QUALIFIER_AND); } - result = search(ctx, handler, queryParams, orderBy, keywords, advancedSearch, partialTerm); + result = search(ctx, handler, uriInfo, orderBy, keywords, advancedSearch, partialTerm); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.LIST_FAILED); } @@ -762,14 +774,13 @@ public abstract class AuthorityResource public AuthorityRefDocList getReferencingObjects( @PathParam("csid") String parentspecifier, @PathParam("itemcsid") String itemspecifier, - @Context UriInfo ui) { + @Context UriInfo uriInfo) { AuthorityRefDocList authRefDocList = null; try { - MultivaluedMap queryParams = ui.getQueryParameters(); - - String parentcsid = lookupParentCSID(parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", queryParams); + ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); + MultivaluedMap queryParams = ctx.getQueryParams(); - ServiceContext ctx = createServiceContext(getItemServiceName(), queryParams); + String parentcsid = lookupParentCSID(parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", uriInfo); String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getReferencingObjects(item)", "GET_ITEM_REF_OBJS", ctx); List serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP); @@ -810,19 +821,16 @@ public abstract class AuthorityResource public AuthorityRefList getAuthorityItemAuthorityRefs( @PathParam("csid") String parentspecifier, @PathParam("itemcsid") String itemspecifier, - @Context UriInfo ui) { + @Context UriInfo uriInfo) { AuthorityRefList authRefList = null; try { // Note that we have to create the service context for the Items, not the main service - MultivaluedMap queryParams = ui.getQueryParameters(); - ServiceContext ctx = null; - - String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItemAuthRefs(parent)", "GET_ITEM_AUTH_REFS", queryParams); - - ctx = createServiceContext(getItemServiceName(), queryParams); + ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo); + MultivaluedMap queryParams = ctx.getQueryParams(); + String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItemAuthRefs(parent)", "GET_ITEM_AUTH_REFS", uriInfo); // We omit the parentShortId, only needed when doing a create... DocumentModelHandler handler = - (DocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, null); + (DocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, null /*no parent short ID*/); String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getAuthorityItemAuthRefs(item)", "GET_ITEM_AUTH_REFS", ctx); diff --git a/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java b/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java index ed5cd247c..1388e31c8 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java @@ -160,7 +160,7 @@ public abstract class AbstractCollectionSpaceResourceImpl ServiceContext ctx = createServiceContext(this.getServiceName(), (IT)null, //inputType null, // The resource map - (MultivaluedMap)null, // The query params + (UriInfo)null, // The query params this.getCommonPartClass()); return ctx; } @@ -179,7 +179,7 @@ public abstract class AbstractCollectionSpaceResourceImpl serviceName, (IT)null, // The input part null, // The resource map - (MultivaluedMap)null, // The queryParams + (UriInfo)null, // The queryParams (Class)null /*input type's Class*/); return ctx; } @@ -189,7 +189,7 @@ public abstract class AbstractCollectionSpaceResourceImpl serviceName, (IT)null, // The input part null, // The resource map - (MultivaluedMap)null, // The queryParams + (UriInfo)null, // The queryParams (Class)null /*input type's Class*/); ctx.setUriInfo(ui); return ctx; @@ -210,35 +210,16 @@ public abstract class AbstractCollectionSpaceResourceImpl ServiceContext ctx = createServiceContext(serviceName, input, null, // The resource map - (MultivaluedMap)null, /*queryParams*/ + (UriInfo)null, /*queryParams*/ (Class)null /*input type's Class*/); return ctx; } - /** - * Creates the service context. - * - * @param serviceName the service name - * @return the service context< i t, o t> - * @throws Exception the exception - */ - protected ServiceContext createServiceContext(String serviceName, - MultivaluedMap queryParams) throws Exception { - ServiceContext ctx = createServiceContext(serviceName, - (IT)null, - null, // The resource map - queryParams, - (Class)null /*input type's Class*/); - return ctx; - } - - protected ServiceContext createServiceContext(UriInfo ui) throws Exception { - MultivaluedMap queryParams = ui.getQueryParameters(); + protected ServiceContext createServiceContext(UriInfo uriInfo) throws Exception { ServiceContext ctx = createServiceContext( (IT)null, /*input*/ - queryParams, + uriInfo, (Class)null /*input type's Class*/); - ctx.setUriInfo(ui); return ctx; } @@ -271,7 +252,7 @@ public abstract class AbstractCollectionSpaceResourceImpl protected ServiceContext createServiceContext(IT input, Class theClass) throws Exception { ServiceContext ctx = createServiceContext( input, - (MultivaluedMap)null, //queryParams, + (UriInfo)null, //queryParams, theClass); return ctx; } @@ -279,41 +260,43 @@ public abstract class AbstractCollectionSpaceResourceImpl protected ServiceContext createServiceContext( String serviceName, ResourceMap resourceMap, - UriInfo ui) throws Exception { + UriInfo uriInfo) throws Exception { ServiceContext ctx = createServiceContext( serviceName, null, // The input object resourceMap, - ui.getQueryParameters(), + uriInfo, null /* the class of the input type */); - ctx.setUriInfo(ui); return ctx; } protected ServiceContext createServiceContext( IT input, ResourceMap resourceMap, - UriInfo ui) throws Exception { + UriInfo uriInfo) throws Exception { ServiceContext ctx = createServiceContext( this.getServiceName(), input, resourceMap, - ui.getQueryParameters(), + uriInfo, null /* the class of the input type */); - ctx.setUriInfo(ui); return ctx; } - + protected ServiceContext createServiceContext( + String serviceName, IT input, - MultivaluedMap queryParams) throws Exception { - return createServiceContext(this.getServiceName(), + ResourceMap resourceMap, + UriInfo uriInfo) throws Exception { + ServiceContext ctx = createServiceContext( + serviceName, input, - null, // The resource map - queryParams, - null); // The class of the input type. + resourceMap, + uriInfo, + null /* the class of the input type */); + return ctx; } - + /** * Creates the service context. * @@ -325,14 +308,14 @@ public abstract class AbstractCollectionSpaceResourceImpl * * @throws Exception the exception */ - protected ServiceContext createServiceContext( + private ServiceContext createServiceContext( IT input, - MultivaluedMap queryParams, + UriInfo uriInfo, Class theClass) throws Exception { return createServiceContext(this.getServiceName(), input, null, // The resource map - queryParams, + uriInfo, theClass); } @@ -352,13 +335,13 @@ public abstract class AbstractCollectionSpaceResourceImpl String serviceName, IT input, ResourceMap resourceMap, - MultivaluedMap queryParams, + UriInfo uriInfo, Class theClass) throws Exception { ServiceContext ctx = getServiceContextFactory().createServiceContext( serviceName, input, resourceMap, - queryParams, + uriInfo, theClass != null ? theClass.getPackage().getName() : null, theClass != null ? theClass.getName() : null); if (theClass != null) { diff --git a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java index 3cf450ea5..3d0c57675 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ResourceBase.java @@ -292,7 +292,7 @@ public abstract class ResourceBase String keywords = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_KW); String advancedSearch = queryParams.getFirst(IQueryManager.SEARCH_TYPE_KEYWORDS_AS); String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM); - list = search(queryParams, orderBy, keywords, advancedSearch, partialTerm); + list = search(ui, orderBy, keywords, advancedSearch, partialTerm); } else { list = getCommonList(ui); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextFactory.java b/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextFactory.java index c98bc8fd9..0b8df0143 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextFactory.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextFactory.java @@ -24,6 +24,7 @@ package org.collectionspace.services.common.context; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; @@ -82,12 +83,12 @@ public class MultipartServiceContextFactory String serviceName, PoxPayloadIn input, ResourceMap resourceMap, - MultivaluedMap queryParams) + UriInfo uriInfo) throws Exception { ServiceContext ctx = new MultipartServiceContextImpl(serviceName, input, resourceMap, - queryParams); + uriInfo); return ctx; } @@ -99,9 +100,9 @@ public class MultipartServiceContextFactory String serviceName, PoxPayloadIn input, ResourceMap resourceMap, - MultivaluedMap queryParams, + UriInfo uriInfo, String documentType, String entityName) throws Exception { - return this.createServiceContext(serviceName, input, resourceMap, queryParams); + return this.createServiceContext(serviceName, input, resourceMap, uriInfo); } } diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java index 1faa6097c..7c786735c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java @@ -28,6 +28,7 @@ import java.io.IOException; import java.io.InputStream; import java.lang.reflect.Constructor; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; import org.collectionspace.services.client.PayloadInputPart; import org.collectionspace.services.client.PayloadOutputPart; @@ -96,9 +97,9 @@ public class MultipartServiceContextImpl String serviceName, PoxPayloadIn theInput, ResourceMap resourceMap, - MultivaluedMap queryParams) + UriInfo uriInfo) throws DocumentException, UnauthorizedException { - super(serviceName, theInput, resourceMap, queryParams); + super(serviceName, theInput, resourceMap, uriInfo); setOutput(new PoxPayloadOut(serviceName)); } diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java index ac9a4e76f..93272ac84 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java @@ -27,6 +27,7 @@ package org.collectionspace.services.common.context; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; import org.collectionspace.services.common.ResourceMap; @@ -82,11 +83,11 @@ public class RemoteServiceContextFactory String serviceName, IT theInput, ResourceMap resourceMap, - MultivaluedMap queryParams) throws Exception { + UriInfo uriInfo) throws Exception { ServiceContext ctx = new RemoteServiceContextImpl(serviceName, theInput, resourceMap, - queryParams); + uriInfo); return ctx; } @@ -95,14 +96,14 @@ public class RemoteServiceContextFactory public ServiceContext createServiceContext(String serviceName, IT input, ResourceMap resourceMap, - MultivaluedMap queryParams, + UriInfo uriInfo, String documentType, String entityName) throws Exception { ServiceContext ctx = createServiceContext( serviceName, input, resourceMap, - queryParams); + uriInfo); ctx.setDocumentType(documentType); //persistence unit ctx.setProperty(ServiceContextProperties.ENTITY_NAME, entityName); return ctx; diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java index 50c1a704c..614ad665c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java @@ -24,11 +24,11 @@ package org.collectionspace.services.common.context; import java.lang.reflect.Constructor; - -import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.security.UnauthorizedException; + import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -99,10 +99,11 @@ public class RemoteServiceContextImpl protected RemoteServiceContextImpl(String serviceName, IT theInput, ResourceMap resourceMap, - MultivaluedMap queryParams) throws UnauthorizedException { + UriInfo uriInfo) throws UnauthorizedException { this(serviceName, theInput); this.setResourceMap(resourceMap); - this.setQueryParams(queryParams); + this.setUriInfo(uriInfo); + this.setQueryParams(uriInfo.getQueryParameters()); } /* (non-Javadoc) diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContextFactory.java b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContextFactory.java index dcaa909a6..bcc5e79a8 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContextFactory.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContextFactory.java @@ -24,6 +24,7 @@ package org.collectionspace.services.common.context; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.UriInfo; import org.collectionspace.services.common.ResourceMap; @@ -72,7 +73,7 @@ public interface ServiceContextFactory { String serviceName, IT input, ResourceMap resourceMap, - MultivaluedMap queryParams) throws Exception; + UriInfo uriInfo) throws Exception; /** * Creates a new ServiceContext object. @@ -91,7 +92,7 @@ public interface ServiceContextFactory { String serviceName, IT input, ResourceMap resourceMap, - MultivaluedMap queryParams, + UriInfo uriInfo, String documentType, String entityName) throws Exception; } diff --git a/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java b/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java index cd2c047a0..76158bfdd 100644 --- a/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java +++ b/services/contact/service/src/main/java/org/collectionspace/services/contact/AuthorityResourceWithContacts.java @@ -150,17 +150,18 @@ public abstract class AuthorityResourceWithContacts public AbstractCommonList getContactList( @PathParam("parentcsid") String parentspecifier, @PathParam("itemcsid") String itemspecifier, - @Context UriInfo ui) { + @Context UriInfo uriInfo) { AbstractCommonList contactObjectList = new AbstractCommonList(); + try { + ServiceContext ctx = createServiceContext(getContactServiceName(), uriInfo); + MultivaluedMap queryParams = ctx.getQueryParams(); + String parentcsid = lookupParentCSID(parentspecifier, "getContactList(parent)", "GET_CONTACT_LIST", null); - ServiceContext itemCtx = createServiceContext(getItemServiceName()); String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "getContactList(item)", "GET_CONTACT_LIST", itemCtx); - MultivaluedMap queryParams = ui.getQueryParameters(); - ServiceContext ctx = createServiceContext(getContactServiceName(), queryParams); - DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid, ui); + DocumentHandler handler = createContactDocumentHandler(ctx, parentcsid, itemcsid, uriInfo); DocumentFilter myFilter = handler.getDocumentFilter(); //new DocumentFilter(); myFilter.appendWhereClause(ContactJAXBSchema.CONTACTS_COMMON + ":" + ContactJAXBSchema.IN_AUTHORITY @@ -178,6 +179,7 @@ public abstract class AuthorityResourceWithContacts + parentspecifier + ": and item:" + itemspecifier + ": was not found.", itemspecifier); } + return contactObjectList; } diff --git a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java index eaa97f7c0..4e44778b6 100644 --- a/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java +++ b/services/media/service/src/main/java/org/collectionspace/services/media/MediaResource.java @@ -120,13 +120,12 @@ public class MediaResource extends ResourceBase { * Creates a new media record/resource AND creates a new blob (using a URL pointing to a media file/resource) and associates * it with the new media record/resource. */ - protected Response createBlobWithUri(ResourceMap resourceMap, UriInfo ui, String xmlPayload, String blobUri) { + protected Response createBlobWithUri(ResourceMap resourceMap, UriInfo uriInfo, String xmlPayload, String blobUri) { Response response = null; try { - MultivaluedMap queryParams = ui.getQueryParameters(); ServiceContext ctx = createServiceContext(BlobClient.SERVICE_NAME, - queryParams); + uriInfo); BlobInput blobInput = BlobUtil.getBlobInput(ctx); // the blob doc handler will look for this in the context blobInput.createBlobFile(blobUri); // The blobUri argument is our payload response = this.create((PoxPayloadIn)null, ctx); // By now the binary bits have been created and we just need to create the metadata blob record -this info is in the blobInput var -- 2.47.3