<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xmlReplay>
-
- <testGroup ID="HierarchicCollectionObject" autoDeletePOSTS="false">
<testGroup ID="CreateCollectionObjects"> <!-- autoDeletePOSTS="true" -->
@DELETE
@Path("{csid}")
- public Response deleteAccount(@PathParam("csid") String csid) {
+ public Response deleteAccount(@Context UriInfo uriInfo, @PathParam("csid") String csid) {
logger.debug("deleteAccount with csid=" + csid);
ensureCSID(csid, ServiceMessages.DELETE_FAILED);
try {
AccountRoleSubResource subResource = new AccountRoleSubResource("accounts/accountroles");
subResource.deleteAccountRole(csid, SubjectType.ROLE);
ServiceContext<AccountsCommon, AccountsCommon> ctx = createServiceContext((AccountsCommon) null,
- AccountsCommon.class);
+ AccountsCommon.class, uriInfo);
getStorageClient(ctx).delete(ctx, csid);
return Response.status(HttpResponseCodes.SC_OK).build();
} catch (Exception e) {
return ctx;\r
}\r
\r
+ protected ServiceContext<IT, OT> createServiceContext(String serviceName,\r
+ IT input,\r
+ UriInfo uriInfo) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(serviceName,\r
+ input,\r
+ null, // The resource map\r
+ uriInfo, /*queryParams*/\r
+ (Class<?>)null /*input type's Class*/);\r
+ return ctx;\r
+ }\r
+ \r
protected ServiceContext<IT, OT> createServiceContext(UriInfo uriInfo) throws Exception {\r
ServiceContext<IT, OT> ctx = createServiceContext(\r
(IT)null, /*input*/\r
return ctx;\r
}\r
\r
+ protected ServiceContext<IT, OT> createServiceContext(IT input, UriInfo uriInfo) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ input,\r
+ uriInfo,\r
+ null ); // The class param/argument\r
+ return ctx;\r
+ } \r
+ \r
/**\r
* Creates the service context.\r
* \r
return ctx;\r
}\r
\r
+ protected ServiceContext<IT, OT> createServiceContext(IT input, Class<?> theClass, UriInfo uriInfo) throws Exception { \r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ input,\r
+ uriInfo,\r
+ theClass);\r
+ return ctx;\r
+ }\r
+ \r
protected ServiceContext<IT, OT> createServiceContext(\r
String serviceName,\r
ResourceMap resourceMap,\r
import javax.ws.rs.PUT;\r
import javax.ws.rs.Path;\r
import javax.ws.rs.PathParam;\r
+import javax.ws.rs.core.Context;\r
+import javax.ws.rs.core.UriInfo;\r
\r
import org.collectionspace.services.client.PayloadOutputPart;\r
import org.collectionspace.services.client.PoxPayloadIn;\r
*/\r
@GET\r
@Path(WorkflowClient.SERVICE_PATH)\r
- public Lifecycle getWorkflow() {\r
+ public Lifecycle getWorkflow(@Context UriInfo uriInfo) {\r
Lifecycle result;\r
\r
String documentType = "undefined";\r
MultipartServiceContext ctx = null;\r
try {\r
- ctx = (MultipartServiceContext) createServiceContext();\r
+ ctx = (MultipartServiceContext) createServiceContext(uriInfo);\r
DocumentHandler handler = ctx.getDocumentHandler();\r
result = handler.getLifecycle();\r
} catch (Exception e) {\r
@GET\r
@Path("{csid}" + WorkflowClient.SERVICE_PATH)\r
public byte[] getWorkflow(\r
+ @Context UriInfo uriInfo,\r
@PathParam("csid") String csid) {\r
PoxPayloadOut result = null;\r
\r
try {\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext();\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext(uriInfo);\r
String parentWorkspaceName = parentCtx.getRepositoryWorkspaceName();\r
\r
- MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(WorkflowClient.SERVICE_NAME);\r
+ MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(WorkflowClient.SERVICE_NAME, uriInfo);\r
WorkflowDocumentModelHandler handler = createWorkflowDocumentHandler(ctx);\r
ctx.setRespositoryWorkspaceName(parentWorkspaceName); //find the document in the parent's workspace\r
getRepositoryClient(ctx).get(ctx, csid, handler);\r
\r
@PUT\r
@Path("{csid}" + WorkflowClient.SERVICE_PATH + "/" + "{transition}")\r
- public byte[] updateWorkflowWithTransition(@PathParam("csid") String csid,\r
+ public byte[] updateWorkflowWithTransition(\r
+ @Context UriInfo uriInfo,\r
+ @PathParam("csid") String csid,\r
@PathParam("transition") String transition) {\r
PoxPayloadOut result = null;\r
- \r
- \r
+ \r
try {\r
//\r
// Create an empty workflow_commons input part and set it into a new "workflow" sub-resource context\r
PoxPayloadIn input = new PoxPayloadIn(WorkflowClient.SERVICE_PAYLOAD_NAME, new WorkflowCommon(), \r
WorkflowClient.SERVICE_COMMONPART_NAME);\r
- MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(WorkflowClient.SERVICE_NAME, input);\r
+ MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(WorkflowClient.SERVICE_NAME, input, uriInfo);\r
\r
// Create a service context and document handler for the parent resource.\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext();\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext(uriInfo);\r
DocumentHandler parentDocHandler = this.createDocumentHandler(parentCtx); \r
ctx.setProperty(WorkflowClient.PARENT_DOCHANDLER, parentDocHandler); //added as a context param for the workflow document handler -it will call the parent's dochandler "prepareForWorkflowTranstion" method\r
\r
\r
public Response create(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx, // REM: 8/13/2012 - Some sub-classes will override this method -e.g., MediaResource does.\r
ResourceMap resourceMap,\r
- UriInfo ui,\r
+ UriInfo uriInfo,\r
String xmlPayload) {\r
Response result = null;\r
\r
try {\r
PoxPayloadIn input = new PoxPayloadIn(xmlPayload);\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input, resourceMap, ui);\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input, resourceMap, uriInfo);\r
ctx.setResourceMap(resourceMap);\r
if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) {\r
ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists\r
//======================= UPDATE ====================================================\r
@PUT\r
@Path("{csid}")\r
- public byte[] update(@Context ResourceMap resourceMap, @PathParam("csid") String csid, String xmlPayload) {\r
+ public byte[] update(@Context ResourceMap resourceMap,\r
+ @Context UriInfo uriInfo,\r
+ @PathParam("csid") String csid,\r
+ String xmlPayload) {\r
PoxPayloadOut result = null;\r
ensureCSID(csid, UPDATE);\r
try {\r
PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(theUpdate);\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(theUpdate, uriInfo);\r
ctx.setResourceMap(resourceMap);\r
result = update(csid, theUpdate, ctx); //==> CALL implementation method, which subclasses may override.\r
} catch (Exception e) {\r
@Path("{csid}")\r
public byte[] get(\r
@Context Request request, \r
- @Context UriInfo ui,\r
+ @Context UriInfo uriInfo,\r
@PathParam("csid") String csid) {\r
PoxPayloadOut result = null;\r
ensureCSID(csid, READ);\r
try {\r
- RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(ui);\r
+ RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(uriInfo);\r
result = get(csid, ctx);// ==> CALL implementation method, which subclasses may override.\r
if (result == null) {\r
Response response = Response.status(Response.Status.NOT_FOUND).entity(\r
return list;\r
}\r
\r
- protected AbstractCommonList getCommonList(UriInfo ui) {\r
+ protected AbstractCommonList getCommonList(UriInfo uriInfo) {\r
try {\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);\r
DocumentHandler handler = createDocumentHandler(ctx);\r
getRepositoryClient(ctx).getFiltered(ctx, handler);\r
AbstractCommonList list = (AbstractCommonList) handler.getCommonPartList();\r
}\r
\r
private AbstractCommonList search(\r
- UriInfo ui,\r
+ UriInfo uriInfo,\r
String orderBy,\r
String keywords,\r
String advancedSearch,\r
\r
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx;\r
try {\r
- ctx = createServiceContext(ui);\r
+ ctx = createServiceContext(uriInfo);\r
DocumentHandler handler = createDocumentHandler(ctx);\r
- result = search(ctx, handler, ui, orderBy, keywords, advancedSearch, partialTerm);\r
+ result = search(ctx, handler, uriInfo, orderBy, keywords, advancedSearch, partialTerm);\r
} catch (Exception e) {\r
throw bigReThrow(e, ServiceMessages.SEARCH_FAILED);\r
}\r
@Produces("application/xml")\r
public AuthorityRefList getAuthorityRefs(\r
@PathParam("csid") String csid,\r
- @Context UriInfo ui) {\r
+ @Context UriInfo uriInfo) {\r
AuthorityRefList authRefList = null;\r
try {\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);\r
DocumentModelHandler<PoxPayloadIn, PoxPayloadOut> handler = (DocumentModelHandler<PoxPayloadIn, PoxPayloadOut>) createDocumentHandler(ctx);\r
List<AuthRefConfigInfo> authRefsInfo = RefNameServiceUtils.getConfiguredAuthorityRefs(ctx);\r
authRefList = handler.getAuthorityRefs(csid, authRefsInfo);\r
this(serviceName, theInput);
this.setResourceMap(resourceMap);
this.setUriInfo(uriInfo);
- this.setQueryParams(uriInfo.getQueryParameters());
+ if (uriInfo != null) {
+ this.setQueryParams(uriInfo.getQueryParameters());
+ }
}
/* (non-Javadoc)