File below this line have been ported. -->\r
<!-- ============================================= -->\r
\r
+ <run controlFile="collectionobject/collectionobject-hierarchy.xml" testGroup="HierarchicCollectionObject" />\r
+ \r
+ \r
<run controlFile="./security.xml" testGroup="deleteBug" />\r
<run controlFile="objectexit/object-exit.xml" testGroup="makeone" />\r
<run controlFile="objectexit/object-exit.xml" testGroup="checkList" />\r
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
-import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriBuilder;
@GET
@Path("{csid}")
@Override
- public byte[] get( // getAuthority(
+ public byte[] get(
+ @Context Request request,
@Context UriInfo ui,
@PathParam("csid") String specifier) {
PoxPayloadOut result = null;
public byte[] getAuthorityItem(
@Context Request request,
@Context UriInfo ui,
+ @Context ResourceMap resourceMap,
@PathParam("csid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier) {
PoxPayloadOut result = null;
try {
- JaxRsContext jaxRsContext = new JaxRsContext(request, ui);
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItem(parent)", "GET_ITEM", queryParams);
RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = null;
- ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), queryParams);
+ ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), resourceMap, ui);
+
+ JaxRsContext jaxRsContext = new JaxRsContext(request, ui); // REM - Why are we setting this? Who is using the getter?
ctx.setJaxRsContext(jaxRsContext);
- ctx.setUriInfo(ui); //ARG! must pass this or subsequent calls will not have a ui.
-
// We omit the parentShortId, only needed when doing a create...
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
protected ServiceContext<IT, OT> createServiceContext() throws Exception { \r
ServiceContext<IT, OT> ctx = createServiceContext(this.getServiceName(),\r
(IT)null, //inputType\r
- (MultivaluedMap<String, String>)null, /*queryParams*/\r
+ null, // The resource map\r
+ (MultivaluedMap<String, String>)null, // The query params\r
this.getCommonPartClass());\r
return ctx;\r
} \r
protected ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception { \r
ServiceContext<IT, OT> ctx = createServiceContext(\r
serviceName,\r
- (IT)null, /*input*/\r
- (MultivaluedMap<String, String>)null, /*queryParams*/\r
+ (IT)null, // The input part\r
+ null, // The resource map\r
+ (MultivaluedMap<String, String>)null, // The queryParams\r
(Class<?>)null /*input type's Class*/);\r
return ctx;\r
}\r
*/\r
protected ServiceContext<IT, OT> createServiceContext(String serviceName,\r
IT input) throws Exception { \r
- ServiceContext<IT, OT> ctx = createServiceContext(serviceName, input,\r
+ ServiceContext<IT, OT> ctx = createServiceContext(serviceName,\r
+ input,\r
+ null, // The resource map\r
(MultivaluedMap<String, String>)null, /*queryParams*/\r
(Class<?>)null /*input type's Class*/);\r
return ctx;\r
MultivaluedMap<String, String> queryParams) throws Exception { \r
ServiceContext<IT, OT> ctx = createServiceContext(serviceName,\r
(IT)null,\r
+ null, // The resource map\r
queryParams,\r
(Class<?>)null /*input type's Class*/);\r
return ctx;\r
return ctx;\r
}\r
\r
+ protected ServiceContext<IT, OT> createServiceContext(\r
+ String serviceName,\r
+ ResourceMap resourceMap,\r
+ UriInfo ui) throws Exception {\r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ serviceName,\r
+ null, // The input object\r
+ resourceMap,\r
+ ui.getQueryParameters(),\r
+ null /* the class of the input type */);\r
+ ctx.setUriInfo(ui);\r
+ return ctx;\r
+ }\r
+ \r
+ protected ServiceContext<IT, OT> createServiceContext(\r
+ IT input,\r
+ ResourceMap resourceMap,\r
+ UriInfo ui) throws Exception {\r
+ ServiceContext<IT, OT> ctx = createServiceContext(\r
+ this.getServiceName(),\r
+ input,\r
+ resourceMap,\r
+ ui.getQueryParameters(),\r
+ null /* the class of the input type */);\r
+ ctx.setUriInfo(ui);\r
+ return ctx;\r
+ }\r
+\r
protected ServiceContext<IT, OT> createServiceContext(\r
IT input,\r
MultivaluedMap<String, String> queryParams) throws Exception {\r
return createServiceContext(this.getServiceName(),\r
input,\r
+ null, // The resource map\r
queryParams,\r
- null /* the class of the input type */);\r
+ null); // The class of the input type.\r
}\r
\r
/**\r
Class<?> theClass) throws Exception {\r
return createServiceContext(this.getServiceName(),\r
input,\r
+ null, // The resource map\r
queryParams,\r
theClass);\r
}\r
private ServiceContext<IT, OT> createServiceContext(\r
String serviceName,\r
IT input,\r
+ ResourceMap resourceMap,\r
MultivaluedMap<String, String> queryParams,\r
Class<?> theClass) throws Exception {\r
ServiceContext<IT, OT> ctx = getServiceContextFactory().createServiceContext(\r
serviceName,\r
input,\r
+ resourceMap,\r
queryParams,\r
theClass != null ? theClass.getPackage().getName() : null,\r
theClass != null ? theClass.getName() : null);\r
- if(theClass != null) {\r
+ if (theClass != null) {\r
ctx.setProperty(ServiceContextProperties.ENTITY_CLASS, theClass);\r
}\r
+ \r
return ctx;\r
}\r
\r
import org.collectionspace.services.common.api.Tools;\r
import org.collectionspace.services.common.authorityref.AuthorityRefList;\r
import org.collectionspace.services.common.config.ServiceConfigUtils;\r
+import org.collectionspace.services.common.context.JaxRsContext;\r
+import org.collectionspace.services.common.context.RemoteServiceContext;\r
import org.collectionspace.services.common.context.ServiceContext;\r
import org.collectionspace.services.common.document.DocumentFilter;\r
import org.collectionspace.services.common.document.DocumentHandler;\r
//======================= CREATE ====================================================\r
\r
@POST\r
- public Response create(@Context ResourceMap resourceMap,\r
+ public Response create(\r
+ @Context ResourceMap resourceMap,\r
@Context UriInfo ui,\r
String xmlPayload) {\r
return this.create(null, resourceMap, ui, xmlPayload); \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
- @Context ResourceMap resourceMap,\r
- @Context UriInfo ui,\r
+ ResourceMap resourceMap,\r
+ UriInfo ui,\r
String xmlPayload) {\r
Response result = null;\r
\r
try {\r
PoxPayloadIn input = new PoxPayloadIn(xmlPayload);\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input, ui.getQueryParameters());\r
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input, resourceMap, ui);\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
@GET\r
@Path("{csid}")\r
public byte[] get(\r
+ @Context Request request, \r
@Context UriInfo ui,\r
@PathParam("csid") String csid) {\r
PoxPayloadOut result = null;\r
ensureCSID(csid, READ);\r
try {\r
MultivaluedMap<String, String> queryParams = ui.getQueryParameters();\r
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);\r
+ RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(queryParams);\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
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
-import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
+import org.collectionspace.services.common.ResourceMap;
/**
*
* @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap)
*/
@Override
- public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(String serviceName,
- PoxPayloadIn input,
+ public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(
+ String serviceName,
+ PoxPayloadIn input,
+ ResourceMap resourceMap,
MultivaluedMap<String, String> queryParams)
throws Exception {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = new MultipartServiceContextImpl(serviceName,
input,
+ resourceMap,
queryParams);
return ctx;
}
* @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap, java.lang.String, java.lang.String)
*/
@Override
- public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(String serviceName,
+ public ServiceContext<PoxPayloadIn, PoxPayloadOut> createServiceContext(
+ String serviceName,
PoxPayloadIn input,
+ ResourceMap resourceMap,
MultivaluedMap<String, String> queryParams,
String documentType,
String entityName) throws Exception {
- return this.createServiceContext(serviceName, input, queryParams);
+ return this.createServiceContext(serviceName, input, resourceMap, queryParams);
}
}
import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
+import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.common.security.UnauthorizedException;
import org.dom4j.DocumentException;
import org.dom4j.Element;
*
* @throws UnauthorizedException the unauthorized exception
*/
- protected MultipartServiceContextImpl(String serviceName,
+ protected MultipartServiceContextImpl(
+ String serviceName,
PoxPayloadIn theInput,
+ ResourceMap resourceMap,
MultivaluedMap<String, String> queryParams)
throws DocumentException, UnauthorizedException {
- super(serviceName, theInput, queryParams);
+ super(serviceName, theInput, resourceMap, queryParams);
setOutput(new PoxPayloadOut(serviceName));
}
\r
import javax.ws.rs.core.MultivaluedMap;\r
\r
+import org.collectionspace.services.common.ResourceMap;\r
+\r
\r
/**\r
* A factory for creating RemoteServiceContext objects.\r
@Override\r
public ServiceContext<IT, OT> createServiceContext(\r
String serviceName,\r
- IT theInput, \r
+ IT theInput,\r
+ ResourceMap resourceMap,\r
MultivaluedMap<String, String> queryParams) throws Exception {\r
ServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName,\r
theInput,\r
+ resourceMap,\r
queryParams);\r
\r
return ctx;\r
\r
@Override\r
public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
- IT input, \r
+ IT input,\r
+ ResourceMap resourceMap,\r
MultivaluedMap<String, String> queryParams,\r
String documentType,\r
String entityName) throws Exception {\r
ServiceContext<IT, OT> ctx = createServiceContext(\r
serviceName,\r
input,\r
+ resourceMap,\r
queryParams);\r
ctx.setDocumentType(documentType); //persistence unit\r
ctx.setProperty(ServiceContextProperties.ENTITY_NAME, entityName);\r
*/
protected RemoteServiceContextImpl(String serviceName,
IT theInput,
+ ResourceMap resourceMap,
MultivaluedMap<String, String> queryParams) throws UnauthorizedException {
this(serviceName, theInput);
+ this.setResourceMap(resourceMap);
this.setQueryParams(queryParams);
}
import javax.ws.rs.core.MultivaluedMap;
+import org.collectionspace.services.common.ResourceMap;
+
/**
*
* ServiceContextFactory creates a service context
*
* @throws Exception the exception
*/
- public ServiceContext<IT, OT> createServiceContext(String serviceName,
+ public ServiceContext<IT, OT> createServiceContext(
+ String serviceName,
IT input,
+ ResourceMap resourceMap,
MultivaluedMap<String, String> queryParams) throws Exception;
/**
public ServiceContext<IT, OT> createServiceContext(
String serviceName,
IT input,
+ ResourceMap resourceMap,
MultivaluedMap<String, String> queryParams,
String documentType,
String entityName) throws Exception;
String currentServiceName = ctx.getServiceName();
String workflowSubResource = "/";
JaxRsContext jaxRsContext = ctx.getJaxRsContext();
- if (jaxRsContext != null) {
+ if (jaxRsContext != null) { // If not null then we're dealing with an authority item
String resourceName = SecurityUtils.getResourceName(jaxRsContext.getUriInfo());
workflowSubResource = workflowSubResource + resourceName + WorkflowClient.SERVICE_PATH + "/";
} else {
org.collectionspace.services.authorization.ObjectFactory objectFactory =
new org.collectionspace.services.authorization.ObjectFactory();
JAXBElement<AccountPermission> ap = objectFactory.createAccountPermission(accountPermission);
- PayloadOutputPart accountPermissionPart = new PayloadOutputPart("account_permission", ap);
+ PayloadOutputPart accountPermissionPart = new PayloadOutputPart("account_permission", ap); // REM - "account_permission" should be using a constant and not a literal
ctx.addOutputPart(accountPermissionPart);
profiler.stop();
List<RelationsCommonList.RelationListItem> childList = null;
List<RelationsCommonList.RelationListItem> parentList = null;
DocumentModel docModel = wrapDoc.getWrappedObject();
- String itemRefName = (String) docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME);
+// String itemRefName = (String) docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME); cow;
+ String itemRefName = (String) docModel.getProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
+ CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME);
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
//Do magic replacement of ${itemCSID} and fix URI's.