From a843926a1fee0f33505be66f4375179d8e0b9a12 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Tue, 12 Apr 2011 02:47:32 +0000 Subject: [PATCH] CSPACE-3781: Fixed this problem with soft-delete on authority items. Need to move this fix to the v1.6 branch as well. --- .../common/vocabulary/AuthorityResource.java | 25 +- .../services/client/AuthorityClient.java | 27 ++ .../services/client/AuthorityClientImpl.java | 72 +++- .../services/client/AuthorityProxy.java | 52 ++- .../client/test/AbstractServiceTestImpl.java | 186 +++++++++- .../client/LocationAuthorityClient.java | 1 + .../client/LocationAuthorityProxy.java | 6 +- .../src/test/resources/log4j.properties | 6 +- .../services/client/OrgAuthorityClient.java | 1 + .../services/client/OrgAuthorityProxy.java | 6 +- .../client/test/OrgAuthorityServiceTest.java | 26 ++ .../client/PersonAuthorityClient.java | 8 +- .../client/PersonAuthorityClientUtils.java | 5 +- .../services/client/PersonAuthorityProxy.java | 6 +- .../test/PersonAuthorityServiceTest.java | 24 ++ services/vocabulary/client/.classpath | 317 +----------------- .../services/client/VocabularyClient.java | 8 +- .../services/client/VocabularyProxy.java | 6 +- .../client/test/VocabularyServiceTest.java | 78 +++-- 19 files changed, 471 insertions(+), 389 deletions(-) diff --git a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java b/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java index 85caae4ea..94d2e32e9 100644 --- a/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java +++ b/services/authority/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityResource.java @@ -548,8 +548,9 @@ public abstract class AuthorityResource queryParams = ui.getQueryParameters(); Specifier parentSpec = getSpecifier(parentspecifier, "getAuthorityItem(parent)", "GET_ITEM"); Specifier itemSpec = getSpecifier(itemspecifier, "getAuthorityItem(item)", "GET_ITEM"); @@ -560,10 +561,10 @@ public abstract class AuthorityResource createItem(String vcsid, PoxPayloadOut poxPayloadOut); //(R)ead Item ClientResponse readItem(String vcsid, String csid); + + //(R)ead Item + ClientResponse readItem(String vcsid, String csid, Boolean includeDeleted); //(U)pdate Item ClientResponse updateItem(String vcsid, String csid, PoxPayloadOut poxPayloadOut); @@ -51,6 +56,8 @@ public interface AuthorityClient readByName(String name); + ClientResponse readByName(String name, Boolean includeDeleted); + /* * Item subresource methods */ @@ -64,6 +71,8 @@ public interface AuthorityClient readNamedItem(String vcsid, String shortId); + public ClientResponse readNamedItem(String vcsid, String shortId, Boolean includeDeleted); + /** * Read item in Named Authority. * @@ -73,6 +82,8 @@ public interface AuthorityClient readItemInNamedAuthority(String authShortId, String csid); + public ClientResponse readItemInNamedAuthority(String authShortId, String csid, Boolean includeDeleted); + /** * Read named item in Named Authority. * @@ -82,6 +93,8 @@ public interface AuthorityClient readNamedItemInNamedAuthority(String authShortId, String itemShortId); + public ClientResponse readNamedItemInNamedAuthority(String authShortId, String itemShortId, Boolean includeDeleted); + /** * Read item list, filtering by partial term match, or keywords. Only one of * partialTerm or keywords should be specified. If both are specified, keywords @@ -96,6 +109,8 @@ public interface AuthorityClient readItemList(String inAuthority, String partialTerm, String keywords); + public ClientResponse readItemList(String inAuthority, String partialTerm, String keywords, Boolean includeDeleted); + /** * Read item list for named vocabulary, filtering by partial term match, or keywords. Only one of * partialTerm or keywords should be specified. If both are specified, keywords @@ -111,4 +126,16 @@ public interface AuthorityClient readItemListForNamedAuthority(String specifier, String partialTerm, String keywords); + public ClientResponse readItemListForNamedAuthority(String specifier, + String partialTerm, + String keywords, + Boolean includeDeleted); + + /* + * Workflow related methods + */ + + public ClientResponse readItemWorkflow(String vcsid, String csid); + + public ClientResponse updateItemWorkflow(String vcsid, String csid, PoxPayloadOut workflowPayload); } diff --git a/services/client/src/main/java/org/collectionspace/services/client/AuthorityClientImpl.java b/services/client/src/main/java/org/collectionspace/services/client/AuthorityClientImpl.java index baf419565..02a16d770 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/AuthorityClientImpl.java +++ b/services/client/src/main/java/org/collectionspace/services/client/AuthorityClientImpl.java @@ -16,6 +16,7 @@ public abstract class AuthorityClientImpl implements AuthorityClient { + private static final String INCLUDE_DELETE_TRUE = Boolean.TRUE.toString(); /* * Basic CRUD proxied methods */ @@ -29,7 +30,12 @@ public abstract class AuthorityClientImpl readItem(String vcsid, String csid) { - return getProxy().readItem(vcsid, csid); + return getProxy().readItem(vcsid, csid, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse readItem(String vcsid, String csid, Boolean includeDeleted) { + return getProxy().readItem(vcsid, csid, includeDeleted.toString()); } //(U)pdate Item @@ -48,7 +54,7 @@ public abstract class AuthorityClientImpl getReferencingObjects( String parentcsid, String itemcsid) { - return getProxy().getReferencingObjects(parentcsid, itemcsid); + return getProxy().getReferencingObjects(parentcsid, itemcsid, Boolean.TRUE.toString()); } /** @@ -69,7 +75,12 @@ public abstract class AuthorityClientImpl readByName(String name) { - return getProxy().readByName(name); + return getProxy().readByName(name, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse readByName(String name, Boolean includeDeleted) { + return getProxy().readByName(name, includeDeleted.toString()); } /* @@ -85,7 +96,12 @@ public abstract class AuthorityClientImpl readNamedItem(String vcsid, String shortId) { - return getProxy().readNamedItem(vcsid, shortId); + return getProxy().readNamedItem(vcsid, shortId, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse readNamedItem(String vcsid, String shortId, Boolean includeDeleted) { + return getProxy().readNamedItem(vcsid, shortId, includeDeleted.toString()); } /** @@ -97,7 +113,12 @@ public abstract class AuthorityClientImpl readItemInNamedAuthority(String authShortId, String csid) { - return getProxy().readItemInNamedAuthority(authShortId, csid); + return getProxy().readItemInNamedAuthority(authShortId, csid, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse readItemInNamedAuthority(String authShortId, String csid, Boolean includeDeleted) { + return getProxy().readItemInNamedAuthority(authShortId, csid, includeDeleted.toString()); } /** @@ -109,7 +130,12 @@ public abstract class AuthorityClientImpl readNamedItemInNamedAuthority(String authShortId, String itemShortId) { - return getProxy().readNamedItemInNamedAuthority(authShortId, itemShortId); + return getProxy().readNamedItemInNamedAuthority(authShortId, itemShortId, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse readNamedItemInNamedAuthority(String authShortId, String itemShortId, Boolean includeDeleted) { + return getProxy().readNamedItemInNamedAuthority(authShortId, itemShortId, includeDeleted.toString()); } /** @@ -127,7 +153,13 @@ public abstract class AuthorityClientImpl readItemList(String inAuthority, String partialTerm, String keywords) { - return getProxy().readItemList(inAuthority, partialTerm, keywords); + return getProxy().readItemList(inAuthority, partialTerm, keywords, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse + readItemList(String inAuthority, String partialTerm, String keywords, Boolean includeDeleted) { + return getProxy().readItemList(inAuthority, partialTerm, keywords, includeDeleted.toString()); } /** @@ -146,6 +178,30 @@ public abstract class AuthorityClientImpl readItemListForNamedAuthority( String specifier, String partialTerm, String keywords) { - return getProxy().readItemListForNamedAuthority(specifier, partialTerm, keywords); + return getProxy().readItemListForNamedAuthority(specifier, partialTerm, keywords, INCLUDE_DELETE_TRUE); + } + + @Override + public ClientResponse readItemListForNamedAuthority( + String specifier, + String partialTerm, + String keywords, + Boolean includeDeleted) { + return getProxy().readItemListForNamedAuthority(specifier, partialTerm, keywords, includeDeleted.toString()); } + + /* + * Workflow related methods + */ + + @Override + public ClientResponse readItemWorkflow(String vcsid, String csid) { + return getProxy().readItemWorkflow(vcsid, csid); + } + + @Override + public ClientResponse updateItemWorkflow(String vcsid, String csid, PoxPayloadOut xmlPayload) { + return getProxy().updateItemWorkflow(vcsid, csid, xmlPayload.getBytes()); + } + } diff --git a/services/client/src/main/java/org/collectionspace/services/client/AuthorityProxy.java b/services/client/src/main/java/org/collectionspace/services/client/AuthorityProxy.java index 91785232b..d64d17d12 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/AuthorityProxy.java +++ b/services/client/src/main/java/org/collectionspace/services/client/AuthorityProxy.java @@ -1,5 +1,6 @@ package org.collectionspace.services.client; +import javax.ws.rs.Consumes; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; @@ -10,6 +11,7 @@ import javax.ws.rs.Produces; import javax.ws.rs.QueryParam; import javax.ws.rs.core.Response; +import org.collectionspace.services.client.workflow.WorkflowClient; import org.collectionspace.services.common.authorityref.AuthorityRefDocList; import org.collectionspace.services.common.authorityref.AuthorityRefList; import org.collectionspace.services.jaxb.AbstractCommonList; @@ -33,8 +35,10 @@ public interface AuthorityProxy readItem(@PathParam("vcsid") String vcsid, @PathParam("csid") String csid); - + ClientResponse readItem(@PathParam("vcsid") String vcsid, + @PathParam("csid") String csid, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); + //(U)pdate Item @PUT @Path("/{vcsid}/items/{csid}") @@ -59,7 +63,8 @@ public interface AuthorityProxy getReferencingObjects( @PathParam("csid") String parentcsid, - @PathParam("itemcsid") String itemcsid); + @PathParam("itemcsid") String itemcsid, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); // List Item Authority References @GET @@ -76,7 +81,8 @@ public interface AuthorityProxy readByName(@PathParam("name") String name); + ClientResponse readByName(@PathParam("name") String name, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); /* * Item subresource methods @@ -85,17 +91,23 @@ public interface AuthorityProxy readNamedItem(@PathParam("vcsid") String vcsid, @PathParam("specifier") String specifier); + ClientResponse readNamedItem(@PathParam("vcsid") String vcsid, + @PathParam("specifier") String specifier, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); //(R)ead Item In Named Authority @GET @Path("/urn:cspace:name({specifier})/items/{csid}") - ClientResponse readItemInNamedAuthority(@PathParam("specifier") String specifier, @PathParam("csid") String csid); + ClientResponse readItemInNamedAuthority(@PathParam("specifier") String specifier, + @PathParam("csid") String csid, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); //(R)ead Named Item In Named Authority @GET @Path("/urn:cspace:name({specifier})/items/urn:cspace:name({itemspecifier})") - ClientResponse readNamedItemInNamedAuthority(@PathParam("specifier") String specifier, @PathParam("itemspecifier") String itemspecifier); + ClientResponse readNamedItemInNamedAuthority(@PathParam("specifier") String specifier, + @PathParam("itemspecifier") String itemspecifier, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); /* * Item subresource List methods @@ -108,7 +120,8 @@ public interface AuthorityProxy readItemList( @PathParam("csid") String vcsid, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); // List Items for a named authority matching a partial term or keywords. @GET @@ -117,6 +130,27 @@ public interface AuthorityProxy readItemListForNamedAuthority( @PathParam("specifier") String specifier, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); + /* + * Workflow related methods + * + */ + + //(R)ead Item workflow + @GET + @Produces({"application/xml"}) + @Consumes({"application/xml"}) + @Path("/{vcsid}/items/{csid}" + WorkflowClient.SERVICE_PATH) + ClientResponse readItemWorkflow(@PathParam("vcsid") String vcsid, + @PathParam("csid") String csid); + + //(U)pdate Item workflow + @PUT + @Path("/{vcsid}/items/{csid}" + WorkflowClient.SERVICE_PATH) + ClientResponse updateItemWorkflow(@PathParam("vcsid") String vcsid, + @PathParam("csid") String csid, + byte[] xmlPayload); + } diff --git a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java index dead5ac26..697f8fb6e 100644 --- a/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java +++ b/services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java @@ -25,11 +25,14 @@ package org.collectionspace.services.client.test; import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.workflow.WorkflowCommon; import org.collectionspace.services.client.AbstractPoxServiceClientImpl; +import org.collectionspace.services.client.AuthorityClient; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.CollectionSpacePoxClient; import org.collectionspace.services.client.PayloadOutputPart; @@ -97,6 +100,9 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements } /* Use this to keep track of resources to delete */ protected List allResourceIdsCreated = new ArrayList(); + /* Use this to track authority items */ + protected Map allResourceItemIdsCreated = new HashMap(); /* itemCsid, parentCsid */ + private String EMPTY_SORT_BY_ORDER = ""; /** @@ -434,6 +440,21 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements logger.debug("Cleaning up temporary resources created for testing ..."); } CollectionSpaceClient client = this.getClientInstance(); + // + // First, check to see if we need to cleanup any authority items + // + if (this.isAuthorityClient(client) == true) { + AuthorityClient authorityClient = (AuthorityClient)client; + for (Map.Entry entry : allResourceItemIdsCreated.entrySet()) { + String itemResourceId = entry.getKey(); + String authorityResourceId = entry.getValue(); + // Note: Any non-success responses are ignored and not reported. + authorityClient.deleteItem(authorityResourceId, itemResourceId).releaseConnection(); + } + } + // + // Next, delete all other entities include possible authorities. + // for (String resourceId : allResourceIdsCreated) { // Note: Any non-success responses are ignored and not reported. client.delete(resourceId).releaseConnection(); @@ -655,7 +676,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState); } - private CollectionSpacePoxClient assertPoxCandidate() { + private CollectionSpacePoxClient assertPoxClient() { CollectionSpaceClient clientCandidate = this.getClientInstance(); if (CollectionSpacePoxClient.class.isInstance(clientCandidate) != true) { //FIXME: REM - We should remove this check and instead make CollectionSpaceClient support the readIncludeDeleted() method. String clientCandidateName = "Unknown"; @@ -678,7 +699,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements // // Ask for a list of all resources filtered by the incoming 'includeDeleted' workflow param // - CollectionSpacePoxClient client = assertPoxCandidate(); + CollectionSpacePoxClient client = assertPoxClient(); ClientResponse res = client.readIncludeDeleted(includeDeleted); AbstractCommonList list = res.getEntity(); int statusCode = res.getStatus(); @@ -705,6 +726,37 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements return result; } + protected long readItemsIncludeDeleted(String testName, String parentCsid, Boolean includeDeleted) { + long result = 0; + // Perform setup. + setupReadList(); + + // + // Ask for a list of all resources filtered by the incoming 'includeDeleted' workflow param + // + AuthorityClient client = (AuthorityClient)this.getClientInstance(); + ClientResponse res = client.readItemList(parentCsid, + null, /* partial terms */ + null, /* keywords */ + includeDeleted); + AbstractCommonList list = res.getEntity(); + int statusCode = res.getStatus(); + // + // Check the status code of the response: does it match + // the expected response(s)? + // + if (logger.isDebugEnabled()) { + logger.debug(testName + ": status = " + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + result = list.getTotalItems(); + + return result; + } + /* * This test assumes that no objects exist yet. * @@ -742,7 +794,7 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements // // Next, test that a GET with WorkflowClient.WORKFLOWSTATE_DELETED query param set to 'false' returns a 404 // - CollectionSpacePoxClient client = this.assertPoxCandidate(); + CollectionSpacePoxClient client = this.assertPoxClient(); ClientResponse res = client.readIncludeDeleted(csid, Boolean.FALSE); int result = res.getStatus(); Assert.assertEquals(result, STATUS_NOT_FOUND); @@ -785,6 +837,134 @@ public abstract class AbstractServiceTestImpl extends BaseServiceTest implements logger.warn("Sub-class test clients should override this method"); throw new UnsupportedOperationException(); } + + /* + * Test classes for authority services should override these method and return 'true' + */ + protected boolean isAuthorityClient(CollectionSpaceClient theClient) { + return AuthorityClient.class.isInstance(theClient); + } + + protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) { + logger.warn("Sub-class test clients should override this method"); + throw new UnsupportedOperationException(); + } + + final protected String createWorkflowItemTarget(String testName, String parentCsid) throws Exception { + String result = null; + + result = createTestItemObject(testName, parentCsid); + + return result; + } + + protected String createTestItemObject(String testName, String parentCsid) throws Exception { + String result = null; + + AuthorityClient client = (AuthorityClient)getClientInstance(); + String identifier = createIdentifier(); + PoxPayloadOut multipart = createItemInstance(parentCsid, identifier); + ClientResponse res = client.createItem(parentCsid, multipart); + + int statusCode = res.getStatus(); + Assert.assertEquals(statusCode, STATUS_CREATED); + + result = extractId(res); + allResourceItemIdsCreated.put(result, parentCsid); + + return result; + } + + /* + * This test assumes that no objects exist yet. + * + * http://localhost:8180/cspace-services/intakes?wf_deleted=false + */ + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) + public void readAuthorityItemWorkflow(String testName) throws Exception { + // + // Run this test only if the client is an AuthorityClient //FIXME: REM - Replace this will an AuthorityServiceTest class + // + if (this.isAuthorityClient(this.getClientInstance()) == true) { + try { + // + // Get the total count of non-deleted existing records + // + String parentCsid = this.createTestObject(testName); + + // + // Create 3 new items + // + final int OBJECTS_TO_CREATE = 3; + String lastCreatedItem = null; + for (int i = 0; i < OBJECTS_TO_CREATE; i++) { + lastCreatedItem = this.createWorkflowItemTarget(testName, parentCsid); + } + + // + // Mark one item as soft deleted + // + String csid = lastCreatedItem; + this.setupUpdate(); + this.updateItemLifeCycleState(testName, parentCsid, csid, WorkflowClient.WORKFLOWSTATE_DELETED); + // + // Read the list of existing non-deleted records + // + long updatedTotal = readItemsIncludeDeleted(testName, parentCsid, Boolean.FALSE); + Assert.assertEquals(updatedTotal, OBJECTS_TO_CREATE - 1, "Deleted items seem to be returned in list results."); + + // + // Next, test that a GET with WorkflowClient.WORKFLOWSTATE_DELETED query param set to 'false' returns a 404 + // + AuthorityClient client = (AuthorityClient)this.getClientInstance(); + ClientResponse res = client.readItem(parentCsid, csid, Boolean.FALSE); + int result = res.getStatus(); + Assert.assertEquals(result, STATUS_NOT_FOUND); + + } catch (UnsupportedOperationException e) { + logger.warn(this.getClass().getName() + " did not implement createWorkflowTarget() method. No workflow tests performed."); + return; + } + } + } + + protected void updateItemLifeCycleState(String testName, String parentCsid, String itemCsid, String lifeCycleState) throws Exception { + // + // Read the existing object + // + AuthorityClient client = (AuthorityClient)this.getClientInstance(); + ClientResponse res = client.readItemWorkflow(parentCsid, itemCsid); + assertStatusCode(res, testName); + logger.debug("Got object to update life cycle state with ID: " + itemCsid); + PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); + WorkflowCommon workflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class); + Assert.assertNotNull(workflowCommons); + // + // Mark it for a soft delete. + // + logger.debug("Current workflow state:" + objectAsXmlString(workflowCommons, WorkflowCommon.class)); + workflowCommons.setCurrentLifeCycleState(lifeCycleState); + PoxPayloadOut output = new PoxPayloadOut(WorkflowClient.SERVICE_PAYLOAD_NAME); + PayloadOutputPart commonPart = output.addPart(WorkflowClient.SERVICE_COMMONPART_NAME, workflowCommons); + // + // Perform the update + // + res = client.updateItemWorkflow(parentCsid, itemCsid, output); + assertStatusCode(res, testName); + input = new PoxPayloadIn(res.getEntity()); + WorkflowCommon updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class); + Assert.assertNotNull(updatedWorkflowCommons); + // + // Read the updated object and make sure it was updated correctly. + // + res = client.readItemWorkflow(parentCsid, itemCsid); + assertStatusCode(res, testName); + logger.debug("Got workflow state of updated object with ID: " + itemCsid); + input = new PoxPayloadIn(res.getEntity()); + updatedWorkflowCommons = (WorkflowCommon) extractPart(input, WorkflowClient.SERVICE_COMMONPART_NAME, WorkflowCommon.class); + Assert.assertNotNull(workflowCommons); + Assert.assertEquals(updatedWorkflowCommons.getCurrentLifeCycleState(), lifeCycleState); + } } diff --git a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java index a55767db8..21714f5f3 100644 --- a/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java +++ b/services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClient.java @@ -74,6 +74,7 @@ public class LocationAuthorityClient extends AuthorityClientImpl readItemList( @PathParam("csid") String vcsid, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); // List Items for a named authority matching a partial term or keywords. @Override @@ -48,7 +49,8 @@ public interface LocationAuthorityProxy extends AuthorityProxy readItemListForNamedAuthority( @PathParam("specifier") String specifier, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); @Override @GET diff --git a/services/media/client/src/test/resources/log4j.properties b/services/media/client/src/test/resources/log4j.properties index 294c02d68..66bef70e6 100644 --- a/services/media/client/src/test/resources/log4j.properties +++ b/services/media/client/src/test/resources/log4j.properties @@ -17,10 +17,10 @@ log4j.appender.R.layout=org.apache.log4j.PatternLayout log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n #packages -log4j.logger.org.collectionspace.services.client.PoxPayloadIn=TRACE -log4j.logger.org.collectionspace.services.client.PoxPayloadOut=TRACE +log4j.logger.org.collectionspace.services.client.PoxPayloadIn=DEBUG +log4j.logger.org.collectionspace.services.client.PoxPayloadOut=DEBUG -log4j.logger.org.collectionspace=ERROR +log4j.logger.org.collectionspace=DEBUG log4j.logger.org.apache=INFO log4j.logger.httpclient=INFO log4j.logger.org.jboss.resteasy=INFO diff --git a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java index 21df2d941..1856a9c31 100644 --- a/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java +++ b/services/organization/client/src/main/java/org/collectionspace/services/client/OrgAuthorityClient.java @@ -67,6 +67,7 @@ public class OrgAuthorityClient extends AuthorityWithContactsClientImpl readItemList( @PathParam("csid") String vcsid, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); // List Items for a named authority matching a partial term or keywords. @Override @@ -52,5 +53,6 @@ public interface OrgAuthorityProxy extends AuthorityWithContactsProxy readItemListForNamedAuthority( @PathParam("specifier") String specifier, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); } diff --git a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java index 9eee82fd2..597af32cd 100644 --- a/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java +++ b/services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java @@ -30,10 +30,13 @@ import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; import org.collectionspace.services.OrganizationJAXBSchema; +import org.collectionspace.services.PersonJAXBSchema; import org.collectionspace.services.client.CollectionSpaceClient; import org.collectionspace.services.client.ContactClient; import org.collectionspace.services.client.ContactClientUtils; import org.collectionspace.services.client.PayloadOutputPart; +import org.collectionspace.services.client.PersonAuthorityClient; +import org.collectionspace.services.client.PersonAuthorityClientUtils; import org.collectionspace.services.client.PoxPayloadIn; import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.contact.ContactsCommon; @@ -199,6 +202,29 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl { //FIXME: allResourceIdsCreated.add(newID); } + @Override + protected PoxPayloadOut createInstance(String identifier) { + OrgAuthorityClient client = new OrgAuthorityClient(); + String displayName = "displayName-" + identifier; + PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance( + displayName, identifier, client.getCommonPartName()); + return multipart; + } + + @Override + protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) { + String headerLabel = new OrgAuthorityClient().getItemCommonPartName(); + String shortId = "testOrg"; + Map testOrgMap = new HashMap(); + testOrgMap.put(OrganizationJAXBSchema.SHORT_IDENTIFIER, shortId); + testOrgMap.put(OrganizationJAXBSchema.SHORT_NAME, TEST_ORG_SHORTNAME); + testOrgMap.put(OrganizationJAXBSchema.LONG_NAME, "The real official test organization"); + testOrgMap.put(OrganizationJAXBSchema.FOUNDING_DATE, "May 26, 1907"); + testOrgMap.put(OrganizationJAXBSchema.FOUNDING_PLACE, TEST_ORG_FOUNDING_PLACE); + + return OrgAuthorityClientUtils.createOrganizationInstance(identifier, testOrgMap, headerLabel); + } + /** * Creates the item. * diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java index 01cd11abe..99fe74494 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClient.java @@ -65,8 +65,14 @@ public class PersonAuthorityClient extends AuthorityWithContactsClientImpl personInfo, - String headerLabel){ + String personAuthRefName, + Map personInfo, + String headerLabel){ final Map> EMPTY_PERSON_REPEATABLES_INFO = new HashMap>(); return createPersonInstance(inAuthority, personAuthRefName, personInfo, diff --git a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java index c02b5a06e..b193296cd 100644 --- a/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java +++ b/services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityProxy.java @@ -43,7 +43,8 @@ public interface PersonAuthorityProxy extends AuthorityWithContactsProxy readItemList( @PathParam("csid") String vcsid, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); // List Items for a named authority matching a partial term or keywords. @Override @@ -53,5 +54,6 @@ public interface PersonAuthorityProxy extends AuthorityWithContactsProxy readItemListForNamedAuthority( @PathParam("specifier") String specifier, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); } diff --git a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java index e75b462d0..921ace619 100644 --- a/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java +++ b/services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java @@ -37,6 +37,7 @@ import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.client.ContactClient; import org.collectionspace.services.client.ContactClientUtils; +import org.collectionspace.services.common.vocabulary.AuthorityItemJAXBSchema; import org.collectionspace.services.contact.ContactsCommon; import org.collectionspace.services.contact.ContactsCommonList; @@ -215,6 +216,29 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl { //FIXM allResourceIdsCreated.add(newID); } + @Override + protected PoxPayloadOut createInstance(String identifier) { + PersonAuthorityClient client = new PersonAuthorityClient(); + String displayName = "displayName-" + identifier; + PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance( + displayName, identifier, client.getCommonPartName()); + return multipart; + } + + @Override + protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) { + String headerLabel = new PersonAuthorityClient().getItemCommonPartName(); + HashMap personInfo = new HashMap(); + String shortId = "johnWayneTempActor"; + personInfo.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false"); + personInfo.put(PersonJAXBSchema.DISPLAY_NAME, "John Wayne Temp"); + personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false"); + personInfo.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayneTemp"); + personInfo.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId); + + return PersonAuthorityClientUtils.createPersonInstance(parentCsid, identifier, personInfo, headerLabel); + } + /** * Creates the item. * diff --git a/services/vocabulary/client/.classpath b/services/vocabulary/client/.classpath index 808c067f9..425cd1620 100644 --- a/services/vocabulary/client/.classpath +++ b/services/vocabulary/client/.classpath @@ -1,309 +1,10 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + + + + + + + + diff --git a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java index 05fa3729b..e3f04d088 100644 --- a/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java +++ b/services/vocabulary/client/src/main/java/org/collectionspace/services/client/VocabularyClient.java @@ -71,10 +71,16 @@ public class VocabularyClient extends AuthorityClientImpl readItemList( @PathParam("csid") String vcsid, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); // List Items for a named authority matching a partial term or keywords. @Override @@ -54,5 +55,6 @@ public interface VocabularyProxy extends AuthorityProxy readItemListForNamedAuthority( @PathParam("specifier") String specifier, @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm, - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords); + @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, + @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); } diff --git a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java index a65b361d8..de103d1fb 100644 --- a/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java +++ b/services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java @@ -71,9 +71,9 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { private String knownResourceFullRefName = null; private String knownItemResourceId = null; private int nItemsToCreateInList = 5; - private List allResourceIdsCreated = new ArrayList(); - private Map allResourceItemIdsCreated = - new HashMap(); +// private List allResourceIdsCreated = new ArrayList(); +// private Map allResourceItemIdsCreated = +// new HashMap(); protected void setKnownResource(String id, String shortIdentifer, String refName, String fullRefName) { @@ -107,8 +107,7 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance( displayName, identifier, client.getCommonPartName()); return multipart; - } - + } // --------------------------------------------------------------- // CRUD tests : CREATE tests @@ -164,6 +163,17 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { } + @Override + protected PoxPayloadOut createItemInstance(String parentCsid, String identifier) { + String headerLabel = new VocabularyClient().getItemCommonPartName(); + HashMap vocabItemInfo = new HashMap(); + String shortId = createIdentifier(); + vocabItemInfo.put(AuthorityItemJAXBSchema.SHORT_IDENTIFIER, shortId); + vocabItemInfo.put(AuthorityItemJAXBSchema.DISPLAY_NAME, "display-" + shortId); + + return VocabularyClientUtils.createVocabularyItemInstance(identifier, vocabItemInfo, headerLabel); + } + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, dependsOnMethods = {"create"}) public void createItem(String testName) { @@ -1290,35 +1300,35 @@ public class VocabularyServiceTest extends AbstractServiceTestImpl { * at any point during testing, even if some of those resources * may be expected to be deleted by certain tests. */ - @AfterClass(alwaysRun = true) - public void cleanUp() { - String noTest = System.getProperty("noTestCleanup"); - if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { - if (logger.isDebugEnabled()) { - logger.debug("Skipping Cleanup phase ..."); - } - return; - } - if (logger.isDebugEnabled()) { - logger.debug("Cleaning up temporary resources created for testing ..."); - } - VocabularyClient client = new VocabularyClient(); - String vocabularyResourceId; - String vocabularyItemResourceId; - // Clean up vocabulary item resources. - for (Map.Entry entry : allResourceItemIdsCreated.entrySet()) { - vocabularyItemResourceId = entry.getKey(); - vocabularyResourceId = entry.getValue(); - // Note: Any non-success responses are ignored and not reported. - client.deleteItem(vocabularyResourceId, vocabularyItemResourceId).releaseConnection(); - } - // Clean up vocabulary resources. - for (String resourceId : allResourceIdsCreated) { - // Note: Any non-success responses are ignored and not reported. - client.delete(resourceId).releaseConnection(); - } - - } +// @AfterClass(alwaysRun = true) +// public void cleanUp() { +// String noTest = System.getProperty("noTestCleanup"); +// if (Boolean.TRUE.toString().equalsIgnoreCase(noTest)) { +// if (logger.isDebugEnabled()) { +// logger.debug("Skipping Cleanup phase ..."); +// } +// return; +// } +// if (logger.isDebugEnabled()) { +// logger.debug("Cleaning up temporary resources created for testing ..."); +// } +// VocabularyClient client = new VocabularyClient(); +// String vocabularyResourceId; +// String vocabularyItemResourceId; +// // Clean up vocabulary item resources. +// for (Map.Entry entry : allResourceItemIdsCreated.entrySet()) { +// vocabularyItemResourceId = entry.getKey(); +// vocabularyResourceId = entry.getValue(); +// // Note: Any non-success responses are ignored and not reported. +// client.deleteItem(vocabularyResourceId, vocabularyItemResourceId).releaseConnection(); +// } +// // Clean up vocabulary resources. +// for (String resourceId : allResourceIdsCreated) { +// // Note: Any non-success responses are ignored and not reported. +// client.delete(resourceId).releaseConnection(); +// } +// +// } // --------------------------------------------------------------- // Utility methods used by tests above -- 2.47.3