From: Richard Millet Date: Fri, 8 Apr 2016 05:45:16 +0000 (-0700) Subject: CSPACE-6935: Adding sync support for both individual authorities and authority terms. X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=b53a063e92fb44613fd70ef3d6e8e0a44a3c5400;p=tmp%2Fjakarta-migration.git CSPACE-6935: Adding sync support for both individual authorities and authority terms. --- diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 96abf6c08..60547b788 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -83,10 +83,9 @@ import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter; import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; import org.collectionspace.services.workflow.WorkflowCommon; - +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; - import org.jboss.resteasy.util.HttpResponseCodes; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; @@ -261,19 +260,20 @@ public abstract class AuthorityResource protected String lookupParentCSID(String parentspecifier, String method, String op, UriInfo uriInfo) throws Exception { - CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer( + CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(null, parentspecifier, method, op, uriInfo); return tempResult.CSID; } private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer( - String parentspecifier, + ServiceContext itemServiceCtx, + String parentSpecifier, String method, String op, UriInfo uriInfo) throws Exception { CsidAndShortIdentifier result = new CsidAndShortIdentifier(); - Specifier parentSpec = getSpecifier(parentspecifier, method, op); + Specifier parentSpec = getSpecifier(parentSpecifier, method, op); // Note that we have to create the service context for the Items, not the main service String parentcsid; String parentShortIdentifier; @@ -287,8 +287,13 @@ public abstract class AuthorityResource parentShortIdentifier = parentSpec.value; String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, parentSpec.value); ServiceContext ctx = createServiceContext(getServiceName(), uriInfo); - parentcsid = getRepositoryClient(ctx).findDocCSID(null, ctx, whereClause); //FIXME: REM - If the parent has been soft-deleted, should we be looking for the item? + CoreSessionInterface repoSession = null; + if (itemServiceCtx != null) { + repoSession = (CoreSessionInterface) itemServiceCtx.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? } + result.CSID = parentcsid; result.shortIdentifier = parentShortIdentifier; return result; @@ -369,35 +374,38 @@ public abstract class AuthorityResource */ @GET @Path("{csid}/sync") - public Response synchronize( + public byte[] synchronize( @Context Request request, @Context UriInfo ui, @PathParam("csid") String csid) { - PoxPayloadOut result = null; + byte[] result; + boolean neededSync = false; + PoxPayloadOut payloadOut = null; Specifier specifier; try { ServiceContext ctx = createServiceContext(ui); AuthorityDocumentModelHandler handler = (AuthorityDocumentModelHandler)createDocumentHandler(ctx); specifier = getSpecifier(csid, "getAuthority", "GET"); - - getRepositoryClient(ctx).synchronize(ctx, specifier, handler); - result = ctx.getOutput(); - + neededSync = getRepositoryClient(ctx).synchronize(ctx, specifier, handler); + payloadOut = ctx.getOutput(); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.SYNC_FAILED, csid); } - if (result == null) { - Response response = Response.status(Response.Status.NOT_FOUND).entity( - "Get failed, the requested Authority specifier:" + specifier + ": was not found.").type( - "text/plain").build(); + // + // 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 Response.status(Response.Status.OK).entity( - "Synchronization completed, the requested Authority specifier:" + specifier.value + ": was synchronized.").type( - "text/plain").build(); + + return result; } /** @@ -606,7 +614,7 @@ public abstract class AuthorityResource ServiceContext ctx = createServiceContext(getItemServiceName(), input, resourceMap, uriInfo); // Note: must have the parentShortId, to do the create. - CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(parentspecifier, "createAuthorityItem", "CREATE_ITEM", null); + CsidAndShortIdentifier parent = lookupParentCSIDAndShortIdentifer(null, parentspecifier, "createAuthorityItem", "CREATE_ITEM", null); DocumentHandler handler = createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier); String itemcsid = getRepositoryClient(ctx).create(ctx, handler); @@ -705,7 +713,7 @@ public abstract class AuthorityResource RemoteServiceContext ctx = (RemoteServiceContext) createServiceContext(getItemServiceName(), resourceMap, uriInfo); - JaxRsContext jaxRsContext = new JaxRsContext(request, uriInfo); // REM - Why are we setting this? Who is using the getter? + JaxRsContext jaxRsContext = new JaxRsContext(request, uriInfo); // Needed for getting account permissions part of the payload ctx.setJaxRsContext(jaxRsContext); // We omit the parentShortId, only needed when doing a create... @@ -920,6 +928,56 @@ public abstract class AuthorityResource return authRefList; } + /** + * Synchronizes the authority and its terms with a Shared Authority Server (SAS). + * + * @param specifier either CSIDs and/or one of the urn forms + * + * @return the authority item if it was synchronized with SAS + */ + @GET + @Path("{csid}/items/{itemcsid}/sync") + public byte[] synchronizeItem( + @Context ResourceMap resourceMap, + @Context Request request, + @Context UriInfo uriInfo, + @PathParam("csid") String parentIdentifier, + @PathParam("itemcsid") String itemIdentifier + ) { + byte[] result; + boolean neededSync = false; + PoxPayloadOut payloadOut = null; + AuthorityItemSpecifier specifier; + CsidAndShortIdentifier parent; + + try { + ServiceContext ctx = createServiceContext(getItemServiceName(), null, resourceMap, uriInfo); + parent = lookupParentCSIDAndShortIdentifer(null, parentIdentifier, "syncAuthorityItem(parent)", "SYNC_ITEM", null); + AuthorityItemDocumentModelHandler handler = (AuthorityItemDocumentModelHandler)createItemDocumentHandler(ctx, parent.CSID, parent.shortIdentifier); + Specifier parentSpecifier = getSpecifier(parent.CSID, "getAuthority", "GET"); + Specifier itemSpecifier = getSpecifier(itemIdentifier, "getAuthorityItem", "GET"); + specifier = new AuthorityItemSpecifier(parentSpecifier, itemSpecifier); + neededSync = getRepositoryClient(ctx).synchronize(ctx, specifier, handler); + payloadOut = ctx.getOutput(); + } 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(); + } 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(); + throw new CSWebApplicationException(response); + } + + return result; + } + /** * Update authorityItem. * @@ -933,31 +991,51 @@ public abstract class AuthorityResource public byte[] updateAuthorityItem( @Context ResourceMap resourceMap, @Context UriInfo uriInfo, - @PathParam("csid") String parentspecifier, - @PathParam("itemcsid") String itemspecifier, + @PathParam("csid") String parentSpecifier, + @PathParam("itemcsid") String itemSpecifier, String xmlPayload) { PoxPayloadOut result = null; + try { PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload); - // Note that we have to create the service context for the Items, not the main service - // Laramie CSPACE-3175. passing null for queryParams, because prior to this refactor, the code moved to lookupParentCSID in this instance called the version of getServiceContext() that passes null - CsidAndShortIdentifier csidAndShortId = lookupParentCSIDAndShortIdentifer(parentspecifier, "updateAuthorityItem(parent)", "UPDATE_ITEM", null); - String parentcsid = csidAndShortId.CSID; - String parentShortId = csidAndShortId.shortIdentifier; - - ServiceContext ctx = createServiceContext(getItemServiceName(), theUpdate, resourceMap, uriInfo); - String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM", ctx); - - // We omit the parentShortId, only needed when doing a create... - DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid, parentShortId); - getRepositoryClient(ctx).update(ctx, itemcsid, handler); - result = ctx.getOutput(); - + result = updateAuthorityItem(null, resourceMap, uriInfo, parentSpecifier, itemSpecifier, theUpdate, true); // passing TRUE so parent authority rev num increases } catch (Exception e) { throw bigReThrow(e, ServiceMessages.UPDATE_FAILED); } + return result.getBytes(); } + + public PoxPayloadOut updateAuthorityItem( + ServiceContext itemServiceCtx, // Ok to be null + ResourceMap resourceMap, + UriInfo uriInfo, + String parentspecifier, + String itemspecifier, + PoxPayloadIn theUpdate, + boolean shouldUpdateParentRev) throws Exception { + PoxPayloadOut result = null; + + CsidAndShortIdentifier csidAndShortId = lookupParentCSIDAndShortIdentifer(itemServiceCtx, parentspecifier, "updateAuthorityItem(parent)", "UPDATE_ITEM", null); + String parentcsid = csidAndShortId.CSID; + String parentShortId = csidAndShortId.shortIdentifier; + // + // If the itemServiceCtx context is not null, use it. Otherwise, create a new context + // + ServiceContext ctx = itemServiceCtx; + if (ctx == null) { + ctx = createServiceContext(getItemServiceName(), theUpdate, resourceMap, uriInfo); + } + String itemcsid = lookupItemCSID(itemspecifier, parentcsid, "updateAuthorityItem(item)", "UPDATE_ITEM", ctx); //use itemServiceCtx if it is not null + + // We omit the parentShortId, only needed when doing a create... + AuthorityItemDocumentModelHandler handler = (AuthorityItemDocumentModelHandler)createItemDocumentHandler(ctx, parentcsid, parentShortId); + handler.setShouldUpdateParentRevNumber(shouldUpdateParentRev); + getRepositoryClient(ctx).update(ctx, itemcsid, handler); + result = ctx.getOutput(); + + return result; + } /** * Delete authorityItem. diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java index 3b8b8b9ce..35c85b80c 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityDocumentModelHandler.java @@ -33,6 +33,8 @@ import org.collectionspace.services.client.PayloadInputPart; import org.collectionspace.services.client.VocabularyClient; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.ResourceMap; +import org.collectionspace.services.common.XmlTools; import org.collectionspace.services.common.api.RefName; import org.collectionspace.services.common.api.RefName.Authority; import org.collectionspace.services.common.api.RefNameUtils; @@ -44,6 +46,8 @@ import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; +import org.collectionspace.services.common.vocabulary.AuthorityResource; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm; import org.collectionspace.services.config.service.ObjectPartType; @@ -57,7 +61,6 @@ import org.nuxeo.ecm.core.api.ClientException; import org.nuxeo.ecm.core.api.DocumentModel; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.testng.Assert; /** * AuthorityDocumentModelHandler @@ -95,26 +98,43 @@ public abstract class AuthorityDocumentModelHandler } @Override - public void handleSync(DocumentWrapper wrapDoc) throws Exception { - - ServiceContext ctx = this.getServiceContext(); - Specifier specifier = wrapDoc.getWrappedObject(); + public boolean handleSync(DocumentWrapper wrapDoc) throws Exception { + boolean result = false; + ServiceContext ctx = getServiceContext(); + Specifier specifier = (Specifier) wrapDoc.getWrappedObject(); // // Get the rev number of the authority so we can compare with rev number of shared authority // DocumentModel docModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), authorityCommonSchemaName, specifier); - Long rev = (Long) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.REV); - String shortId = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); - String refName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityItemJAXBSchema.REF_NAME); - AuthorityInfo authorityInfo = RefNameUtils.parseAuthorityInfo(refName); + Long rev = (Long) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.REV); + String shortId = (String) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.SHORT_IDENTIFIER); + String refName = (String) NuxeoUtils.getProperyValue(docModel, AuthorityJAXBSchema.REF_NAME); // // Using the short ID of the local authority, created a URN specifier to retrieve the SAS authority // Specifier sasSpecifier = new Specifier(SpecifierForm.URN_NAME, RefNameUtils.createShortIdRefName(shortId)); - Long sasRev = getRevFromSASInstance(sasSpecifier); + PoxPayloadIn sasPayloadIn = getPayloadIn(ctx, sasSpecifier); + + Long sasRev = getRevision(sasPayloadIn); + if (sasRev > rev) { + ResourceMap resourceMap = ctx.getResourceMap(); + String resourceName = ctx.getClient().getServiceName(); + AuthorityResource authorityResource = (AuthorityResource) resourceMap.get(resourceName); + PoxPayloadOut payloadOut = authorityResource.update(ctx, resourceMap, null, docModel.getName(), sasPayloadIn); + if (payloadOut != null) { + ctx.setOutput(payloadOut); + result = true; + } + } + + return result; + } - AuthorityClient client = ctx.getAuthorityClient(); - Response res = client.read(sasSpecifier.value); + private PoxPayloadIn getPayloadIn(ServiceContext ctx, Specifier specifier) throws Exception { + PoxPayloadIn result = null; + + AuthorityClient client = (AuthorityClient) ctx.getClient(); + Response res = client.read(specifier.value); try { int statusCode = res.getStatus(); @@ -124,26 +144,10 @@ public abstract class AuthorityDocumentModelHandler logger.debug(client.getClass().getCanonicalName() + ": status = " + statusCode); } - PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(getEntityResponseType())); // Get the entire response! - - PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName()); - if (payloadInputPart != null) { -// result = (client.getc) payloadInputPart.getBody(); - } - Document document = input.getDOMDocument(); - Element rootElement = document.getRootElement(); - + result = new PoxPayloadIn((String)res.readEntity(getEntityResponseType())); // Get the entire response! } finally { res.close(); } - - } - - private Long getRevFromSASInstance(Specifier specifier) { - Long result = null; - - VocabularyClient client = new VocabularyClient(); - String uri = getUri(specifier); return result; } @@ -315,6 +319,9 @@ public abstract class AuthorityDocumentModelHandler repoSession = nuxeoRepoClient.getRepositorySession(ctx); DocumentWrapper wrapDoc = nuxeoRepoClient.getDocFromCsid(ctx, repoSession, authCSID); DocumentModel docModel = wrapDoc.getWrappedObject(); + if (docModel == null) { + throw new DocumentNotFoundException(String.format("Could not find authority resource with CSID='%s'.", authCSID)); + } shortIdentifier = (String) docModel.getProperty(schemaName, AuthorityJAXBSchema.SHORT_IDENTIFIER); } catch (ClientException ce) { throw new RuntimeException("AuthorityDocHandler Internal Error: cannot get shortId!", ce); diff --git a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java index 99b6865b6..b1b0bdfb9 100644 --- a/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java +++ b/services/authority/service/src/main/java/org/collectionspace/services/common/vocabulary/nuxeo/AuthorityItemDocumentModelHandler.java @@ -27,14 +27,20 @@ import org.collectionspace.services.client.AuthorityClient; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; +import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.UriTemplateRegistry; import org.collectionspace.services.common.api.RefName; +import org.collectionspace.services.common.api.RefNameUtils; +import org.collectionspace.services.common.api.RefNameUtils.AuthorityTermInfo; import org.collectionspace.services.common.api.Tools; +import org.collectionspace.services.common.api.RefNameUtils.AuthorityInfo; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; import org.collectionspace.services.common.context.MultipartServiceContext; +import org.collectionspace.services.common.context.MultipartServiceContextImpl; import org.collectionspace.services.common.context.ServiceContext; import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentFilter; +import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.DocumentWrapper; import org.collectionspace.services.common.document.DocumentHandler.Action; import org.collectionspace.services.common.repository.RepositoryClient; @@ -42,6 +48,9 @@ import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema; import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.common.vocabulary.AuthorityResource; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm; import org.collectionspace.services.config.service.ListResultField; import org.collectionspace.services.config.service.ObjectPartType; import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler; @@ -57,6 +66,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.core.MultivaluedMap; +import javax.ws.rs.core.Response; import java.util.ArrayList; import java.util.Collections; @@ -78,8 +88,11 @@ public abstract class AuthorityItemDocumentModelHandler extends NuxeoDocumentModelHandler { private final Logger logger = LoggerFactory.getLogger(AuthorityItemDocumentModelHandler.class); - private String authorityItemCommonSchemaName; + + protected String authorityCommonSchemaName; + protected String authorityItemCommonSchemaName; private String authorityItemTermGroupXPathBase; + private boolean shouldUpdateParentRevNumber = true; /** * inVocabulary is the parent Authority for this context */ @@ -91,11 +104,19 @@ public abstract class AuthorityItemDocumentModelHandler private final static String LIST_SUFFIX = "List"; private final static String ZERO_OR_MORE_ANY_CHAR_REGEX = ".*"; - public AuthorityItemDocumentModelHandler(String authorityItemCommonSchemaName) { + public AuthorityItemDocumentModelHandler(String authorityCommonSchemaName, String authorityItemCommonSchemaName) { this.authorityItemCommonSchemaName = authorityItemCommonSchemaName; } abstract public String getParentCommonSchemaName(); + + public boolean getShouldUpdateParentRevNumber() { + return this.shouldUpdateParentRevNumber; + } + + public void setShouldUpdateParentRevNumber(boolean flag) { + this.shouldUpdateParentRevNumber = flag; + } @Override protected String getRefnameDisplayName(DocumentWrapper docWrapper) { @@ -323,6 +344,85 @@ public abstract class AuthorityItemDocumentModelHandler return list; } + private PoxPayloadIn getPayloadIn(AuthorityItemSpecifier specifier) throws Exception { + PoxPayloadIn result = null; + + ServiceContext parentCtx = new MultipartServiceContextImpl(this.getAuthorityServicePath()); + AuthorityClient client = (AuthorityClient) parentCtx.getClient(); + Response res = client.readItem(specifier.getParentSpecifier().value, specifier.getItemSpecifier().value); + try { + int statusCode = res.getStatus(); + + // Check the status code of the response: does it match + // the expected response(s)? + if (logger.isDebugEnabled()) { + logger.debug(client.getClass().getCanonicalName() + ": status = " + statusCode); + } + + result = new PoxPayloadIn((String)res.readEntity(getEntityResponseType())); // Get the entire response! + } finally { + res.close(); + } + + return result; + } + + @Override + public boolean handleSync(DocumentWrapper wrapDoc) throws Exception { + boolean result = false; + ServiceContext ctx = getServiceContext(); + AuthorityItemSpecifier authorityItemSpecifier = (AuthorityItemSpecifier) wrapDoc.getWrappedObject(); + // + // Get the rev number of the authority item so we can compare with rev number of shared authority + // + DocumentModel itemDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), getAuthorityItemCommonSchemaName(), + authorityItemSpecifier.getItemSpecifier()); + if (itemDocModel == null) { + throw new DocumentNotFoundException(String.format("Could not find authority item resource with CSID='%s'", + authorityItemSpecifier.getItemSpecifier().value)); + } + Long itemRev = (Long) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.REV); + String itemShortId = (String) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.SHORT_IDENTIFIER); + String itemRefName = (String) NuxeoUtils.getProperyValue(itemDocModel, AuthorityItemJAXBSchema.REF_NAME); + // + // Now get the Authority (the parent) information + // + DocumentModel authorityDocModel = NuxeoUtils.getDocFromSpecifier(ctx, getRepositorySession(), authorityCommonSchemaName, + authorityItemSpecifier.getParentSpecifier()); + Long authorityRev = (Long) NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.REV); + String authorityShortId = (String) NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.SHORT_IDENTIFIER); + String authorityRefName = (String) NuxeoUtils.getProperyValue(authorityDocModel, AuthorityJAXBSchema.REF_NAME); + AuthorityInfo authorityInfo = RefNameUtils.parseAuthorityInfo(authorityRefName); + // + // Using the short IDs of the local authority and item, create URN specifiers to retrieve the SAS authority item + // + Specifier sasAuthoritySpecifier = new Specifier(SpecifierForm.URN_NAME, RefNameUtils.createShortIdRefName(authorityShortId)); + Specifier sasItemSpecifier = new Specifier(SpecifierForm.URN_NAME, RefNameUtils.createShortIdRefName(itemShortId)); + AuthorityItemSpecifier sasAuthorityItemSpecifier = new AuthorityItemSpecifier(sasAuthoritySpecifier, sasItemSpecifier); + // Get the shared authority server's copy + PoxPayloadIn sasPayloadIn = getPayloadIn(sasAuthorityItemSpecifier); + + Long sasRev = getRevision(sasPayloadIn); + if (sasRev > itemRev) { + ResourceMap resourceMap = ctx.getResourceMap(); + String resourceName = this.getAuthorityServicePath(); + AuthorityResource authorityResource = (AuthorityResource) resourceMap.get(resourceName); + PoxPayloadOut payloadOut = authorityResource.updateAuthorityItem(ctx, + resourceMap, + null, + authorityDocModel.getName(), // parent's CSID + itemDocModel.getName(), // item's CSID + sasPayloadIn, // the payload from the SAS + false); // don't update the parent's revision number + if (payloadOut != null) { + ctx.setOutput(payloadOut); + result = true; + } + } + + return result; + } + /* (non-Javadoc) * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper) */ @@ -418,11 +518,13 @@ public abstract class AuthorityItemDocumentModelHandler // // Next, update the inAuthority (the parent's) rev number // - DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), getInAuthority()); - Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV); - parentRev++; - inAuthorityDocModel.setProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV, parentRev); - getRepositorySession().saveDocument(inAuthorityDocModel); + if (this.shouldUpdateParentRevNumber == true) { + DocumentModel inAuthorityDocModel = NuxeoUtils.getDocFromCsid(getServiceContext(), getRepositorySession(), getInAuthority()); + Long parentRev = (Long)inAuthorityDocModel.getProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV); + parentRev++; + inAuthorityDocModel.setProperty(getParentCommonSchemaName(), AuthorityJAXBSchema.REV, parentRev); + getRepositorySession().saveDocument(inAuthorityDocModel); + } } /** diff --git a/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java b/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java index 13482dec3..9723ad180 100644 --- a/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java +++ b/services/citation/service/src/main/java/org/collectionspace/services/citation/nuxeo/CitationDocumentModelHandler.java @@ -35,7 +35,7 @@ public class CitationDocumentModelHandler extends AuthorityItemDocumentModelHandler { public CitationDocumentModelHandler() { - super(CitationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(CitationAuthorityClient.SERVICE_COMMON_PART_NAME, CitationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java b/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java index 66c72036e..94386d144 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java +++ b/services/common/src/main/java/org/collectionspace/services/common/NuxeoBasedResource.java @@ -221,24 +221,49 @@ public abstract class NuxeoBasedResource @PathParam("csid") String csid, String xmlPayload) { PoxPayloadOut result = null; + ensureCSID(csid, UPDATE); try { PoxPayloadIn theUpdate = new PoxPayloadIn(xmlPayload); - ServiceContext ctx = createServiceContext(theUpdate, uriInfo); - ctx.setResourceMap(resourceMap); - if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) { - ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists - } - result = update(csid, theUpdate, ctx); //==> CALL implementation method, which subclasses may override. + result = update(parentCtx, resourceMap, uriInfo, csid, theUpdate); } catch (Exception e) { throw bigReThrow(e, ServiceMessages.UPDATE_FAILED, csid); } + return result.getBytes(); } + + /** + * This method is used to synchronize data with the SAS (Shared Authority Server). + * + * @param parentCtx + * @param resourceMap + * @param uriInfo + * @param csid + * @param theUpdate + * @return + * @throws Exception + */ + public PoxPayloadOut update(ServiceContext parentCtx, // REM: 4/6/2016 - Some sub-classes will override this method -e.g., MediaResource does. + ResourceMap resourceMap, + UriInfo uriInfo, + String csid, + PoxPayloadIn theUpdate) throws Exception { + PoxPayloadOut result = null; + + ServiceContext ctx = createServiceContext(theUpdate, uriInfo); + ctx.setResourceMap(resourceMap); + if (parentCtx != null && parentCtx.getCurrentRepositorySession() != null) { + ctx.setCurrentRepositorySession(parentCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists + } + result = update(csid, theUpdate, ctx); //==> CALL implementation method, which subclasses may override. + + return result; + } /** Subclasses may override this overload, which gets called from #udpate(String,MultipartInput) */ protected PoxPayloadOut update(String csid, - PoxPayloadIn theUpdate, + PoxPayloadIn theUpdate, // not used in this method, but could be used by an overriding method ServiceContext ctx) throws Exception { DocumentHandler handler = createDocumentHandler(ctx); diff --git a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java index 78f36f5c9..427a87e5c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java +++ b/services/common/src/main/java/org/collectionspace/services/common/ServiceMain.java @@ -754,6 +754,14 @@ public class ServiceMain { return tenantBindingConfigReader; } + public ResourceMap getJaxRSResourceMap() { + ResourceMap result; + + result = ResteasyProviderFactory.getContextData(ResourceMap.class); + + return result; + } + /** * Populate a registry of URI templates by querying each resource * for its own entries in the registry. @@ -764,7 +772,7 @@ public class ServiceMain { private synchronized void populateUriTemplateRegistry() { if (uriTemplateRegistry.isEmpty()) { NuxeoBasedResource resource = null; - ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class); + ResourceMap resourceMap = getJaxRSResourceMap(); for (Map.Entry entry : resourceMap.entrySet()) { resource = entry.getValue(); Map entries = diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java index 9a18c008a..f3d620990 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/AbstractServiceContextImpl.java @@ -627,7 +627,7 @@ public abstract class AbstractServiceContextImpl } @Override - public AuthorityClient getAuthorityClient() throws Exception { + public AuthorityClient getClient() throws Exception { AuthorityClient result = authorityClient; if (authorityClient == null) { diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java index 3898cb85a..97322e405 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/MultipartServiceContextImpl.java @@ -55,6 +55,13 @@ public class MultipartServiceContextImpl final Logger logger = LoggerFactory.getLogger(MultipartServiceContextImpl.class); private String repositoryWorkspaceName; + + public MultipartServiceContextImpl(String serviceName) + throws DocumentException, UnauthorizedException { + super(serviceName, null); + setOutput(new PoxPayloadOut(serviceName)); + } + /** * Instantiates a new multipart service context impl. * diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java index b0cfee337..dd5c34799 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextImpl.java @@ -177,7 +177,13 @@ public class RemoteServiceContextImpl * @return the map of service names to resource classes. */ public ResourceMap getResourceMap() { - return resourceMap; + ResourceMap result = resourceMap; + + if (result == null) { + result = ServiceMain.getInstance().getJaxRSResourceMap(); + } + + return result; } /** diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java index 241206a36..0cb4cf8f2 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java +++ b/services/common/src/main/java/org/collectionspace/services/common/context/ServiceContext.java @@ -29,7 +29,7 @@ import java.util.Map; import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.UriInfo; -import org.collectionspace.services.client.AuthorityClient; +import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.common.ResourceMap; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.ValidatorHandler; @@ -353,7 +353,7 @@ public interface ServiceContext { public void setRepositoryDomain(RepositoryDomainType repositoryDomain); - public AuthorityClient getAuthorityClient() throws Exception; + public CollectionSpaceClient getClient() throws Exception; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java index 56368f4f6..61ff77bb8 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandlerImpl.java @@ -227,7 +227,9 @@ public abstract class AbstractDocumentHandlerImpl * @see org.collectionspace.services.common.document.DocumentHandler#handle(org.collectionspace.services.common.document.DocumentHandler.Action, org.collectionspace.services.common.document.DocumentWrapper) */ @Override - final public void handle(Action action, DocumentWrapper wrapDoc) throws Exception { + final public boolean handle(Action action, DocumentWrapper wrapDoc) throws Exception { + boolean result = true; + switch (action) { case CREATE: handleCreate((DocumentWrapper) wrapDoc); @@ -250,7 +252,7 @@ public abstract class AbstractDocumentHandlerImpl break; case SYNC: - handleSync((DocumentWrapper) wrapDoc); + result = handleSync((DocumentWrapper) wrapDoc); break; case WORKFLOW: @@ -263,6 +265,8 @@ public abstract class AbstractDocumentHandlerImpl Thread.dumpStack(); break; } + + return result; } /* (non-Javadoc) @@ -301,8 +305,9 @@ public abstract class AbstractDocumentHandlerImpl * @see org.collectionspace.services.common.document.DocumentHandler#handleDelete(org.collectionspace.services.common.document.DocumentWrapper) */ @Override - public void handleSync(DocumentWrapper wrapDoc) throws Exception { + public boolean handleSync(DocumentWrapper wrapDoc) throws Exception { // Do nothing. Subclasses can override if they want/need to. + return true; } @@ -333,7 +338,7 @@ public abstract class AbstractDocumentHandlerImpl break; case SYNC: - completeSync((DocumentWrapper) wrapDoc); + completeSync((DocumentWrapper) wrapDoc); break; case WORKFLOW: @@ -388,7 +393,7 @@ public abstract class AbstractDocumentHandlerImpl * @see org.collectionspace.services.common.document.DocumentHandler#completeDelete(org.collectionspace.services.common.document.DocumentWrapper) */ @Override - public void completeSync(DocumentWrapper wrapDoc) throws Exception { + public void completeSync(DocumentWrapper wrapDoc) throws Exception { } /* (non-Javadoc) diff --git a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java index cf09bc1f0..386151d82 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java @@ -125,7 +125,7 @@ public interface DocumentHandler { * @param doc wrapped doc * @throws Exception */ - public void handle(Action action, DocumentWrapper docWrap) throws Exception; + public boolean handle(Action action, DocumentWrapper docWrap) throws Exception; /** * handleCreate processes documents before creating document in repository @@ -375,13 +375,13 @@ public interface DocumentHandler { * @param wrapDoc * @throws Exception */ - void handleSync(DocumentWrapper wrapDoc) throws Exception; + boolean handleSync(DocumentWrapper wrapDoc) throws Exception; /** * * @param wrapDoc * @throws Exception */ - void completeSync(DocumentWrapper wrapDoc) throws Exception; + void completeSync(DocumentWrapper wrapDoc) throws Exception; } diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/StorageClient.java b/services/common/src/main/java/org/collectionspace/services/common/storage/StorageClient.java index ffb433a75..f0caf1845 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/StorageClient.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/StorageClient.java @@ -25,6 +25,7 @@ import org.collectionspace.services.common.document.DocumentException; import org.collectionspace.services.common.document.DocumentHandler; import org.collectionspace.services.common.document.DocumentNotFoundException; import org.collectionspace.services.common.document.TransactionException; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; import org.collectionspace.services.lifecycle.TransitionDef; @@ -145,9 +146,16 @@ public interface StorageClient { throws BadRequestException, DocumentNotFoundException, DocumentException; /* - * Ask a resource to synchronize itself with a shared server resource + * Ask a resource to synchronize itself with a shared server resource. Returns "TRUE" if sync was needed. */ - void synchronize(ServiceContext ctx, Specifier specifier, DocumentHandler handler) + boolean synchronize(ServiceContext ctx, Object specifier, DocumentHandler handler) + throws DocumentNotFoundException, TransactionException, + DocumentException; + + /* + * Ask an item resource (e.g., an Authority or Vocabulary items) to synchronize itself with a shared server resource. Returns "TRUE" if sync was needed. + */ + boolean synchronizeItem(ServiceContext ctx, AuthorityItemSpecifier itemSpecifier, DocumentHandler handler) throws DocumentNotFoundException, TransactionException, DocumentException; diff --git a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClientImpl.java b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClientImpl.java index ba237810e..560c355ee 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/common/storage/jpa/JpaStorageClientImpl.java @@ -39,6 +39,7 @@ import org.collectionspace.services.common.document.DocumentWrapperImpl; import org.collectionspace.services.common.document.JaxbUtils; import org.collectionspace.services.common.document.TransactionException; import org.collectionspace.services.common.storage.StorageClient; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; import org.collectionspace.services.common.context.ServiceContextProperties; import org.collectionspace.services.common.context.ServiceContext; @@ -597,10 +598,21 @@ public class JpaStorageClientImpl implements StorageClient { } @Override - public void synchronize(ServiceContext ctx, Specifier specifier, + 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; } + + @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; + } + } diff --git a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java index a490e7d27..ccaf2639c 100644 --- a/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java +++ b/services/common/src/main/java/org/collectionspace/services/common/vocabulary/RefNameServiceUtils.java @@ -94,6 +94,24 @@ public class RefNameServiceUtils { this.value = value; } } + + public static class AuthorityItemSpecifier { + private Specifier parentSpecifier; + private Specifier itemSpecifier; + + public AuthorityItemSpecifier(Specifier parentSpecifier, Specifier itemSpecifier) { + this.parentSpecifier = parentSpecifier; + this.itemSpecifier = itemSpecifier; + } + + public Specifier getParentSpecifier() { + return this.parentSpecifier; + } + + public Specifier getItemSpecifier() { + return this.itemSpecifier; + } + } public static class AuthRefConfigInfo { diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java index a3e93d035..e56a91936 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/NuxeoDocumentModelHandler.java @@ -38,6 +38,7 @@ import org.collectionspace.services.client.IRelationsManager; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.ReflectionMapper; +import org.collectionspace.services.common.XmlTools; import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils; import org.collectionspace.services.common.api.Tools; import org.collectionspace.services.common.config.ServiceConfigUtils; @@ -53,10 +54,9 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.nuxeo.client.java.CommonList; import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; import org.collectionspace.services.nuxeo.util.NuxeoUtils; - +import org.dom4j.Document; import org.nuxeo.ecm.core.api.DocumentModel; import org.nuxeo.ecm.core.api.DocumentModelList; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -107,6 +107,24 @@ public abstract class NuxeoDocumentModelHandler extends RemoteDocumentModelHa this.commonPart = commonPart; } + /** + * The entity type expected from the JAX-RS Response object. By default it is of type String. Child classes + * can override this if they need to. + */ + protected Class getEntityResponseType() { + return String.class; + } + + protected Long getRevision(PoxPayloadIn payloadIn) { + Long result = null; + + Document document = payloadIn.getDOMDocument(); + String xmlRev = XmlTools.getElementValue(document, "//rev"); + result = Long.valueOf(xmlRev); + + return result; + } + /** * Subclass DocHandlers may override this method to control exact creation of the common list. * This class instantiates an AbstractCommonList from the classname returned by getDocHandlerParams().AbstractCommonListClassname. diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryClientImpl.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryClientImpl.java index fd1b38494..5de76630d 100644 --- a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryClientImpl.java +++ b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryClientImpl.java @@ -62,6 +62,7 @@ import org.collectionspace.services.common.config.ConfigUtils; import org.collectionspace.services.common.config.TenantBindingConfigReaderImpl; import org.collectionspace.services.common.config.TenantBindingUtils; import org.collectionspace.services.common.storage.PreparedStatementBuilder; +import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier; import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier; import org.collectionspace.services.config.tenant.TenantBindingType; import org.collectionspace.services.config.tenant.RepositoryDomainType; @@ -258,9 +259,46 @@ public class RepositoryClientImpl implements RepositoryClient wrapDoc = new DocumentWrapperImpl(specifier); + result = handler.handle(Action.SYNC, wrapDoc); + handler.complete(Action.SYNC, wrapDoc); + } catch (IllegalArgumentException iae) { + throw iae; + } catch (DocumentException de) { + throw de; + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception ", e); + } + throw new NuxeoDocumentException(e); + } finally { + if (repoSession != null) { + releaseRepositorySession(ctx, repoSession); + } + } + + return result; + } + + @Override + public boolean synchronizeItem(ServiceContext ctx, AuthorityItemSpecifier itemSpecifier, DocumentHandler handler) + throws DocumentNotFoundException, TransactionException, DocumentException { + boolean result = false; + if (handler == null) { throw new IllegalArgumentException( "RepositoryJavaClient.get: handler is missing"); @@ -271,8 +309,8 @@ public class RepositoryClientImpl implements RepositoryClient wrapDoc = new DocumentWrapperImpl(specifier); - handler.handle(Action.SYNC, wrapDoc); + DocumentWrapper wrapDoc = new DocumentWrapperImpl(itemSpecifier); + result = handler.handle(Action.SYNC, wrapDoc); handler.complete(Action.SYNC, wrapDoc); } catch (IllegalArgumentException iae) { throw iae; @@ -288,6 +326,8 @@ public class RepositoryClientImpl implements RepositoryClient { public ConceptDocumentModelHandler() { - super(ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(ConceptAuthorityClient.SERVICE_COMMON_PART_NAME, ConceptAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java index c7cd1c914..933e2c9bd 100644 --- a/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java +++ b/services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java @@ -35,7 +35,7 @@ public class LocationDocumentModelHandler extends AuthorityItemDocumentModelHandler { public LocationDocumentModelHandler() { - super(LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(LocationAuthorityClient.SERVICE_COMMON_PART_NAME, LocationAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java b/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java index a2c9e74b7..611da504f 100644 --- a/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java +++ b/services/material/service/src/main/java/org/collectionspace/services/material/nuxeo/MaterialDocumentModelHandler.java @@ -35,7 +35,7 @@ public class MaterialDocumentModelHandler extends AuthorityItemDocumentModelHandler { public MaterialDocumentModelHandler() { - super(MaterialAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(MaterialAuthorityClient.SERVICE_COMMON_PART_NAME, MaterialAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java index 0c2ecb6db..b47a4d521 100644 --- a/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java +++ b/services/organization/service/src/main/java/org/collectionspace/services/organization/nuxeo/OrganizationDocumentModelHandler.java @@ -35,7 +35,7 @@ public class OrganizationDocumentModelHandler extends AuthorityItemDocumentModelHandler { public OrganizationDocumentModelHandler() { - super(OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(OrgAuthorityClient.SERVICE_COMMON_PART_NAME, OrgAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java index 215975f19..088abf597 100644 --- a/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java +++ b/services/person/service/src/main/java/org/collectionspace/services/person/nuxeo/PersonDocumentModelHandler.java @@ -35,7 +35,7 @@ public class PersonDocumentModelHandler extends AuthorityItemDocumentModelHandler { public PersonDocumentModelHandler() { - super(PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(PersonAuthorityClient.SERVICE_COMMON_PART_NAME, PersonAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java index c60e59899..acfbdbadd 100644 --- a/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java +++ b/services/place/service/src/main/java/org/collectionspace/services/place/nuxeo/PlaceDocumentModelHandler.java @@ -35,7 +35,7 @@ public class PlaceDocumentModelHandler extends AuthorityItemDocumentModelHandler { public PlaceDocumentModelHandler() { - super(PlaceAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(PlaceAuthorityClient.SERVICE_COMMON_PART_NAME, PlaceAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java index 6a73471d5..cdcb79da6 100644 --- a/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java +++ b/services/taxonomy/service/src/main/java/org/collectionspace/services/taxonomy/nuxeo/TaxonDocumentModelHandler.java @@ -35,7 +35,7 @@ public class TaxonDocumentModelHandler extends AuthorityItemDocumentModelHandler { public TaxonDocumentModelHandler() { - super(TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(TaxonomyAuthorityClient.SERVICE_COMMON_PART_NAME, TaxonomyAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java index 591442e5d..00e49f828 100644 --- a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyItemDocumentModelHandler.java @@ -40,7 +40,7 @@ public class VocabularyItemDocumentModelHandler extends AuthorityItemDocumentModelHandler { public VocabularyItemDocumentModelHandler() { - super(VocabularyClient.SERVICE_ITEM_COMMON_PART_NAME); + super(VocabularyClient.SERVICE_COMMON_PART_NAME, VocabularyClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override diff --git a/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java b/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java index 24507afe0..3cd3648d9 100644 --- a/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java +++ b/services/work/service/src/main/java/org/collectionspace/services/work/nuxeo/WorkDocumentModelHandler.java @@ -35,7 +35,7 @@ public class WorkDocumentModelHandler extends AuthorityItemDocumentModelHandler { public WorkDocumentModelHandler() { - super(WorkAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); + super(WorkAuthorityClient.SERVICE_COMMON_PART_NAME, WorkAuthorityClient.SERVICE_ITEM_COMMON_PART_NAME); } @Override