package org.collectionspace.services.client;
+import org.collectionspace.services.acquisition.AcquisitionsCommon;
+
/**
* An AcquisitionClient.
* @version $Revision:$
*/
-public class AcquisitionClient extends AbstractCommonListPoxServiceClientImpl<AcquisitionProxy> {
+public class AcquisitionClient extends AbstractCommonListPoxServiceClientImpl<AcquisitionProxy, AcquisitionsCommon> {
public static final String SERVICE_NAME = "acquisitions";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
final static String REF_NAME = "refName";
final static String SHORT_IDENTIFIER = "shortIdentifier";
final static String CSID = "csid";
+ final static String REV = "rev";
final static String URI = "url";
}
*/
package org.collectionspace.services.common.vocabulary;
-/**
- * @author pschmitz
- *
- */
public interface AuthorityJAXBSchema {
final static String DISPLAY_NAME = "displayName";
- final static String SHORT_IDENTIFIER = "shortIdentifier";
final static String REF_NAME = "refName";
+ final static String SHORT_IDENTIFIER = "shortIdentifier";
final static String VOCAB_TYPE = "vocabType";
final static String CSID = "csid";
final static String REV = "rev";
final static String SHORT_IDENTIFIER = "shortIdentifier";
final static String VOCAB_TYPE = "vocabType";
final static String CSID = "csid";
+ final static String REV = "rev";
final static String URI = "url";
}
<artifactId>org.collectionspace.services.client</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.vocabulary.client</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.common</artifactId>
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.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;
final Logger logger = LoggerFactory.getLogger(AuthorityResource.class);
- public enum SpecifierForm {
-
- CSID, URN_NAME
- };
-
- public class Specifier {
-
- public SpecifierForm form;
- public String value;
-
- Specifier(SpecifierForm form, String value) {
- this.form = form;
- this.value = value;
- }
- }
-
protected Specifier getSpecifier(String specifierIn, String method, String op) throws CSWebApplicationException {
if (logger.isDebugEnabled()) {
logger.debug("getSpecifier called by: " + method + " with specifier: " + specifierIn);
@Context Request request,
@Context UriInfo ui,
@PathParam("csid") String csid) {
- boolean result = false;
+ PoxPayloadOut result = null;
Specifier specifier;
try {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(ui);
AuthorityDocumentModelHandler handler = (AuthorityDocumentModelHandler)createDocumentHandler(ctx);
specifier = getSpecifier(csid, "getAuthority", "GET");
- result = handler.synchronize(specifier);
+
+ getRepositoryClient(ctx).synchronize(ctx, specifier, handler);
+ result = ctx.getOutput();
+
} catch (Exception e) {
throw bigReThrow(e, ServiceMessages.SYNC_FAILED, csid);
}
- if (result == false) {
+ 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();
import java.util.Map;
+import javax.ws.rs.core.Response;
+
+import org.collectionspace.services.client.AuthorityClient;
+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.api.RefName;
import org.collectionspace.services.common.api.RefName.Authority;
+import org.collectionspace.services.common.api.RefNameUtils;
+import org.collectionspace.services.common.api.RefNameUtils.AuthorityInfo;
import org.collectionspace.services.common.api.Tools;
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.vocabulary.AuthorityItemJAXBSchema;
import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
-import org.collectionspace.services.common.vocabulary.AuthorityResource.Specifier;
-import org.collectionspace.services.common.vocabulary.AuthorityResource.SpecifierForm;
-import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
import org.collectionspace.services.config.service.ObjectPartType;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter;
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.util.NuxeoUtils;
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
this.authorityItemCommonSchemaName = authorityItemCommonSchemaName;
}
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<String> getEntityResponseType() {
+ return String.class;
+ }
- public boolean synchronize(Specifier specifier) throws DocumentNotFoundException, DocumentException {
- boolean result = true;
+ protected PayloadInputPart extractPart(Response res, String partLabel)
+ throws Exception {
+ PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(getEntityResponseType()));
+ PayloadInputPart payloadInputPart = input.getPart(partLabel);
+ Assert.assertNotNull(payloadInputPart,
+ "Part " + partLabel + " was unexpectedly null.");
+ return payloadInputPart;
+ }
+
+ @Override
+ public void handleSync(DocumentWrapper<Specifier> wrapDoc) throws Exception {
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = this.getServiceContext();
- if (specifier.form == SpecifierForm.CSID) {
- if (logger.isDebugEnabled()) {
- logger.debug("Synchronize Authority with csid=" + specifier.value);
- }
- getRepositoryClient(ctx).get(getServiceContext(), specifier.value, this);
- } else {
- String whereClause = RefNameServiceUtils.buildWhereForAuthByName(authorityCommonSchemaName, specifier.value);
- DocumentFilter myFilter = new NuxeoDocumentFilter(whereClause, 0, 1);
- this.setDocumentFilter(myFilter);
- getRepositoryClient(ctx).get(ctx, this);
- }
+ 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);
+ //
+ // 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);
- PoxPayloadOut output = ctx.getOutput();
+ AuthorityClient client = ctx.getAuthorityClient();
+ Response res = client.read(sasSpecifier.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);
+ }
+
+ PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());
+ if (payloadInputPart != null) {
+ result = (CPT) payloadInputPart.getBody();
+ }
+ } finally {
+ res.close();
+ }
- return result;
+ }
+
+ private Long getRevFromSASInstance(Specifier specifier) {
+ Long result = null;
+
+ VocabularyClient client = new VocabularyClient();
+ String uri = getUri(specifier);
+
+ return result;
}
/*
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.batch.BatchCommon;
+
/**
* BatchClient.java
*
* $LastChangedDate: 2010-05-17 18:25:37 -0700 (Mon, 17 May 2010) $
*
*/
-public class BatchClient extends AbstractCommonListPoxServiceClientImpl<BatchProxy> {
+public class BatchClient extends AbstractCommonListPoxServiceClientImpl<BatchProxy, BatchCommon> {
public static final String SERVICE_NAME = "batch";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
*
* @param <P>
*/
-public abstract class AbstractCommonListPoxServiceClientImpl<P extends CollectionSpaceCommonListPoxProxy>
- extends AbstractPoxServiceClientImpl<AbstractCommonList, P> {
+public abstract class AbstractCommonListPoxServiceClientImpl<P extends CollectionSpaceCommonListPoxProxy, CPT>
+ extends AbstractPoxServiceClientImpl<AbstractCommonList, P, CPT> {
//
// All clients returning AbstractCommonList types should extend this class.
//
package org.collectionspace.services.client;
import javax.ws.rs.core.Response;
-import org.jboss.resteasy.client.ClientResponse;
+import org.jboss.resteasy.client.ClientResponse;
+import org.testng.Assert;
import org.collectionspace.services.jaxb.AbstractCommonList;
/*
* CLT = List type
* P = Proxy type
*/
-public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonList, P extends CollectionSpacePoxProxy<CLT>>
+public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonList, P extends CollectionSpacePoxProxy<CLT>, CPT>
extends AbstractServiceClientImpl<CLT, PoxPayloadOut, String, P>
implements CollectionSpacePoxClient<CLT, P> {
CollectionSpacePoxProxy<CLT> proxy = getProxy();
return proxy.advancedSearchIncludeDeleted(whereClause, includeDeleted.toString());
}
-
+
+ //
+ // REM - Attemp to move methods from test framework into Java client framework
+ //
+
+ public CPT extractCommonPartValue(Response res) throws Exception {
+ CPT result = null;
+
+ PayloadInputPart payloadInputPart = extractPart(res, this.getCommonPartName());
+ if (payloadInputPart != null) {
+ result = (CPT) payloadInputPart.getBody();
+ }
+
+ return result;
+ }
+
+ protected void printList(String testName, CLT list) {
+ if (getLogger().isDebugEnabled()){
+ AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
+ }
+ }
+
+ protected long getSizeOfList(CLT list) {
+ return list.getTotalItems();
+ }
+
+ /**
+ * The entity type expected from the JAX-RS Response object
+ */
+ public Class<String> getEntityResponseType() {
+ return String.class;
+ }
+
+ public CPT extractCommonPartValue(PoxPayloadOut payloadOut) throws Exception {
+ CPT result = null;
+
+ PayloadOutputPart payloadOutputPart = payloadOut.getPart(this.getCommonPartName());
+ if (payloadOutputPart != null) {
+ result = (CPT) payloadOutputPart.getBody();
+ }
+
+ return result;
+ }
+
+ public PoxPayloadOut createRequestTypeInstance(CPT commonPartTypeInstance) {
+ PoxPayloadOut result = null;
+
+ PoxPayloadOut payloadOut = new PoxPayloadOut(this.getServicePathComponent());
+ PayloadOutputPart part = payloadOut.addPart(this.getCommonPartName(), commonPartTypeInstance);
+ result = payloadOut;
+
+ return result;
+ }
+
+ protected PayloadInputPart extractPart(Response res, String partLabel)
+ throws Exception {
+ if (getLogger().isDebugEnabled()) {
+ getLogger().debug("Reading part " + partLabel + " ...");
+ }
+ PoxPayloadIn input = new PoxPayloadIn((String)res.readEntity(getEntityResponseType()));
+ PayloadInputPart payloadInputPart = input.getPart(partLabel);
+ Assert.assertNotNull(payloadInputPart,
+ "Part " + partLabel + " was unexpectedly null.");
+ return payloadInputPart;
+ }
}
* Instantiates a new abstract service client impl.
*/
protected AbstractServiceClientImpl() {
- readProperties();
+ readClientProperties();
setupHttpClient();
setupHttpClient4(); // temp fix for CSPACE-6281
ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance();
*
* @exception RuntimeException
*/
- private void readProperties() {
+ protected void readClientProperties() {
ClassLoader cl = Thread.currentThread().getContextClassLoader();
InputStream is = null;
* P - Proxy type
*/
public abstract class AuthorityClientImpl<AUTHORITY_ITEM_TYPE, P extends AuthorityProxy>
- extends AbstractPoxServiceClientImpl<AbstractCommonList, P>
+ extends AbstractPoxServiceClientImpl<AbstractCommonList, P, AUTHORITY_ITEM_TYPE>
implements AuthorityClient<AUTHORITY_ITEM_TYPE, P> {
private static final String INCLUDE_DELETE_TRUE = Boolean.TRUE.toString();
+
+ @Override
+ protected void readClientProperties() {
+ super.readClientProperties();
+ //
+ // Override with Shared Authority Server properties from tenant bindings
+ //
+ }
+
/*
* Basic CRUD proxied methods
*/
--- /dev/null
+package org.collectionspace.services.client;
+
+public class GenericAuthorityClientImpl extends
+ AuthorityClientImpl<Object, AuthorityProxy> {
+
+ @Override
+ public String getItemCommonPartName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getInAuthority(Object item) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public void setInAuthority(Object item, String inAuthorityCsid) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ public Class<AuthorityProxy> getProxyClass() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServiceName() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public String getServicePathComponent() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+}
import javax.ws.rs.core.Response;
import org.collectionspace.services.client.AbstractCommonListPoxServiceClientImpl;
+import org.collectionspace.services.index.IndexesCommon;
/**
* IndexClient.java
* $LastChangedDate: 2010-05-17 18:25:37 -0700 (Mon, 17 May 2010) $
*
*/
-public class IndexClient extends AbstractCommonListPoxServiceClientImpl<IndexProxy> {
+public class IndexClient extends AbstractCommonListPoxServiceClientImpl<IndexProxy, IndexesCommon> {
public static final String SERVICE_NAME = "index";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
}
protected void printList(String testName, CLT list) {
- if (getLogger().isTraceEnabled()){
+ if (getLogger().isDebugEnabled()){
AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
}
}
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.workflow.WorkflowCommon;
+import org.collectionspace.services.client.AbstractCommonListUtils;
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.CollectionSpacePoxClient;
protected void printList(String testName, CLT list) {
// By default, do nothing. Tests can override this method to produce additional
// output after the "readList" test has run.
+ AbstractCommonListUtils.ListItemsInAbstractCommonList((AbstractCommonList)list, logger, testName);
}
@Override
// Optionally output additional data about list members for debugging.
boolean iterateThroughList = true;
- if (iterateThroughList && logger.isDebugEnabled()) {
+ if (iterateThroughList && logger.isTraceEnabled()) {
printList(testName, list);
}
}
import javax.ws.rs.core.Response;
+import org.collectionspace.services.collectionobject.CollectionobjectsCommon;
+
// FIXME: http://issues.collectionspace.org/browse/CSPACE-1684
/**
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class CollectionObjectClient extends AbstractCommonListPoxServiceClientImpl<CollectionObjectProxy> {
+public class CollectionObjectClient extends AbstractCommonListPoxServiceClientImpl<CollectionObjectProxy, CollectionobjectsCommon> {
public static final String SERVICE_NAME = "collectionobjects";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
import javax.ws.rs.core.UriInfo;
import org.collectionspace.authentication.spi.AuthNContext;
+import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.IClientQueryParams;
import org.collectionspace.services.client.IQueryManager;
import org.collectionspace.services.client.workflow.WorkflowClient;
private String overrideDocumentType = null;
/** The val handlers. */
private List<ValidatorHandler<IT, OT>> valHandlers = null;
+ /** The authority client -use for shared authority server */
+ private AuthorityClient authorityClient = null;
/** The doc handler. */
private DocumentHandler docHandler = null;
/** security context */
return valHandlers;
}
+ @Override
+ public AuthorityClient getAuthorityClient() throws Exception {
+ AuthorityClient result = authorityClient;
+
+ if (authorityClient == null) {
+ String authorityClientClazz = getServiceBinding().getClientHandler();
+ ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+ authorityClientClazz = authorityClientClazz.trim();
+ try {
+ Class<?> c = tccl.loadClass(authorityClientClazz);
+ if (AuthorityClient.class.isAssignableFrom(c)) {
+ result = authorityClient = ((AuthorityClient) c.newInstance());
+ } else {
+ logger.error(String.format("The service binding clientHandler class '%s' for '%s' service was not of type AuthorityClient.",
+ authorityClientClazz, this.getServiceName()));
+ }
+ } catch (ClassNotFoundException e) {
+ String msg = String.format("Missing document validation handler: '%s'.", authorityClientClazz);
+ logger.warn(msg);
+ logger.trace(msg, e);
+ }
+ }
+
+ return result;
+ }
+
@Override
public void addValidatorHandler(ValidatorHandler<IT, OT> validator) throws Exception {
if (valHandlers == null) {
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.UriInfo;
+import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.common.document.DocumentHandler;
import org.collectionspace.services.common.document.ValidatorHandler;
public RepositoryDomainType getRepositoryDomain();
public void setRepositoryDomain(RepositoryDomainType repositoryDomain);
+
+ public AuthorityClient getAuthorityClient() throws Exception;
}
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.query.QueryContext;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
case DELETE:
validate(action);
prepareDelete();
+ break;
+
+ case SYNC:
+ prepareSync();
break;
case WORKFLOW:
public void prepareDelete() throws Exception {
}
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.document.DocumentHandler#prepareDelete()
+ */
+ @Override
+ public void prepareSync() throws Exception {
+ // Do nothing. Subclasses can override if they want/need to.
+ }
+
/* (non-Javadoc)
* @see org.collectionspace.services.common.document.DocumentHandler#handle(org.collectionspace.services.common.document.DocumentHandler.Action, org.collectionspace.services.common.document.DocumentWrapper)
*/
handleDelete((DocumentWrapper<WT>) wrapDoc);
break;
+ case SYNC:
+ handleSync((DocumentWrapper<Specifier>) wrapDoc);
+ break;
+
case WORKFLOW:
logger.error("Should never get to this code path. If you did, there is a bug in the code.");
Thread.dumpStack();
*/
@Override
public void handleDelete(DocumentWrapper<WT> wrapDoc) throws Exception {
-
+ // Do nothing. Subclasses can override if they want/need to.
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.document.DocumentHandler#handleDelete(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void handleSync(DocumentWrapper<Specifier> wrapDoc) throws Exception {
+ // Do nothing. Subclasses can override if they want/need to.
+ }
+
/* (non-Javadoc)
* @see org.collectionspace.services.common.document.DocumentHandler#complete(org.collectionspace.services.common.document.DocumentHandler.Action, org.collectionspace.services.common.document.DocumentWrapper)
case DELETE:
completeDelete((DocumentWrapper<WT>) wrapDoc);
+ break;
+
+ case SYNC:
+ completeSync((DocumentWrapper<Specifier>) wrapDoc);
break;
case WORKFLOW:
@Override
public void completeDelete(DocumentWrapper<WT> wrapDoc) throws Exception {
}
+
+ /* (non-Javadoc)
+ * @see org.collectionspace.services.common.document.DocumentHandler#completeDelete(org.collectionspace.services.common.document.DocumentWrapper)
+ */
+ @Override
+ public void completeSync(DocumentWrapper<Specifier> wrapDoc) throws Exception {
+ }
/* (non-Javadoc)
* @see org.collectionspace.services.common.document.DocumentHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.query.QueryContext;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
import org.collectionspace.services.lifecycle.Lifecycle;
import org.collectionspace.services.lifecycle.TransitionDef;
import org.nuxeo.ecm.core.api.DocumentModel;
public interface DocumentHandler<T, TL, WT, WTL> {
public enum Action {
- CREATE, GET, GET_ALL, UPDATE, DELETE, WORKFLOW
+ CREATE, GET, GET_ALL, UPDATE, DELETE, WORKFLOW, SYNC
}
public Lifecycle getLifecycle();
*/
public Map<String,String> getJDBCQueryParams();
+ /**
+ *
+ * @throws Exception
+ */
+ void prepareSync() throws Exception;
+
+ /**
+ *
+ * @param wrapDoc
+ * @throws Exception
+ */
+ void handleSync(DocumentWrapper<Specifier> wrapDoc) throws Exception;
+
+ /**
+ *
+ * @param wrapDoc
+ * @throws Exception
+ */
+ void completeSync(DocumentWrapper<Specifier> wrapDoc) throws Exception;
+
}
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.Specifier;
import org.collectionspace.services.lifecycle.TransitionDef;
/**
void doWorkflowTransition(ServiceContext ctx, String id, DocumentHandler handler, TransitionDef transitionDef)
throws BadRequestException, DocumentNotFoundException, DocumentException;
+ /*
+ * Ask a resource to synchronize itself with a shared server resource
+ */
+ void synchronize(ServiceContext ctx, Specifier specifier, DocumentHandler handler)
+ throws DocumentNotFoundException, TransactionException,
+ DocumentException;
+
}
import org.collectionspace.services.common.document.DocumentWrapper;
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.Specifier;
import org.collectionspace.services.common.context.ServiceContextProperties;
import org.collectionspace.services.common.context.ServiceContext;
import org.collectionspace.services.common.query.QueryContext;
DocumentException {
throw new UnsupportedOperationException();
}
+
+ @Override
+ public void synchronize(ServiceContext ctx, Specifier specifier,
+ DocumentHandler handler) throws DocumentNotFoundException,
+ TransactionException, DocumentException {
+ // TODO Auto-generated method stub
+ // Do nothing. Subclasses can override if they want/need to.
+ }
}
import org.nuxeo.ecm.core.api.model.PropertyException;
import org.nuxeo.ecm.core.api.model.PropertyNotFoundException;
import org.nuxeo.ecm.core.api.model.impl.primitives.StringProperty;
-import org.nuxeo.ecm.core.api.CoreSession;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.IQueryManager;
import org.collectionspace.services.client.IRelationsManager;
*/
public class RefNameServiceUtils {
+ public static enum SpecifierForm {
+ CSID, URN_NAME
+ };
+
+ public static class Specifier {
+ public SpecifierForm form;
+ public String value;
+
+ public Specifier(SpecifierForm form, String value) {
+ this.form = form;
+ this.value = value;
+ }
+ }
+
public static class AuthRefConfigInfo {
public String getQualifiedDisplayName() {
import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.common.repository.RepositoryClientFactory;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.AuthRefConfigInfo;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
import org.collectionspace.services.lifecycle.Lifecycle;
import org.collectionspace.services.lifecycle.State;
import org.collectionspace.services.lifecycle.StateList;
public String getUri(DocumentModel docModel) {
return getServiceContextPath()+getCsid(docModel);
}
+
+ public String getUri(Specifier specifier) {
+ return getServiceContextPath() + specifier.value;
+ }
+
public RepositoryClient<PoxPayloadIn, PoxPayloadOut> getRepositoryClient(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
RepositoryClient<PoxPayloadIn, PoxPayloadOut> repositoryClient =
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.Specifier;
import org.collectionspace.services.config.tenant.TenantBindingType;
import org.collectionspace.services.config.tenant.RepositoryDomainType;
return result;
}
+ @Override
+ public void synchronize(ServiceContext ctx, Specifier specifier, DocumentHandler handler)
+ throws DocumentNotFoundException, TransactionException, DocumentException {
+
+ if (handler == null) {
+ throw new IllegalArgumentException(
+ "RepositoryJavaClient.get: handler is missing");
+ }
+
+ CoreSessionInterface repoSession = null;
+ try {
+ handler.prepare(Action.SYNC);
+ repoSession = getRepositorySession(ctx);
+ ((DocumentModelHandler) handler).setRepositorySession(repoSession);
+ DocumentWrapper<Specifier> wrapDoc = new DocumentWrapperImpl<Specifier>(specifier);
+ 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);
+ }
+ }
+ }
+
/**
* get document from the Nuxeo repository
*
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentUtils;
import org.collectionspace.services.common.query.QueryContext;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.Specifier;
+import org.collectionspace.services.common.vocabulary.RefNameServiceUtils.SpecifierForm;
import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentException;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
+import org.collectionspace.services.nuxeo.client.java.NuxeoDocumentFilter;
import org.dom4j.Document;
import org.dom4j.io.SAXReader;
import org.mortbay.log.Log;
}
return result;
- }
+ }
+
+ static public DocumentModel getDocFromSpecifier(
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
+ CoreSessionInterface repoSession,
+ String schemaName,
+ Specifier specifier) throws Exception {
+ DocumentModel result = null;
+
+ if (specifier.form == SpecifierForm.CSID) {
+ result = getDocFromCsid(ctx, repoSession, specifier.value);
+ } else {
+ String whereClause = RefNameServiceUtils.buildWhereForAuthByName(schemaName, specifier.value);
+ QueryContext queryContext = new QueryContext(ctx, whereClause);
+ //
+ // Set of query context using the current service context, but change the document type
+ // to be the base Nuxeo document type so we can look for the document across service workspaces
+ //
+ queryContext.setDocType(NuxeoUtils.BASE_DOCUMENT_TYPE);
+
+ DocumentModelList docModelList = null;
+ //
+ // Since we're doing a query, we get back a list so we need to make sure there is only
+ // a single result since CSID values are supposed to be unique.
+ String query = buildNXQLQuery(ctx, queryContext);
+ docModelList = repoSession.query(query);
+ long resultSize = docModelList.totalSize();
+ if (resultSize == 1) {
+ result = docModelList.get(0);
+ } else if (resultSize > 1) {
+ throw new DocumentException("Found more than 1 document with CSID = " + specifier.value);
+ }
+ }
+
+ return result;
+ }
/*
public static void printDocumentModel(DocumentModel docModel) throws Exception {
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.conditioncheck.ConditionchecksCommon;
+
/**
* ConditioncheckClient.java
*/
-public class ConditioncheckClient extends AbstractCommonListPoxServiceClientImpl<ConditioncheckProxy> {
+public class ConditioncheckClient extends AbstractCommonListPoxServiceClientImpl<ConditioncheckProxy, ConditionchecksCommon> {
public static final String SERVICE_NAME = "conditionchecks";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
<!-- validator handler(s) to be used to validate the content (need to be in classpath) -->
<!-- validator handler is called for create (POST) and update (PUT) requests only -->
<xs:element name="validatorHandler" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
+ <xs:element name="clientHandler" type="xs:string" minOccurs="0" maxOccurs="1"/>
<xs:element name="disableAsserts" type="xs:boolean" minOccurs="0" maxOccurs="1"/>
<!-- initHandler is a post-init task after the Nuxeo repository is available. -->
<!-- worked: <xs:element name="initHandler" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>-->
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.conservation.ConservationCommon;
+
/**
* ConservationClient.java
*
* $LastChangedDate$
*
*/
-public class ConservationClient extends AbstractCommonListPoxServiceClientImpl<ConservationProxy> {
+public class ConservationClient extends AbstractCommonListPoxServiceClientImpl<ConservationProxy, ConservationCommon> {
public static final String SERVICE_NAME = "conservation";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.contact.ContactsCommon;
+
/**
* ContactClient.java
*
* $LastChangedDate: $
*
*/
-public class ContactClient extends AbstractCommonListPoxServiceClientImpl<ContactProxy> {
+public class ContactClient extends AbstractCommonListPoxServiceClientImpl<ContactProxy, ContactsCommon> {
public static final String SERVICE_NAME = "contacts";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.dimension.DimensionsCommon;
+
/**
* A DimensionClient.
* @version $Revision:$
*/
-public class DimensionClient extends AbstractCommonListPoxServiceClientImpl<DimensionProxy> {
+public class DimensionClient extends AbstractCommonListPoxServiceClientImpl<DimensionProxy, DimensionsCommon> {
public static final String SERVICE_NAME = "dimensions";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT;
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.exhibition.ExhibitionsCommon;
+
/**
* ExhibitionClient.java
*/
-public class ExhibitionClient extends AbstractCommonListPoxServiceClientImpl<ExhibitionProxy> {
+public class ExhibitionClient extends AbstractCommonListPoxServiceClientImpl<ExhibitionProxy, ExhibitionsCommon> {
public static final String SERVICE_NAME = "exhibitions";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.group.GroupsCommon;
+
/**
* GroupClient.java
*
* $LastChangedDate: 2010-05-17 18:25:37 -0700 (Mon, 17 May 2010) $
*
*/
-public class GroupClient extends AbstractCommonListPoxServiceClientImpl<GroupProxy> {
+public class GroupClient extends AbstractCommonListPoxServiceClientImpl<GroupProxy, GroupsCommon> {
public static final String SERVICE_NAME = "groups";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
</dependency>
<dependency>
<groupId>org.collectionspace.services</groupId>
- <artifactId>org.collectionspace.services.dimension.client</artifactId> <!-- Dimension instances are used as a unit-tests targets -->
+ <artifactId>org.collectionspace.services.index.jaxb</artifactId>
<version>${project.version}</version>
</dependency>
<!-- External dependencies -->
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent>
- <artifactId>org.collectionspace.services.index</artifactId>
<groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.index</artifactId>
<version>4.4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.index.jaxb</artifactId>
<name>services.index.jaxb</name>
--- /dev/null
+/**
+ *
+ */
+package org.collectionspace.services.index;
+
+public interface IndexJAXBSchema {
+}
+
+
--- /dev/null
+package org.collectionspace.services.index;
+
+public interface IndexListItemJAXBSchema {
+}
Part : Common
Used for: JAXB binding between XML and Java objects
- $LastChangedRevision: 2316 $
- $LastChangedDate: 2010-06-02 16:03:51 -0700 (Wed, 02 Jun 2010) $
+ $LastChangedRevision: 860 $
+ $LastChangedDate: 2009-10-14 14:48:05 -0700 (Wed, 14 Oct 2009) $
-->
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
- xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
- jaxb:version="1.0" elementFormDefault="unqualified"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" jaxb:version="2.0"
+ elementFormDefault="unqualified"
xmlns:ns="http://collectionspace.org/services/index"
xmlns="http://collectionspace.org/services/index"
targetNamespace="http://collectionspace.org/services/index"
version="0.1">
+
<!--
Avoid XmlRootElement nightmare:
See http://weblogs.java.net/blog/kohsuke/archive/2006/03/why_does_jaxb_p.html
--->
- <!-- index -->
- <xs:element name="index_common">
+-->
+<!-- See http://wiki.collectionspace.org/display/collectionspace/Index+Schema -->
+
+ <!-- index -->
+ <xs:element name="indexes_common">
<xs:complexType>
<xs:sequence>
- <!-- Index Information Group -->
- <xs:element name="indexPolicy" type="xs:string"/>
+ <xs:element name="csid" type="xs:string" />
</xs:sequence>
</xs:complexType>
- </xs:element>
-
+ </xs:element>
</xs:schema>
<packaging>pom</packaging>
<modules>
+ <module>jaxb</module>
<module>3rdparty</module>
<module>client</module>
<module>service</module>
*/
package org.collectionspace.services.client;
+import org.collectionspace.services.intake.IntakesCommon;
+
/**
* IntakeClient
*
* $LastChangedRevision: $
* $LastChangedDate: $
*/
-public class IntakeClient extends AbstractCommonListPoxServiceClientImpl<IntakeProxy> {
+public class IntakeClient extends AbstractCommonListPoxServiceClientImpl<IntakeProxy, IntakesCommon> {
public static final String SERVICE_NAME = "intakes";
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
import javax.ws.rs.core.Response;
+import org.collectionspace.services.relation.RelationsCommon;
import org.collectionspace.services.relation.RelationsCommonList;
/**
* The Class RelationClient.
*/
-public class RelationClient extends AbstractPoxServiceClientImpl<RelationsCommonList, RelationProxy> {
+public class RelationClient extends AbstractPoxServiceClientImpl<RelationsCommonList, RelationProxy, RelationsCommon> {
public static final String SERVICE_DOC_TYPE = IRelationsManager.DOC_TYPE; // Used for CMIS queries only -should be the same as what's in the tenant bindings
public static final String SERVICE_NAME = IRelationsManager.SERVICE_NAME;
public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME;
public interface VocabularyItemJAXBSchema {
final static String DISPLAY_NAME = "displayName";
final static String TERM_STATUS = "termStatus";
+ final static String REV = "rev";
}
\ No newline at end of file
--- /dev/null
+package org.collectionspace.services.vocabulary;
+
+public class VocabularyJAXBSchema {
+ final static String REV = "rev";
+}