@Produces("application/xml")
public abstract class AuthorityResource<AuthCommon, AuthItemHandler>
extends NuxeoBasedResource {
-
+
final Logger logger = LoggerFactory.getLogger(AuthorityResource.class);
final static String SEARCH_TYPE_TERMSTATUS = "ts";
final static String FETCH_SHORT_ID = "_fetch_";
public final static String PARENT_WILDCARD = "_ALL_";
- protected static final boolean DONT_INCLUDE_ITEMS = false;
- protected static final boolean INCLUDE_ITEMS = true;
-
+ protected static final boolean DONT_INCLUDE_ITEMS = false;
+ protected static final boolean INCLUDE_ITEMS = true;
+
/**
* Instantiates a new Authority resource.
*/
ServiceContext<PoxPayloadIn, PoxPayloadOut> containerCtx = createServiceContext(getServiceName());
if (containerShortIdentifier.equals(FETCH_SHORT_ID)) { // We need to fetch this from the repo
if (ctx.getCurrentRepositorySession() != null) {
- containerCtx.setCurrentRepositorySession(ctx.getCurrentRepositorySession()); // We need to use the current repo session if one exists
+ containerCtx.setCurrentRepositorySession(ctx.getCurrentRepositorySession()); // We need to use the current repo session if one exists
}
// Get from parent document
containerShortIdentifier = getAuthShortIdentifier(containerCtx, inAuthority);
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String shortIdentifier) {
RefName.Authority authority = RefName.Authority.buildAuthority(ctx.getTenantName(),
ctx.getServiceName(),
- null, // Only use shortId form!!!
+ null, // Only use shortId form!!!
shortIdentifier, null);
return authority.toString();
}
String shortIdentifier;
}
- protected String lookupParentCSID(String parentspecifier, String method,
- String op, UriInfo uriInfo) throws Exception {
- CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(NULL_CONTEXT,
- parentspecifier, method, op, uriInfo);
- return tempResult.CSID;
- }
-
- protected String lookupParentCSID(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String parentspecifier, String method,
- String op, UriInfo uriInfo) throws Exception {
- CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(ctx,
- parentspecifier, method, op, uriInfo);
- return tempResult.CSID;
- }
+ protected String lookupParentCSID(String parentspecifier, String method,
+ String op, UriInfo uriInfo) throws Exception {
+ CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(NULL_CONTEXT,
+ parentspecifier, method, op, uriInfo);
+ return tempResult.CSID;
+ }
+
+ protected String lookupParentCSID(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String parentspecifier, String method,
+ String op, UriInfo uriInfo) throws Exception {
+ CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(ctx,
+ parentspecifier, method, op, uriInfo);
+ return tempResult.CSID;
+ }
private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx, // Ok to be null
- String parentIdentifier,
- String method,
- String op,
- UriInfo uriInfo)
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx, // Ok to be null
+ String parentIdentifier,
+ String method,
+ String op,
+ UriInfo uriInfo)
throws Exception {
CsidAndShortIdentifier result = new CsidAndShortIdentifier();
Specifier parentSpec = Specifier.getSpecifier(parentIdentifier, method, op);
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getServiceName(), uriInfo);
CoreSessionInterface repoSession = null;
if (existingCtx != null) {
- repoSession = (CoreSessionInterface) existingCtx.getCurrentRepositorySession(); // We want to use the thread's current repo session
+ repoSession = (CoreSessionInterface) existingCtx.getCurrentRepositorySession(); // We want to use the thread's current repo session
}
parentcsid = getRepositoryClient(ctx).findDocCSID(repoSession, ctx, whereClause); //FIXME: REM - If the parent has been soft-deleted, should we be looking for the item?
}
itemcsid = itemSpec.value;
} else {
String itemWhereClause = RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, itemSpec.value, parentcsid);
- MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(getItemServiceName());
+ MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(getItemServiceName());
CoreSessionInterface repoSession = null;
if (existingContext != null) {
- repoSession = (CoreSessionInterface) existingContext.getCurrentRepositorySession(); // We want to use the thread's current repo session
+ repoSession = (CoreSessionInterface) existingContext.getCurrentRepositorySession(); // We want to use the thread's current repo session
}
itemcsid = getRepositoryClient(ctx).findDocCSID(repoSession, ctx, itemWhereClause); //FIXME: REM - Should we be looking for the 'wf_deleted' query param and filtering on it?
}
* Resource. They then call this method on that resource.
*/
@Override
- public DocumentModel getDocModelForAuthorityItem(CoreSessionInterface repoSession, RefName.AuthorityItem item)
- throws Exception, DocumentNotFoundException {
- if (item == null) {
- return null;
- }
+ public DocumentModel getDocModelForAuthorityItem(CoreSessionInterface repoSession, RefName.AuthorityItem item)
+ throws Exception, DocumentNotFoundException {
+ if (item == null) {
+ return null;
+ }
String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, item.getParentShortIdentifier());
// Ensure we have the right context.
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(item.inAuthority.resource);
@POST
public Response createAuthority(
- @Context ResourceMap resourceMap,
- @Context UriInfo uriInfo,
- String xmlPayload) {
- //
- // Requests to create new authorities come in on new threads. Unfortunately, we need to synchronize those threads on this block because, as of 8/27/2015, we can't seem to get Nuxeo
- // transaction code to deal with a database level UNIQUE constraint violations on the 'shortidentifier' column of the vocabularies_common table.
- // Therefore, to prevent having multiple authorities with the same shortid, we need to synchronize
- // the code that creates new authorities. The authority document model handler will first check for authorities with the same short id before
- // trying to create a new authority.
- //
- synchronized(AuthorityResource.class) {
- try {
- PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input);
- DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
-
- String csid = getRepositoryClient(ctx).create(ctx, handler);
- UriBuilder path = UriBuilder.fromResource(resourceClass);
- path.path("" + csid);
- Response response = Response.created(path.build()).build();
- return response;
- } catch (Exception e) {
- throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
- }
- }
+ @Context ResourceMap resourceMap,
+ @Context UriInfo uriInfo,
+ String xmlPayload) {
+ //
+ // Requests to create new authorities come in on new threads. Unfortunately, we need to synchronize those threads on this block because, as of 8/27/2015, we can't seem to get Nuxeo
+ // transaction code to deal with a database level UNIQUE constraint violations on the 'shortidentifier' column of the vocabularies_common table.
+ // Therefore, to prevent having multiple authorities with the same shortid, we need to synchronize
+ // the code that creates new authorities. The authority document model handler will first check for authorities with the same short id before
+ // trying to create a new authority.
+ //
+ synchronized(AuthorityResource.class) {
+ try {
+ PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(input);
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
+
+ String csid = getRepositoryClient(ctx).create(ctx, handler);
+ UriBuilder path = UriBuilder.fromResource(resourceClass);
+ path.path("" + csid);
+ Response response = Response.created(path.build()).build();
+ return response;
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+ }
}
protected boolean supportsReplicating(String tenantId, String serviceName) {
- boolean result = false;
-
+ boolean result = false;
+
ServiceBindingType sb = getTenantBindingsReader().getServiceBinding(tenantId, getServiceName());
result = sb.isSupportsReplicating();
@Context Request request,
@Context UriInfo uriInfo,
@PathParam("csid") String identifier) {
- uriInfo = new UriInfoWrapper(uriInfo);
- byte[] result;
- boolean neededSync = false;
+ uriInfo = new UriInfoWrapper(uriInfo);
+ byte[] result;
+ boolean neededSync = false;
PoxPayloadOut payloadOut = null;
Specifier specifier;
//
// Prevent multiple SAS synchronizations from occurring simultaneously by synchronizing this method.
//
- synchronized(AuthorityResource.class) {
- try {
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
- /*
- * Make sure this authority service supports synchronization
- */
- if (supportsReplicating(ctx.getTenantId(), ctx.getServiceName()) == false) {
- throw new DocumentException(Response.Status.FORBIDDEN.getStatusCode());
- }
- AuthorityDocumentModelHandler handler = (AuthorityDocumentModelHandler)createDocumentHandler(ctx);
- specifier = Specifier.getSpecifier(identifier, "getAuthority", "GET");
- handler.setShouldUpdateRevNumber(AuthorityServiceUtils.DONT_UPDATE_REV); // Never update rev number on sync calls
- neededSync = getRepositoryClient(ctx).synchronize(ctx, specifier, handler);
- payloadOut = ctx.getOutput();
- } catch (Exception e) {
- throw bigReThrow(e, ServiceMessages.SYNC_FAILED, identifier);
- }
-
- //
- // If a sync was needed and was successful, return a copy of the updated resource. Acts like an UPDATE.
- //
- if (neededSync == true) {
- result = payloadOut.getBytes();
- } else {
- result = String.format("Authority resource '%s' was already in sync with shared authority server.",
- specifier.value).getBytes();
- Response response = Response.status(Response.Status.NOT_MODIFIED).entity(result).type("text/plain").build();
- throw new CSWebApplicationException(response);
- }
- }
-
- return result;
+ synchronized(AuthorityResource.class) {
+ try {
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
+ /*
+ * Make sure this authority service supports synchronization
+ */
+ if (supportsReplicating(ctx.getTenantId(), ctx.getServiceName()) == false) {
+ throw new DocumentException(Response.Status.FORBIDDEN.getStatusCode());
+ }
+ AuthorityDocumentModelHandler handler = (AuthorityDocumentModelHandler)createDocumentHandler(ctx);
+ specifier = Specifier.getSpecifier(identifier, "getAuthority", "GET");
+ handler.setShouldUpdateRevNumber(AuthorityServiceUtils.DONT_UPDATE_REV); // Never update rev number on sync calls
+ neededSync = getRepositoryClient(ctx).synchronize(ctx, specifier, handler);
+ payloadOut = ctx.getOutput();
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.SYNC_FAILED, identifier);
+ }
+
+ //
+ // If a sync was needed and was successful, return a copy of the updated resource. Acts like an UPDATE.
+ //
+ if (neededSync == true) {
+ result = payloadOut.getBytes();
+ } else {
+ result = String.format("Authority resource '%s' was already in sync with shared authority server.",
+ specifier.value).getBytes();
+ Response response = Response.status(Response.Status.NOT_MODIFIED).entity(result).type("text/plain").build();
+ throw new CSWebApplicationException(response);
+ }
+ }
+
+ return result;
}
/*
* Builds a cached JAX-RS response.
*/
protected Response buildResponse(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, PoxPayloadOut payloadOut) {
- Response result = null;
+ Response result = null;
- ResponseBuilder responseBuilder = Response.ok(payloadOut.getBytes());
+ ResponseBuilder responseBuilder = Response.ok(payloadOut.getBytes());
this.setCacheControl(ctx, responseBuilder);
result = responseBuilder.build();
@Context Request request,
@Context UriInfo uriInfo,
@PathParam("csid") String specifier) {
- Response result = null;
- uriInfo = new UriInfoWrapper(uriInfo);
+ Response result = null;
+ uriInfo = new UriInfoWrapper(uriInfo);
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(request, uriInfo);
return result;
}
- protected PoxPayloadOut getAuthority(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ protected PoxPayloadOut getAuthority(
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
Request request,
UriInfo uriInfo,
String specifier,
boolean includeItems) throws Exception {
- uriInfo = new UriInfoWrapper(uriInfo);
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut payloadout = null;
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> docHandler = createDocumentHandler(ctx);
getRepositoryClient(ctx).get(ctx, docHandler);
}
- payloadout = ctx.getOutput();
+ payloadout = ctx.getOutput();
if (includeItems == true) {
- AbstractCommonList itemsList = this.getAuthorityItemList(ctx, specifier, uriInfo);
- payloadout.addPart(PoxPayload.ABSTRACT_COMMON_LIST_ROOT_ELEMENT_LABEL, itemsList);
+ AbstractCommonList itemsList = this.getAuthorityItemList(ctx, specifier, uriInfo);
+ payloadout.addPart(PoxPayload.ABSTRACT_COMMON_LIST_ROOT_ELEMENT_LABEL, itemsList);
}
return payloadout;
@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 {
+ uriInfo = new UriInfoWrapper(uriInfo);
+ AbstractCommonList result = null;
+
+ try {
MultivaluedMap<String, String> queryParams = uriInfo.getQueryParameters();
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
- DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
DocumentFilter myFilter = handler.getDocumentFilter();
// Need to make the default sort order for authority items
// be on the displayName field
AuthorityDocumentModelHandler handler = (AuthorityDocumentModelHandler) createDocumentHandler(ctx);
Boolean shouldUpdateRev = (Boolean) ctx.getProperty(AuthorityServiceUtils.SHOULD_UPDATE_REV_PROPERTY);
if (shouldUpdateRev != null) {
- handler.setShouldUpdateRevNumber(shouldUpdateRev);
+ handler.setShouldUpdateRevNumber(shouldUpdateRev);
}
getRepositoryClient(ctx).update(ctx, csid, handler);
return ctx.getOutput();
@PUT
@Path("{csid}")
public byte[] updateAuthority(
- @Context Request request,
- @Context ResourceMap resourceMap,
- @Context UriInfo uriInfo,
+ @Context Request request,
+ @Context ResourceMap resourceMap,
+ @Context UriInfo uriInfo,
@PathParam("csid") String specifier,
String xmlPayload) {
PoxPayloadOut result = null;
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
- RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = this.getRepositoryClient(ctx);
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = this.getRepositoryClient(ctx);
- CoreSessionInterface repoSession = repoClient.getRepositorySession(ctx);
- try {
- DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
- //
- // Delete all the items one by one
- //
- AbstractCommonList itemsList = this.getAuthorityItemList(ctx, specifier, uriInfo);
- for (ListItem item : itemsList.getListItem()) {
- deleteAuthorityItem(ctx, specifier, getCsid(item), AuthorityServiceUtils.UPDATE_REV);
- }
- } catch (Throwable t) {
- repoSession.setTransactionRollbackOnly();
- throw t;
+ CoreSessionInterface repoSession = repoClient.getRepositorySession(ctx);
+ try {
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
+ //
+ // Delete all the items one by one
+ //
+ AbstractCommonList itemsList = this.getAuthorityItemList(ctx, specifier, uriInfo);
+ for (ListItem item : itemsList.getListItem()) {
+ deleteAuthorityItem(ctx, specifier, getCsid(item), AuthorityServiceUtils.UPDATE_REV);
+ }
+ } catch (Throwable t) {
+ repoSession.setTransactionRollbackOnly();
+ throw t;
} finally {
- repoClient.releaseRepositorySession(ctx, repoSession);
+ repoClient.releaseRepositorySession(ctx, repoSession);
}
return Response.status(HttpResponseCodes.SC_OK).build();
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(uriInfo);
Specifier spec = Specifier.getSpecifier(specifier, "getAuthority", "GET");
- RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = this.getRepositoryClient(ctx);
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = this.getRepositoryClient(ctx);
- CoreSessionInterface repoSession = repoClient.getRepositorySession(ctx);
- try {
- DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
- //
- // First try to delete all the items
- //
- AbstractCommonList itemsList = this.getAuthorityItemList(ctx, specifier, uriInfo);
- for (ListItem item : itemsList.getListItem()) {
- deleteAuthorityItem(ctx, specifier, getCsid(item), AuthorityServiceUtils.UPDATE_REV);
- }
-
- //
- // Lastly, delete the parent/container
- //
- if (spec.form == SpecifierForm.CSID) {
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAuthority with csid=" + spec.value);
- }
- ensureCSID(spec.value, ServiceMessages.DELETE_FAILED, "Authority.csid");
- getRepositoryClient(ctx).delete(ctx, spec.value, handler);
- } else {
- if (logger.isDebugEnabled()) {
- logger.debug("deleteAuthority with specifier=" + spec.value);
- }
- String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, spec.value);
- getRepositoryClient(ctx).deleteWithWhereClause(ctx, whereClause, handler);
- }
- } catch (Throwable t) {
- repoSession.setTransactionRollbackOnly();
- throw t;
+ CoreSessionInterface repoSession = repoClient.getRepositorySession(ctx);
+ try {
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
+ //
+ // First try to delete all the items
+ //
+ AbstractCommonList itemsList = this.getAuthorityItemList(ctx, specifier, uriInfo);
+ for (ListItem item : itemsList.getListItem()) {
+ deleteAuthorityItem(ctx, specifier, getCsid(item), AuthorityServiceUtils.UPDATE_REV);
+ }
+
+ //
+ // Lastly, delete the parent/container
+ //
+ if (spec.form == SpecifierForm.CSID) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteAuthority with csid=" + spec.value);
+ }
+ ensureCSID(spec.value, ServiceMessages.DELETE_FAILED, "Authority.csid");
+ getRepositoryClient(ctx).delete(ctx, spec.value, handler);
+ } else {
+ if (logger.isDebugEnabled()) {
+ logger.debug("deleteAuthority with specifier=" + spec.value);
+ }
+ String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, spec.value);
+ getRepositoryClient(ctx).deleteWithWhereClause(ctx, whereClause, handler);
+ }
+ } catch (Throwable t) {
+ repoSession.setTransactionRollbackOnly();
+ throw t;
} finally {
- repoClient.releaseRepositorySession(ctx, repoSession);
+ repoClient.releaseRepositorySession(ctx, repoSession);
}
return Response.status(HttpResponseCodes.SC_OK).build();
}
}
- private String getCsid(ListItem item) {
- String result = null;
-
- for (Element ele : item.getAny()) {
- String elementName = ele.getTagName().toLowerCase();
- if (elementName.equals("csid")) {
- result = ele.getTextContent();
- break;
- }
- }
-
- return result;
- }
-
- /**
+ private String getCsid(ListItem item) {
+ String result = null;
+
+ for (Element ele : item.getAny()) {
+ String elementName = ele.getTagName().toLowerCase();
+ if (elementName.equals("csid")) {
+ result = ele.getTextContent();
+ break;
+ }
+ }
+
+ return result;
+ }
+
+ /**
*
* @param ctx
- * @param parentspecifier - ID of the container. Can be URN or CSID form
+ * @param parentspecifier - ID of the container. Can be URN or CSID form
* @param shouldUpdateRevNumber - Indicates if the revision number should be updated on create -won't do this when synching with SAS
- * @param isProposed - In a shared authority context, indicates if this item just a proposed item and not yet part of the SAS authority
+ * @param isProposed - In a shared authority context, indicates if this item just a proposed item and not yet part of the SAS authority
* @return
* @throws Exception
*/
protected Response createAuthorityItem(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String parentIdentifier,
- boolean shouldUpdateRevNumber,
- boolean isProposed,
- boolean isSasItem) throws Exception {
- Response result = null;
-
+ boolean shouldUpdateRevNumber,
+ boolean isProposed,
+ boolean isSasItem) throws Exception {
+ Response result = null;
+
// Note: must have the parentShortId, to do the create.
CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(ctx, parentIdentifier, "createAuthorityItem", "CREATE_ITEM", null);
AuthorityItemDocumentModelHandler handler =
- (AuthorityItemDocumentModelHandler) createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier);
+ (AuthorityItemDocumentModelHandler) createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier);
handler.setShouldUpdateRevNumber(shouldUpdateRevNumber);
handler.setIsProposed(isProposed);
handler.setIsSASItem(isSasItem);
path.path(parent.CSID + "/items/" + itemcsid);
result = Response.created(path.build()).build();
- return result;
+ return result;
}
public PoxPayloadOut updateAuthorityItem(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> itemServiceCtx, // Ok to be null. Will be null on PUT calls, but not on sync calls
- ResourceMap resourceMap,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> itemServiceCtx, // Ok to be null. Will be null on PUT calls, but not on sync calls
+ ResourceMap resourceMap,
UriInfo uriInfo,
String parentspecifier,
String itemspecifier,
//
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = itemServiceCtx;
if (ctx == null) {
- ctx = createServiceContext(getItemServiceName(), theUpdate, resourceMap, uriInfo);
+ ctx = createServiceContext(getItemServiceName(), theUpdate, resourceMap, uriInfo);
} else {
- ctx.setInput(theUpdate); // the update payload
+ ctx.setInput(theUpdate); // the update payload
}
String itemcsid = lookupItemCSID(ctx, itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM"); //use itemServiceCtx if it is not null
boolean updateSASFields = isProposed != null || isSASItem != null;
handler.setshouldUpdateSASFields(updateSASFields);
if (updateSASFields == true) {
- handler.setshouldUpdateSASFields(true);
- if (isProposed != null) {
- handler.setIsProposed(isProposed);
- }
- if (isSASItem != null) {
- handler.setIsSASItem(isSASItem);
- }
+ handler.setshouldUpdateSASFields(true);
+ if (isProposed != null) {
+ handler.setIsProposed(isProposed);
+ }
+ if (isSASItem != null) {
+ handler.setIsSASItem(isSASItem);
+ }
}
getRepositoryClient(ctx).update(ctx, itemcsid, handler);
* @throws Exception
*/
public Response createAuthorityItemWithParentContext(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,
- String parentIdentifier,
- PoxPayloadIn input,
- boolean shouldUpdateRevNumber,
- boolean isProposed,
- boolean isSASItem) throws Exception {
- Response result = null;
-
+ String parentIdentifier,
+ PoxPayloadIn input,
+ boolean shouldUpdateRevNumber,
+ boolean isProposed,
+ boolean isSASItem) throws Exception {
+ Response result = null;
+
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), input,
- parentCtx.getResourceMap(), parentCtx.getUriInfo());
+ parentCtx.getResourceMap(), parentCtx.getUriInfo());
if (parentCtx.getCurrentRepositorySession() != null) {
- ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession());
+ ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession());
}
result = this.createAuthorityItem(ctx, parentIdentifier, shouldUpdateRevNumber, isProposed, isSASItem);
- return result;
+ return result;
}
/*************************************************************************
@POST
@Path("{csid}/items")
public Response createAuthorityItem(
- @Context ResourceMap resourceMap,
- @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;
-
+ @Context ResourceMap resourceMap,
+ @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 {
PoxPayloadIn input = new PoxPayloadIn(xmlPayload);
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), input, resourceMap, uriInfo);
result = this.createAuthorityItem(ctx, parentIdentifier, AuthorityServiceUtils.UPDATE_REV,
- AuthorityServiceUtils.PROPOSED, AuthorityServiceUtils.NOT_SAS_ITEM);
+ AuthorityServiceUtils.PROPOSED, AuthorityServiceUtils.NOT_SAS_ITEM);
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
}
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier,
@PathParam("transition") String transition) {
- uriInfo = new UriInfoWrapper(uriInfo);
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
result = updateItemWorkflowWithTransition(ctx,
- parentIdentifier, itemIdentifier, transition, AuthorityServiceUtils.UPDATE_REV);
+ parentIdentifier, itemIdentifier, transition, AuthorityServiceUtils.UPDATE_REV);
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.UPDATE_FAILED + WorkflowClient.SERVICE_PAYLOAD_NAME, parentIdentifier);
}
String itemIdentifier,
String transition,
boolean updateRevNumber) throws DocumentReferenceException {
- PoxPayloadOut result = null;
-
+ PoxPayloadOut result = null;
+
try {
- //
- // We need CSIDs for both the parent authority and the authority item
- //
+ //
+ // We need CSIDs for both the parent authority and the authority item
+ //
CsidAndShortIdentifier csidAndShortId = lookupParentCSIDAndShortIdentifer(existingContext, parentIdentifier, "updateItemWorkflowWithTransition(parent)", "UPDATE_ITEM", null);
String itemCsid = lookupItemCSID(existingContext, itemIdentifier, csidAndShortId.CSID, "updateAuthorityItem(item)", "UPDATE_ITEM");
//
- // Create an empty workflow_commons input part and set it into a new "workflow" sub-resource context
- //
- PoxPayloadIn input = new PoxPayloadIn(WorkflowClient.SERVICE_PAYLOAD_NAME, new WorkflowCommon(),
- WorkflowClient.SERVICE_COMMONPART_NAME);
+ // Create an empty workflow_commons input part and set it into a new "workflow" sub-resource context
+ //
+ PoxPayloadIn input = new PoxPayloadIn(WorkflowClient.SERVICE_PAYLOAD_NAME, new WorkflowCommon(),
+ WorkflowClient.SERVICE_COMMONPART_NAME);
MultipartServiceContext ctx = (MultipartServiceContext) createServiceContext(WorkflowClient.SERVICE_NAME, input);
if (existingContext != null && existingContext.getCurrentRepositorySession() != null) {
- ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession());// If a repo session is already open, we need to use it and not create a new one
+ ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession());// If a repo session is already open, we need to use it and not create a new one
}
//
// Create a service context and document handler for the target resource -not the workflow resource itself.
String targetWorkspaceName = targetCtx.getRepositoryWorkspaceName();
ctx.setRespositoryWorkspaceName(targetWorkspaceName); //find the document in the parent's workspace
- // Get the type of transition we're being asked to make and store it as a context parameter -used by the workflow document handler
+ // Get the type of transition we're being asked to make and store it as a context parameter -used by the workflow document handler
TransitionDef transitionDef = getTransitionDef(targetCtx, transition);
if (transitionDef == null) {
- throw new DocumentException(String.format("The document with ID='%s' does not support the workflow transition '%s'.",
- itemIdentifier, transition));
+ throw new DocumentException(String.format("The document with ID='%s' does not support the workflow transition '%s'.",
+ itemIdentifier, transition));
}
ctx.setProperty(WorkflowClient.TRANSITION_ID, transitionDef);
getRepositoryClient(ctx).update(ctx, itemCsid, handler);
result = ctx.getOutput();
} catch (DocumentReferenceException de) {
- throw de;
+ throw de;
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.UPDATE_FAILED + WorkflowClient.SERVICE_PAYLOAD_NAME, itemIdentifier);
}
-
- return result;
+
+ return result;
}
private PoxPayloadOut getAuthorityItem(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String parentIdentifier,
String itemIdentifier) throws Exception {
- PoxPayloadOut result = null;
-
+ PoxPayloadOut result = null;
+
String parentcsid = lookupParentCSID(ctx, parentIdentifier, "getAuthorityItem(parent)", "GET_ITEM", null);
// We omit the parentShortId, only needed when doing a create...
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createItemDocumentHandler(ctx, parentcsid, null);
getRepositoryClient(ctx).get(ctx, itemSpec.value, handler);
} else {
String itemWhereClause =
- RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, itemSpec.value, parentcsid);
+ RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, itemSpec.value, parentcsid);
DocumentFilter myFilter = new NuxeoDocumentFilter(itemWhereClause, 0, 1); // start at page 0 and get 1 item
handler.setDocumentFilter(myFilter);
getRepositoryClient(ctx).get(ctx, handler);
result = (PoxPayloadOut) ctx.getOutput();
if (result != null) {
- String inAuthority = XmlTools.getElementValue(result.getDOMDocument(), "//" + AuthorityItemJAXBSchema.IN_AUTHORITY);
- if (inAuthority.equalsIgnoreCase(parentcsid) == false) {
- throw new Exception(String.format("Looked up item = '%s' and found with inAuthority = '%s', but expected inAuthority = '%s'.",
- itemSpec.value, inAuthority, parentcsid));
- }
+ String inAuthority = XmlTools.getElementValue(result.getDOMDocument(), "//" + AuthorityItemJAXBSchema.IN_AUTHORITY);
+ if (inAuthority.equalsIgnoreCase(parentcsid) == false) {
+ throw new Exception(String.format("Looked up item = '%s' and found with inAuthority = '%s', but expected inAuthority = '%s'.",
+ itemSpec.value, inAuthority, parentcsid));
+ }
}
- return result;
+ return result;
}
public PoxPayloadOut getAuthorityItemWithExistingContext(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
String parentIdentifier,
String itemIdentifier) throws Exception {
- PoxPayloadOut result = null;
-
+ PoxPayloadOut result = null;
+
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), existingCtx.getResourceMap(), existingCtx.getUriInfo());
if (existingCtx.getCurrentRepositorySession() != null) {
- ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists
- ctx.setProperties(existingCtx.getProperties());
+ ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists
+ ctx.setProperties(existingCtx.getProperties());
}
result = getAuthorityItem(ctx, parentIdentifier, itemIdentifier);
-
- return result;
+
+ return result;
}
/**
public byte[] getAuthorityItem(
@Context Request request,
@Context UriInfo uriInfo,
- @Context ResourceMap resourceMap,
+ @Context ResourceMap resourceMap,
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier) {
- uriInfo = new UriInfoWrapper(uriInfo);
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
RemoteServiceContext<PoxPayloadIn, PoxPayloadOut> ctx =
- (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), resourceMap, uriInfo);
+ (RemoteServiceContext<PoxPayloadIn, PoxPayloadOut>) createServiceContext(getItemServiceName(), resourceMap, uriInfo);
JaxRsContext jaxRsContext = new JaxRsContext(request, uriInfo); // Needed for getting account permissions part of the resource
ctx.setJaxRsContext(jaxRsContext);
* different enough that it will have to override this method in it's resource class.
*/
@Override
- protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
- String result = null;
+ protected String getOrderByField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
+ String result = null;
- result = NuxeoUtils.getPrimaryElPathPropertyName(
- authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(),
- AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+ result = NuxeoUtils.getPrimaryElPathPropertyName(
+ authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(),
+ AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
- return result;
- }
-
+ return result;
+ }
+
@Override
- protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
- String result = null;
-
- result = NuxeoUtils.getMultiElPathPropertyName(
- authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(),
- AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
-
- return result;
- }
+ protected String getPartialTermMatchField(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
+ String result = null;
+
+ result = NuxeoUtils.getMultiElPathPropertyName(
+ authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(),
+ AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+
+ return result;
+ }
/**
* Gets the authorityItem list for the specified authority
*
*/
public AbstractCommonList getAuthorityItemList(ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
- String authorityIdentifier,
+ String authorityIdentifier,
UriInfo uriInfo) throws Exception {
- AbstractCommonList result = null;
-
+ AbstractCommonList result = null;
+
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
if (existingContext != null && existingContext.getCurrentRepositorySession() != null) { // Merge some of the existing context properties with our new context
- ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession());
- ctx.setProperties(existingContext.getProperties());
+ ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession());
+ ctx.setProperties(existingContext.getProperties());
}
String orderBy = queryParams.getFirst(IClientQueryParams.ORDER_BY_PARAM);
// 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(authorityIdentifier) ? null :
- lookupParentCSID(ctx, authorityIdentifier, "getAuthorityItemList", "LIST", uriInfo);
+ lookupParentCSID(ctx, authorityIdentifier, "getAuthorityItemList", "LIST", uriInfo);
DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler =
- createItemDocumentHandler(ctx, parentcsid, null);
+ createItemDocumentHandler(ctx, parentcsid, null);
DocumentFilter myFilter = handler.getDocumentFilter();
// If we are not wildcarding the parent, add a restriction
}
if (Tools.notBlank(termStatus)) {
- // Start with the qualified termStatus field
- String qualifiedTermStatusField = authorityItemCommonSchemaName + ":"
+ // Start with the qualified termStatus field
+ String qualifiedTermStatusField = authorityItemCommonSchemaName + ":"
+ AuthorityItemJAXBSchema.TERM_STATUS;
- String[] filterTerms = termStatus.trim().split("\\|");
- String tsClause = QueryManager.createWhereClauseToFilterFromStringList(qualifiedTermStatusField, filterTerms, IQueryManager.FILTER_EXCLUDE);
+ String[] filterTerms = termStatus.trim().split("\\|");
+ String tsClause = QueryManager.createWhereClauseToFilterFromStringList(qualifiedTermStatusField, filterTerms, IQueryManager.FILTER_EXCLUDE);
myFilter.appendWhereClause(tsClause, IQueryManager.SEARCH_QUALIFIER_AND);
}
result = search(ctx, handler, uriInfo, orderBy, keywords, advancedSearch, partialTerm);
-
- return result;
+
+ return result;
}
/**
@Produces("application/xml")
public AbstractCommonList getAuthorityItemList(@PathParam("csid") String authorityIdentifier,
@Context UriInfo uriInfo) {
- uriInfo = new UriInfoWrapper(uriInfo);
- AbstractCommonList result = null;
-
+ uriInfo = new UriInfoWrapper(uriInfo);
+ AbstractCommonList result = null;
+
try {
result = getAuthorityItemList(NULL_CONTEXT, authorityIdentifier, uriInfo);
} catch (Exception e) {
* Some types (like Vocabulary) use a separate property.
*/
protected String getRefPropName() {
- return ServiceBindingUtils.AUTH_REF_PROP;
+ return ServiceBindingUtils.AUTH_REF_PROP;
}
/**
@PathParam("itemcsid") String itemSpecifier,
@Context UriTemplateRegistry uriTemplateRegistry,
@Context UriInfo uriInfo) {
- uriInfo = new UriInfoWrapper(uriInfo);
+ uriInfo = new UriInfoWrapper(uriInfo);
AuthorityRefDocList authRefDocList = null;
try {
authRefDocList = getReferencingObjects(null, parentSpecifier, itemSpecifier, uriTemplateRegistry, uriInfo);
}
public AuthorityRefDocList getReferencingObjects(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
String parentspecifier,
String itemspecifier,
UriTemplateRegistry uriTemplateRegistry,
UriInfo uriInfo) throws Exception {
- //uriInfo = new UriInfoWrapper(uriInfo);
- AuthorityRefDocList authRefDocList = null;
+ AuthorityRefDocList authRefDocList = null;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
// Merge parts of existing context with our new context
//
if (existingContext != null && existingContext.getCurrentRepositorySession() != null) {
- ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession()); // If one exists, use the existing repo session
- ctx.setProperties(existingContext.getProperties());
+ ctx.setCurrentRepositorySession(existingContext.getCurrentRepositorySession()); // If one exists, use the existing repo session
+ ctx.setProperties(existingContext.getProperties());
}
String parentcsid = lookupParentCSID(ctx, parentspecifier, "getReferencingObjects(parent)", "GET_ITEM_REF_OBJS", uriInfo);
// Remove the "type" property from the query params
List<String> serviceTypes = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
if (serviceTypes == null || serviceTypes.isEmpty()) {
- serviceTypes = ServiceBindingUtils.getCommonServiceTypes(true); //CSPACE-5359: Should now include objects, procedures, and authorities
+ serviceTypes = ServiceBindingUtils.getCommonServiceTypes(true); //CSPACE-5359: Should now include objects, procedures, and authorities
}
AuthorityItemDocumentModelHandler handler = (AuthorityItemDocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, null);
@PathParam("csid") String parentspecifier,
@PathParam("itemcsid") String itemspecifier,
@Context UriInfo uriInfo) {
- uriInfo = new UriInfoWrapper(uriInfo);
+ uriInfo = new UriInfoWrapper(uriInfo);
AuthorityRefList authRefList = null;
try {
* @throws Exception
*/
private PoxPayloadOut synchronizeItem(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String parentIdentifier,
String itemIdentifier,
boolean syncHierarchicalRelationships) throws Exception {
- PoxPayloadOut result = null;
+ PoxPayloadOut result = null;
AuthorityItemSpecifier specifier;
- boolean neededSync = false;
+ boolean neededSync = false;
- CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(ctx, parentIdentifier, "syncAuthorityItem(parent)", "SYNC_ITEM", null);
+ CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(ctx, parentIdentifier, "syncAuthorityItem(parent)", "SYNC_ITEM", null);
AuthorityItemDocumentModelHandler handler = (AuthorityItemDocumentModelHandler)createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier);
handler.setIsProposed(AuthorityServiceUtils.NOT_PROPOSED); // In case it was formally locally proposed, clear the proposed flag
handler.setIsSASItem(AuthorityServiceUtils.SAS_ITEM); // Since we're sync'ing, this is now a SAS controlled item
//
neededSync = getRepositoryClient(ctx).synchronize(ctx, specifier, handler);
if (neededSync == true) {
- result = (PoxPayloadOut) ctx.getOutput();
+ result = (PoxPayloadOut) ctx.getOutput();
}
-
- return result;
+
+ return result;
}
/**
* @throws Exception
*/
public PoxPayloadOut synchronizeItemWithExistingContext(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
String parentIdentifier,
String itemIdentifier,
boolean syncHierarchicalRelationships
) throws Exception {
- PoxPayloadOut result = null;
-
+ PoxPayloadOut result = null;
+
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(),
- existingCtx.getResourceMap(),
- existingCtx.getUriInfo());
+ existingCtx.getResourceMap(),
+ existingCtx.getUriInfo());
if (existingCtx.getCurrentRepositorySession() != null) {
- ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession());
-
+ ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession());
+
}
result = synchronizeItem(ctx, parentIdentifier, itemIdentifier, syncHierarchicalRelationships);
-
- return result;
+
+ return result;
}
/**
@POST
@Path("{csid}/items/{itemcsid}/sync")
public byte[] synchronizeItem(
- @Context ResourceMap resourceMap,
+ @Context ResourceMap resourceMap,
@Context UriInfo uriInfo,
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier) {
- uriInfo = new UriInfoWrapper(uriInfo);
- byte[] result;
- boolean neededSync = false;
+ uriInfo = new UriInfoWrapper(uriInfo);
+ byte[] result;
+ boolean neededSync = false;
PoxPayloadOut payloadOut = null;
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), null, resourceMap, uriInfo);
payloadOut = this.synchronizeItem(ctx, parentIdentifier, itemIdentifier, true);
if (payloadOut != null) {
- neededSync = true;
+ neededSync = true;
}
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.SYNC_FAILED, itemIdentifier);
// If a sync was needed and was successful, return a copy of the updated resource. Acts like an UPDATE.
//
if (neededSync == true) {
- result = payloadOut.getBytes();
+ result = payloadOut.getBytes();
} else {
- result = String.format("Authority item resource '%s' was already in sync with shared authority server.",
- itemIdentifier).getBytes();
- Response response = Response.status(Response.Status.NOT_MODIFIED).entity(result).type("text/plain").build();
+ result = String.format("Authority item resource '%s' was already in sync with shared authority server.",
+ itemIdentifier).getBytes();
+ Response response = Response.status(Response.Status.NOT_MODIFIED).entity(result).type("text/plain").build();
throw new CSWebApplicationException(response);
}
@PUT
@Path("{csid}/items/{itemcsid}")
public byte[] updateAuthorityItem(
- @Context ResourceMap resourceMap,
+ @Context ResourceMap resourceMap,
@Context UriInfo uriInfo,
@PathParam("csid") String parentSpecifier,
@PathParam("itemcsid") String itemSpecifier,
String xmlPayload) {
- uriInfo = new UriInfoWrapper(uriInfo);
+ uriInfo = new UriInfoWrapper(uriInfo);
PoxPayloadOut result = null;
try {
PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload);
result = updateAuthorityItem(null, resourceMap, uriInfo, parentSpecifier, itemSpecifier, theUpdate,
- AuthorityServiceUtils.UPDATE_REV, // passing TRUE so rev num increases, passing
- AuthorityServiceUtils.NO_CHANGE, // don't change the state of the "proposed" field -we could be performing a sync or just a plain update
- AuthorityServiceUtils.NO_CHANGE); // don't change the state of the "sas" field -we could be performing a sync or just a plain update
+ AuthorityServiceUtils.UPDATE_REV, // passing TRUE so rev num increases, passing
+ AuthorityServiceUtils.NO_CHANGE, // don't change the state of the "proposed" field -we could be performing a sync or just a plain update
+ AuthorityServiceUtils.NO_CHANGE); // don't change the state of the "sas" field -we could be performing a sync or just a plain update
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.UPDATE_FAILED);
}
@Context UriInfo uriInfo,
@PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier) {
- uriInfo = new UriInfoWrapper(uriInfo);
- Response result = null;
+ uriInfo = new UriInfoWrapper(uriInfo);
+ Response result = null;
ensureCSID(parentIdentifier, ServiceMessages.DELETE_FAILED, "AuthorityItem.parentcsid");
ensureCSID(itemIdentifier, ServiceMessages.DELETE_FAILED, "AuthorityItem.itemcsid");
* @param itemIdentifier
* @throws Exception
*/
- public boolean deleteAuthorityItem(ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
+ public boolean deleteAuthorityItem(ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
String parentIdentifier,
String itemIdentifier,
boolean shouldUpdateRevNumber
) throws Exception {
- boolean result = true;
-
+ boolean result = true;
+
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), existingCtx.getUriInfo());
if (existingCtx != null && existingCtx.getCurrentRepositorySession() != null) {
- ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession());
- ctx.setProperties(existingCtx.getProperties());
+ ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession());
+ ctx.setProperties(existingCtx.getProperties());
}
String parentcsid = null;
try {
- parentcsid = lookupParentCSID(ctx, parentIdentifier, "deleteAuthorityItem(parent)", "DELETE_ITEM", null);
+ parentcsid = lookupParentCSID(ctx, parentIdentifier, "deleteAuthorityItem(parent)", "DELETE_ITEM", null);
} catch (DocumentNotFoundException de) {
- String msg = String.format("Could not find parent with ID='%s' when trying to delete item ID='%s'",
- parentIdentifier, itemIdentifier);
- logger.warn(msg);
- throw de;
+ String msg = String.format("Could not find parent with ID='%s' when trying to delete item ID='%s'",
+ parentIdentifier, itemIdentifier);
+ logger.warn(msg);
+ throw de;
}
String itemCsid = lookupItemCSID(ctx, itemIdentifier, parentcsid, "deleteAuthorityItem(item)", "DELETE_ITEM"); //use itemServiceCtx if it is not null
@Path("{csid}/items/{itemcsid}/" + hierarchy)
@Produces("application/xml")
public String getHierarchy(
- @PathParam("csid") String parentIdentifier,
+ @PathParam("csid") String parentIdentifier,
@PathParam("itemcsid") String itemIdentifier,
@Context UriInfo uriInfo) throws Exception {
- uriInfo = new UriInfoWrapper(uriInfo);
- String result = null;
+ uriInfo = new UriInfoWrapper(uriInfo);
+ String result = null;
try {
- //
+ //
// All items in dive can look at their child uri's to get uri. So we calculate the very first one. We could also do a GET and look at the common part uri field, but why...?
- //
+ //
String calledUri = uriInfo.getPath();
String uri = "/" + calledUri.substring(0, (calledUri.length() - ("/" + hierarchy).length()));
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
*
*/
@Override
- public ServiceDescription getDescription(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
- ServiceDescription result = super.getDescription(ctx);
- result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId()));
- return result;
+ public ServiceDescription getDescription(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
+ ServiceDescription result = super.getDescription(ctx);
+ result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId()));
+ return result;
}
- public Response createAuthority(String xmlPayload) {
- return this.createAuthority(null, null, xmlPayload);
- }
+ public Response createAuthority(String xmlPayload) {
+ return this.createAuthority(null, null, xmlPayload);
+ }
}
// Getter and Setter for 'shouldUpdateSASFields'
//
public boolean getShouldUpdateSASFields() {
- return shouldUpdateSASFields;
+ return shouldUpdateSASFields;
}
public void setshouldUpdateSASFields(boolean flag) {
- shouldUpdateSASFields = flag;
+ shouldUpdateSASFields = flag;
}
//
// Getter and Setter for 'proposed'
//
public boolean getIsProposed() {
- return this.isProposed;
+ return this.isProposed;
}
public void setIsProposed(boolean flag) {
- this.isProposed = flag;
+ this.isProposed = flag;
}
//
// Getter and Setter for 'isSAS'
//
public boolean getIsSASItem() {
- return this.isSAS;
+ return this.isSAS;
}
public void setIsSASItem(boolean flag) {
- this.isSAS = flag;
+ this.isSAS = flag;
}
//
// Getter and Setter for 'shouldUpdateRevNumber'
//
public boolean getShouldUpdateRevNumber() {
- return this.shouldUpdateRevNumber;
+ return this.shouldUpdateRevNumber;
}
public void setShouldUpdateRevNumber(boolean flag) {
- this.shouldUpdateRevNumber = flag;
+ this.shouldUpdateRevNumber = flag;
}
//
// Getter and Setter for deciding if we need to synch hierarchical relationships
//
public boolean getShouldSyncHierarchicalRelationships() {
- return this.syncHierarchicalRelationships;
+ return this.syncHierarchicalRelationships;
}
public void setShouldSyncHierarchicalRelationships(boolean flag) {
- this.syncHierarchicalRelationships = flag;
+ this.syncHierarchicalRelationships = flag;
}
@Override
public void prepareSync() throws Exception {
- this.setShouldUpdateRevNumber(AuthorityServiceUtils.DONT_UPDATE_REV); // Never update rev nums on sync operations
+ this.setShouldUpdateRevNumber(AuthorityServiceUtils.DONT_UPDATE_REV); // Never update rev nums on sync operations
}
@Override
protected String getRefnameDisplayName(DocumentWrapper<DocumentModel> docWrapper) {
- String result = null;
-
- DocumentModel docModel = docWrapper.getWrappedObject();
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
- RefName.AuthorityItem refname = (RefName.AuthorityItem)getRefName(ctx, docModel);
- result = refname.getDisplayName();
-
- return result;
+ String result = null;
+
+ DocumentModel docModel = docWrapper.getWrappedObject();
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
+ RefName.AuthorityItem refname = (RefName.AuthorityItem)getRefName(ctx, docModel);
+ result = refname.getDisplayName();
+
+ return result;
}
/*
*/
@Override
public RefName.RefNameInterface getRefName(ServiceContext ctx,
- DocumentModel docModel) {
- RefName.RefNameInterface refname = null;
-
- try {
- String displayName = getPrimaryDisplayName(docModel, authorityItemCommonSchemaName,
+ DocumentModel docModel) {
+ RefName.RefNameInterface refname = null;
+
+ try {
+ String displayName = getPrimaryDisplayName(docModel, authorityItemCommonSchemaName,
getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
- if (Tools.isEmpty(displayName)) {
- throw new Exception("The displayName for this authority term was empty or not set.");
- }
+ if (Tools.isEmpty(displayName)) {
+ throw new Exception("The displayName for this authority term was empty or not set.");
+ }
- String shortIdentifier = (String) docModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
- if (Tools.isEmpty(shortIdentifier)) {
- // We didn't find a short ID in the payload request, so we need to synthesize one.
- shortIdentifier = handleDisplayNameAsShortIdentifier(docModel); // updates the document model with the new short ID as a side-effect
- }
-
- String authorityRefBaseName = getAuthorityRefNameBase();
- if (Tools.isEmpty(authorityRefBaseName)) {
- throw new Exception("Could not create the refName for this authority term, because the refName for its authority parent was empty.");
- }
-
- // Create the items refname using the parent's as a base
- RefName.Authority parentsRefName = RefName.Authority.parse(authorityRefBaseName);
- refname = RefName.buildAuthorityItem(parentsRefName, shortIdentifier, displayName);
- // Now update the document model with the refname value
- String refNameStr = refname.toString();
- docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REF_NAME, refNameStr); // REM - This field is deprecated now that the refName is part of the collection_space core schema
+ String shortIdentifier = (String) docModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+ if (Tools.isEmpty(shortIdentifier)) {
+ // We didn't find a short ID in the payload request, so we need to synthesize one.
+ shortIdentifier = handleDisplayNameAsShortIdentifier(docModel); // updates the document model with the new short ID as a side-effect
+ }
+
+ String authorityRefBaseName = getAuthorityRefNameBase();
+ if (Tools.isEmpty(authorityRefBaseName)) {
+ throw new Exception("Could not create the refName for this authority term, because the refName for its authority parent was empty.");
+ }
+
+ // Create the items refname using the parent's as a base
+ RefName.Authority parentsRefName = RefName.Authority.parse(authorityRefBaseName);
+ refname = RefName.buildAuthorityItem(parentsRefName, shortIdentifier, displayName);
+ // Now update the document model with the refname value
+ String refNameStr = refname.toString();
+ docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REF_NAME, refNameStr); // REM - This field is deprecated now that the refName is part of the collection_space core schema
- } catch (Exception e) {
- logger.error(e.getMessage(), e);
- }
+ } catch (Exception e) {
+ logger.error(e.getMessage(), e);
+ }
return refname;
}
public String getUri(DocumentModel docModel) {
// Laramie20110510 CSPACE-3932
String authorityServicePath = getAuthorityServicePath();
- if(inAuthority==null) { // Only true with the first document model received, on queries to wildcarded authorities
+ if(inAuthority==null) { // Only true with the first document model received, on queries to wildcarded authorities
wildcardedAuthorityRequest = true;
}
// If this search crosses multiple authorities, get the inAuthority value
// from each record, rather than using the cached value from the first record
if(wildcardedAuthorityRequest) {
- try {
- inAuthority = (String) docModel.getProperty(authorityItemCommonSchemaName,
- AuthorityItemJAXBSchema.IN_AUTHORITY);
- } catch (ClientException pe) {
- throw new RuntimeException("Could not get parent specifier for item!");
- }
+ try {
+ inAuthority = (String) docModel.getProperty(authorityItemCommonSchemaName,
+ AuthorityItemJAXBSchema.IN_AUTHORITY);
+ } catch (ClientException pe) {
+ throw new RuntimeException("Could not get parent specifier for item!");
+ }
}
return "/" + authorityServicePath + '/' + inAuthority + '/' + AuthorityClient.ITEMS + '/' + getCsid(docModel);
}
* Note: the Vocabulary service's VocabularyItemDocumentModelHandler class overrides this method.
*/
protected ListResultField getListResultsDisplayNameField() {
- ListResultField result = new ListResultField();
- // Per CSPACE-5132, the name of this element remains 'displayName'
+ ListResultField result = new ListResultField();
+ // Per CSPACE-5132, the name of this element remains 'displayName'
// for backwards compatibility, although its value is obtained
// from the termDisplayName field.
//
// In CSPACE-5134, these list results will change substantially
// to return display names for both the preferred term and for
// each non-preferred term (if any).
- result.setElement(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
- result.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
+ result.setElement(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+ result.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_DISPLAY_NAME));
-
- return result;
+
+ return result;
}
/*
* Note: the Vocabulary service's VocabularyItemDocumentModelHandler class overrides this method.
*/
protected ListResultField getListResultsTermStatusField() {
- ListResultField result = new ListResultField();
+ ListResultField result = new ListResultField();
- result.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
- result.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
+ result.setElement(AuthorityItemJAXBSchema.TERM_STATUS);
+ result.setXpath(NuxeoUtils.getPrimaryXPathPropertyName(
authorityItemCommonSchemaName, getItemTermInfoGroupXPathBase(), AuthorityItemJAXBSchema.TERM_STATUS));
return result;
}
private boolean isTermDisplayName(String elName) {
- return AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName) || VocabularyItemJAXBSchema.DISPLAY_NAME.equals(elName);
+ return AuthorityItemJAXBSchema.TERM_DISPLAY_NAME.equals(elName) || VocabularyItemJAXBSchema.DISPLAY_NAME.equals(elName);
}
/*
// One-time initialization for each authority item service.
if (isListItemArrayExtended() == false) {
- synchronized(AuthorityItemDocumentModelHandler.class) {
- if (isListItemArrayExtended() == false) {
- int nFields = list.size();
- // Ensure that each item in a list of Authority items includes
- // a set of common fields, so we do not depend upon configuration
- // for general logic.
- List<Integer> termDisplayNamePositionsInList = new ArrayList<>();
- boolean hasShortId = false;
- boolean hasTermStatus = false;
- for (int i = 0; i < nFields; i++) {
- ListResultField field = list.get(i);
- String elName = field.getElement();
- if (isTermDisplayName(elName) == true) {
- termDisplayNamePositionsInList.add(i);
- } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) {
- hasShortId = true;
- } else if (AuthorityItemJAXBSchema.TERM_STATUS.equals(elName)) {
- hasTermStatus = true;
- }
- }
-
- ListResultField field;
+ synchronized(AuthorityItemDocumentModelHandler.class) {
+ if (isListItemArrayExtended() == false) {
+ int nFields = list.size();
+ // Ensure that each item in a list of Authority items includes
+ // a set of common fields, so we do not depend upon configuration
+ // for general logic.
+ List<Integer> termDisplayNamePositionsInList = new ArrayList<>();
+ boolean hasShortId = false;
+ boolean hasTermStatus = false;
+ for (int i = 0; i < nFields; i++) {
+ ListResultField field = list.get(i);
+ String elName = field.getElement();
+ if (isTermDisplayName(elName) == true) {
+ termDisplayNamePositionsInList.add(i);
+ } else if (AuthorityItemJAXBSchema.SHORT_IDENTIFIER.equals(elName)) {
+ hasShortId = true;
+ } else if (AuthorityItemJAXBSchema.TERM_STATUS.equals(elName)) {
+ hasTermStatus = true;
+ }
+ }
+
+ ListResultField field;
// Certain fields in authority item list results
// are handled specially here
// terms (if any). The following is a placeholder
// entry that will trigger this code. See the
// getListResultValue() method in this class.
- field = getListResultsDisplayNameField();
- list.add(field);
+ field = getListResultsDisplayNameField();
+ list.add(field);
// Short identifier
- if (!hasShortId) {
- field = new ListResultField();
- field.setElement(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
- field.setXpath(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
- list.add(field);
- }
+ if (!hasShortId) {
+ field = new ListResultField();
+ field.setElement(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+ field.setXpath(AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+ list.add(field);
+ }
// Term status
- if (!hasTermStatus) {
- field = getListResultsTermStatusField();
- list.add(field);
- }
+ if (!hasTermStatus) {
+ field = getListResultsTermStatusField();
+ list.add(field);
+ }
- }
+ }
- setListItemArrayExtended(true);
- } // end of synchronized block
+ setListItemArrayExtended(true);
+ } // end of synchronized block
}
return list;
*/
@Override
public void handleWorkflowTransition(ServiceContext ctx, DocumentWrapper<DocumentModel> wrapDoc, TransitionDef transitionDef) throws Exception {
- // Decide whether or not to update the revision number
- if (this.getShouldUpdateRevNumber() == true) { // We don't update the rev number of synchronization requests
- updateRevNumbers(wrapDoc);
- }
- //
- // We can't delete an authority item that has referencing records.
- //
- DocumentModel docModel = wrapDoc.getWrappedObject();
- if (transitionDef.getName().equalsIgnoreCase(WorkflowClient.WORKFLOWTRANSITION_DELETE)) {
- long refsToAllObjects = hasReferencingObjects(ctx, docModel, false);
- long refsToSoftDeletedObjects = hasReferencingObjects(ctx, docModel, true);
- if (refsToAllObjects > 0) {
- if (refsToAllObjects > refsToSoftDeletedObjects) {
- //
- // If the number of refs to active objects is greater than the number of refs to
- // soft deleted objects then we can't delete the item.
- //
- throw new DocumentReferenceException(String.format("Cannot delete authority item '%s' because it still has records in the system that are referencing it. See the service layer log file for details.",
- docModel.getName()));
- }
- }
- }
+ // Decide whether or not to update the revision number
+ if (this.getShouldUpdateRevNumber() == true) { // We don't update the rev number of synchronization requests
+ updateRevNumbers(wrapDoc);
+ }
+ //
+ // We can't delete an authority item that has referencing records.
+ //
+ DocumentModel docModel = wrapDoc.getWrappedObject();
+ if (transitionDef.getName().equalsIgnoreCase(WorkflowClient.WORKFLOWTRANSITION_DELETE)) {
+ long refsToAllObjects = hasReferencingObjects(ctx, docModel, false);
+ long refsToSoftDeletedObjects = hasReferencingObjects(ctx, docModel, true);
+ if (refsToAllObjects > 0) {
+ if (refsToAllObjects > refsToSoftDeletedObjects) {
+ //
+ // If the number of refs to active objects is greater than the number of refs to
+ // soft deleted objects then we can't delete the item.
+ //
+ throw new DocumentReferenceException(String.format("Cannot delete authority item '%s' because it still has records in the system that are referencing it. See the service layer log file for details.",
+ docModel.getName()));
+ }
+ }
+ }
}
/**
* @throws Exception
*/
protected boolean handleRelationsSync(DocumentWrapper<Object> wrapDoc) throws Exception {
- boolean result = false;
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
+ boolean result = false;
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
//
// Get information about the local authority item so we can compare with corresponding item on the shared authority server
//
- AuthorityItemSpecifier authorityItemSpecifier = (AuthorityItemSpecifier) wrapDoc.getWrappedObject();
+ AuthorityItemSpecifier authorityItemSpecifier = (AuthorityItemSpecifier) wrapDoc.getWrappedObject();
DocumentModel itemDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), getAuthorityItemCommonSchemaName(),
- authorityItemSpecifier);
+ authorityItemSpecifier);
if (itemDocModel == null) {
- throw new DocumentNotFoundException(String.format("Could not find authority item resource with CSID='%s'",
- authorityItemSpecifier.getItemSpecifier().value));
+ throw new DocumentNotFoundException(String.format("Could not find authority item resource with CSID='%s'",
+ authorityItemSpecifier.getItemSpecifier().value));
}
Long localItemRev = (Long) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.REV);
Boolean localIsProposed = (Boolean) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.PROPOSED);
// Now get the item's Authority (the parent) information
//
DocumentModel authorityDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), authorityCommonSchemaName,
- authorityItemSpecifier.getParentSpecifier());
+ authorityItemSpecifier.getParentSpecifier());
String authorityShortId = (String)NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.SHORT_IDENTIFIER);
String localParentCsid = authorityDocModel.getName();
String remoteClientConfigName = (String)NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.REMOTECLIENT_CONFIG_NAME);
AuthorityItemSpecifier sasAuthorityItemSpecifier = new AuthorityItemSpecifier(SpecifierForm.URN_NAME, authorityShortId, itemShortId);
// Get the shared authority server's copy
PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadInFromRemoteServer(sasAuthorityItemSpecifier,
- remoteClientConfigName, getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.INCLUDE_RELATIONS);
+ remoteClientConfigName, getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.INCLUDE_RELATIONS);
//
// Get the RelationsCommonList and remove the CSIDs since they are for remote items only. We'll use
relationsCommonListPart.clearElementBody(); // clear the existing DOM element that was created from the incoming XML payload
RelationsCommonList rcl = (RelationsCommonList) relationsCommonListPart.getBody(); // Get the JAX-B object and clear the CSID values
for (RelationsCommonList.RelationListItem listItem : rcl.getRelationListItem()) {
- // clear the remote relation item's CSID
- listItem.setCsid(null);
- // clear the remote subject's CSID
- listItem.setSubjectCsid(null);
- listItem.getSubject().setCsid(null);
- listItem.getSubject().setUri(null);
- // clear the remote object's CSID
- listItem.setObjectCsid(null);
- listItem.getObject().setCsid(null);
- listItem.getObject().setUri(null);
+ // clear the remote relation item's CSID
+ listItem.setCsid(null);
+ // clear the remote subject's CSID
+ listItem.setSubjectCsid(null);
+ listItem.getSubject().setCsid(null);
+ listItem.getSubject().setUri(null);
+ // clear the remote object's CSID
+ listItem.setObjectCsid(null);
+ listItem.getObject().setCsid(null);
+ listItem.getObject().setUri(null);
}
//
sasPayloadIn.setParts(newPartList);
sasPayloadIn = new PoxPayloadIn(sasPayloadIn.toXML()); // Builds a new payload using the current set of parts -i.e., just the relations part
- sasPayloadIn = AuthorityServiceUtils.filterRefnameDomains(ctx, sasPayloadIn); // We need to filter the domain name part of any and all refnames in the payload
- AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
- PoxPayloadOut payloadOut = authorityResource.updateAuthorityItem(ctx,
- ctx.getResourceMap(),
- ctx.getUriInfo(),
- localParentCsid, // parent's CSID
- localItemCsid, // item's CSID
- sasPayloadIn, // the payload from the remote SAS
- AuthorityServiceUtils.DONT_UPDATE_REV, // don't update the parent's revision number
- AuthorityServiceUtils.NOT_PROPOSED, // The items is not proposed, make it a real SAS item now
- AuthorityServiceUtils.SAS_ITEM); // Since we're sync'ing, this must be a SAS item
- if (payloadOut != null) {
- ctx.setOutput(payloadOut);
- result = true;
- }
-
- return result;
+ sasPayloadIn = AuthorityServiceUtils.filterRefnameDomains(ctx, sasPayloadIn); // We need to filter the domain name part of any and all refnames in the payload
+ AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
+ PoxPayloadOut payloadOut = authorityResource.updateAuthorityItem(ctx,
+ ctx.getResourceMap(),
+ ctx.getUriInfo(),
+ localParentCsid, // parent's CSID
+ localItemCsid, // item's CSID
+ sasPayloadIn, // the payload from the remote SAS
+ AuthorityServiceUtils.DONT_UPDATE_REV, // don't update the parent's revision number
+ AuthorityServiceUtils.NOT_PROPOSED, // The items is not proposed, make it a real SAS item now
+ AuthorityServiceUtils.SAS_ITEM); // Since we're sync'ing, this must be a SAS item
+ if (payloadOut != null) {
+ ctx.setOutput(payloadOut);
+ result = true;
+ }
+
+ return result;
}
@Override
public boolean handleSync(DocumentWrapper<Object> wrapDoc) throws Exception {
- boolean result = false;
+ boolean result = false;
- if (this.getShouldSyncHierarchicalRelationships() == true) {
- result = handleRelationsSync(wrapDoc);
- } else {
- result = handlePayloadSync(wrapDoc);
- }
-
- return result;
+ if (this.getShouldSyncHierarchicalRelationships() == true) {
+ result = handleRelationsSync(wrapDoc);
+ } else {
+ result = handlePayloadSync(wrapDoc);
+ }
+
+ return result;
}
/**
* @throws Exception
*/
protected boolean handlePayloadSync(DocumentWrapper<Object> wrapDoc) throws Exception {
- boolean result = false;
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
-
+ boolean result = false;
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = getServiceContext();
+
//
// Get information about the local authority item so we can compare with corresponding item on the shared authority server
//
- AuthorityItemSpecifier authorityItemSpecifier = (AuthorityItemSpecifier) wrapDoc.getWrappedObject();
+ AuthorityItemSpecifier authorityItemSpecifier = (AuthorityItemSpecifier) wrapDoc.getWrappedObject();
DocumentModel itemDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), getAuthorityItemCommonSchemaName(),
- authorityItemSpecifier);
+ authorityItemSpecifier);
if (itemDocModel == null) {
- throw new DocumentNotFoundException(String.format("Could not find authority item resource with CSID='%s'",
- authorityItemSpecifier.getItemSpecifier().value));
+ throw new DocumentNotFoundException(String.format("Could not find authority item resource with CSID='%s'",
+ authorityItemSpecifier.getItemSpecifier().value));
}
Long localItemRev = (Long) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.REV);
Boolean localIsProposed = (Boolean) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.PROPOSED);
// Now get the item's Authority (the parent) information
//
DocumentModel authorityDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), authorityCommonSchemaName,
- authorityItemSpecifier.getParentSpecifier());
+ authorityItemSpecifier.getParentSpecifier());
String authorityShortId = (String) NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.SHORT_IDENTIFIER);
String localParentCsid = authorityDocModel.getName();
String remoteClientConfigName = (String)NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.REMOTECLIENT_CONFIG_NAME);
AuthorityItemSpecifier sasAuthorityItemSpecifier = new AuthorityItemSpecifier(SpecifierForm.URN_NAME, authorityShortId, itemShortId);
// Get the shared authority server's copy
PoxPayloadIn sasPayloadIn = AuthorityServiceUtils.requestPayloadInFromRemoteServer(sasAuthorityItemSpecifier,
- remoteClientConfigName, getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.DONT_INCLUDE_RELATIONS);
+ remoteClientConfigName, getAuthorityServicePath(), getEntityResponseType(), AuthorityClient.DONT_INCLUDE_RELATIONS);
Long sasRev = getRevision(sasPayloadIn);
String sasWorkflowState = getWorkflowState(sasPayloadIn);
//
// If the shared authority item is newer, update our local copy
//
if (sasRev > localItemRev || localIsProposed || ctx.shouldForceSync()) {
- sasPayloadIn = AuthorityServiceUtils.filterRefnameDomains(ctx, sasPayloadIn); // We need to filter the domain name part of any and all refnames in the payload
- AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
- PoxPayloadOut payloadOut = authorityResource.updateAuthorityItem(ctx,
- ctx.getResourceMap(),
- ctx.getUriInfo(),
- localParentCsid, // parent's CSID
- localItemCsid, // item's CSID
- sasPayloadIn, // the payload from the remote SAS
- AuthorityServiceUtils.DONT_UPDATE_REV, // don't update the parent's revision number
- AuthorityServiceUtils.NOT_PROPOSED, // The items is not proposed, make it a real SAS item now
- AuthorityServiceUtils.SAS_ITEM); // Since we're sync'ing, this must be a SAS item
- if (payloadOut != null) {
- ctx.setOutput(payloadOut);
- result = true;
- }
+ sasPayloadIn = AuthorityServiceUtils.filterRefnameDomains(ctx, sasPayloadIn); // We need to filter the domain name part of any and all refnames in the payload
+ AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
+ PoxPayloadOut payloadOut = authorityResource.updateAuthorityItem(ctx,
+ ctx.getResourceMap(),
+ ctx.getUriInfo(),
+ localParentCsid, // parent's CSID
+ localItemCsid, // item's CSID
+ sasPayloadIn, // the payload from the remote SAS
+ AuthorityServiceUtils.DONT_UPDATE_REV, // don't update the parent's revision number
+ AuthorityServiceUtils.NOT_PROPOSED, // The items is not proposed, make it a real SAS item now
+ AuthorityServiceUtils.SAS_ITEM); // Since we're sync'ing, this must be a SAS item
+ if (payloadOut != null) {
+ ctx.setOutput(payloadOut);
+ result = true;
+ }
}
//
// Check to see if we need to update the local items's workflow state to reflect that of the remote's
//
- List<String> transitionList = getTransitionList(sasWorkflowState, localItemWorkflowState);
+ List<String> transitionList = getTransitionList(sasWorkflowState, localItemWorkflowState);
if (transitionList.isEmpty() == false) {
- AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath()); // Get the authority (parent) client not the item client
- //
- // We need to move the local item to the SAS workflow state. This might involve multiple transitions.
- //
- for (String transition:transitionList) {
- try {
- authorityResource.updateItemWorkflowWithTransition(ctx, localParentCsid, localItemCsid, transition, AuthorityServiceUtils.DONT_UPDATE_REV);
- } catch (DocumentReferenceException de) {
- //
- // This exception means we tried unsuccessfully to soft-delete (workflow transition 'delete') an item that still has references to it from other records.
- //
- AuthorityServiceUtils.setAuthorityItemDeprecated(ctx, itemDocModel, authorityItemCommonSchemaName, AuthorityServiceUtils.DEPRECATED); // Since we can't sof-delete it, we need to mark it as deprecated since it is soft-deleted on the SAS
- logger.warn(String.format("Could not transition item CSID='%s' from workflow state '%s' to '%s'. Check the services log file for details.",
- localItemCsid, localItemWorkflowState, sasWorkflowState));
- }
- }
- result = true;
+ AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath()); // Get the authority (parent) client not the item client
+ //
+ // We need to move the local item to the SAS workflow state. This might involve multiple transitions.
+ //
+ for (String transition:transitionList) {
+ try {
+ authorityResource.updateItemWorkflowWithTransition(ctx, localParentCsid, localItemCsid, transition, AuthorityServiceUtils.DONT_UPDATE_REV);
+ } catch (DocumentReferenceException de) {
+ //
+ // This exception means we tried unsuccessfully to soft-delete (workflow transition 'delete') an item that still has references to it from other records.
+ //
+ AuthorityServiceUtils.setAuthorityItemDeprecated(ctx, itemDocModel, authorityItemCommonSchemaName, AuthorityServiceUtils.DEPRECATED); // Since we can't sof-delete it, we need to mark it as deprecated since it is soft-deleted on the SAS
+ logger.warn(String.format("Could not transition item CSID='%s' from workflow state '%s' to '%s'. Check the services log file for details.",
+ localItemCsid, localItemWorkflowState, sasWorkflowState));
+ }
+ }
+ result = true;
}
return result;
* state. This might involve making multiple transitions.
*
* WIKI:
- * See table at https://wiki.collectionspace.org/pages/viewpage.action?pageId=162496564
+ * See table at https://wiki.collectionspace.org/pages/viewpage.action?pageId=162496564
*
*/
private List<String> getTransitionList(String sasWorkflowState, String localItemWorkflowState) throws DocumentException {
- List<String> result = new ArrayList<String>();
- //
- // The first set of conditions maps a replication-server "project" state to a local client state of "replicated"
- //
- if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
- // Do nothing. We're good with this state
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
- //
- // The second set of conditions maps a replication-server "deleted" state to a local client state of "deleted"
- //
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
- // Do nothing. We're good with this state
- //
- // The third set of conditions maps a replication-server "replicated" state to a local state of "replicated"
- //
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
- // Do nothing. We're good with this state
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
- //
- // The last set of conditions maps a replication-server "replicated_deleted" state to a local client state of "deleted"
- //
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
- result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
- } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
- // Do nothing. We're good with this state
- } else {
- //
- // If we get here, we've encountered a SAS workflow state that we don't recognize.
- //
- throw new DocumentException(String.format("Encountered an invalid workflow state of '%s' on a SAS authority item.", sasWorkflowState));
- }
-
- return result;
+ List<String> result = new ArrayList<String>();
+ //
+ // The first set of conditions maps a replication-server "project" state to a local client state of "replicated"
+ //
+ if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
+ // Do nothing. We're good with this state
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
+ //
+ // The second set of conditions maps a replication-server "deleted" state to a local client state of "deleted"
+ //
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
+ // Do nothing. We're good with this state
+ //
+ // The third set of conditions maps a replication-server "replicated" state to a local state of "replicated"
+ //
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
+ // Do nothing. We're good with this state
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_UNDELETE);
+ //
+ // The last set of conditions maps a replication-server "replicated_deleted" state to a local client state of "deleted"
+ //
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_PROJECT)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_DELETED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_REPLICATE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED)) {
+ result.add(WorkflowClient.WORKFLOWTRANSITION_DELETE);
+ } else if (sasWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED) && localItemWorkflowState.equals(WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED)) {
+ // Do nothing. We're good with this state
+ } else {
+ //
+ // If we get here, we've encountered a SAS workflow state that we don't recognize.
+ //
+ throw new DocumentException(String.format("Encountered an invalid workflow state of '%s' on a SAS authority item.", sasWorkflowState));
+ }
+
+ return result;
}
/* (non-Javadoc)
*/
@Override
public boolean handleDelete(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- boolean result = true;
-
- ServiceContext ctx = getServiceContext();
- DocumentModel docModel = wrapDoc.getWrappedObject();
-
- long refsToAllObjects = hasReferencingObjects(ctx, docModel, false);
- long refsToSoftDeletedObjects = hasReferencingObjects(ctx, docModel, true);
- if (refsToAllObjects > 0) {
- if (refsToAllObjects > refsToSoftDeletedObjects) {
- //
- // If the number of refs to active objects is greater than the number of refs to
- // soft deleted objects then we can't delete the item.
- //
- throw new DocumentReferenceException(String.format("Cannot delete authority item '%s' because it still has records in the system that are referencing it. See the service layer log file for details.",
- docModel.getName()));
- } else {
- //
- // If all the refs are to soft-deleted objects, we should soft-delete this authority item instead of hard-deleting it and instead of failing.
- //
- String parentCsid = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.IN_AUTHORITY);
- String itemCsid = docModel.getName();
- AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
- authorityResource.updateItemWorkflowWithTransition(ctx, parentCsid, itemCsid, WorkflowClient.WORKFLOWTRANSITION_DELETE,
- this.getShouldUpdateRevNumber());
- result = false; // Don't delete since we just soft-deleted it.
- }
- }
-
- //
- // Since we've changed the state of the parent by deleting (or soft-deleting) one of its items, we might need to update the parent rev number
- //
- if (getShouldUpdateRevNumber() == true) {
- updateRevNumbers(wrapDoc);
- }
-
- return result;
+ boolean result = true;
+
+ ServiceContext ctx = getServiceContext();
+ DocumentModel docModel = wrapDoc.getWrappedObject();
+
+ long refsToAllObjects = hasReferencingObjects(ctx, docModel, false);
+ long refsToSoftDeletedObjects = hasReferencingObjects(ctx, docModel, true);
+ if (refsToAllObjects > 0) {
+ if (refsToAllObjects > refsToSoftDeletedObjects) {
+ //
+ // If the number of refs to active objects is greater than the number of refs to
+ // soft deleted objects then we can't delete the item.
+ //
+ throw new DocumentReferenceException(String.format("Cannot delete authority item '%s' because it still has records in the system that are referencing it. See the service layer log file for details.",
+ docModel.getName()));
+ } else {
+ //
+ // If all the refs are to soft-deleted objects, we should soft-delete this authority item instead of hard-deleting it and instead of failing.
+ //
+ String parentCsid = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.IN_AUTHORITY);
+ String itemCsid = docModel.getName();
+ AuthorityResource authorityResource = (AuthorityResource) ctx.getResource(getAuthorityServicePath());
+ authorityResource.updateItemWorkflowWithTransition(ctx, parentCsid, itemCsid, WorkflowClient.WORKFLOWTRANSITION_DELETE,
+ this.getShouldUpdateRevNumber());
+ result = false; // Don't delete since we just soft-deleted it.
+ }
+ }
+
+ //
+ // Since we've changed the state of the parent by deleting (or soft-deleting) one of its items, we might need to update the parent rev number
+ //
+ if (getShouldUpdateRevNumber() == true) {
+ updateRevNumbers(wrapDoc);
+ }
+
+ return result;
}
/**
* @throws Exception
*/
private long hasReferencingObjects(ServiceContext ctx, DocumentModel docModel, boolean onlyRefsToDeletedObjects) throws Exception {
- long result = 0;
-
- String inAuthorityCsid = (String) docModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY);
- AuthorityResource authorityResource = (AuthorityResource)ctx.getResource(getAuthorityServicePath());
- String itemCsid = docModel.getName();
+ long result = 0;
+
+ String inAuthorityCsid = (String) docModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY);
+ AuthorityResource authorityResource = (AuthorityResource)ctx.getResource(getAuthorityServicePath());
+ String itemCsid = docModel.getName();
UriTemplateRegistry uriTemplateRegistry = ServiceMain.getInstance().getUriTemplateRegistry();
if (ctx.getUriInfo() == null) {
- //
- // We need a UriInfo object so we can pass "query" params to the AuthorityResource's getReferencingObjects() method
- //
- ctx.setUriInfo(this.getServiceContext().getUriInfo()); // try to get a UriInfo instance from the handler's context
+ //
+ // We need a UriInfo object so we can pass "query" params to the AuthorityResource's getReferencingObjects() method
+ //
+ ctx.setUriInfo(this.getServiceContext().getUriInfo()); // try to get a UriInfo instance from the handler's context
}
+
+ //
+ // Since the call to get referencing objects might indirectly use the WorkflowClient.WORKFLOW_QUERY_NONDELETED query param, we need to
+ // temporarily remove that query param if it is set. If set, we'll save the value and reset once we're finished.
+ //
+ boolean doesContainValue = ctx.getUriInfo().getQueryParameters().containsKey(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ String previousValue = ctx.getUriInfo().getQueryParameters().getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ AuthorityRefDocList refObjs = null;
+ try {
+ if (doesContainValue) {
+ ctx.getUriInfo().getQueryParameters().remove(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ }
- ctx.getUriInfo().getQueryParameters().addFirst(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED, Boolean.toString(onlyRefsToDeletedObjects)); // Add the wf_only_deleted query param to the resource call
- AuthorityRefDocList refObjs = authorityResource.getReferencingObjects(ctx, inAuthorityCsid, itemCsid,
- uriTemplateRegistry, ctx.getUriInfo());
- ctx.getUriInfo().getQueryParameters().remove(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED); // Need to clear wf_only_deleted values to prevent unexpected side effects
-
- result = refObjs.getTotalItems();
- if (result > 0) {
- logger.error(String.format("Cannot delete authority item '%s' because it still has %d records in the system that are referencing it.",
- itemCsid, refObjs.getTotalItems()));
- if (logger.isWarnEnabled() == true) {
- logReferencingObjects(docModel, refObjs);
- }
- }
-
- return result;
+ ctx.getUriInfo().getQueryParameters().addFirst(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED_QP, Boolean.toString(onlyRefsToDeletedObjects)); // Add the wf_only_deleted query param to the resource call
+ refObjs = authorityResource.getReferencingObjects(ctx, inAuthorityCsid, itemCsid, uriTemplateRegistry, ctx.getUriInfo());
+ } finally {
+ ctx.getUriInfo().getQueryParameters().remove(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED_QP); // Need to clear wf_only_deleted values to prevent unexpected side effects
+ if (doesContainValue) {
+ ctx.getUriInfo().getQueryParameters().addFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP, previousValue);
+ }
+ }
+
+ result = refObjs.getTotalItems();
+ if (result > 0) {
+ logger.error(String.format("Cannot delete authority item '%s' because it still has %d records in the system that are referencing it.",
+ itemCsid, refObjs.getTotalItems()));
+ if (logger.isWarnEnabled() == true) {
+ logReferencingObjects(docModel, refObjs);
+ }
+ }
+
+ return result;
}
private void logReferencingObjects(DocumentModel docModel, AuthorityRefDocList refObjs) {
- List<AuthorityRefDocList.AuthorityRefDocItem> items = refObjs.getAuthorityRefDocItem();
- int i = 0;
- logger.warn(String.format("The authority item '%s' has the following references:", docModel.getName()));
- for (AuthorityRefDocList.AuthorityRefDocItem item : items) {
+ List<AuthorityRefDocList.AuthorityRefDocItem> items = refObjs.getAuthorityRefDocItem();
+ int i = 0;
+ logger.warn(String.format("The authority item '%s' has the following references:", docModel.getName()));
+ for (AuthorityRefDocList.AuthorityRefDocItem item : items) {
logger.warn(docModel.getName() + " referenced by : list-item[" + i + "] "
+ item.getDocType() + "("
+ item.getDocId() + ") Name:["
* @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#completeUpdate(org.collectionspace.services.common.document.DocumentWrapper)
*/
public void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- // Must call our super class' version first
- super.completeUpdate(wrapDoc);
-
- //
- // Look for and update authority references with the updated refName
- //
+ // Must call our super class' version first
+ super.completeUpdate(wrapDoc);
+
+ //
+ // Look for and update authority references with the updated refName
+ //
if (hasRefNameUpdate() == true) {
// We have work to do.
if (logger.isDebugEnabled()) {
/*
* Note that the Vocabulary service's document-model for items overrides this method.
*/
- protected String getPrimaryDisplayName(DocumentModel docModel, String schema,
- String complexPropertyName, String fieldName) {
- String result = null;
+ protected String getPrimaryDisplayName(DocumentModel docModel, String schema,
+ String complexPropertyName, String fieldName) {
+ String result = null;
- result = getStringValueInPrimaryRepeatingComplexProperty(docModel, schema, complexPropertyName, fieldName);
-
- return result;
- }
+ result = getStringValueInPrimaryRepeatingComplexProperty(docModel, schema, complexPropertyName, fieldName);
+
+ return result;
+ }
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleUpdate(org.collectionspace.services.common.document.DocumentWrapper)
// FIXME: Once we remove the refName field from the authority item schemas, we can remove this override method since our super does everthing for us now.
@Deprecated
public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- // Must call our super's version first, this updates the core schema and the relationship records to deal with possible refName changes/update
+ // Must call our super's version first, this updates the core schema and the relationship records to deal with possible refName changes/update
super.handleUpdate(wrapDoc);
if (this.hasRefNameUpdate() == true) {
- DocumentModel docModel = wrapDoc.getWrappedObject();
- docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REF_NAME, this.newRefNameOnUpdate); // This field is deprecated since it is now a duplicate of what is in the collectionspace_core:refName field
+ DocumentModel docModel = wrapDoc.getWrappedObject();
+ docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REF_NAME, this.newRefNameOnUpdate); // This field is deprecated since it is now a duplicate of what is in the collectionspace_core:refName field
}
}
// Handles both update calls (PUTS) AND create calls (POSTS)
//
public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc, Action action) throws Exception {
- super.fillAllParts(wrapDoc, action);
+ super.fillAllParts(wrapDoc, action);
DocumentModel documentModel = wrapDoc.getWrappedObject();
- //
- // Update the record's revision number on both CREATE and UPDATE actions (as long as it is NOT a SAS authority item)
- //
+ //
+ // Update the record's revision number on both CREATE and UPDATE actions (as long as it is NOT a SAS authority item)
+ //
Boolean propertyValue = (Boolean) documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SAS);
boolean isMarkedAsSASItem = propertyValue != null ? propertyValue : false;
- if (this.getShouldUpdateRevNumber() == true && !isMarkedAsSASItem) { // We won't update rev numbers on synchronization with SAS items and on local changes to SAS items
- updateRevNumbers(wrapDoc);
- }
-
- if (getShouldUpdateSASFields() == true) {
- //
- // If this is a proposed item (not part of the SAS), mark it as such
- //
- documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PROPOSED,
- new Boolean(this.getIsProposed()));
- //
- // If it is a SAS authority item, mark it as such
- //
- documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SAS,
- new Boolean(this.getIsSASItem()));
- }
+ if (this.getShouldUpdateRevNumber() == true && !isMarkedAsSASItem) { // We won't update rev numbers on synchronization with SAS items and on local changes to SAS items
+ updateRevNumbers(wrapDoc);
+ }
+
+ if (getShouldUpdateSASFields() == true) {
+ //
+ // If this is a proposed item (not part of the SAS), mark it as such
+ //
+ documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.PROPOSED,
+ new Boolean(this.getIsProposed()));
+ //
+ // If it is a SAS authority item, mark it as such
+ //
+ documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SAS,
+ new Boolean(this.getIsSASItem()));
+ }
}
/**
* @throws Exception
*/
protected void updateRevNumbers(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- DocumentModel documentModel = wrapDoc.getWrappedObject();
- Long rev = (Long)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV);
- if (rev == null) {
- rev = (long)0;
- } else {
- rev++;
- }
- documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV, rev);
- //
- // Next, update the inAuthority (the parent's) rev number
- //
- String inAuthorityCsid = this.getInAuthorityCsid();
- if (inAuthorityCsid == null) {
- // When inAuthorityCsid is null, it usually means we're performing and update or synch with the SAS
- inAuthorityCsid = (String)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY);
- }
- DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), inAuthorityCsid);
- if (inAuthorityDocModel != null) {
- Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV);
- if (parentRev == null) {
- parentRev = new Long(0);
- }
- parentRev++;
- inAuthorityDocModel.setProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV, parentRev);
- getRepositorySession().saveDocument(inAuthorityDocModel);
- } else {
- logger.warn(String.format("Containing authority '%s' for item '%s' has been deleted. Item is orphaned, so revision numbers can't be updated.",
- inAuthorityCsid, documentModel.getName()));
- }
+ DocumentModel documentModel = wrapDoc.getWrappedObject();
+ Long rev = (Long)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV);
+ if (rev == null) {
+ rev = (long)0;
+ } else {
+ rev++;
+ }
+ documentModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.REV, rev);
+ //
+ // Next, update the inAuthority (the parent's) rev number
+ //
+ String inAuthorityCsid = this.getInAuthorityCsid();
+ if (inAuthorityCsid == null) {
+ // When inAuthorityCsid is null, it usually means we're performing and update or synch with the SAS
+ inAuthorityCsid = (String)documentModel.getProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY);
+ }
+ DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), inAuthorityCsid);
+ if (inAuthorityDocModel != null) {
+ Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV);
+ if (parentRev == null) {
+ parentRev = new Long(0);
+ }
+ parentRev++;
+ inAuthorityDocModel.setProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV, parentRev);
+ getRepositorySession().saveDocument(inAuthorityDocModel);
+ } else {
+ logger.warn(String.format("Containing authority '%s' for item '%s' has been deleted. Item is orphaned, so revision numbers can't be updated.",
+ inAuthorityCsid, documentModel.getName()));
+ }
}
/**
* If no short identifier was provided in the input payload, generate a
* short identifier from the preferred term display name or term name.
*/
- private String handleDisplayNameAsShortIdentifier(DocumentModel docModel) throws Exception {
- String result = (String) docModel.getProperty(authorityItemCommonSchemaName,
- AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
+ private String handleDisplayNameAsShortIdentifier(DocumentModel docModel) throws Exception {
+ String result = (String) docModel.getProperty(authorityItemCommonSchemaName,
+ AuthorityItemJAXBSchema.SHORT_IDENTIFIER);
- if (Tools.isEmpty(result)) {
- String termDisplayName = getPrimaryDisplayName(
- docModel, authorityItemCommonSchemaName,
- getItemTermInfoGroupXPathBase(),
- AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+ if (Tools.isEmpty(result)) {
+ String termDisplayName = getPrimaryDisplayName(
+ docModel, authorityItemCommonSchemaName,
+ getItemTermInfoGroupXPathBase(),
+ AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
- String termName = getPrimaryDisplayName(
- docModel, authorityItemCommonSchemaName,
- getItemTermInfoGroupXPathBase(),
- AuthorityItemJAXBSchema.TERM_NAME);
+ String termName = getPrimaryDisplayName(
+ docModel, authorityItemCommonSchemaName,
+ getItemTermInfoGroupXPathBase(),
+ AuthorityItemJAXBSchema.TERM_NAME);
- String generatedShortIdentifier = AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(termDisplayName,
- termName);
- docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER,
- generatedShortIdentifier);
- result = generatedShortIdentifier;
- }
-
- return result;
- }
+ String generatedShortIdentifier = AuthorityIdentifierUtils.generateShortIdentifierFromDisplayName(termDisplayName,
+ termName);
+ docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.SHORT_IDENTIFIER,
+ generatedShortIdentifier);
+ result = generatedShortIdentifier;
+ }
+
+ return result;
+ }
/**
* Generate a refName for the authority item from the short identifier
*/
protected String updateRefnameForAuthorityItem(DocumentModel docModel,
String schemaName) throws Exception {
- String result = null;
-
+ String result = null;
+
RefName.RefNameInterface refname = getRefName(getServiceContext(), docModel);
String refNameStr = refname.toString();
docModel.setProperty(schemaName, AuthorityItemJAXBSchema.REF_NAME, refNameStr);
*
* @throws Exception the exception
*/
- private void handleInAuthority(DocumentModel docModel) throws Exception {
- if (inAuthority == null) { // Only happens on queries to wildcarded authorities
- throw new IllegalStateException("Trying to Create an object with no inAuthority value!");
- }
- docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY, inAuthority);
- }
+ private void handleInAuthority(DocumentModel docModel) throws Exception {
+ if (inAuthority == null) { // Only happens on queries to wildcarded authorities
+ throw new IllegalStateException("Trying to Create an object with no inAuthority value!");
+ }
+ docModel.setProperty(authorityItemCommonSchemaName, AuthorityItemJAXBSchema.IN_AUTHORITY, inAuthority);
+ }
/**
* Returns a list of records that reference this authority item
* @throws Exception
*/
public AuthorityRefDocList getReferencingObjects(
- ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
UriTemplateRegistry uriTemplateRegistry,
- List<String> serviceTypes,
- String propertyName,
+ List<String> serviceTypes,
+ String propertyName,
String itemcsid) throws Exception {
AuthorityRefDocList authRefDocList = null;
CoreSessionInterface repoSession = (CoreSessionInterface) ctx.getCurrentRepositorySession();
- boolean releaseRepoSession = false;
+ boolean releaseRepoSession = false;
- try {
- NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
- repoSession = this.getRepositorySession();
- if (repoSession == null) {
- repoSession = repoClient.getRepositorySession(ctx);
- releaseRepoSession = true;
- }
+ try {
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
+ repoSession = this.getRepositorySession();
+ if (repoSession == null) {
+ repoSession = repoClient.getRepositorySession(ctx);
+ releaseRepoSession = true;
+ }
DocumentFilter myFilter = getDocumentFilter();
- try {
- DocumentWrapper<DocumentModel> wrapper = repoClient.getDoc(repoSession, ctx, itemcsid);
- DocumentModel docModel = wrapper.getWrappedObject();
- String refName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.REF_NAME); //docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME);
+ try {
+ DocumentWrapper<DocumentModel> wrapper = repoClient.getDoc(repoSession, ctx, itemcsid);
+ DocumentModel docModel = wrapper.getWrappedObject();
+ String refName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.REF_NAME); //docModel.getPropertyValue(AuthorityItemJAXBSchema.REF_NAME);
authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(
- repoSession, ctx, uriTemplateRegistry, repoClient,
+ repoSession, ctx, uriTemplateRegistry, repoClient,
serviceTypes,
refName,
propertyName,
myFilter, true /*computeTotal*/);
- } catch (PropertyException pe) {
- throw pe;
- } catch (DocumentException de) {
- throw de;
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception ", e);
- }
- throw new DocumentException(e);
- } finally {
- // If we got/aquired a new seesion then we're responsible for releasing it.
- if (releaseRepoSession && repoSession != null) {
- repoClient.releaseRepositorySession(ctx, repoSession);
- }
- }
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception ", e);
- }
- throw new DocumentException(e);
- }
-
+ } catch (PropertyException pe) {
+ throw pe;
+ } catch (DocumentException de) {
+ throw de;
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception ", e);
+ }
+ throw new DocumentException(e);
+ } finally {
+ // If we got/aquired a new seesion then we're responsible for releasing it.
+ if (releaseRepoSession && repoSession != null) {
+ repoClient.releaseRepositorySession(ctx, repoSession);
+ }
+ }
+ } catch (Exception e) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Caught exception ", e);
+ }
+ throw new DocumentException(e);
+ }
+
return authRefDocList;
}
* wildcards and anchor characters) are filtered out from both compared terms.
*/
protected List<String> getPartialTermDisplayNameMatches(List<String> termDisplayNameList, String partialTerm) {
- List<String> result = new ArrayList<>();
- String partialTermMatchExpression = filterAnchorAndWildcardChars(partialTerm).toLowerCase();
+ List<String> result = new ArrayList<>();
+ String partialTermMatchExpression = filterAnchorAndWildcardChars(partialTerm).toLowerCase();
try {
for (String termDisplayName : termDisplayNameList) {
if (termDisplayName.toLowerCase()
logger.warn("Error in regex match pattern '%s' for term display names: %s",
partialTermMatchExpression, pse.getMessage());
}
- return result;
+ return result;
}
/**
}
@SuppressWarnings("unchecked")
- private List<String> getPartialTermDisplayNameMatches(DocumentModel docModel, // REM - CSPACE-5133
- String schema, ListResultField field, String partialTerm) {
- List<String> result = null;
-
- String xpath = field.getXpath(); // results in something like "persons_common:personTermGroupList/[0]/termDisplayName"
- int endOfTermGroup = xpath.lastIndexOf("/[0]/");
- String propertyName = endOfTermGroup != -1 ? xpath.substring(0, endOfTermGroup) : xpath; // it may not be multivalued so the xpath passed in would be the property name
- Object value = null;
-
- try {
- value = docModel.getProperty(schema, propertyName);
- } catch (Exception e) {
- logger.error("Could not extract term display name with property = "
- + propertyName, e);
- }
-
- if (value != null && value instanceof ArrayList) {
- ArrayList<HashMap<String, Object>> termGroupList = (ArrayList<HashMap<String, Object>>)value;
- int arrayListSize = termGroupList.size();
- if (arrayListSize > 1) { // if there's only 1 element in the list then we've already matched the primary term's display name
- List<String> displayNameList = new ArrayList<String>();
- for (int i = 1; i < arrayListSize; i++) { // start at 1, skip the primary term's displayName since we will always return it
- HashMap<String, Object> map = (HashMap<String, Object>)termGroupList.get(i);
- String termDisplayName = (String) map.get(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
- displayNameList.add(i - 1, termDisplayName);
- }
-
- result = getPartialTermDisplayNameMatches(displayNameList, partialTerm);
- }
- }
+ private List<String> getPartialTermDisplayNameMatches(DocumentModel docModel, // REM - CSPACE-5133
+ String schema, ListResultField field, String partialTerm) {
+ List<String> result = null;
+
+ String xpath = field.getXpath(); // results in something like "persons_common:personTermGroupList/[0]/termDisplayName"
+ int endOfTermGroup = xpath.lastIndexOf("/[0]/");
+ String propertyName = endOfTermGroup != -1 ? xpath.substring(0, endOfTermGroup) : xpath; // it may not be multivalued so the xpath passed in would be the property name
+ Object value = null;
+
+ try {
+ value = docModel.getProperty(schema, propertyName);
+ } catch (Exception e) {
+ logger.error("Could not extract term display name with property = "
+ + propertyName, e);
+ }
+
+ if (value != null && value instanceof ArrayList) {
+ ArrayList<HashMap<String, Object>> termGroupList = (ArrayList<HashMap<String, Object>>)value;
+ int arrayListSize = termGroupList.size();
+ if (arrayListSize > 1) { // if there's only 1 element in the list then we've already matched the primary term's display name
+ List<String> displayNameList = new ArrayList<String>();
+ for (int i = 1; i < arrayListSize; i++) { // start at 1, skip the primary term's displayName since we will always return it
+ HashMap<String, Object> map = (HashMap<String, Object>)termGroupList.get(i);
+ String termDisplayName = (String) map.get(AuthorityItemJAXBSchema.TERM_DISPLAY_NAME);
+ displayNameList.add(i - 1, termDisplayName);
+ }
+
+ result = getPartialTermDisplayNameMatches(displayNameList, partialTerm);
+ }
+ }
- return result;
+ return result;
}
@Override
- protected Object getListResultValue(DocumentModel docModel, // REM - CSPACE-5133
- String schema, ListResultField field) throws DocumentException {
- Object result = null;
+ protected Object getListResultValue(DocumentModel docModel, // REM - CSPACE-5133
+ String schema, ListResultField field) throws DocumentException {
+ Object result = null;
- result = NuxeoUtils.getXPathValue(docModel, schema, field.getXpath());
+ result = NuxeoUtils.getXPathValue(docModel, schema, field.getXpath());
- //
+ //
// Special handling of list item values for authority items (only)
// takes place here:
//
- // If the list result field is the termDisplayName element,
+ // If the list result field is the termDisplayName element,
// check whether a partial term matching query was made.
// If it was, emit values for both the preferred (aka primary)
// term and for all non-preferred terms, if any.
- //
- String elName = field.getElement();
- if (isTermDisplayName(elName) == true) {
- MultivaluedMap<String, String> queryParams = this.getServiceContext().getQueryParams();
- String partialTerm = queryParams != null ? queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM) : null;
- if (partialTerm != null && partialTerm.trim().isEmpty() == false) {
- String primaryTermDisplayName = (String)result;
- List<String> matches = getPartialTermDisplayNameMatches(docModel, schema, field, partialTerm);
- if (matches != null && matches.isEmpty() == false) {
- matches.add(0, primaryTermDisplayName); // insert the primary term's display name at the beginning of the list
- result = matches; // set the result to a list of matching term display names with the primary term's display name at the beginning
- }
- }
- }
-
- return result;
- }
+ //
+ String elName = field.getElement();
+ if (isTermDisplayName(elName) == true) {
+ MultivaluedMap<String, String> queryParams = this.getServiceContext().getQueryParams();
+ String partialTerm = queryParams != null ? queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM) : null;
+ if (partialTerm != null && partialTerm.trim().isEmpty() == false) {
+ String primaryTermDisplayName = (String)result;
+ List<String> matches = getPartialTermDisplayNameMatches(docModel, schema, field, partialTerm);
+ if (matches != null && matches.isEmpty() == false) {
+ matches.add(0, primaryTermDisplayName); // insert the primary term's display name at the beginning of the list
+ result = matches; // set the result to a list of matching term display names with the primary term's display name at the beginning
+ }
+ }
+ }
+
+ return result;
+ }
@Override
public void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
}
protected String getAuthorityItemCommonSchemaName() {
- return authorityItemCommonSchemaName;
+ return authorityItemCommonSchemaName;
}
// @Override
public boolean isJDBCQuery() {
- boolean result = false;
-
- MultivaluedMap<String, String> queryParams = getServiceContext().getQueryParams();
- //
- // Look the query params to see if we need to make a SQL query.
- //
+ boolean result = false;
+
+ MultivaluedMap<String, String> queryParams = getServiceContext().getQueryParams();
+ //
+ // Look the query params to see if we need to make a SQL query.
+ //
String partialTerm = queryParams.getFirst(IQueryManager.SEARCH_TYPE_PARTIALTERM);
- if (partialTerm != null && partialTerm.trim().isEmpty() == false) {
- result = true;
- }
-
- return result;
+ if (partialTerm != null && partialTerm.trim().isEmpty() == false) {
+ result = true;
+ }
+
+ return result;
}
// By convention, the name of the database table that contains
import org.collectionspace.services.common.context.RemoteServiceContextFactory;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.context.ServiceContextFactory;
+import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.document.DocumentNotFoundException;
import org.collectionspace.services.common.storage.StorageClient;
import org.collectionspace.services.common.storage.TransactionContext;
@POST
public Response createRole(Role input) {
- return create(input);
+ try {
+ return create(input);
+ } catch (CSWebApplicationException we) {
+ if (we.getCause() instanceof DocumentException) {
+ DocumentException de = (DocumentException)we.getCause();
+ if (de.getErrorCode() == DocumentException.DUPLICATE_RECORD_ERR) {
+ //
+ // Replace the generic error message with a Role-specific error message
+ //
+ String msg = String.format("There is already a role with the name '%s'. Please choose a different name.", input.displayName);
+ throw bigReThrow(new DocumentException(msg, de, de.getErrorCode()), msg);
+ }
+ }
+ throw we;
+ }
}
@GET
if (uriInfo == null) {
uriInfo = createUriInfo();
}
- uriInfo.getQueryParameters().add(WorkflowClient.WORKFLOW_QUERY_NONDELETED, Boolean.FALSE.toString());
+ uriInfo.getQueryParameters().add(WorkflowClient.WORKFLOW_QUERY_DELETED_QP, Boolean.FALSE.toString());
return uriInfo;
}
@GET
@Produces({"application/xml"})
ClientResponse<AbstractCommonList> readIncludeDeleted(
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+ @QueryParam(WorkflowClient.WORKFLOW_QUERY_DELETED_QP) String includeDeleted);
@Override
@GET
@Produces({"application/xml"})
ClientResponse<AbstractCommonList> keywordSearchIncludeDeleted(
@QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords,
- @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted);
+ @QueryParam(WorkflowClient.WORKFLOW_QUERY_DELETED_QP) String includeDeleted);
@GET
@Produces({"application/xml"})
//
// Service Query Params
//
- public static final String WORKFLOW_QUERY_ONLY_DELETED = "wf_only_deleted";
- public static final String WORKFLOW_QUERY_NONDELETED = "wf_deleted";
- public static final String WORKFLOWSTATE_QUERY = "wf_deleted";
+ public static final String WORKFLOW_QUERY_ONLY_DELETED_QP = "wf_only_deleted";
+ public static final String WORKFLOW_QUERY_DELETED_QP = "wf_deleted";
+ public static final String WORKFLOWSTATE_QUERY = WORKFLOW_QUERY_DELETED_QP;
public static final String TARGET_DOCHANDLER = "wf_dochandler";
//
* @author Laramie Crocker
* v.1.4
*/
-public class Tools {
- private static final String PROPERTY_VAR_REGEX = "\\$\\{([A-Za-z0-9_\\.]+)\\}";
-
+public class Tools {
+ private static final String PROPERTY_VAR_REGEX = "\\$\\{([A-Za-z0-9_\\.]+)\\}";
+
/** @return first glued to second with the separator string, at most one time - useful for appending paths.
*/
public static String glue(String first, String separator, String second){
}
/** Handles null strings as false. */
- public static boolean isTrue(String test){
+ public static boolean isTrue(String test) {
return notEmpty(test) && (new Boolean(test)).booleanValue();
}
+
+ /** Handles null value with 'true' result. */
+ public static boolean isFalse(String test) {
+ if (test == null) {
+ return true;
+ }
+
+ return (new Boolean(test)).booleanValue() == false;
+ }
- /* Example usage of searchAndReplace:
- for (Map.Entry<String,String> entry : variablesMap.entrySet()){
- String key = entry.getKey();
- String replace = entry.getValue();
- String find = "\\$\\{"+key+"\\}"; //must add expression escapes
- //because $ and braces are "special", and we want to find "${object.CSID}"
- uri = Tools.searchAndReplace(uri, find, replace);
- System.out.println("---- REPLACE.uri: "+initURI);
- System.out.println("---- REPLACE.find: "+find);
- System.out.println("---- REPLACE.replace: "+replace);
- System.out.println("---- REPLACE.uri result: "+uri);
- }
- */
-
- public static String searchAndReplace(String source, String find, String replace){
+ public static String searchAndReplace(String source, String find, String replace){
Pattern pattern = Pattern.compile(find);
Matcher matcher = pattern.matcher(source);
String output = matcher.replaceAll(replace);
static boolean m_fileSystemIsMac = ":".equals(File.separator);
public final static String FILE_EXTENSION_SEPARATOR = ".";
- public final static String OPTIONAL_VALUE_SUFFIX = "_OPT";
+ public final static String OPTIONAL_VALUE_SUFFIX = "_OPT";
public static boolean fileSystemIsDOS(){return m_fileSystemIsDOS;}
public static boolean fileSystemIsMac(){return m_fileSystemIsMac;}
public static String getFilenameBase(String filename) {
int dot = filename.lastIndexOf(FILE_EXTENSION_SEPARATOR);
if(dot<0)
- dot = filename.length();
+ dot = filename.length();
int sep = filename.lastIndexOf(File.separator); // Note: if -1, then sep+1=0, which is right
return filename.substring(sep + 1, dot);
}
}
public static String implode(String strings[], String sep) {
- String implodedString;
- if (strings.length == 0) {
- implodedString = "";
- } else {
- StringBuffer sb = new StringBuffer();
- sb.append(strings[0]);
- for (int i = 1; i < strings.length; i++) {
- if (strings[i] != null && !strings[i].trim().isEmpty()) {
- sb.append(sep);
- sb.append(strings[i]);
- }
- }
- implodedString = sb.toString();
- }
- return implodedString;
- }
-
+ String implodedString;
+ if (strings.length == 0) {
+ implodedString = "";
+ } else {
+ StringBuffer sb = new StringBuffer();
+ sb.append(strings[0]);
+ for (int i = 1; i < strings.length; i++) {
+ if (strings[i] != null && !strings[i].trim().isEmpty()) {
+ sb.append(sep);
+ sb.append(strings[i]);
+ }
+ }
+ implodedString = sb.toString();
+ }
+ return implodedString;
+ }
+
* presentation of error messages to clients.
* @param includeLines if zero, return all lines of stack trace, otherwise return number of lines from top.
*/
- public static String errorToString(Throwable e, boolean stackTraceOnException, int includeLines) {
- if (e == null) {
- return "";
- }
- String s = "\r\n -- Exception: " + e.getClass().getCanonicalName() + "\r\n -- Message: " + e.getMessage();
-
- StringBuffer causeBuffer = new StringBuffer();
- Throwable cause = e.getCause();
- while (cause != null) {
- causeBuffer.append(cause.getClass().getName() + "::" + cause.getMessage() + "\r\n");
- cause = cause.getCause();
- }
- if (causeBuffer.length() > 0) {
- s = s + "\r\n -- Causes: " + causeBuffer.toString();
- }
-
- s = s + "\r\n -- Stack Trace: \r\n -- " + getStackTrace(e, includeLines);
- return s;
- }
+ public static String errorToString(Throwable e, boolean stackTraceOnException, int includeLines) {
+ if (e == null) {
+ return "";
+ }
+ String s = "\r\n -- Exception: " + e.getClass().getCanonicalName() + "\r\n -- Message: " + e.getMessage();
+
+ StringBuffer causeBuffer = new StringBuffer();
+ Throwable cause = e.getCause();
+ while (cause != null) {
+ causeBuffer.append(cause.getClass().getName() + "::" + cause.getMessage() + "\r\n");
+ cause = cause.getCause();
+ }
+ if (causeBuffer.length() > 0) {
+ s = s + "\r\n -- Causes: " + causeBuffer.toString();
+ }
+
+ s = s + "\r\n -- Stack Trace: \r\n -- " + getStackTrace(e, includeLines);
+ return s;
+ }
/**
* Return a set of properties from a properties file.
* @param clientPropertiesFilename
* @return
*/
- static public Properties loadProperties(String clientPropertiesFilename) {
- Properties inProperties = new Properties();
- ClassLoader cl = Thread.currentThread().getContextClassLoader();
- InputStream is = null;
-
- try {
- is = cl.getResourceAsStream(clientPropertiesFilename);
- inProperties.load(is);
- } catch (Exception e) {
- throw new RuntimeException(e);
- } finally {
- if (is != null) {
- try {
- is.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
-
- return inProperties;
- }
-
- static public Properties loadProperties(String clientPropertiesFilename, boolean filterPasswords) throws Exception {
- Properties result = loadProperties(clientPropertiesFilename);
-
- if (filterPasswords) {
- result = filterPropertiesWithEnvVars(result);
- }
-
- return result;
- }
-
- /**
- * Looks for property values if the form ${foo} and tries to find environment property "foo" value to replace with.
- *
- * For example, a property value of "${foo}" would be replaced with the value of the environment variable "foo" if a
- * value for "foo" exists in the current environment.
- *
- * @param inProperties
- * @return
- * @throws Exception
- */
- static public Properties filterPropertiesWithEnvVars(Properties inProperties) throws Exception {
- final String filteredFlag = "fe915b1b-7411-4aaa-887f";
- final String filteredKey = filteredFlag;
- Properties result = inProperties;
-
- if (inProperties.containsKey(filteredKey) == false) {
- // Only process the properties once
- if (inProperties != null && inProperties.size() > 0) {
- for (String key : inProperties.stringPropertyNames()) {
- String propertyValue = inProperties.getProperty(key);
- String newPropertyValue = Tools.getValueFromEnv(propertyValue);
- if (newPropertyValue != null) { // non-null result means the property value was the name of an environment variable
- inProperties.setProperty(key, newPropertyValue);
- }
- }
- inProperties.setProperty(filteredKey, filteredFlag); // set to indicated we've already process these properties
- }
- }
-
- return result;
- }
-
- static public boolean isOptional(String properyValue) {
- boolean result = false;
-
- result = properyValue.endsWith(OPTIONAL_VALUE_SUFFIX);
-
- return result;
- }
-
- /**
- * Try to find the value of a property variable in the system or JVM environment. This code substitutes only property values formed
- * like ${cspace.password.mysecret} or ${cspace_password_mysecret_secret}. The corresponding environment variables would
- * be "cspace.password.mysecret" and "cspace.password.mysecret.secret".
- *
- * Returns null if the passed in property value is not a property variable -i.e., not something of the form {$cspace.password.foo}
- *
- * Throws an exception if the passed in property value has a valid variable form but the corresponding environment variable is not
- * set.
- *
- * @param propertyValue
- * @return
- * @throws Exception
- */
- static public String getValueFromEnv(String propertyValue) throws Exception {
- String result = null;
- //
- // Replace things like ${cspace.password.cow} with values from either the environment
- // or from the JVM system properties.
- //
- Pattern pattern = Pattern.compile(PROPERTY_VAR_REGEX); // For example, "${cspace.password.mysecret}" or "${password_strong_longpassword}"
- Matcher matcher = pattern.matcher(propertyValue);
- String key = null;
- if (matcher.find()) {
- key = matcher.group(1); // Gets the string inside the ${} enclosure. For example, gets "cspace.password.mysecret" from "${cspace.password.mysecret}"
- result = System.getenv(key);
- if (result == null || result.isEmpty()) {
- // If we couldn't find a value in the environment, check the JVM system properties
- result = System.getProperty(key);
- }
-
- if (result == null || result.isEmpty()) {
- String errMsg = String.format("Could find neither an environment variable nor a systen variable named '%s'", key);
- if (isOptional(key) == true) {
- System.err.println(errMsg);
- } else {
- throw new Exception(errMsg);
- }
- }
- }
-
- return result;
- }
-
- /**
- * Test to see if 'propertyValue' is actually a property variable
- * @param propertyValue
- * @return
- */
- static public boolean isValuePropretyVar(String propertyValue) {
- boolean result = false;
-
- if (propertyValue != null) {
- Pattern pattern = Pattern.compile(PROPERTY_VAR_REGEX); // For example, "${cspace.password.mysecret}" or "${password_strong_longpassword}"
- Matcher matcher = pattern.matcher(propertyValue);
- if (matcher.find()) {
- result = true;
- }
- }
-
- return result;
- }
-
- public static boolean isEmpty(List<?> theList) {
- if (theList != null && theList.size() > 0) {
- return false;
- } else {
- return true;
- }
- }
+ static public Properties loadProperties(String clientPropertiesFilename) {
+ Properties inProperties = new Properties();
+ ClassLoader cl = Thread.currentThread().getContextClassLoader();
+ InputStream is = null;
+
+ try {
+ is = cl.getResourceAsStream(clientPropertiesFilename);
+ inProperties.load(is);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ } finally {
+ if (is != null) {
+ try {
+ is.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ return inProperties;
+ }
+
+ static public Properties loadProperties(String clientPropertiesFilename, boolean filterPasswords) throws Exception {
+ Properties result = loadProperties(clientPropertiesFilename);
+
+ if (filterPasswords) {
+ result = filterPropertiesWithEnvVars(result);
+ }
+
+ return result;
+ }
+
+ /**
+ * Looks for property values if the form ${foo} and tries to find environment property "foo" value to replace with.
+ *
+ * For example, a property value of "${foo}" would be replaced with the value of the environment variable "foo" if a
+ * value for "foo" exists in the current environment.
+ *
+ * @param inProperties
+ * @return
+ * @throws Exception
+ */
+ static public Properties filterPropertiesWithEnvVars(Properties inProperties) throws Exception {
+ final String filteredFlag = "fe915b1b-7411-4aaa-887f";
+ final String filteredKey = filteredFlag;
+ Properties result = inProperties;
+
+ if (inProperties.containsKey(filteredKey) == false) {
+ // Only process the properties once
+ if (inProperties != null && inProperties.size() > 0) {
+ for (String key : inProperties.stringPropertyNames()) {
+ String propertyValue = inProperties.getProperty(key);
+ String newPropertyValue = Tools.getValueFromEnv(propertyValue);
+ if (newPropertyValue != null) { // non-null result means the property value was the name of an environment variable
+ inProperties.setProperty(key, newPropertyValue);
+ }
+ }
+ inProperties.setProperty(filteredKey, filteredFlag); // set to indicated we've already process these properties
+ }
+ }
+
+ return result;
+ }
+
+ static public boolean isOptional(String properyValue) {
+ boolean result = false;
+
+ result = properyValue.endsWith(OPTIONAL_VALUE_SUFFIX);
+
+ return result;
+ }
+
+ /**
+ * Try to find the value of a property variable in the system or JVM environment. This code substitutes only property values formed
+ * like ${cspace.password.mysecret} or ${cspace_password_mysecret_secret}. The corresponding environment variables would
+ * be "cspace.password.mysecret" and "cspace.password.mysecret.secret".
+ *
+ * Returns null if the passed in property value is not a property variable -i.e., not something of the form {$cspace.password.foo}
+ *
+ * Throws an exception if the passed in property value has a valid variable form but the corresponding environment variable is not
+ * set.
+ *
+ * @param propertyValue
+ * @return
+ * @throws Exception
+ */
+ static public String getValueFromEnv(String propertyValue) throws Exception {
+ String result = null;
+ //
+ // Replace things like ${cspace.password.cow} with values from either the environment
+ // or from the JVM system properties.
+ //
+ Pattern pattern = Pattern.compile(PROPERTY_VAR_REGEX); // For example, "${cspace.password.mysecret}" or "${password_strong_longpassword}"
+ Matcher matcher = pattern.matcher(propertyValue);
+ String key = null;
+ if (matcher.find()) {
+ key = matcher.group(1); // Gets the string inside the ${} enclosure. For example, gets "cspace.password.mysecret" from "${cspace.password.mysecret}"
+ result = System.getenv(key);
+ if (result == null || result.isEmpty()) {
+ // If we couldn't find a value in the environment, check the JVM system properties
+ result = System.getProperty(key);
+ }
+
+ if (result == null || result.isEmpty()) {
+ String errMsg = String.format("Could find neither an environment variable nor a systen variable named '%s'", key);
+ if (isOptional(key) == true) {
+ System.err.println(errMsg);
+ } else {
+ throw new Exception(errMsg);
+ }
+ }
+ }
+
+ return result;
+ }
+
+ /**
+ * Test to see if 'propertyValue' is actually a property variable
+ * @param propertyValue
+ * @return
+ */
+ static public boolean isValuePropretyVar(String propertyValue) {
+ boolean result = false;
+
+ if (propertyValue != null) {
+ Pattern pattern = Pattern.compile(PROPERTY_VAR_REGEX); // For example, "${cspace.password.mysecret}" or "${password_strong_longpassword}"
+ Matcher matcher = pattern.matcher(propertyValue);
+ if (matcher.find()) {
+ result = true;
+ }
+ }
+
+ return result;
+ }
+
+ public static boolean isEmpty(List<?> theList) {
+ if (theList != null && theList.size() > 0) {
+ return false;
+ } else {
+ return true;
+ }
+ }
}
}
}
- protected CSWebApplicationException bigReThrow(Exception e, String serviceMsg) throws CSWebApplicationException {
+ protected CSWebApplicationException bigReThrow(Throwable e, String serviceMsg) throws CSWebApplicationException {
return bigReThrow(e, serviceMsg, "");
}
- protected CSWebApplicationException bigReThrow(Exception e, String serviceMsg, String csid) throws CSWebApplicationException {
+ protected CSWebApplicationException bigReThrow(Throwable e, String serviceMsg, String csid) throws CSWebApplicationException {
boolean logException = true;
CSWebApplicationException result = null;
Response response;
@SuppressWarnings("rawtypes")
public abstract class SecurityResourceBase<IT, OT> extends AbstractCollectionSpaceResourceImpl<IT, OT> {
- @SuppressWarnings("hiding")
- final Logger logger = LoggerFactory.getLogger(SecurityResourceBase.class);
+ final Logger logger = LoggerFactory.getLogger(SecurityResourceBase.class);
public Response create(IT input) {
- Response response = null;
-
+ Response response = null;
+
try {
ServiceContext<IT, OT> ctx = createServiceContext(input, input.getClass());
response = create(ctx, input);
+ } catch (CSWebApplicationException we) {
+ throw we;
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.POST_FAILED+"create in "+this.getClass().getName());
}
}
protected Response create(ServiceContext<IT, OT> ctx, IT input) {
- Response response = null;
-
+ Response response = null;
+
try {
DocumentHandler handler = createDocumentHandler(ctx);
String csid = getStorageClient(ctx).create(ctx, handler);
}
public Response create(JPATransactionContext jpaTransactionContext, IT input) {
- Response response = null;
-
+ Response response = null;
+
try {
ServiceContext<IT, OT> ctx = createServiceContext(jpaTransactionContext, input, input.getClass());
DocumentHandler handler = createDocumentHandler(ctx);
}
private ServiceContext<IT, OT> createServiceContext(JPATransactionContext jpaTransactionContext, IT input,
- Class<? extends Object> clazz) throws Exception {
+ Class<? extends Object> clazz) throws Exception {
ServiceContext<IT, OT> result = createServiceContext(input, clazz);
if (jpaTransactionContext != null) {
- result.setTransactionContext(jpaTransactionContext);
+ result.setTransactionContext(jpaTransactionContext);
}
return result;
- }
+ }
- public Object get(String csid, Class objectClass) {
- return get((UriInfo)null, csid, objectClass);
+ public Object get(String csid, Class objectClass) {
+ return get((UriInfo)null, csid, objectClass);
}
public Object get(UriInfo ui, String csid, Class objectClass) {
getStorageClient(ctx).get(ctx, csid, handler);
result = ctx.getOutput();
} catch (DocumentException e) {
- Exception cause = (Exception) e.getCause();
- if (cause instanceof NoResultException) {
- Response response = Response.status(Response.Status.NOT_FOUND).entity(result).type("text/plain").build();
- throw new CSWebApplicationException(response);
- }
- } catch (Exception e) {
+ Exception cause = (Exception) e.getCause();
+ if (cause instanceof NoResultException) {
+ Response response = Response.status(Response.Status.NOT_FOUND).entity(result).type("text/plain").build();
+ throw new CSWebApplicationException(response);
+ }
+ } catch (Exception e) {
throw bigReThrow(e, ServiceMessages.GET_FAILED, csid);
}
return result;
}
- public Object getList(UriInfo ui, Class objectClass) {
+ public Object getList(UriInfo ui, Class objectClass) {
try {
ServiceContext<IT, OT> ctx = createServiceContext((IT) null, objectClass, ui);
DocumentHandler handler = createDocumentHandler(ctx);
}
public Object update(String csid, IT theUpdate, Class<?> objectClass) {
- return update((UriInfo)null, csid, theUpdate, objectClass);
+ return update((UriInfo)null, csid, theUpdate, objectClass);
}
- public Object update(UriInfo ui, String csid, IT theUpdate, Class objectClass) {
+ public Object update(UriInfo ui, String csid, IT theUpdate, Class objectClass) {
if (logger.isDebugEnabled()) {
logger.debug("updateRole with csid=" + csid);
}
throw bigReThrow(e, ServiceMessages.PUT_FAILED, csid);
}
}
-
- public Object update(ServiceContext<?, ?> parentCtx, UriInfo ui, String csid, IT theUpdate, Class objectClass) {
+
+ public Object update(ServiceContext<?, ?> parentCtx, UriInfo ui, String csid, IT theUpdate, Class objectClass) {
if (logger.isDebugEnabled()) {
logger.debug("updateRole with csid=" + csid);
}
}
protected ServiceContext<IT, OT> createServiceContext(
- ServiceContext<?, ?> parentCtx,
- IT input,
- Class<?> theClass,
- UriInfo uriInfo) throws Exception {
- ServiceContext<IT, OT> ctx = createServiceContext(input, theClass, uriInfo);
- JPATransactionContext parentTransactionContext = parentCtx != null ? (JPATransactionContext)parentCtx.getCurrentTransactionContext() : null;
- //
- // If the parent context has an active JPA connection then we'll use it.
- //
- if (parentTransactionContext != null) {
- ctx.setTransactionContext(parentTransactionContext);
- }
-
- return ctx;
- }
+ ServiceContext<?, ?> parentCtx,
+ IT input,
+ Class<?> theClass,
+ UriInfo uriInfo) throws Exception {
+ ServiceContext<IT, OT> ctx = createServiceContext(input, theClass, uriInfo);
+ JPATransactionContext parentTransactionContext = parentCtx != null ? (JPATransactionContext)parentCtx.getCurrentTransactionContext() : null;
+ //
+ // If the parent context has an active JPA connection then we'll use it.
+ //
+ if (parentTransactionContext != null) {
+ ctx.setTransactionContext(parentTransactionContext);
+ }
+
+ return ctx;
+ }
}
/**
* Helps to filter for queries that either want to include or exclude documents in deleted workflow states.
*
+ * By default, we return *all* objects/records.
+ *
* @param queryParams
* @return
*/
private static String buildWorkflowWhereClause(MultivaluedMap<String, String> queryParams) {
String result = null;
- String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_NONDELETED);
- String includeOnlyDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED); // if set to true, it doesn't matter what the value is for 'includeDeleted'
+ String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
+ String includeOnlyDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_ONLY_DELETED_QP); // if set to true, it doesn't matter what the value is for 'includeDeleted'
if (includeOnlyDeleted != null) {
if (Tools.isTrue(includeOnlyDeleted)) {
// A value of 'true' for 'includeOnlyDeleted' means we're looking *only* for soft-deleted records/documents.
//
result = String.format("(ecm:currentLifeCycleState = '%s' OR ecm:currentLifeCycleState = '%s' OR ecm:currentLifeCycleState = '%s')",
- WorkflowClient.WORKFLOWSTATE_DELETED, WorkflowClient.WORKFLOWSTATE_LOCKED_DELETED,
+ WorkflowClient.WORKFLOWSTATE_DELETED,
+ WorkflowClient.WORKFLOWSTATE_LOCKED_DELETED,
WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED);
}
- } else if (!Tools.isTrue(includeDeleted)) {
+ } else if (includeDeleted != null && Tools.isFalse(includeDeleted)) {
//
// We can only get here if the 'includeOnlyDeleted' query param is missing altogether.
// Ensure we don't return soft-deleted records
//
result = String.format("(ecm:currentLifeCycleState <> '%s' AND ecm:currentLifeCycleState <> '%s' AND ecm:currentLifeCycleState <> '%s')",
- WorkflowClient.WORKFLOWSTATE_DELETED, WorkflowClient.WORKFLOWSTATE_LOCKED_DELETED,
+ WorkflowClient.WORKFLOWSTATE_DELETED,
+ WorkflowClient.WORKFLOWSTATE_LOCKED_DELETED,
WorkflowClient.WORKFLOWSTATE_REPLICATED_DELETED);
}
*/
public class DocumentException extends ServiceException {
+ public static final int DUPLICATE_RECORD_ERR = 409;
+ public static final String DUPLICATE_RECORD_MSG = "Record already exists.";
+
static public DocumentException createDocumentException(Throwable ex) {
DocumentException result = new DocumentException(ex);
public DocumentException(String message, Throwable cause) {
super(message, cause);
}
+
+ public DocumentException(String message, Throwable cause, int errorCode) {
+ super(message, cause);
+ setErrorCode(errorCode);
+ }
/**
* Constructs a new exception with the specified cause and a detail
public DocumentException(Throwable cause) {
super(cause);
}
+
+ public DocumentException(Throwable cause, int errorCode) {
+ super(cause);
+ setErrorCode(errorCode);
+ }
public boolean exceptionChainContainsNetworkError() {
boolean result = false;
public void sanitize(DocumentWrapper<WT> wrapDoc);
+ /**
+ * Should return true if the document supports workflow states (usually, just Nuxeo documents/records)
+ * @return
+ */
+ public boolean supportsWorkflowStates();
+
}
throws Exception {
// Do nothing. JPA document handlers do not support workflow transitions yet.
}
-
+
+ @Override
+ public boolean supportsWorkflowStates() {
+ return false;
+ }
}
import java.util.List;
import javax.persistence.EntityExistsException;
+import javax.persistence.PersistenceException;
import javax.persistence.Query;
import javax.persistence.RollbackException;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.lifecycle.TransitionDef;
-
+import org.hibernate.exception.ConstraintViolationException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* Instantiates a new jpa storage client.
*/
public JpaStorageClientImpl() {
- //intentionally empty
+ //intentionally empty
}
/* (non-Javadoc)
* @see org.collectionspace.services.common.storage.StorageClient#create(org.collectionspace.services.common.context.ServiceContext, org.collectionspace.services.common.document.DocumentHandler)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
+ @Override
public String create(ServiceContext ctx,
DocumentHandler handler) throws BadRequestException,
DocumentException {
- String result = null;
+ String result = null;
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
handler.prepare(Action.CREATE);
Object entity = handler.getCommonPart();
jpaConnectionContext.beginTransaction();
try {
- handler.handle(Action.CREATE, wrapDoc);
- JaxbUtils.setValue(entity, "setCreatedAtItem", Date.class, new Date());
- jpaConnectionContext.persist(entity);
+ handler.handle(Action.CREATE, wrapDoc);
+ JaxbUtils.setValue(entity, "setCreatedAtItem", Date.class, new Date());
+ jpaConnectionContext.persist(entity);
} catch (EntityExistsException ee) { // FIXME: No, don't allow duplicates
- //
- // We found an existing matching entity in the store, so we don't need to create one. Just update the transient 'entity' instance with the existing persisted entity we found.
- // An entity's document handler class will throw this exception only if attempting to create (but not actually creating) duplicate is ok -e.g., Permission records.
- //
- entity = wrapDoc.getWrappedObject(); // the handler should have reset the wrapped transient object with the existing persisted entity we just found.
+ //
+ // We found an existing matching entity in the store, so we don't need to create one. Just update the transient 'entity' instance with the existing persisted entity we found.
+ // An entity's document handler class will throw this exception only if attempting to create (but not actually creating) duplicate is ok -e.g., Permission records.
+ //
+ entity = wrapDoc.getWrappedObject(); // the handler should have reset the wrapped transient object with the existing persisted entity we just found.
}
handler.complete(Action.CREATE, wrapDoc);
jpaConnectionContext.commitTransaction();
result = (String)JaxbUtils.getValue(entity, "getCsid");
} catch (BadRequestException bre) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
throw bre;
} catch (DocumentException de) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
throw de;
} catch (RollbackException rbe) {
- //jpaConnectionContext.markForRollback();
+ //jpaConnectionContext.markForRollback();
throw DocumentException.createDocumentException(rbe);
+ } catch (PersistenceException pe) {
+ if (pe.getCause() instanceof ConstraintViolationException) {
+ throw new DocumentException(DocumentException.DUPLICATE_RECORD_MSG, pe, DocumentException.DUPLICATE_RECORD_ERR);
+ } else {
+ throw new DocumentException(pe);
+ }
} catch (Exception e) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
logger.debug("Caught exception ", e);
throw DocumentException.createDocumentException(e);
} finally {
- ctx.closeConnection();
+ ctx.closeConnection();
}
return result;
* @see org.collectionspace.services.common.storage.StorageClient#get(org.collectionspace.services.common.context.ServiceContext, java.util.List, org.collectionspace.services.common.document.DocumentHandler)
*/
@SuppressWarnings("rawtypes")
- @Override
+ @Override
public void get(ServiceContext ctx, List<String> csidList, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
throw new UnsupportedOperationException();
* @see org.collectionspace.services.common.storage.StorageClient#get(org.collectionspace.services.common.context.ServiceContext, java.lang.String, org.collectionspace.services.common.document.DocumentHandler)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
+ @Override
public void get(ServiceContext ctx, String id, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
- JPATransactionContext jpaTransactionContext = (JPATransactionContext)ctx.openConnection();
+ JPATransactionContext jpaTransactionContext = (JPATransactionContext)ctx.openConnection();
try {
handler.prepare(Action.GET);
Object o = null;
* @see org.collectionspace.services.common.storage.StorageClient#getAll(org.collectionspace.services.common.context.ServiceContext, org.collectionspace.services.common.document.DocumentHandler)
*/
@SuppressWarnings("rawtypes")
- @Override
+ @Override
public void getAll(ServiceContext ctx, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
throw new UnsupportedOperationException("use getFiltered instead");
* @see org.collectionspace.services.common.storage.StorageClient#getFiltered(org.collectionspace.services.common.context.ServiceContext, org.collectionspace.services.common.document.DocumentHandler)
*/
@SuppressWarnings({ "unchecked", "rawtypes" })
- @Override
+ @Override
public void getFiltered(ServiceContext ctx, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
-
+
DocumentFilter docFilter = handler.getDocumentFilter();
if (docFilter == null) {
docFilter = handler.createDocumentFilter();
}
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
handler.prepare(Action.GET_ALL);
StringBuilder queryStrBldr = new StringBuilder("SELECT a FROM ");
* Return the COUNT for a query to find the total number of matches independent of the paging restrictions.
*/
@SuppressWarnings("rawtypes")
- private long getTotalItems(JPATransactionContext jpaTransactionContext, ServiceContext ctx, DocumentHandler handler) {
- long result = -1;
-
+ private long getTotalItems(JPATransactionContext jpaTransactionContext, ServiceContext ctx, DocumentHandler handler) {
+ long result = -1;
+
DocumentFilter docFilter = handler.getDocumentFilter();
StringBuilder queryStrBldr = new StringBuilder("SELECT COUNT(*) FROM ");
queryStrBldr.append(getEntityName(ctx));
return result;
}
- /* (non-Javadoc)
+ /* (non-Javadoc)
* @see org.collectionspace.services.common.storage.StorageClient#update(org.collectionspace.services.common.context.ServiceContext, java.lang.String, org.collectionspace.services.common.document.DocumentHandler)
*/
@SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
+ @Override
public void update(ServiceContext ctx, String id, DocumentHandler handler)
throws BadRequestException, DocumentNotFoundException,
DocumentException {
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
jpaConnectionContext.beginTransaction();
}
throw new DocumentException(e);
} finally {
- ctx.closeConnection();
+ ctx.closeConnection();
}
}
throws DocumentNotFoundException,
DocumentException {
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
- jpaConnectionContext.beginTransaction();
+ jpaConnectionContext.beginTransaction();
Object entityFound = getEntity(ctx, id);
if (entityFound == null) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
String msg = "delete(ctx, id): could not find entity with id=" + id;
logger.error(msg);
throw new DocumentNotFoundException(msg);
jpaConnectionContext.remove(entityFound);
jpaConnectionContext.commitTransaction();
} catch (DocumentException de) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
throw de;
} catch (Exception e) {
if (logger.isDebugEnabled()) {
throws DocumentNotFoundException,
DocumentException {
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
StringBuilder deleteStr = new StringBuilder("DELETE FROM ");
deleteStr.append(getEntityName(ctx));
jpaConnectionContext.beginTransaction();
rcount = q.executeUpdate();
if (rcount != 1) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
String msg = "deleteWhere(ctx, id) could not find entity with id=" + id;
logger.error(msg);
throw new DocumentNotFoundException(msg);
}
jpaConnectionContext.commitTransaction();
} catch (DocumentException de) {
- jpaConnectionContext.markForRollback();
+ jpaConnectionContext.markForRollback();
throw de;
} catch (Exception e) {
if (logger.isDebugEnabled()) {
* @see org.collectionspace.services.common.storage.StorageClient#delete(org.collectionspace.services.common.context.ServiceContext, java.lang.String)
*/
@SuppressWarnings({ "rawtypes" })
- @Override
+ @Override
public boolean delete(ServiceContext ctx, String id, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
- boolean result = false;
-
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ boolean result = false;
+
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
jpaConnectionContext.beginTransaction();
Object entityFound = getEntity(ctx, id);
result = delete(ctx, entityFound, handler);
jpaConnectionContext.commitTransaction();
} catch (DocumentException de) {
- jpaConnectionContext.markForRollback();
- throw de;
+ jpaConnectionContext.markForRollback();
+ throw de;
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("delete(ctx, ix, handler): Caught exception ", e);
jpaConnectionContext.markForRollback();
throw new DocumentException(e);
} finally {
- ctx.closeConnection();
+ ctx.closeConnection();
}
return result;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
- @Override
+ @Override
public boolean delete(ServiceContext ctx, Object entity, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
- boolean result = false;
-
- JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
+ boolean result = false;
+
+ JPATransactionContext jpaConnectionContext = (JPATransactionContext)ctx.openConnection();
try {
jpaConnectionContext.beginTransaction();
handler.prepare(Action.DELETE);
jpaConnectionContext.commitTransaction();
result = true;
} catch (DocumentException de) {
- jpaConnectionContext.markForRollback();
- throw de;
+ jpaConnectionContext.markForRollback();
+ throw de;
} catch (Exception e) {
if (logger.isDebugEnabled()) {
logger.debug("delete(ctx, ix, handler): Caught exception ", e);
jpaConnectionContext.markForRollback();
throw new DocumentException(e);
} finally {
- ctx.closeConnection();
+ ctx.closeConnection();
}
return result;
*/
protected Object getEntity(@SuppressWarnings("rawtypes") ServiceContext ctx, String id, Class<?> entityClazz)
throws DocumentNotFoundException, TransactionException {
- Object entityFound = null;
-
- JPATransactionContext jpaTransactionContext = (JPATransactionContext)ctx.openConnection();
- try {
- entityFound = JpaStorageUtils.getEntity(jpaTransactionContext, id, entityClazz); // FIXME: # Should be qualifying with the tenant ID
- if (entityFound == null) {
- String msg = "could not find entity of type=" + entityClazz.getName()
- + " with id=" + id;
- logger.error(msg);
- throw new DocumentNotFoundException(msg);
- }
- } finally {
- ctx.closeConnection();
- }
-
+ Object entityFound = null;
+
+ JPATransactionContext jpaTransactionContext = (JPATransactionContext)ctx.openConnection();
+ try {
+ entityFound = JpaStorageUtils.getEntity(jpaTransactionContext, id, entityClazz); // FIXME: # Should be qualifying with the tenant ID
+ if (entityFound == null) {
+ String msg = "could not find entity of type=" + entityClazz.getName()
+ + " with id=" + id;
+ logger.error(msg);
+ throw new DocumentNotFoundException(msg);
+ }
+ } finally {
+ ctx.closeConnection();
+ }
+
return entityFound;
}
@SuppressWarnings("rawtypes")
- @Override
+ @Override
public void get(ServiceContext ctx, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException {
throw new UnsupportedOperationException();
}
- @SuppressWarnings("rawtypes")
- @Override
- public void doWorkflowTransition(ServiceContext ctx, String id,
- DocumentHandler handler, TransitionDef transitionDef)
- throws BadRequestException, DocumentNotFoundException,
- DocumentException {
- // Do nothing. JPA services do not support workflow.
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public void deleteWithWhereClause(ServiceContext ctx, String whereClause,
- DocumentHandler handler) throws DocumentNotFoundException,
- DocumentException {
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void doWorkflowTransition(ServiceContext ctx, String id,
+ DocumentHandler handler, TransitionDef transitionDef)
+ throws BadRequestException, DocumentNotFoundException,
+ DocumentException {
+ // Do nothing. JPA services do not support workflow.
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public void deleteWithWhereClause(ServiceContext ctx, String whereClause,
+ DocumentHandler handler) throws DocumentNotFoundException,
+ DocumentException {
throw new UnsupportedOperationException();
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public boolean synchronize(ServiceContext ctx, Object specifier,
- DocumentHandler handler) throws DocumentNotFoundException,
- TransactionException, DocumentException {
- // TODO Auto-generated method stub
- // Do nothing. Subclasses can override if they want/need to.
- return true;
- }
-
- @SuppressWarnings("rawtypes")
- @Override
- public boolean synchronizeItem(ServiceContext ctx, AuthorityItemSpecifier itemSpecifier,
- DocumentHandler handler) throws DocumentNotFoundException,
- TransactionException, DocumentException {
- // TODO Auto-generated method stub
- // Do nothing. Subclasses can override if they want/need to.
- return true;
- }
-
- @Override
- public void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, Object repoSession)
- throws TransactionException {
- // TODO Auto-generated method stub
- }
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean synchronize(ServiceContext ctx, Object specifier,
+ DocumentHandler handler) throws DocumentNotFoundException,
+ TransactionException, DocumentException {
+ // TODO Auto-generated method stub
+ // Do nothing. Subclasses can override if they want/need to.
+ return true;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public boolean synchronizeItem(ServiceContext ctx, AuthorityItemSpecifier itemSpecifier,
+ DocumentHandler handler) throws DocumentNotFoundException,
+ TransactionException, DocumentException {
+ // TODO Auto-generated method stub
+ // Do nothing. Subclasses can override if they want/need to.
+ return true;
+ }
+
+ @Override
+ public void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, Object repoSession)
+ throws TransactionException {
+ // TODO Auto-generated method stub
+ }
}
return new ArrayList();
}
}
+
+ @Override
+ public boolean supportsWorkflowStates() {
+ return true;
+ }
}
// docModel is in a non-deleted workflow state.
//
String currentState = docModel.getCurrentLifeCycleState();
- String includeDeletedStr = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_NONDELETED);
+ String includeDeletedStr = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
boolean includeDeleted = (includeDeletedStr == null) ? true : Boolean.parseBoolean(includeDeletedStr);
if (includeDeleted == false) {
//
// in the current request
// Restrict the query to filter out deleted records, if requested
- String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_NONDELETED);
+ String includeDeleted = queryParams.getFirst(WorkflowClient.WORKFLOW_QUERY_DELETED_QP);
if (includeDeleted != null && includeDeleted.equalsIgnoreCase(Boolean.FALSE.toString())) {
whereClause = whereClause
+ " AND (misc.lifecyclestate <> '" + WorkflowClient.WORKFLOWSTATE_DELETED + "')"
}
}
- /*
- private String getCommonSchemaNameForDocType(String docType) {
- String common_schema = null;
- if(docType!=null) {
- // HACK - Use startsWith to allow for extension of schemas.
- if(docType.startsWith("Person"))
- common_schema = PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- else if(docType.startsWith("Citation"))
- common_schema = CitationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- else if(docType.startsWith("Organization"))
- common_schema = OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- else if(docType.startsWith("Locationitem"))
- common_schema = LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- else if(docType.startsWith("Taxon"))
- common_schema = TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- else if(docType.startsWith("Placeitem"))
- common_schema = PlaceAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- else if(docType.startsWith("Conceptitem"))
- common_schema = ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME;
- //else leave it null.
- }
- return common_schema;
- }
- */
-
+ @Override
+ public boolean supportsWorkflowStates() {
+ return true;
+ }
}
public DocumentFilter createDocumentFilter() {
throw new RuntimeException("Unimplemented method.");
}
+
+ @Override
+ public boolean supportsWorkflowStates() {
+ return false;
+ }
}
public DocumentFilter createDocumentFilter() {
throw new RuntimeException("Unimplemented method.");
}
+
+ @Override
+ public boolean supportsWorkflowStates() {
+ return false;
+ }
}