From: Aron Roberts Date: Thu, 21 Jul 2011 03:40:58 +0000 (+0000) Subject: CSPACE-4172,CSPACE-3332: Revised Intake service to return CommonList format for list... X-Git-Url: https://git.aero2k.de/?a=commitdiff_plain;h=612c100a77a0299c91a1d4268e296e91aca954b9;p=tmp%2Fjakarta-migration.git CSPACE-4172,CSPACE-3332: Revised Intake service to return CommonList format for list results. Also needed to remove a now-obsolete, perhaps experimental method from CollectionObjectResource that appears to have been intended to return related Intake records. --- diff --git a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java index b5afe101c..69ff10747 100644 --- a/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java +++ b/services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/CollectionObjectResource.java @@ -29,8 +29,6 @@ import org.collectionspace.services.client.CollectionObjectClient; import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.common.ResourceBase; import org.collectionspace.services.common.profile.Profiler; -import org.collectionspace.services.intake.IntakeResource; -import org.collectionspace.services.intake.IntakesCommonList; import org.collectionspace.services.jaxb.AbstractCommonList; import org.collectionspace.services.relation.RelationResource; import org.collectionspace.services.relation.RelationsCommonList; @@ -77,65 +75,6 @@ public class CollectionObjectResource extends ResourceBase { return CollectionobjectsCommon.class; } - - /** - * Gets the intakes common list. - * - * @param ui the ui - * @param csid the csid - * - * @return the intakes common list - */ - @GET - @Path("{csid}/intakes") - @Produces("application/xml") - public IntakesCommonList getIntakesCommonList(@Context UriInfo ui, - @PathParam("csid") String csid) { - IntakesCommonList result = null; - MultivaluedMap queryParams = ui.getQueryParameters(); - - try { - // - // Find all the intake-related relation records. - // - String subjectCsid = csid; - String predicate = RelationshipType.COLLECTIONOBJECT_INTAKE.value(); - String objectCsid = null; - RelationResource relationResource = new RelationResource(); - RelationsCommonList relationsCommonList = relationResource.getRelationList(queryParams, - subjectCsid, - null, /*subjectType*/ - predicate, - objectCsid, - null /*objectType*/); - - // - // Create an array of Intake csid's - // - List relationsListItems = relationsCommonList.getRelationListItem(); - List intakeCsidList = new ArrayList(); - for (RelationsCommonList.RelationListItem relationsListItem : relationsListItems) { - intakeCsidList.add(relationsListItem.getObjectCsid()); - } - - // - // Get a response list for the Intake records from the Intake resource - // - IntakeResource intakeResource = new IntakeResource(); - result = intakeResource.getIntakeList(intakeCsidList); - } catch (Exception e) { - if (logger.isDebugEnabled()) { - logger.debug("Caught exception in getIntakeList", e); - } - Response response = Response.status( - Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build(); - throw new WebApplicationException(response); - } - - return result; - } - - /** * Roundtrip. * diff --git a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java index 913b98508..f18038a73 100644 --- a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java +++ b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeClient.java @@ -1,14 +1,4 @@ -/** - * IntakeClient.java - * - * {Purpose of This Class} - * - * {Other Notes Relating to This Class (Optional)} - * - * $LastChangedBy: $ - * $LastChangedRevision: $ - * $LastChangedDate: $ - * +/** * This document is a part of the source code and related artifacts * for CollectionSpace, an open source collections management system * for museums and related institutions: @@ -16,57 +6,49 @@ * http://www.collectionspace.org * http://wiki.collectionspace.org * - * Copyright (c) 2009 {Contributing Institution} + * Copyright (c) 2009 Regents of the University of California * * Licensed under the Educational Community License (ECL), Version 2.0. * You may not use this file except in compliance with this License. * * You may obtain a copy of the ECL 2.0 License at * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; -import org.collectionspace.services.jaxb.AbstractCommonList; - /** - * A IntakeClient. - - * @version $Revision:$ - * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 + * IntakeClient + * + * $LastChangedRevision: $ + * $LastChangedDate: $ */ -public class IntakeClient extends AbstractPoxServiceClientImpl { - public static final String SERVICE_NAME = "intakes"; - public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; - public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; - public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; - public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; +public class IntakeClient extends AbstractCommonListPoxServiceClientImpl { - @Override - public String getServiceName() { - return SERVICE_NAME; - } - - @Override + public static final String SERVICE_NAME = "intakes"; + public static final String SERVICE_PATH_COMPONENT = SERVICE_NAME; + public static final String SERVICE_PATH = "/" + SERVICE_PATH_COMPONENT; + public static final String SERVICE_PATH_PROXY = SERVICE_PATH + "/"; + public static final String SERVICE_PAYLOAD_NAME = SERVICE_NAME; + + @Override + public String getServiceName() { + return SERVICE_NAME; + } + + @Override public String getServicePathComponent() { return SERVICE_PATH_COMPONENT; } - @Override - public Class getProxyClass() { - // TODO Auto-generated method stub - return IntakeProxy.class; - } - - /* - * Proxied service calls - */ - - /** - * @return - * @see org.collectionspace.services.client.IntakeProxy#getIntake() - */ - public ClientResponse readList() { - return getProxy().readList(); - } + @Override + public Class getProxyClass() { + // TODO Auto-generated method stub + return IntakeProxy.class; + } } diff --git a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java index 3ba64c3a9..beb1e9a8d 100644 --- a/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java +++ b/services/intake/client/src/main/java/org/collectionspace/services/client/IntakeProxy.java @@ -1,14 +1,4 @@ -/** - * IntakeProxy.java - * - * {Purpose of This Class} - * - * {Other Notes Relating to This Class (Optional)} - * - * $LastChangedBy: $ - * $LastChangedRevision: $ - * $LastChangedDate: $ - * +/** * This document is a part of the source code and related artifacts * for CollectionSpace, an open source collections management system * for museums and related institutions: @@ -16,53 +6,34 @@ * http://www.collectionspace.org * http://wiki.collectionspace.org * - * Copyright © 2009 {Contributing Institution} + * Copyright (c) 2009 Regents of the University of California * * Licensed under the Educational Community License (ECL), Version 2.0. * You may not use this file except in compliance with this License. * * You may obtain a copy of the ECL 2.0 License at * https://source.collectionspace.org/collection-space/LICENSE.txt + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. */ package org.collectionspace.services.client; -import org.jboss.resteasy.client.ClientResponse; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -import org.collectionspace.services.client.workflow.WorkflowClient; -import org.collectionspace.services.jaxb.AbstractCommonList; /** - * @version $Revision:$ - * FIXME: http://issues.collectionspace.org/browse/CSPACE-1684 + * IntakeProxy + * + * $LastChangedRevision: $ + * $LastChangedDate: $ */ @Path(IntakeClient.SERVICE_PATH_PROXY) @Produces({"application/xml"}) @Consumes({"application/xml"}) -public interface IntakeProxy extends CollectionSpacePoxProxy { - /** - * Read list. - * - * @return the client response - */ - @GET - @Produces({"application/xml"}) - ClientResponse readList(); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse readIncludeDeleted( - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); - - @Override - @GET - @Produces({"application/xml"}) - ClientResponse keywordSearchIncludeDeleted( - @QueryParam(IQueryManager.SEARCH_TYPE_KEYWORDS_KW) String keywords, - @QueryParam(WorkflowClient.WORKFLOW_QUERY_NONDELETED) String includeDeleted); +public interface IntakeProxy extends CollectionSpaceCommonListPoxProxy { } diff --git a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java index 1e0d80635..766d0c5b9 100644 --- a/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java +++ b/services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeServiceTest.java @@ -40,18 +40,14 @@ import org.collectionspace.services.intake.IntakesCommon; import org.collectionspace.services.jaxb.AbstractCommonList; import org.jboss.resteasy.client.ClientResponse; -//import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; -//import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; -//import org.jboss.resteasy.plugins.providers.multipart.OutputPart; import org.testng.Assert; -//import org.testng.annotations.AfterClass; import org.testng.annotations.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +// FIXME: http://issues.collectionspace.org/browse/CSPACE-1685 /** - * FIXME: http://issues.collectionspace.org/browse/CSPACE-1685 * IntakeServiceTest, carries out tests against a * deployed and running Intake Service. * @@ -59,41 +55,43 @@ import org.slf4j.LoggerFactory; * $LastChangedDate$ */ public class IntakeServiceTest extends AbstractServiceTestImpl { - /** The logger. */ + + /** The logger. */ private final String CLASS_NAME = IntakeServiceTest.class.getName(); private final Logger logger = LoggerFactory.getLogger(IntakeServiceTest.class); - /** The known resource id. */ private String knownResourceId = null; - + @Override protected CollectionSpaceClient getClientInstance() { - return new IntakeClient(); + return new IntakeClient(); } - - @Override - protected String getServiceName() { - return IntakeClient.SERVICE_NAME; - } - + + @Override + protected String getServiceName() { + return IntakeClient.SERVICE_NAME; + } + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) */ @Override - protected AbstractCommonList getAbstractCommonList( - ClientResponse response) { - return response.getEntity(AbstractCommonList.class); + protected AbstractCommonList getAbstractCommonList( + ClientResponse response) { + return response.getEntity(AbstractCommonList.class); } - + // --------------------------------------------------------------- // CRUD tests : CREATE tests // --------------------------------------------------------------- + // Success outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.ServiceTest#create(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class) public void create(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -118,7 +116,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Specifically: // Does it fall within the set of valid status codes? // Does it exactly match the expected status code? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -127,13 +125,13 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Store the ID returned from the first resource created // for additional tests below. - if (knownResourceId == null){ + if (knownResourceId == null) { knownResourceId = extractId(res); if (logger.isDebugEnabled()) { logger.debug(testName + ": knownResourceId=" + knownResourceId); } } - + // Store the IDs from every resource created by tests, // so they can be deleted after tests have been run. allResourceIdsCreated.add(extractId(res)); @@ -143,23 +141,24 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createList(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"create"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create"}) public void createList(String testName) throws Exception { - for(int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { create(testName); } } // Failure outcomes // Placeholders until the three tests below can be uncommented. + // See Issue CSPACE-401. /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#createWithEmptyEntityBody(java.lang.String) */ @Override public void createWithEmptyEntityBody(String testName) throws Exception { - //Should this really be empty? + //Should this really be empty? } /* (non-Javadoc) @@ -167,7 +166,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { */ @Override public void createWithMalformedXml(String testName) throws Exception { - //Should this really be empty? + //Should this really be empty? } /* (non-Javadoc) @@ -175,108 +174,110 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { */ @Override public void createWithWrongXmlSchema(String testName) throws Exception { - //Should this really be empty? + //Should this really be empty? } /* @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - dependsOnMethods = {"create", "testSubmitRequest"}) + dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithEmptyEntityBody(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - } - // Perform setup. - setupCreateWithEmptyEntityBody(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("createWithEmptyEntityBody url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); } - + // Perform setup. + setupCreateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - dependsOnMethods = {"create", "testSubmitRequest"}) + dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithMalformedXml(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - } - // Perform setup. - setupCreateWithMalformedXml(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; // Constant from base class. - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); } - + // Perform setup. + setupCreateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - dependsOnMethods = {"create", "testSubmitRequest"}) + dependsOnMethods = {"create", "testSubmitRequest"}) public void createWithWrongXmlSchema(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - } - // Perform setup. - setupCreateWithWrongXmlSchema(testName, logger); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getServiceRootURL(); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupCreateWithWrongXmlSchema(testName, logger); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ - + // --------------------------------------------------------------- // CRUD tests : READ tests // --------------------------------------------------------------- + // Success outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#read(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"create"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create"}) public void read(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -292,7 +293,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -303,7 +304,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); IntakesCommon intakeCommons = null; if (payloadInputPart != null) { - intakeCommons = (IntakesCommon) payloadInputPart.getBody(); + intakeCommons = (IntakesCommon) payloadInputPart.getBody(); } // IntakesCommon intake = (IntakesCommon) extractPart(input, // client.getCommonPartName(), IntakesCommon.class); @@ -312,12 +313,12 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Verify the number and contents of values in repeatable fields, // as created in the instance record used for testing. List entryMethods = - intakeCommons.getEntryMethods().getEntryMethod(); + intakeCommons.getEntryMethods().getEntryMethod(); Assert.assertTrue(entryMethods.size() > 0); Assert.assertNotNull(entryMethods.get(0)); List fieldCollectionEventNames = - intakeCommons.getFieldCollectionEventNames().getFieldCollectionEventName(); + intakeCommons.getFieldCollectionEventNames().getFieldCollectionEventName(); Assert.assertTrue(fieldCollectionEventNames.size() > 0); Assert.assertNotNull(fieldCollectionEventNames.get(0)); @@ -331,22 +332,23 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { Assert.assertNotNull(currentLocationGroup.getCurrentLocationNote()); // Check the values of fields containing Unicode UTF-8 (non-Latin-1) characters. - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug("UTF-8 data sent=" + getUTF8DataFragment() + "\n" + "UTF-8 data received=" + intakeCommons.getEntryNote()); - } + } Assert.assertEquals(intakeCommons.getEntryNote(), getUTF8DataFragment(), "UTF-8 data retrieved '" + intakeCommons.getEntryNote() + "' does not match expected data '" + getUTF8DataFragment()); } // Failure outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readNonExistent(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"read"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"read"}) public void readNonExistent(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -362,7 +364,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -373,13 +375,15 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // CRUD tests : READ_LIST tests // --------------------------------------------------------------- + // Success outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#readList(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"createList", "read"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"createList", "read"}) public void readList(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -396,7 +400,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -404,32 +408,28 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); // Optionally output additional data about list members for debugging. - boolean iterateThroughList = false; - if(iterateThroughList && logger.isDebugEnabled()){ - List items = - list.getListItem(); - int i = 0; - for(AbstractCommonList.ListItem item : items){ - logger.debug(testName + ": list-item[" + i + "] " + - item.toString()); - i++; - } + boolean iterateThroughList = true; + if (iterateThroughList && logger.isDebugEnabled()) { + ListItemsInAbstractCommonList(list, logger, testName); } } // Failure outcomes // None at present. + // --------------------------------------------------------------- // CRUD tests : UPDATE tests // --------------------------------------------------------------- + // Success outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#update(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"read"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"read"}) public void update(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -441,20 +441,20 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Retrieve the contents of a resource to update. IntakeClient client = new IntakeClient(); ClientResponse res = client.read(knownResourceId); - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": read status = " + res.getStatus()); } Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE); - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug("got object to update with ID: " + knownResourceId); } PoxPayloadIn input = new PoxPayloadIn(res.getEntity()); PayloadInputPart payloadInputPart = input.getPart(client.getCommonPartName()); IntakesCommon intakeCommons = null; if (payloadInputPart != null) { - intakeCommons = (IntakesCommon) payloadInputPart.getBody(); - } + intakeCommons = (IntakesCommon) payloadInputPart.getBody(); + } // IntakesCommon intake = (IntakesCommon) extractPart(input, // client.getCommonPartName(), IntakesCommon.class); Assert.assertNotNull(intakeCommons); @@ -462,7 +462,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Update the content of this resource. intakeCommons.setEntryNumber("updated-" + intakeCommons.getEntryNumber()); intakeCommons.setEntryDate("updated-" + intakeCommons.getEntryDate()); - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug("to be updated object"); logger.debug(objectAsXmlString(intakeCommons, IntakesCommon.class)); } @@ -488,22 +488,22 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { res = client.update(knownResourceId, output); int statusCode = res.getStatus(); // Check the status code of the response: does it match the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); - input = new PoxPayloadIn(res.getEntity()); + input = new PoxPayloadIn(res.getEntity()); IntakesCommon updatedIntake = (IntakesCommon) extractPart(input, - client.getCommonPartName(), IntakesCommon.class); + client.getCommonPartName(), IntakesCommon.class); Assert.assertNotNull(updatedIntake); Assert.assertEquals(updatedIntake.getEntryDate(), - intakeCommons.getEntryDate(), + intakeCommons.getEntryDate(), "Data in updated object did not match submitted data."); currentLocationGroupList = updatedIntake.getCurrentLocationGroupList(); @@ -516,10 +516,10 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { currentLocationGroups.get(0).getCurrentLocationNote(), "Data in updated object did not match submitted data."); - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug("UTF-8 data sent=" + intakeCommons.getEntryNote() + "\n" + "UTF-8 data received=" + updatedIntake.getEntryNote()); - } + } Assert.assertTrue(updatedIntake.getEntryNote().contains(getUTF8DataFragment()), "UTF-8 data retrieved '" + updatedIntake.getEntryNote() + "' does not contain expected data '" + getUTF8DataFragment()); @@ -531,117 +531,118 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Failure outcomes // Placeholders until the three tests below can be uncommented. + // See Issue CSPACE-401. /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithEmptyEntityBody(java.lang.String) */ @Override public void updateWithEmptyEntityBody(String testName) throws Exception { - //Should this really be empty? + //Should this really be empty? } - + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String) */ @Override public void updateWithMalformedXml(String testName) throws Exception { - //Should this really be empty? + //Should this really be empty? } - + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithWrongXmlSchema(java.lang.String) */ @Override public void updateWithWrongXmlSchema(String testName) throws Exception { - //Should this really be empty? + //Should this really be empty? } /* @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - dependsOnMethods = {"create", "update", "testSubmitRequest"}) + dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithEmptyEntityBody(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - } - // Perform setup. - setupUpdateWithEmptyEntityBody(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = ""; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); } - + // Perform setup. + setupUpdateWithEmptyEntityBody(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - dependsOnMethods = {"create", "update", "testSubmitRequest"}) + dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithMalformedXml(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - } - // Perform setup. - setupUpdateWithMalformedXml(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = MALFORMED_XML_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); } - + // Perform setup. + setupUpdateWithMalformedXml(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + @Override @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, - dependsOnMethods = {"create", "update", "testSubmitRequest"}) + dependsOnMethods = {"create", "update", "testSubmitRequest"}) public void updateWithWrongXmlSchema(String testName) throws Exception { - - if (logger.isDebugEnabled()) { - logger.debug(testBanner(testName, CLASS_NAME)); - } - // Perform setup. - setupUpdateWithWrongXmlSchema(); - - // Submit the request to the service and store the response. - String method = REQUEST_TYPE.httpMethodName(); - String url = getResourceURL(knownResourceId); - String mediaType = MediaType.APPLICATION_XML; - final String entity = WRONG_XML_SCHEMA_DATA; - int statusCode = submitRequest(method, url, mediaType, entity); - - // Check the status code of the response: does it match - // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug(testName + ": url=" + url + - " status=" + statusCode); - } - Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), - invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); - Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + if (logger.isDebugEnabled()) { + logger.debug(testBanner(testName, CLASS_NAME)); + } + // Perform setup. + setupUpdateWithWrongXmlSchema(); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } */ @@ -649,8 +650,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateNonExistent(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"update", "testSubmitRequest"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"update", "testSubmitRequest"}) public void updateNonExistent(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -670,7 +671,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -681,13 +682,15 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // CRUD tests : DELETE tests // --------------------------------------------------------------- + // Success outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#delete(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) public void delete(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -703,21 +706,22 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); } - + // Failure outcomes + /* (non-Javadoc) * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#deleteNonExistent(java.lang.String) */ @Override - @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, - dependsOnMethods = {"delete"}) + @Test(dataProvider = "testName", dataProviderClass = AbstractServiceTestImpl.class, + dependsOnMethods = {"delete"}) public void deleteNonExistent(String testName) throws Exception { if (logger.isDebugEnabled()) { @@ -733,7 +737,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug(testName + ": status = " + statusCode); } Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), @@ -744,6 +748,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility tests : tests of code used in tests above // --------------------------------------------------------------- + /** * Tests the code for manually submitting data that is used by several * of the methods above. @@ -761,9 +766,9 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // Check the status code of the response: does it match // the expected response(s)? - if(logger.isDebugEnabled()){ - logger.debug("testSubmitRequest: url=" + url + - " status=" + statusCode); + if (logger.isDebugEnabled()) { + logger.debug("testSubmitRequest: url=" + url + + " status=" + statusCode); } Assert.assertEquals(statusCode, EXPECTED_STATUS); @@ -772,6 +777,7 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { // --------------------------------------------------------------- // Utility methods used by tests above // --------------------------------------------------------------- + /* (non-Javadoc) * @see org.collectionspace.services.client.test.BaseServiceTest#getServicePathComponent() */ @@ -803,8 +809,8 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { * @return the multipart output */ private PoxPayloadOut createIntakeInstance(String entryNumber, - String entryDate, - String depositor) { + String entryDate, + String depositor) { IntakesCommon intake = new IntakesCommon(); intake.setEntryNumber(entryNumber); intake.setEntryDate(entryDate); @@ -837,15 +843,14 @@ public class IntakeServiceTest extends AbstractServiceTestImpl { PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME); PayloadOutputPart commonPart = - multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); + multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE); commonPart.setLabel(new IntakeClient().getCommonPartName()); - if(logger.isDebugEnabled()){ + if (logger.isDebugEnabled()) { logger.debug("to be created, intake common"); logger.debug(objectAsXmlString(intake, IntakesCommon.class)); } return multipart; } - } diff --git a/services/intake/jaxb/src/main/resources/intakes-common.xsd b/services/intake/jaxb/src/main/resources/intakes-common.xsd index fe567f4bb..a088782e2 100644 --- a/services/intake/jaxb/src/main/resources/intakes-common.xsd +++ b/services/intake/jaxb/src/main/resources/intakes-common.xsd @@ -151,43 +151,5 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java index 8d65cb963..910ee0bbc 100644 --- a/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java +++ b/services/intake/service/src/main/java/org/collectionspace/services/intake/IntakeResource.java @@ -23,27 +23,14 @@ */ package org.collectionspace.services.intake; -import org.collectionspace.services.client.IQueryManager; import org.collectionspace.services.client.IntakeClient; -import org.collectionspace.services.client.PoxPayloadIn; -import org.collectionspace.services.client.PoxPayloadOut; import org.collectionspace.services.common.ResourceBase; -import org.collectionspace.services.common.ServiceMessages; -import org.collectionspace.services.common.context.ServiceContext; -import org.collectionspace.services.common.document.DocumentHandler; -import org.collectionspace.services.jaxb.AbstractCommonList; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import javax.ws.rs.Consumes; -import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.core.Context; -import javax.ws.rs.core.MultivaluedMap; -import javax.ws.rs.core.UriInfo; -import java.util.List; @Path(IntakeClient.SERVICE_PATH) @Consumes("application/xml") @@ -68,27 +55,4 @@ public class IntakeResource extends ResourceBase { return IntakesCommon.class; } - public IntakesCommonList getIntakeList(List csidList) { - IntakesCommonList intakeObjectList = new IntakesCommonList(); - try { - ServiceContext ctx = createServiceContext(); - DocumentHandler handler = createDocumentHandler(ctx); - getRepositoryClient(ctx).get(ctx, csidList, handler); - intakeObjectList = (IntakesCommonList) handler.getCommonPartList(); - } catch (Exception e) { - throw bigReThrow(e, ServiceMessages.LIST_FAILED); - } - return intakeObjectList; - } - - @GET - @Path("/search") - @Produces("application/xml") - @Deprecated - public AbstractCommonList keywordsSearchIntakes(@Context UriInfo ui, - @QueryParam (IQueryManager.SEARCH_TYPE_KEYWORDS) String keywords) { - MultivaluedMap queryParams = ui.getQueryParameters(); - return search(queryParams, keywords); - } - }