final Log logger = LogFactory.getLog(CreateVersionListener.class);
+ @Override
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
if (ec.hasProperty(SKIP_PROPERTY) && ((Boolean) ec.getProperty(SKIP_PROPERTY))) {
/*
* Delete dead locations.
*/
- public void handleEvent(Event event) {
+ @Override
+ public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
private static final String TAXONOMIC_IDENT_GROUP_LIST_FIELD_NAME = TAXON_PATH_ELEMENTS[0];
private static final String TAXON_FIELD_NAME = TAXON_PATH_ELEMENTS[2];
+ @Override
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
/*
* Set the dead flag and dead date on collectionobjects related to a new or modified movement record.
*/
+ @Override
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
* <li>Set the previousLocation field to the previous value of the currentLocation field</li>
* </ui>
*/
+ @Override
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.collectionspace.services.batch.nuxeo.UpdateRareFlagBatchJob;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectBotGardenConstants;
import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
private static final String PLANT_ATTRIBUTES_GROUP_LIST_FIELD_NAME = CONSERVATION_CATEGORY_PATH_ELEMENTS[0];
private static final String CONSERVATION_CATEGORY_FIELD_NAME = CONSERVATION_CATEGORY_PATH_ELEMENTS[2];
+ @Override
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
}
private UpdateRareFlagBatchJob createUpdater() {
- ResourceMap<PoxPayloadIn, PoxPayloadOut> resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class);
+ ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class);
UpdateRareFlagBatchJob updater = new UpdateRareFlagBatchJob();
updater.setResourceMap(resourceMap);
import org.jboss.resteasy.spi.ResteasyProviderFactory;
import org.collectionspace.services.batch.nuxeo.FormatVoucherNameBatchJob;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.loanout.nuxeo.LoanoutBotGardenConstants;
final Log logger = LogFactory.getLog(UpdateStyledNameListener.class);
+ @Override
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
}
private FormatVoucherNameBatchJob createFormatter() {
- ResourceMap<PoxPayloadIn, PoxPayloadOut> resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class);
+ ResourceMap resourceMap = ResteasyProviderFactory.getContextData(ResourceMap.class);
FormatVoucherNameBatchJob formatter = new FormatVoucherNameBatchJob();
formatter.setResourceMap(resourceMap);
-package org.collectionspace.services.listener.ucb;
+package org.collectionspace.services.listener.naturalhistory;
import java.util.HashMap;
import java.util.List;
public void handleEvent(Event event) {
EventContext ec = event.getContext();
- if (ec instanceof DocumentEventContext) {
+ if (isRegistered(event) && ec instanceof DocumentEventContext) {
DocumentEventContext context = (DocumentEventContext) ec;
DocumentModel doc = context.getSourceDocument();
EventContext eventContext = event.getContext();
if (eventContext != null) {
- if (eventContext instanceof DocumentEventContext) {
+ if (isRegistered(event) && eventContext instanceof DocumentEventContext) {
result = true;
}
}
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
import org.collectionspace.services.client.LocationAuthorityClient;
import org.collectionspace.services.client.workflow.WorkflowClient;
import org.collectionspace.services.collectionobject.nuxeo.CollectionObjectConstants;
import org.collectionspace.services.nuxeo.client.java.CoreSessionWrapper;
import org.collectionspace.services.nuxeo.listener.AbstractCSEventListenerImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
-import org.nuxeo.common.collections.ScopeType;
-import org.nuxeo.common.collections.ScopedMap;
-import org.nuxeo.ecm.core.api.ClientException;
+
import org.nuxeo.ecm.core.api.DocumentModel;
import org.nuxeo.ecm.core.api.DocumentModelList;
import org.nuxeo.ecm.core.api.event.DocumentEventTypes;
}
@Override
- public void handleEvent(Event event) throws ClientException {
+ public void handleEvent(Event event) {
// Ensure we have all the event data we need to proceed.
if (isRegistered(event) == false || !(event.getContext() instanceof DocumentEventContext)) {
if (logger.isTraceEnabled() == true) {
return;
}
- Map<String, String> params = this.getParams(event);
+ Map<String, String> params = this.getParams(event); // Will be null if no params were configured.
logEvent(event, "Update Location");
DocumentEventContext docEventContext = (DocumentEventContext) event.getContext();
* related to the Movement record.
*/
private Set<String> getCollectionObjectCsidsRelatedToMovement(String movementCsid,
- CoreSessionInterface coreSession) throws ClientException {
+ CoreSessionInterface coreSession) {
Set<String> csids = new HashSet<>();
boolean isActiveDocument = false;
if (docModel != null) {
- try {
- if (!docModel.getCurrentLifeCycleState().contains(WorkflowClient.WORKFLOWSTATE_DELETED)) {
- isActiveDocument = true;
- }
- } catch (ClientException ce) {
- logger.warn("Error while identifying whether document is an active document: ", ce);
- }
+ if (!docModel.getCurrentLifeCycleState().contains(WorkflowClient.WORKFLOWSTATE_DELETED)) {
+ isActiveDocument = true;
+ }
//
// If doc model is the target of the "aboutToBeRemoved" event, mark it as not active.
//
*/
protected String getMostRecentLocation(Event event,
CoreSessionInterface session, String collectionObjectCsid,
- boolean isAboutToBeRemovedEvent, String eventMovementCsid)
- throws ClientException {
+ boolean isAboutToBeRemovedEvent, String eventMovementCsid) {
//
// Assume we can determine the most recent location by creating an indeterminate result
//
* and related document types.
*/
protected static String getCsidForDesiredDocTypeFromRelation(DocumentModel relationDocModel,
- String desiredDocType, String relatedDocType) throws ClientException {
+ String desiredDocType, String relatedDocType) {
String csid = null;
String subjectDocType = (String) relationDocModel.getProperty(RELATIONS_COMMON_SCHEMA, SUBJECT_DOCTYPE_PROPERTY);
String objectDocType = (String) relationDocModel.getProperty(RELATIONS_COMMON_SCHEMA, OBJECT_DOCTYPE_PROPERTY);
*/
protected abstract boolean updateCollectionObjectLocation(DocumentModel collectionObjectDocModel,
DocumentModel movmentDocModel,
- String movementRecordsLocation)
- throws ClientException;
+ String movementRecordsLocation);
}
\ No newline at end of file
import org.nuxeo.ecm.core.api.impl.LifeCycleFilter;
import org.nuxeo.ecm.core.event.Event;
import org.nuxeo.ecm.core.event.EventContext;
-import org.nuxeo.ecm.core.event.EventListener;
import org.nuxeo.ecm.core.event.impl.DocumentEventContext;
public class UpdateRelationsOnDelete extends AbstractCSEventListenerImpl {
EventContext eventContext = event.getContext();
- if (isDocumentSoftDeletedEvent(eventContext)) {
+ if (isRegistered(event) && isDocumentSoftDeletedEvent(eventContext)) {
logger.trace("A soft deletion event was received by UpdateRelationsOnDelete ...");
import org.collectionspace.services.account.AccountResource;
import org.collectionspace.services.account.TenantResource;
import org.collectionspace.services.blob.BlobResource;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.collectionobject.CollectionObjectResource;
import org.collectionspace.services.id.IDResource;
import org.collectionspace.services.media.MediaResource;
}
@Override
- public ResourceMap<PoxPayloadIn, PoxPayloadOut> getResourceMap() {
+ public ResourceMap getResourceMap() {
return resourceMap;
}
}
}
- //
- // Tests with expected failure outcomes
- //
- // Placeholders until the three tests below can be uncommented.
- // See Issue CSPACE-401.
- @Override
- public void createWithEmptyEntityBody(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithMalformedXml(java.lang.String)
- */
- @Override
- public void createWithMalformedXml(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithWrongXmlSchema(java.lang.String)
- */
- @Override
- public void createWithWrongXmlSchema(String testName) throws Exception {
- //FIXME: Should this test really be empty? If so, please comment accordingly.
- }
-
// ---------------------------------------------------------------
// CRUD tests : READ_LIST tests
// ---------------------------------------------------------------
return tempResult.CSID;
}
- protected String lookupParentCSID(ServiceContext ctx, String parentspecifier, String method,
+ protected String lookupParentCSID(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String parentspecifier, String method,
String op, UriInfo uriInfo) throws Exception {
CsidAndShortIdentifier tempResult = lookupParentCSIDAndShortIdentifer(ctx,
parentspecifier, method, op, uriInfo);
private CsidAndShortIdentifier lookupParentCSIDAndShortIdentifer(
- ServiceContext existingCtx, // Ok to be null
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx, // Ok to be null
String parentIdentifier,
String method,
String op,
* @return
* @throws Exception
*/
- protected Response createAuthorityItem(ServiceContext ctx, String parentIdentifier,
+ protected Response createAuthorityItem(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String parentIdentifier,
boolean shouldUpdateRevNumber,
boolean isProposed,
boolean isSasItem) throws Exception {
* @return
* @throws Exception
*/
- public Response createAuthorityItemWithParentContext(ServiceContext parentCtx,
+ public Response createAuthorityItemWithParentContext(ServiceContext<PoxPayloadIn, PoxPayloadOut> parentCtx,
String parentIdentifier,
PoxPayloadIn input,
boolean shouldUpdateRevNumber,
PoxPayloadOut result = null;
try {
- ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
result = updateItemWorkflowWithTransition(ctx,
parentIdentifier, itemIdentifier, transition, AuthorityServiceUtils.UPDATE_REV);
} catch (Exception e) {
* @return
* @throws DocumentReferenceException
*/
- public PoxPayloadOut updateItemWorkflowWithTransition(ServiceContext existingContext,
+ public PoxPayloadOut updateItemWorkflowWithTransition(ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
String parentIdentifier,
String itemIdentifier,
String transition,
}
private PoxPayloadOut getAuthorityItem(
- ServiceContext ctx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String parentIdentifier,
String itemIdentifier) throws Exception {
PoxPayloadOut result = null;
}
public PoxPayloadOut getAuthorityItemWithExistingContext(
- ServiceContext existingCtx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
String parentIdentifier,
String itemIdentifier) throws Exception {
PoxPayloadOut result = null;
- ServiceContext ctx = createServiceContext(getItemServiceName(), existingCtx.getResourceMap(), existingCtx.getUriInfo());
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), existingCtx.getResourceMap(), existingCtx.getUriInfo());
if (existingCtx.getCurrentRepositorySession() != null) {
ctx.setCurrentRepositorySession(existingCtx.getCurrentRepositorySession()); // Reuse the current repo session if one exists
ctx.setProperties(existingCtx.getProperties());
* @param ui passed to include additional parameters, like pagination controls
*
*/
- public AbstractCommonList getAuthorityItemList(ServiceContext existingContext,
+ public AbstractCommonList getAuthorityItemList(ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
String authorityIdentifier,
UriInfo uriInfo) throws Exception {
AbstractCommonList result = null;
}
public AuthorityRefDocList getReferencingObjects(
- ServiceContext existingContext,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingContext,
String parentspecifier,
String itemspecifier,
UriTemplateRegistry uriTemplateRegistry,
try {
// Note that we have to create the service context for the Items, not the main service
ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
- MultivaluedMap<String, String> queryParams = ctx.getQueryParams();
String parentcsid = lookupParentCSID(parentspecifier, "getAuthorityItemAuthRefs(parent)", "GET_ITEM_AUTH_REFS", uriInfo);
// We omit the parentShortId, only needed when doing a create...
DocumentModelHandler<?, AbstractCommonList> handler =
* @return
* @throws Exception
*/
- @SuppressWarnings("unchecked")
- private PoxPayloadOut synchronizeItem(
- ServiceContext ctx,
+ private PoxPayloadOut synchronizeItem(
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx,
String parentIdentifier,
String itemIdentifier,
boolean syncHierarchicalRelationships) throws Exception {
* @throws Exception
*/
public PoxPayloadOut synchronizeItemWithExistingContext(
- ServiceContext existingCtx,
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
String parentIdentifier,
String itemIdentifier,
boolean syncHierarchicalRelationships
}
public PoxPayloadOut updateAuthorityItem(
- ServiceContext itemServiceCtx, // Ok to be null. Will be null on PUT calls, but not on sync calls
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> itemServiceCtx, // Ok to be null. Will be null on PUT calls, but not on sync calls
ResourceMap resourceMap,
UriInfo uriInfo,
String parentspecifier,
}
try {
- ServiceContext ctx = createServiceContext(getItemServiceName(), uriInfo);
+ ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(getItemServiceName(), uriInfo);
deleteAuthorityItem(ctx, parentIdentifier, itemIdentifier, AuthorityServiceUtils.UPDATE_REV);
result = Response.status(HttpResponseCodes.SC_OK).build();
} catch (Exception e) {
* @throws Exception
*/
@SuppressWarnings("rawtypes")
- public boolean deleteAuthorityItem(ServiceContext existingCtx,
+ public boolean deleteAuthorityItem(ServiceContext<PoxPayloadIn, PoxPayloadOut> existingCtx,
String parentIdentifier,
String itemIdentifier,
boolean shouldUpdateRevNumber
/**
*
*/
- public ServiceDescription getDescription(ServiceContext ctx) {
+ @Override
+ public ServiceDescription getDescription(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
ServiceDescription result = super.getDescription(ctx);
result.setSubresourceDocumentType(this.getItemDocType(ctx.getTenantId()));
return result;
import org.collectionspace.services.authorization.perms.PermissionsList;
import org.collectionspace.services.client.PermissionFactory;
import org.collectionspace.services.client.test.AbstractServiceTestImpl;
+import org.collectionspace.services.client.test.ServiceRequestType;
import org.testng.Assert;
import org.testng.annotations.Test;
import org.slf4j.Logger;
/**
* The entity type expected from the JAX-RS Response object
*/
- public Class<Permission> getEntityResponseType() {
+ @Override
+ public Class<Permission> getEntityResponseType() {
return Permission.class;
}
return knownResource;
}
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupCreateWithEmptyEntityBody() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR; // Empty payload never gets past RESTEasy filter
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with malformed xml.
+ */
+ @Override
+ protected void setupCreateWithMalformedXml() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR; // Malformed payload never gets past RESTEasy filter
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with wrong xml schema.
+ */
+ @Override
+ protected void setupCreateWithWrongXmlSchema() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR; // Empty payload never gets past RESTEasy filter
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
/**
* Creates the without resource name.
*
// Do nothing. Simply here to for a TestNG execution order for our tests
}
- @Override
- public void updateWithEmptyEntityBody(String testName) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void updateWithMalformedXml(String testName) throws Exception {
- // TODO Auto-generated method stub
-
- }
-
- @Override
- public void updateWithWrongXmlSchema(String testName) throws Exception {
- // TODO Auto-generated method stub
-
- }
+// @Override
+// public void updateWithEmptyEntityBody(String testName) throws Exception {
+// // TODO Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void updateWithMalformedXml(String testName) throws Exception {
+// // TODO Auto-generated method stub
+//
+// }
+//
+// @Override
+// public void updateWithWrongXmlSchema(String testName) throws Exception {
+// // TODO Auto-generated method stub
+//
+// }
@Override
protected long getSizeOfList(PermissionsList list) {
--- /dev/null
+<jaxb:bindings version="1.0"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:annox="http://annox.dev.java.net"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <!--
+ <jaxb:bindings schemaLocation="permissions_roles.xsd" node="/xs:schema">
+ <jaxb:bindings node="xs:complexType[@name='permission_role']">
+ <annox:annotate>
+ <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="permission_role" />
+ </annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+ <jaxb:bindings schemaLocation="accounts_roles.xsd" node="/xs:schema">
+ <jaxb:bindings node="xs:complexType[@name='account_role']">
+ <annox:annotate>
+ <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="account_role" />
+ </annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+ <jaxb:bindings schemaLocation="accounts_permissions.xsd" node="/xs:schema">
+ <jaxb:bindings node="xs:complexType[@name='account_permission']">
+ <annox:annotate>
+ <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="account_permission" />
+ </annox:annotate>
+ </jaxb:bindings>
+ </jaxb:bindings>
+ -->
+</jaxb:bindings>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
-
-<!--
- CollectionSpace default (security) authorization provider schema (XSD)
-
- Entity(s) : role
- Used for:
-
- $LastChangedRevision: 916 $
- $LastChangedDate: 2009-11-05 16:59:20 -0800 (Thu, 05 Nov 2009) $
--->
-
<xs:schema
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
<xs:annotation>
<xs:appinfo>
<jaxb:globalBindings generateIsSetMethod="true" localScoping="toplevel">
- <jaxb:serializable/>
+ <jaxb:serializable uid="1966"/>
</jaxb:globalBindings>
</xs:appinfo>
</xs:annotation>
<xs:element name="forDocTypes">
<xs:complexType>
<xs:sequence>
- <xs:element name="forDocType" type="xs:string" minOccurs="1" maxOccurs="unbounded" />
+ <xs:element name="forDocType" type="xs:string" minOccurs="0" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="forRoles">
<xs:complexType>
<xs:sequence>
- <xs:element name="roleDisplayName" type="xs:string" minOccurs="1" maxOccurs="unbounded"/>
+ <xs:element name="roleDisplayName" type="xs:string" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:complexType name="resourceActionGroupList">
<xs:sequence>
- <xs:element name="resourceActionGroup" type="resourceActionGroup" minOccurs="3" maxOccurs="unbounded"/>
+ <xs:element name="resourceActionGroup" type="resourceActionGroup" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
</xs:complexType>
</target>
<target name="deploy" depends="install" description="deploy batch service">
- <!-- Now obsolete since the Nuxeo artifact is now created and deployed from config in the Application Layer -->
+ <!-- Now obsolete since the Nuxeo artifact is now created and deployed using config from the Application Layer -->
<!--
<ant antfile="3rdparty/build.xml" target="deploy" inheritall="false"/>
-->
</parent>
<modelVersion>4.0.0</modelVersion>
- <groupId>org.collectionspace.services</groupId>
<artifactId>org.collectionspace.services.batch</artifactId>
<name>services.batch</name>
<packaging>pom</packaging>
private ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx;
private List<String> invocationModes;
- private ResourceMap<PoxPayloadIn, PoxPayloadOut> resourceMap;
+ private ResourceMap resourceMap;
protected InvocationContext invocationCtx;
protected int completionStatus;
this.invocationModes = invocationModes;
}
- public ResourceMap<PoxPayloadIn, PoxPayloadOut> getResourceMap() {
+ public ResourceMap getResourceMap() {
return resourceMap;
}
@Override
- public void setResourceMap(ResourceMap<PoxPayloadIn, PoxPayloadOut> resourceMap) {
+ public void setResourceMap(ResourceMap resourceMap) {
this.resourceMap = resourceMap;
}
package org.collectionspace.services.batch;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.ResourceMap;
import org.collectionspace.services.common.invocable.Invocable;
import org.collectionspace.services.nuxeo.client.java.CoreSessionInterface;
* Sets the invocation context for the batch job. Called before run().
* @param context an instance of InvocationContext.
*/
- public void setResourceMap(ResourceMap<PoxPayloadIn, PoxPayloadOut> resourceMap);
+ public void setResourceMap(ResourceMap resourceMap);
public CoreSessionInterface getRepoSession();
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;
+
import org.collectionspace.services.batch.AbstractBatchInvocable;
import org.collectionspace.services.client.CollectionObjectClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.common.api.RefName;
import org.collectionspace.services.common.authorityref.AuthorityRefDocList;
import org.collectionspace.services.common.context.ServiceBindingUtils;
+import org.collectionspace.services.common.query.UriInfoImpl;
import org.collectionspace.services.common.relation.RelationResource;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.dom4j.Node;
import org.jboss.resteasy.specimpl.PathSegmentImpl;
-//import org.jboss.resteasy.specimpl.UriInfoImpl;
-import org.collectionspace.services.batch.UriInfoImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractBatchJob extends AbstractBatchInvocable {
- public final int CREATED_STATUS = Response.Status.CREATED.getStatusCode();
- public final int BAD_REQUEST_STATUS = Response.Status.BAD_REQUEST.getStatusCode();
- public final int INT_ERROR_STATUS = Response.Status.INTERNAL_SERVER_ERROR.getStatusCode();
final Logger logger = LoggerFactory.getLogger(AbstractBatchJob.class);
private Map<String, String> authorityServiceNamesByDocType;
-
- public abstract void run();
-
+
protected String getFieldXml(Map<String, String> fields, String fieldName) {
return getFieldXml(fieldName, fields.get(fieldName));
}
setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST, INVOCATION_MODE_NO_CONTEXT));
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST, INVOCATION_MODE_NO_CONTEXT));
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
this.setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE, INVOCATION_MODE_LIST, INVOCATION_MODE_NO_CONTEXT));
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE));
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
this.taxonFormatter = new TaxonFormatter();
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
this.taxonFormatter = new TaxonFormatter();
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
import org.collectionspace.services.common.relation.RelationResource;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
import org.collectionspace.services.relation.RelationsCommonList;
-import org.collectionspace.services.relation.RelationsCommonList.RelationListItem;
+
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.Node;
+
import org.nuxeo.common.utils.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.Set;
import org.apache.commons.lang.StringUtils;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.common.CollectionSpaceResource;
import org.collectionspace.services.common.NuxeoBasedResource;
import org.collectionspace.services.common.StoredValuesUriTemplate;
import org.collectionspace.services.common.vocabulary.AuthorityResource;
import org.collectionspace.services.nuxeo.util.ReindexFulltextRoot.ReindexInfo;
import org.nuxeo.ecm.core.api.AbstractSession;
-import org.nuxeo.ecm.core.api.ClientException;
import org.nuxeo.ecm.core.api.CoreSession;
import org.nuxeo.ecm.core.api.IterableQueryResult;
import org.nuxeo.ecm.core.api.NuxeoException;
private void initResourceMap() {
resourcesByDocType = new HashMap<String, NuxeoBasedResource>();
- for (CollectionSpaceResource<PoxPayloadIn, PoxPayloadOut> resource : getResourceMap().values()) {
+ for (CollectionSpaceResource<?, ?> resource : getResourceMap().values()) {
Map<UriTemplateRegistryKey, StoredValuesUriTemplate> entries = resource.getUriRegistryEntries();
for (UriTemplateRegistryKey key : entries.keySet()) {
this.setSupportedInvocationModes(Arrays.asList(INVOCATION_MODE_SINGLE));
}
+ @Override
public void run() {
setCompletionStatus(STATUS_MIN_PROGRESS);
import org.collectionspace.services.client.AuthorityClient;
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PayloadInputPart;
-import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadIn;
import org.collectionspace.services.client.PoxPayloadOut;
import org.collectionspace.services.client.RelationClient;
return result;
}
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupCreateWithEmptyEntityBody() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with malformed xml.
+ */
+ @Override
+ protected void setupCreateWithMalformedXml() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR; // Malformed payload never gets past RESTEasy filter
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with wrong xml schema.
+ */
+ @Override
+ protected void setupCreateWithWrongXmlSchema() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR; // Empty payload never gets past RESTEasy filter
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
}
return result;
}
- protected void printList(String testName, CLT list) {
+ @Override
+ protected void printList(String testName, CLT list) {
if (getLogger().isDebugEnabled()){
AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
}
/**
* The entity type expected from the JAX-RS Response object
*/
- public Class<String> getEntityResponseType() {
+ @Override
+ public Class<String> getEntityResponseType() {
return String.class;
}
return payloadInputPart;
}
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupCreateWithEmptyEntityBody() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupCreateWithInvalidBody() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupUpdateWithInvalidBody() {
+ testExpectedStatusCode = STATUS_BAD_REQUEST;
+ testRequestType = ServiceRequestType.UPDATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with malformed xml.
+ */
+ @Override
+ protected void setupCreateWithMalformedXml() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with wrong xml schema.
+ */
+ @Override
+ protected void setupCreateWithWrongXmlSchema() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
}
/*
* We use this method to force a TestNG execution order for our tests
*/
+ @Override
public abstract void CRUDTests(String testName);
/*
/*
* Test that searches honor the workflow deleted state.
*/
- @Test(dataProvider = "testName")
+ @Override
+ @Test(dataProvider = "testName")
public void searchWorkflowDeleted(String testName) throws Exception {
// FIXME: Temporarily avoid running test if client is of an authority service
invalidStatusCodeMessage(testRequestType, statusCode));
Assert.assertEquals(statusCode, testExpectedStatusCode);
}
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupCreateWithEmptyEntityBody() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ @Override
+ protected void setupCreateWithInvalidBody() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with malformed xml.
+ */
+ @Override
+ protected void setupCreateWithMalformedXml() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with wrong xml schema.
+ */
+ @Override
+ protected void setupCreateWithWrongXmlSchema() {
+ testExpectedStatusCode = STATUS_INTERNAL_SERVER_ERROR;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
}
import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import javax.xml.bind.JAXBContext;
+import javax.xml.bind.JAXBElement;
import javax.xml.bind.JAXBException;
+import javax.xml.bind.MarshalException;
import javax.xml.bind.Marshaller;
import javax.xml.bind.Unmarshaller;
+import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilderFactory;
import org.apache.commons.httpclient.HttpMethodBase;
* @param clazz the clazz
* @return the string
*/
- static protected String objectAsXmlString(Object o, Class<?> clazz) {
- StringWriter sw = new StringWriter();
- try {
- JAXBContext jc = JAXBContext.newInstance(clazz);
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
- Boolean.TRUE);
- m.marshal(o, sw);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return sw.toString();
- }
+ static protected String objectAsXmlString(Object o, Class<?> clazz) {
+ StringWriter sw = new StringWriter();
+ JAXBContext jc;
+ try {
+ jc = JAXBContext.newInstance(clazz);
+ Marshaller m = jc.createMarshaller();
+ try {
+ m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+ m.marshal(o, sw);
+ } catch (MarshalException e) {
+ sw = new StringWriter(); // reset the StringWriter value
+ JAXBElement root = new JAXBElement(new QName("uri", "local"), clazz, o);
+ m.marshal(root, sw);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ } catch (JAXBException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ return sw.toString();
+ }
static protected String objectAsXmlString(Object o) {
- StringWriter sw = new StringWriter();
- try {
- JAXBContext jc = JAXBContext.newInstance(o.getClass());
- Marshaller m = jc.createMarshaller();
- m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT,
- Boolean.TRUE);
- m.marshal(o, sw);
- } catch (Exception e) {
- e.printStackTrace();
- }
- return sw.toString();
- }
+ return objectAsXmlString(o, o.getClass());
+ }
/**
* getObjectFromFile get object of given class from given file (in classpath)
// Status code setup methods for tests
//
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ protected void setupCreateWithEmptyEntityBody() {
+ testExpectedStatusCode = STATUS_BAD_REQUEST;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ protected void setupCreateWithInvalidBody() {
+ testExpectedStatusCode = STATUS_BAD_REQUEST;
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
+
/**
* Sets up create tests with malformed xml.
*/
testRequestType = ServiceRequestType.DELETE;
testSetup(testExpectedStatusCode, testRequestType);
}
+
+ /**
+ * Sets up create tests with empty entity body.
+ */
+ protected void setupUpdateWithInvalidBody() {
+ testExpectedStatusCode = STATUS_BAD_REQUEST;
+ testRequestType = ServiceRequestType.UPDATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
// Failure outcomes
testRequestType = ServiceRequestType.DELETE;
testSetup(testExpectedStatusCode, testRequestType);
}
-
- /**
- * Sets up create tests with empty entity body.
- */
- protected void setupCreateWithEmptyEntityBody() {
- testExpectedStatusCode = STATUS_BAD_REQUEST;
- testRequestType = ServiceRequestType.CREATE;
- testSetup(testExpectedStatusCode, testRequestType);
- }
-
- /**
- * Sets up create tests with empty entity body.
- */
- protected void setupCreateWithInvalidBody() {
- testExpectedStatusCode = STATUS_BAD_REQUEST;
- testRequestType = ServiceRequestType.CREATE;
- testSetup(testExpectedStatusCode, testRequestType);
- }
-
- /**
- * Sets up create tests with empty entity body.
- */
- protected void setupUpdateWithInvalidBody() {
- testExpectedStatusCode = STATUS_BAD_REQUEST;
- testRequestType = ServiceRequestType.UPDATE;
- testSetup(testExpectedStatusCode, testRequestType);
- }
-
+
public void updateWithEmptyEntityBody(String testName) throws Exception {
//FIXME: Should this test really be empty? If so, please comment accordingly.
}
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<tenant:TenantBindingConfig
+ xmlns:merge="http://xmlmerge.el4j.elca.ch"
+ xmlns:tenant="http://collectionspace.org/services/config/tenant">
+
+ <!-- Add your changes, if any, within the following tag pair. -->
+ <!-- The value of the 'id' attribute, below, should match the corresponding -->
+ <!-- value in cspace/config/services/tenants/testsci-tenant-bindings-proto.xml -->
+
+ <tenant:tenantBinding id="3500">
+ <tenant:eventListenerConfigurations id="default" merge:matcher="id">
+ <tenant:eventListenerConfig id="UpdateObjectLocationOnMove" merge:matcher="id">
+ <tenant:paramList id="default" merge:matcher="id" merge:action="delete"/>
+ </tenant:eventListenerConfig>
+ <tenant:eventListenerConfig id="UpdateObjectLocationAndCrateOnMove" merge:matcher="id" merge:action="delete"/>
+ </tenant:eventListenerConfigurations>
+ </tenant:tenantBinding>
+</tenant:TenantBindingConfig>
}
public CSWebApplicationException(Throwable cause, Response response) {
- super(cause);
+ super(cause, response);
this.response = getFinalResponse(cause, response);
}
}
@Override
- public ServiceDescription getDescription(ServiceContext ctx) {
+ public ServiceDescription getDescription(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx) {
ServiceDescription result = new ServiceDescription();
result.setDocumentType(getDocType(ctx.getTenantId()));
* for all inheriting resource classes. Just use ServiceContext.getResourceMap() to get
* the map, and pass it in.
*/
- public static DocumentModel getDocModelForRefName(ServiceContext ctx, String refName, ResourceMap resourceMap)
+ public static DocumentModel getDocModelForRefName(ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx, String refName, ResourceMap resourceMap)
throws Exception, DocumentNotFoundException {
return NuxeoUtils.getDocModelForRefName(ctx, refName, resourceMap);
}
package org.collectionspace.services.common;
-import org.collectionspace.services.client.PoxPayloadIn;
-import org.collectionspace.services.client.PoxPayloadOut;
-
public interface ResourceMapHolder {
- public ResourceMap<PoxPayloadIn, PoxPayloadOut> getResourceMap();
+ public ResourceMap getResourceMap();
}
import org.nuxeo.ecm.core.event.Event;
public abstract class AbstractCSEventListenerImpl implements CSEventListener {
- private static List<String> repositoryNameList = new ArrayList<String>();
+ private static Map<String, List<String>> mapOfrepositoryNames = new HashMap<String, List<String>>(); // <className, repositoryName>
private static Map<String, Map<String, Map<String, String>>> eventListenerParamsMap = new HashMap<String, Map<String, Map<String, String>>>(); // <repositoryName, Map<EventListenerId, Map<key, value>>>
private static Map<String, String> nameMap = new HashMap<String, String>();
// Intentionally left blank
}
- protected List<String> getRepositoryNameList() {
- return repositoryNameList;
- }
-
- protected Map<String, Map<String, Map<String, String>>> getEventListenerParamsMap() {
- return eventListenerParamsMap;
- }
-
+ /**
+ * Find out if we (the event listener) are registered (via tenant bindings config) to respond events.
+ */
@Override
public boolean isRegistered(Event event) {
boolean result = false;
if (event != null && event.getContext() != null) {
- result = repositoryNameList.contains(event.getContext().getRepositoryName());
+ result = getRepositoryNameList().contains(event.getContext().getRepositoryName());
}
return result;
}
-
+
+ /**
+ * An event listener can be registered by multiple tenants, so we keep track of that here.
+ *
+ * @return - the list of tenants/repositories that an event listener is registered with.
+ */
+ protected List<String> getRepositoryNameList() {
+ String key = this.getClass().getName();
+ List<String> result = mapOfrepositoryNames.get(key);
+
+ if (result == null) synchronized(this) {
+ result = new ArrayList<String>();
+ mapOfrepositoryNames.put(key, result);
+ }
+
+ return result;
+ }
+
+ /**
+ * The list of parameters (specified in a tenant's bindings) for event listeners
+ * @return
+ */
+ protected Map<String, Map<String, Map<String, String>>> getEventListenerParamsMap() {
+ return eventListenerParamsMap;
+ }
/**
* Returns 'true' if this collection changed as a result of the call.
result = true;
}
- // Set this event listeners parameters, if any. Params are qualified with the repositoryName since multiple tenants might be registering the same event listener but with different params.
- List<Param> paramList = eventListenerConfig.getParamList().getParam(); // values from the tenant bindings that we need to copy into the event listener
- if (paramList != null) {
- //
- // Get the list of event listeners for a given repository
- Map<String, Map<String, String>> eventListenerRepoParams = getEventListenerParamsMap().get(respositoryName); // Get the set of event listers for a given repository
- if (eventListenerRepoParams == null) {
- eventListenerRepoParams = new HashMap<String, Map<String, String>>();
- getEventListenerParamsMap().put(respositoryName, eventListenerRepoParams); // create and put an empty map
- result = true;
- }
- //
- // Get the list of params for a given event listener for a given repository
- Map<String, String> eventListenerParams = eventListenerRepoParams.get(eventListenerConfig.getId()); // Get the set of params for a given event listener for a given repository
- if (eventListenerParams == null) {
- eventListenerParams = new HashMap<String, String>();
- eventListenerRepoParams.put(eventListenerConfig.getId(), eventListenerParams); // create and put an empty map
- result = true;
- }
- //
- // copy all the values from the tenant bindings into the event listener
- for (Param params : paramList) {
- String key = params.getKey();
- String value = params.getValue();
- if (Tools.notBlank(key)) {
- eventListenerParams.put(key, value);
+ if (eventListenerConfig.getParamList() != null) {
+ // Set this event listeners parameters, if any. Params are qualified with the repositoryName since multiple tenants might be registering the same event listener but with different params.
+ List<Param> paramList = eventListenerConfig.getParamList().getParam(); // values from the tenant bindings that we need to copy into the event listener
+ if (paramList != null) {
+ //
+ // Get the list of event listeners for a given repository
+ Map<String, Map<String, String>> eventListenerRepoParams = getEventListenerParamsMap().get(respositoryName); // Get the set of event listers for a given repository
+ if (eventListenerRepoParams == null) {
+ eventListenerRepoParams = new HashMap<String, Map<String, String>>();
+ getEventListenerParamsMap().put(respositoryName, eventListenerRepoParams); // create and put an empty map
+ result = true;
+ }
+ //
+ // Get the list of params for a given event listener for a given repository
+ Map<String, String> eventListenerParams = eventListenerRepoParams.get(eventListenerConfig.getId()); // Get the set of params for a given event listener for a given repository
+ if (eventListenerParams == null) {
+ eventListenerParams = new HashMap<String, String>();
+ eventListenerRepoParams.put(eventListenerConfig.getId(), eventListenerParams); // create and put an empty map
result = true;
}
+ //
+ // copy all the values from the tenant bindings into the event listener
+ for (Param params : paramList) {
+ String key = params.getKey();
+ String value = params.getValue();
+ if (Tools.notBlank(key)) {
+ eventListenerParams.put(key, value);
+ result = true;
+ }
+ }
}
}
@Override
public Map<String, String> getParams(Event event) {
- String repositoryName = event.getContext().getRepositoryName();
- return getEventListenerParamsMap().get(repositoryName).get(getName(repositoryName)); // We need to qualify with the repositoryName since this event listener might be register by multiple tenants using different params
+ Map<String, String> result = null;
+ try {
+ String repositoryName = event.getContext().getRepositoryName();
+ result = getEventListenerParamsMap().get(repositoryName).get(getName(repositoryName)); // We need to qualify with the repositoryName since this event listener might be register by multiple tenants using different params
+ } catch (NullPointerException e) {
+ // Do nothing. Just means no params were configured.
+ }
+ return result;
}
@Override
--- /dev/null
+<jaxb:bindings version="1.0"
+ xmlns:jaxb="http://java.sun.com/xml/ns/jaxb"
+ xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ xmlns:annox="http://annox.dev.java.net"
+ xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <jaxb:bindings schemaLocation="permissions.xsd" node="/xs:schema">
+ <jaxb:globalBindings localScoping="toplevel">
+ <jaxb:serializable uid="1338" />
+ </jaxb:globalBindings>
+ <!--
+ <jaxb:bindings node="xs:complexType[@name='permission']">
+ <annox:annotate>
+ <annox:annotate annox:class="javax.xml.bind.annotation.XmlRootElement" name="permission" />
+ </annox:annotate>
+ </jaxb:bindings>
+ -->
+ </jaxb:bindings>
+</jaxb:bindings>
\ No newline at end of file
* @throws Exception
*/
- @AfterClass(alwaysRun=true)
+ @Override
+ @AfterClass(alwaysRun=true)
public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
*
* @return The root URL for the item service.
*/
- protected String getItemServiceRootURL(String parentResourceIdentifier) {
+ @Override
+ protected String getItemServiceRootURL(String parentResourceIdentifier) {
return getResourceURL(parentResourceIdentifier) + "/" + getItemServicePathComponent();
}
*
* @return The URL of a specific item resource managed by a service.
*/
- protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
+ @Override
+ protected String getItemResourceURL(String parentResourceIdentifier, String itemResourceIdentifier) {
return getItemServiceRootURL(parentResourceIdentifier) + "/" + itemResourceIdentifier;
}
"Display name in updated object did not match submitted data.");
}
- protected void compareReadInstances(MaterialauthoritiesCommon original,
+ @Override
+ protected void compareReadInstances(MaterialauthoritiesCommon original,
MaterialauthoritiesCommon fromRead) throws Exception {
Assert.assertNotNull(fromRead.getDisplayName());
Assert.assertNotNull(fromRead.getShortIdentifier());
<bindingIncludes>
<include>bindings.xjb</include>
</bindingIncludes>
+ <args>
+ <arg>-Xannotate</arg>
+ </args>
<extension>true</extension>
<jdk5>true</jdk5>
<ejb3>false</ejb3>
--- /dev/null
+#url of the collectionspace server
+cspace.url=http://localhost:8180/cspace-services/
+cspace.ssl=false
+cspace.auth=true
+cspace.user=admin@botgarden.collectionspace.org
+cspace.password=Administrator
import org.collectionspace.services.client.CollectionSpaceClient;
import org.collectionspace.services.client.PottagClient;
-import org.collectionspace.services.client.PayloadOutputPart;
import org.collectionspace.services.client.PoxPayloadOut;
-import org.collectionspace.services.common.api.GregorianCalendarDateTimeUtils;
import org.collectionspace.services.jaxb.AbstractCommonList;
import org.collectionspace.services.pottag.PottagsCommon;
/** The logger. */
private final String CLASS_NAME = PottagServiceTest.class.getName();
private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
- // Instance variables specific to this test.
- private final static String CURRENT_DATE_UTC = GregorianCalendarDateTimeUtils.currentDateUTC();
-
/* (non-Javadoc)
* @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance()
*/
+ "' does not match expected data '" + getUTF8DataFragment());
}
- @Override
- protected void compareUpdatedInstances(PottagsCommon pottagCommon,
- PottagsCommon updatedPottagCommon) throws Exception {
- // Check selected fields in the updated common part.
- Assert.assertEquals(updatedPottagCommon.getFamily(), pottagCommon.getFamily(),
- "Data in updated object did not match submitted data.");
-
- if (logger.isDebugEnabled()) {
- logger.debug("UTF-8 data sent=" + pottagCommon.getLabelData() + "\n"
- + "UTF-8 data received=" + updatedPottagCommon.getLabelData());
- }
- Assert.assertTrue(updatedPottagCommon.getLabelData().contains(getUTF8DataFragment()),
- "UTF-8 data retrieved '" + updatedPottagCommon.getLabelData() + "' does not contain expected data '" + getUTF8DataFragment());
- Assert.assertEquals(updatedPottagCommon.getLabelData(),
- pottagCommon.getLabelData(), "Data in updated object did not match submitted data.");
- }
+ @Override
+ protected void compareUpdatedInstances(PottagsCommon requestedUpdate,
+ PottagsCommon actualUpdate) throws Exception {
+ Assert.assertEquals(requestedUpdate.getFamily(), actualUpdate.getFamily(),
+ "Display name in updated object did not match submitted data.");
+ }
// ---------------------------------------------------------------
// Utility methods used by tests above
pottagCommon.setLabelData(getUTF8DataFragment());
PoxPayloadOut multipart = new PoxPayloadOut(this.getServicePathComponent());
- PayloadOutputPart commonPart =
- multipart.addPart(new PottagClient().getCommonPartName(), pottagCommon);
+ multipart.addPart(new PottagClient().getCommonPartName(), pottagCommon);
if (logger.isDebugEnabled()) {
logger.debug("to be created, pottag common");
PoxPayloadOut result = createPottagInstance(identifier);
return result;
}
-
+
@Override
protected PottagsCommon updateInstance(PottagsCommon commonPartObject) {
- // TODO Auto-generated method stub
- return null;
+
+ String updatedFamily = "Updated-" + commonPartObject.getFamily();
+ commonPartObject.setFamily(updatedFamily);
+
+ return commonPartObject;
}
@Override
protected CollectionSpaceClient getClientInstance(String clientPropertiesFilename) throws Exception {
- // TODO Auto-generated method stub
- return null;
+ return new PottagClient();
}
}
--- /dev/null
+#url of the collectionspace server
+cspace.url=http://localhost:8180/cspace-services/
+cspace.ssl=false
+cspace.auth=true
+cspace.user=admin@botgarden.collectionspace.org
+cspace.password=Administrator
AuthorityRefList list = null;
try {
assertStatusCode(res, testName);
- list = (AuthorityRefList) res.getEntity();
+ list = (AuthorityRefList)res.readEntity(AuthorityRefList.class);
Assert.assertNotNull(list);
} finally {
if (res != null) {
* may be expected to be deleted by certain tests.
* @throws Exception
*/
- @AfterClass(alwaysRun=true)
+ @Override
+ @AfterClass(alwaysRun=true)
public void cleanUp() throws Exception {
String noTest = System.getProperty("noTestCleanup");
if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) {
// ---------------------------------------------------------------
// Utility methods used by tests above
// ---------------------------------------------------------------
- public String getServiceName() {
+ @Override
+ public String getServiceName() {
return PropagationClient.SERVICE_NAME;
}
<xs:element name="propDate" type="structuredDateGroup"/>
<xs:element name="propReason" type="xs:string"/>
<xs:element name="propType" type="xs:string"/>
+ <xs:element name="taggedBy" type="xs:string"/>
<xs:element name="propBy" type="xs:string"/>
<xs:element name="propComments" type="xs:string"/>
<xs:element name="numStarted" type="xs:integer"/>
}
}
+ /**
+ * Sets up create tests with malformed xml.
+ */
+ protected void setupcreateItemWithBadShortId() {
+ testExpectedStatusCode = STATUS_BAD_REQUEST; // Malformed payload never gets past RESTEasy filter
+ testRequestType = ServiceRequestType.CREATE;
+ testSetup(testExpectedStatusCode, testRequestType);
+ }
@Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class,
dependsOnMethods = {"authorityTests"})
public void createItemWithBadShortId(String testName) throws Exception {
- setupCreateWithMalformedXml();
+ setupcreateItemWithBadShortId();
// Submit the request to the service and store the response.
VocabularyClient client = new VocabularyClient();