return tempResult.CSID;
}
- private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer(String parentspecifier,
- String method, String op,
+ private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer(
+ String parentspecifier,
+ String method,
+ String op,
UriInfo uriInfo)
throws Exception {
CsidAndShortIdentifier result = new CsidAndShortIdentifier();
public Response createAuthorityItem(
@Context ResourceMap resourceMap,
@Context UriInfo uriInfo,
- @PathParam("csid") String specifier,
+ @PathParam("csid") String parentspecifier,
String xmlPayload) {
Response result = null;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), input, resourceMap, uriInfo);
// Note: must have the parentShortId, to do the create.
- CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(specifier, "createAuthorityItem", "CREATE_ITEM", null);
+ CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(parentspecifier, "createAuthorityItem", "CREATE_ITEM", null);
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler =
createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier);
String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
@Path("{csid}/items/{itemcsid}")
public byte[] updateAuthorityItem(
@Context ResourceMap resourceMap,
- @Context UriInfo ui,
+ @Context UriInfo uriInfo,
@PathParam("csid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier,
String xmlPayload) {
try {
PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);
// Note that we have to create the service context for the Items, not the main service
- //Laramie CSPACE-3175. passing null for queryParams, because prior to this refactor, the code moved to lookupParentCSID in this instance called the version of getServiceContext() that passes null
- String parentcsid = lookupParentCSID(parentspecifier, "updateAuthorityItem(parent)", "UPDATE_ITEM", null);
+ // Laramie CSPACE-3175. passing null for queryParams, because prior to this refactor, the code moved to lookupParentCSID in this instance called the version of getServiceContext() that passes null
+ CsidAndShortIdentifier csidAndShortId = lookupParentCSIDAndShortIdentifer(parentspecifier, "updateAuthorityItem(parent)", "UPDATE_ITEM", null);
+ String parentcsid = csidAndShortId.CSID;
+ String parentShortId = csidAndShortId.shortIdentifier;
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), theUpdate);
- ctx.setResourceMap(resourceMap);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), theUpdate, resourceMap, uriInfo);
String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM", ctx);
// We omit the parentShortId, only needed when doing a create...
- DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
- ctx.setUriInfo(ui);
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, parentShortId);
getRepositoryClient(ctx).update(ctx, itemcsid, handler);
result = ctx.getOutput();
//
documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
CollectionSpaceClient.COLLECTIONSPACE_CORE_URI, getUri(documentModel));
- //
- // Add the resource's refname
- //
- RefNameInterface refname = getRefName(ctx, documentModel); // Sub-classes may override the getRefName() method called here.
- if (refname != null) {
- String refnameStr = refname.toString();
- documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
- CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME, refnameStr);
- }
//
// Add the CSID to the DublinCore title so we can see the CSID in the default
// Nuxeo webapp.
documentModel.getName());
}
}
+ //
+ // Add createdAt timestamp and createdBy user
+ //
documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
CollectionSpaceClient.COLLECTIONSPACE_CORE_CREATED_AT, now);
documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
}
if (action == Action.CREATE || action == Action.UPDATE) {
+ //
+ // Add the resource's refname
+ //
+ RefNameInterface refname = getRefName(ctx, documentModel); // Sub-classes may override the getRefName() method called here.
+ if (refname != null) {
+ String refnameStr = refname.toString();
+ documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
+ CollectionSpaceClient.COLLECTIONSPACE_CORE_REFNAME, refnameStr);
+ }
+ //
+ // Add updatedAt timestamp and updateBy user
+ //
documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_AT, now);
documentModel.setProperty(CollectionSpaceClient.COLLECTIONSPACE_CORE_SCHEMA,
CollectionSpaceClient.COLLECTIONSPACE_CORE_UPDATED_BY, userId);
- }
+ }
}
-
+
/*
* If we see the "rtSbj" query param then we need to perform a CMIS query. Currently, we have only one
* CMIS query, but we could add more. If we do, this method should look at the incoming request and corresponding
}
if (supportsHierarchy() == true) {
- handleRelationsPayload(wrapDoc, true);
- handleItemRefNameReferenceUpdate();
+ handleRelationsPayload(wrapDoc, true); // refNames in relations payload should refer to pre-updated record refName value
+ handleItemRefNameReferenceUpdate(); // if our record's refName changed, we need to update all the references -including relations.
}
}
* @throws Exception
*/
protected void handleItemRefNameReferenceUpdate() throws Exception {
- if (newRefNameOnUpdate != null && oldRefNameOnUpdate != null) {
+ if (hasRefNameUpdate() == true) {
// We have work to do.
if (logger.isDebugEnabled()) {
String eol = System.getProperty("line.separator");
}
}
+ protected boolean hasRefNameUpdate() {
+ return (newRefNameOnUpdate != null && oldRefNameOnUpdate != null);
+ }
+
+ protected String getRefNameUpdate() {
+ String result = null;
+
+ if (hasRefNameUpdate() == true) {
+ result = newRefNameOnUpdate;
+ if (logger.isDebugEnabled() == true) {
+ logger.debug(String.format("There was a refName update. New: %s Old: %s" ,
+ newRefNameOnUpdate, oldRefNameOnUpdate));
+ }
+ }
+
+ return result;
+ }
+
/*
* Note: The Vocabulary document handler overrides this method.
*/