</ns3:vocabularies_common>
<ns2:abstract-common-list xmlns:ns2="http://collectionspace.org/services/jaxb">
<list-item>
- <proposed>true</proposed>
<order>1</order>
<displayName>PostWithItems item PostWithItems1</displayName>
<shortIdentifier>PostWithItems1</shortIdentifier>
</list-item>
<list-item>
- <proposed>true</proposed>
<order>2</order>
<displayName>PostWithItems item PostWithItems2</displayName>
<shortIdentifier>ShowItemsItem2</shortIdentifier>
import org.collectionspace.services.nuxeo.client.java.DocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.workflow.WorkflowCommon;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
*/
protected DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> createItemDocumentHandler(
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
- String inAuthority, String parentShortIdentifier)
+ String inAuthority, String containerShortIdentifier)
throws Exception {
String authorityRefNameBase;
AuthorityItemDocumentModelHandler<?> docHandler;
- if (parentShortIdentifier == null) {
+ if (containerShortIdentifier == null) {
authorityRefNameBase = null;
} else {
- ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx = createServiceContext(getServiceName());
- if (parentShortIdentifier.equals(FETCH_SHORT_ID)) { // We need to fetch this from the repo
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> containerCtx = createServiceContext(getServiceName());
+ if (containerShortIdentifier.equals(FETCH_SHORT_ID)) { // We need to fetch this from the repo
if (ctx.getCurrentRepositorySession() != null) {
- parentCtx.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
- parentShortIdentifier = getAuthShortIdentifier(parentCtx, inAuthority);
+ containerShortIdentifier = getAuthShortIdentifier(containerCtx, inAuthority);
}
- authorityRefNameBase = buildAuthorityRefNameBase(parentCtx, parentShortIdentifier);
+ authorityRefNameBase = buildAuthorityRefNameBase(containerCtx, containerShortIdentifier);
}
docHandler = (AuthorityItemDocumentModelHandler<?>) createDocumentHandler(ctx,
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(item.inAuthority.resource);
// HACK - this really must be moved to the doc handler, not here. No Nuxeo specific stuff here!
- RepositoryClientImpl client = (RepositoryClientImpl)getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl client = (NuxeoRepositoryClientImpl)getRepositoryClient(ctx);
String parentcsid = client.findDocCSID(repoSession, ctx, whereClause);
String itemWhereClause = RefNameServiceUtils.buildWhereForAuthItemByName(authorityItemCommonSchemaName, item.getShortIdentifier(), parentcsid);
@POST
- public Response createAuthority(String xmlPayload) {
+ 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.
*/
@DELETE
@Path("{csid}")
- public Response deleteAuthority(
+ public Response deleteAuthority( // # Delete this authority and all of it's items.
@Context Request request,
@Context UriInfo uriInfo,
@PathParam("csid") String specifier) {
ServiceDescription result = super.getDescription(ctx);
result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId()));
return result;
- }
+ }
+
+ public Response createAuthority(String xmlPayload) {
+ return this.createAuthority(null, null, xmlPayload);
+ }
}
import org.collectionspace.services.lifecycle.TransitionDef;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.dom4j.Element;
import org.nuxeo.ecm.core.api.ClientException;
}
/**
- * This method should only be used as part of a SAS synch operation.
+ * This method should ***only*** be used as part of a SAS synch operation.
+ *
* @param ctx
* @param refNameList
* @return
CoreSessionInterface repoSession = null;
boolean releaseSession = false;
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
try {
repoSession = nuxeoRepoClient.getRepositorySession(ctx);
DocumentWrapper<DocumentModel> wrapDoc = nuxeoRepoClient.getDocFromCsid(ctx, repoSession, authCSID);
import org.collectionspace.services.lifecycle.TransitionDef;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.relation.RelationsCommonList;
import org.collectionspace.services.vocabulary.VocabularyItemJAXBSchema;
boolean releaseRepoSession = false;
try {
- RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
String filteredTerm;
StringBuilder filteredTermBuilder = new StringBuilder(term);
// Term contains no anchor or wildcard characters.
- if ( (! term.contains(RepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR))
- && (! term.contains(RepositoryClientImpl.USER_SUPPLIED_WILDCARD)) ) {
+ if ( (! term.contains(NuxeoRepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR))
+ && (! term.contains(NuxeoRepositoryClientImpl.USER_SUPPLIED_WILDCARD)) ) {
filteredTerm = term;
} else {
// Term contains at least one such character.
// Filter the starting anchor or wildcard character, if any.
String firstChar = filteredTermBuilder.substring(0,1);
switch (firstChar) {
- case RepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
+ case NuxeoRepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
anchorAtStart = true;
break;
- case RepositoryClientImpl.USER_SUPPLIED_WILDCARD:
+ case NuxeoRepositoryClientImpl.USER_SUPPLIED_WILDCARD:
filteredTermBuilder.deleteCharAt(0);
break;
}
int lastPos = filteredTermBuilder.length() - 1;
String lastChar = filteredTermBuilder.substring(lastPos);
switch (lastChar) {
- case RepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
+ case NuxeoRepositoryClientImpl.USER_SUPPLIED_ANCHOR_CHAR:
filteredTermBuilder.deleteCharAt(lastPos);
- filteredTermBuilder.insert(filteredTermBuilder.length(), RepositoryClientImpl.ENDING_ANCHOR_CHAR);
+ filteredTermBuilder.insert(filteredTermBuilder.length(), NuxeoRepositoryClientImpl.ENDING_ANCHOR_CHAR);
anchorAtEnd = true;
break;
- case RepositoryClientImpl.USER_SUPPLIED_WILDCARD:
+ case NuxeoRepositoryClientImpl.USER_SUPPLIED_WILDCARD:
filteredTermBuilder.deleteCharAt(lastPos);
break;
}
}
filteredTerm = filteredTermBuilder.toString();
// Filter all other wildcards, if any.
- filteredTerm = filteredTerm.replaceAll(RepositoryClientImpl.USER_SUPPLIED_WILDCARD_REGEX, ZERO_OR_MORE_ANY_CHAR_REGEX);
+ filteredTerm = filteredTerm.replaceAll(NuxeoRepositoryClientImpl.USER_SUPPLIED_WILDCARD_REGEX, ZERO_OR_MORE_ANY_CHAR_REGEX);
if (logger.isTraceEnabled()) {
logger.trace(String.format("After replacing user wildcards = %s", filteredTerm));
}
import org.collectionspace.services.authorization.perms.ActionType;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.batch.BatchCommon;
import org.collectionspace.services.batch.BatchCommon.ForDocTypes;
import org.collectionspace.services.batch.BatchCommon.ForRoles;
CoreSessionInterface repoSession = null;
boolean releaseRepoSession = false;
- RepositoryClientImpl repoClient = (RepositoryClientImpl) this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl) this.getRepositoryClient(ctx);
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
releaseRepoSession = true;
}
public Element getElementBody() {
+ if (elementBody == null) {
+ elementBody = asElement();
+ }
+
return elementBody;
}
m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, false);
//Marshal object into file.
m.marshal(jaxbObject, outputStream);
- text = outputStream.toString("UTF8");
+ text = outputStream.toString("UTF8"); // FIXME: This method could/should be using JaxbUtils.toString() method
Document doc = DocumentHelper.parseText(text);
result = doc.getRootElement(); //FIXME: REM - call .detach() to free the element
<user>Administrator</user>
<password>Administrator</password>
<client-type>java</client-type>
- <client-class>org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl</client-class>
+ <client-class>org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl</client-class>
<properties>
<types:item><types:key>pageSizeDefault</types:key><types:value>40</types:value></types:item> <!-- Use 'pgSz' query param to override this on a per request bassis. -->
<types:item><types:key>pageSizeMax</types:key><types:value>2500</types:value></types:item> <!-- No list result page size can be greater than this amount -->
if (currentRepoSesssionRefCount == 0) {
this.currentRepositorySession = null;
}
+
+ if (currentRepoSesssionRefCount < 0) {
+ throw new RuntimeException("Attempted to clear/close a repository session that has already been cleared/closed.");
+ }
}
@Override
import org.collectionspace.services.jaxb.BlobJAXBSchema;
import org.collectionspace.services.nuxeo.client.java.CommonList;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.nuxeo.extension.thumbnail.ThumbnailConstants;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.config.service.ListResultField;
static private CoreSessionInterface getRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient) {
CoreSessionInterface result = null;
- RepositoryClientImpl nuxeoClient = (RepositoryClientImpl)repositoryClient;
+ NuxeoRepositoryClientImpl nuxeoClient = (NuxeoRepositoryClientImpl)repositoryClient;
try {
result = nuxeoClient.getRepositorySession(ctx);
static private void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient,
CoreSessionInterface repoSession) throws TransactionException {
- RepositoryClientImpl nuxeoClient = (RepositoryClientImpl)repositoryClient;
+ NuxeoRepositoryClientImpl nuxeoClient = (NuxeoRepositoryClientImpl)repositoryClient;
nuxeoClient.releaseRepositorySession(ctx, repoSession);
}
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
// relations_common:subjectRefName = 'urn:cspace:core.collectionspace.org:placeauthorities:name(place):item:name(Amystan1348082103923)\'Amystan\''"
String query = String.format("%s:%s = '%s'", IRelationsManager.SERVICE_COMMONPART_NAME, targetField, escapedRefName);
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,
docTypes, query, orderByClause, pageSize, pageNum, computeTotal);
DocumentModelList docList = docListWrapper.getWrappedObject();
import java.util.Hashtable;
import java.util.List;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.document.DocumentHandler;
*/
boolean delete(ServiceContext ctx, List<String> idList, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException, TransactionException;
+
+ /**
+ *
+ * @param ctx
+ * @return
+ * @throws Exception
+ */
+ public CoreSessionInterface getRepositorySession(ServiceContext<IT, OT> ctx) throws Exception;
}
import java.util.List;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.document.BadRequestException;
import org.collectionspace.services.common.document.DocumentException;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
import org.collectionspace.services.lifecycle.TransitionDef;
+import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
/**
*
boolean delete(ServiceContext ctx, Object entityFound, DocumentHandler handler)
throws DocumentNotFoundException, DocumentException;
+ void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, Object repoSession)
+ throws TransactionException;
+
}
import org.collectionspace.services.common.storage.TransactionContext;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthorityItemSpecifier;
import org.collectionspace.services.common.context.ServiceContextProperties;
+import org.collectionspace.services.client.PoxPayloadIn;
+import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.lifecycle.TransitionDef;
return true;
}
+ @Override
+ public void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, Object repoSession)
+ throws TransactionException {
+ // TODO Auto-generated method stub
+ }
+
}
import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.common.security.SecurityUtils;
import org.collectionspace.services.config.service.ServiceBindingType;
import org.collectionspace.services.jaxb.AbstractCommonList;
Map<String, ServiceBindingType> queriedServiceBindings = new HashMap<String, ServiceBindingType>();
Map<String, List<AuthRefConfigInfo>> authRefFieldsByService = new HashMap<String, List<AuthRefConfigInfo>>();
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
try {
// Ignore any provided page size and number query parameters in
// the following call, as they pertain to the list of authority
final String ORDER_BY_VALUE = CollectionSpaceClient.CORE_CREATED_AT // "collectionspace_core:createdAt";
+ ", " + IQueryManager.NUXEO_UUID; // CSPACE-6333: Add secondary sort on uuid, in case records have the same createdAt timestamp.
- if (repoClient instanceof RepositoryClientImpl == false) {
+ if (repoClient instanceof NuxeoRepositoryClientImpl == false) {
throw new InternalError("updateAuthorityRefDocs() called with unknown repoClient type!");
}
queriedServiceBindings, authRefFieldsByService, // Perform the refName updates on the list of document models
newRefName);
if (nRefsFoundThisPage > 0) {
- ((RepositoryClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true); // Flush the document model list out to Nuxeo storage
+ ((NuxeoRepositoryClientImpl) repoClient).saveDocListWithoutHandlerProcessing(ctx, repoSession, docList, true); // Flush the document model list out to Nuxeo storage
nRefsFound += nRefsFoundThisPage;
}
query += " AND " + whereClauseAdditions;
}
// Now we have to issue the search
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
DocumentWrapper<DocumentModelList> docListWrapper = nuxeoRepoClient.findDocs(ctx, repoSession,
docTypes, query, orderByClause, pageSize, pageNum, computeTotal);
// Now we gather the info for each document into the list and return
public AbstractCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
CommonList commonList = new CommonList();
CoreSessionInterface repoSession = null;
- RepositoryClientImpl repoClient = null;
+ NuxeoRepositoryClientImpl repoClient = null;
boolean releaseRepoSession = false;
AbstractServiceContextImpl ctx = (AbstractServiceContextImpl) getServiceContext();
try {
if (markRtSbj != null) {
- repoClient = (RepositoryClientImpl) this.getRepositoryClient(ctx);
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
+ repoClient = (NuxeoRepositoryClientImpl) this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
*
* $LastChangedRevision: $ $LastChangedDate: $
*/
-public class RepositoryClientImpl implements RepositoryClient<PoxPayloadIn, PoxPayloadOut> {
+public class NuxeoRepositoryClientImpl implements RepositoryClient<PoxPayloadIn, PoxPayloadOut> {
/**
* The logger.
*/
- private final Logger logger = LoggerFactory.getLogger(RepositoryClientImpl.class);
+ private final Logger logger = LoggerFactory.getLogger(NuxeoRepositoryClientImpl.class);
// private final Logger profilerLogger = LoggerFactory.getLogger("remperf");
// private String foo = Profiler.createLogger();
public static final String NUXEO_CORE_TYPE_DOMAIN = "Domain";
/**
* Instantiates a new repository java client impl.
*/
- public RepositoryClientImpl() {
+ public NuxeoRepositoryClientImpl() {
//Empty constructor
}
return workspaceId;
}
+ @Override
public CoreSessionInterface getRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) throws Exception {
return getRepositorySession(ctx, ctx.getRepositoryName(), ctx.getTimeoutSecs());
}
*
* @param repoSession the repo session
*/
- public void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, CoreSessionInterface repoSession) throws TransactionException {
+ @Override
+ public void releaseRepositorySession(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, Object repositorySession) throws TransactionException {
try {
+ CoreSessionInterface repoSession = (CoreSessionInterface)repositorySession;
NuxeoClientEmbedded client = NuxeoConnectorEmbedded.getInstance().getClient();
// release session
if (ctx != null) {
boolean releaseRepoSession = false;
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
- RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
CoreSessionInterface repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
import org.collectionspace.services.config.service.ServiceBindingType;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.DocumentModel;
// provided as an alternate identifier.
}
if (Tools.notBlank(csid)) {
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl)getRepositoryClient(ctx);
DocumentWrapper<DocumentModel> docWrapper = nuxeoRepoClient.getDocFromCsid(ctx, repoSession, csid);
docModel = docWrapper.getWrappedObject();
} else { // if (Tools.isBlank(objectCsid)) {
import org.collectionspace.services.jaxb.InvocableJAXBSchema;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.jfree.util.Log;
import org.nuxeo.ecm.core.api.DocumentModel;
+invocationMode);
}
- RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
import org.collectionspace.services.nuxeo.client.java.CommonList;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
-import org.collectionspace.services.nuxeo.client.java.RepositoryClientImpl;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.client.CollectionSpaceClient;
boolean releaseRepoSession = false;
try {
- RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
List<String> serviceGroupNames,
Map<String, ServiceBindingType> queriedServiceBindings,
CoreSessionInterface repoSession,
- RepositoryClientImpl repoClient) throws Exception {
+ NuxeoRepositoryClientImpl repoClient) throws Exception {
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl)repoClient;
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl)repoClient;
// Get the service bindings for this tenant
TenantBindingConfigReaderImpl tReader = ServiceMain.getInstance().getTenantBindingConfigReader();
// We need to get all the procedures, authorities, and objects.
list.setPageNum(pageNum);
list.setPageSize(pageSize);
- RepositoryClientImpl repoClient = (RepositoryClientImpl)this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl repoClient = (NuxeoRepositoryClientImpl)this.getRepositoryClient(ctx);
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
String tenantId = ctx.getTenantId();
CoreSessionInterface repoSession = null;
- RepositoryClientImpl repoClient = null;
+ NuxeoRepositoryClientImpl repoClient = null;
boolean releaseRepoSession = false;
MultivaluedMap<String, String> queryParams = getServiceContext().getQueryParams();
try {
if (markRtSbj != null) {
- repoClient = (RepositoryClientImpl) this.getRepositoryClient(ctx);
- RepositoryClientImpl nuxeoRepoClient = (RepositoryClientImpl) repoClient;
+ repoClient = (NuxeoRepositoryClientImpl) this.getRepositoryClient(ctx);
+ NuxeoRepositoryClientImpl nuxeoRepoClient = (NuxeoRepositoryClientImpl) repoClient;
repoSession = this.getRepositorySession();
if (repoSession == null) {
repoSession = repoClient.getRepositorySession(ctx);
package org.collectionspace.services.vocabulary;
import org.collectionspace.services.client.IClientQueryParams;
+import org.collectionspace.services.client.PayloadInputPart;
+import org.collectionspace.services.client.PoxPayload;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.VocabularyClient;
+import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.CSWebApplicationException;
+import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.common.ServiceMessages;
import org.collectionspace.services.common.UriInfoWrapper;
import org.collectionspace.services.common.api.Tools;
import org.collectionspace.services.common.context.ServiceBindingUtils;
import org.collectionspace.services.common.context.ServiceContext;
+import org.collectionspace.services.common.document.DocumentException;
+import org.collectionspace.services.common.document.DocumentHandler;
+import org.collectionspace.services.common.document.JaxbUtils;
+import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
+import org.collectionspace.services.common.vocabulary.AuthorityServiceUtils;
+import org.collectionspace.services.jaxb.AbstractCommonList;
+import org.collectionspace.services.jaxb.AbstractCommonList.ListItem;
+import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
+import org.collectionspace.services.nuxeo.client.java.NuxeoRepositoryClientImpl;
import org.collectionspace.services.vocabulary.nuxeo.VocabularyItemDocumentModelHandler;
-
+import org.collectionspace.services.workflow.WorkflowCommon;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
import javax.ws.rs.GET;
+import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Request;
import javax.ws.rs.core.Response;
+import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
@Path("/" + VocabularyClient.SERVICE_PATH_COMPONENT)
VOCABULARIES_COMMON, VOCABULARYITEMS_COMMON);
}
- @GET
+ @Override
+ @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);
+ RepositoryClient<PoxPayloadIn, PoxPayloadOut> repoClient = this.getRepositoryClient(ctx);
+
+ CoreSessionInterface repoSession = repoClient.getRepositorySession(ctx);
+ try {
+ DocumentHandler<?, AbstractCommonList, DocumentModel, DocumentModelList> handler = createDocumentHandler(ctx);
+ String csid = repoClient.create(ctx, handler);
+ handleItemsPayload(repoSession, csid, resourceMap, uriInfo, input);
+ UriBuilder path = UriBuilder.fromResource(resourceClass);
+ path.path("" + csid);
+ Response response = Response.created(path.build()).build();
+ return response;
+ } catch (Throwable t) {
+ repoSession.setTransactionRollbackOnly();
+ throw t;
+ } finally {
+ repoClient.releaseRepositorySession(ctx, repoSession);
+ }
+ } catch (Exception e) {
+ throw bigReThrow(e, ServiceMessages.CREATE_FAILED);
+ }
+ }
+ }
+
+ private void handleItemsPayload(CoreSessionInterface repoSession,
+ String parentIdentifier,
+ ResourceMap resourceMap,
+ UriInfo uriInfo,
+ PoxPayloadIn input) throws Exception {
+ PayloadInputPart abstractCommonListPart = input.getPart(PoxPayload.ABSTRACT_COMMON_LIST_ROOT_ELEMENT_LABEL);
+ if (abstractCommonListPart != null) {
+ AbstractCommonList itemsList = (AbstractCommonList) abstractCommonListPart.getBody();
+ for (ListItem item : itemsList.getListItem()) {
+ PoxPayloadIn itemXmlPayload = getItemXmlPayload(item);
+ Response res = this.createAuthorityItem(repoSession, resourceMap, uriInfo, parentIdentifier, itemXmlPayload);
+ }
+ }
+
+ }
+
+ /**
+ * This is very brittle. If the class VocabularyitemsCommon changed with new fields we'd have to
+ * update this method.
+ *
+ * @param item
+ * @return
+ * @throws DocumentException
+ */
+ private PoxPayloadIn getItemXmlPayload(ListItem item) throws DocumentException {
+ PoxPayloadIn result = null;
+
+ VocabularyitemsCommon vocabularyItem = new VocabularyitemsCommon();
+ for (Element ele : item.getAny()) {
+ String fieldName = ele.getTagName();
+ String fieldValue = ele.getTextContent();
+ switch (fieldName) {
+ case "displayName":
+ vocabularyItem.setDisplayName(fieldValue);
+ break;
+
+ case "shortIdentifier":
+ vocabularyItem.setShortIdentifier(fieldValue);
+ break;
+
+ case "order":
+ vocabularyItem.setOrder(fieldValue);
+ break;
+
+ case "source":
+ vocabularyItem.setSource(fieldValue);
+ break;
+
+ case "sourcePage":
+ vocabularyItem.setSourcePage(fieldValue);
+ break;
+
+ case "description":
+ vocabularyItem.setDescription(fieldValue);
+
+ default:
+ throw new DocumentException(String.format("Unknown field '%s' in vocabulary item payload.",
+ fieldName));
+ }
+ }
+
+ result = new PoxPayloadIn(VocabularyClient.SERVICE_ITEM_PAYLOAD_NAME, vocabularyItem,
+ VOCABULARYITEMS_COMMON);
+
+ return result;
+ }
+
+ private Response createAuthorityItem(
+ CoreSessionInterface repoSession,
+ ResourceMap resourceMap,
+ UriInfo uriInfo,
+ String parentIdentifier, // Either a CSID or a URN form -e.g., a8ad38ec-1d7d-4bf2-bd31 or urn:cspace:name(bugsbunny)
+ PoxPayloadIn input) throws Exception {
+ Response result = null;
+
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), input, resourceMap, uriInfo);
+ ctx.setCurrentRepositorySession(repoSession);
+
+ result = createAuthorityItem(ctx, parentIdentifier, AuthorityServiceUtils.UPDATE_REV,
+ AuthorityServiceUtils.PROPOSED, AuthorityServiceUtils.NOT_SAS_ITEM);
+
+ return result;
+ }
+
+
+ @GET
@Path("{csid}")
@Override
public Response get(