]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-4875 More work on resoruce to support getting info on one group, and fixing...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 29 Feb 2012 01:46:51 +0000 (17:46 -0800)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Wed, 29 Feb 2012 01:46:51 +0000 (17:46 -0800)
services/JaxRsServiceProvider/pom.xml
services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java
services/JaxRsServiceProvider/src/main/resources/log4j.properties
services/build.xml
services/common/src/main/cspace/config/services/tenants/tenant-bindings-proto.xml
services/pom.xml
services/servicegroup/client/pom.xml
services/servicegroup/client/src/test/java/org/collectionspace/services/client/test/ServiceGroupServiceTest.java
services/servicegroup/service/src/main/java/org/collectionspace/services/servicegroup/ServiceGroupResource.java

index 574af7305232bf6a59e4a6f3d3cc7d6b5591d73c..3820527a0255692db7734c392decfd6d0eebf2df 100644 (file)
             <artifactId>org.collectionspace.services.dimension.service</artifactId>\r
             <version>${project.version}</version>\r
         </dependency>\r
+        <dependency>\r
+            <groupId>org.collectionspace.services</groupId>\r
+            <artifactId>org.collectionspace.services.servicegroup.service</artifactId>\r
+            <version>${project.version}</version>\r
+        </dependency>\r
         <dependency>\r
             <groupId>org.collectionspace.services</groupId>\r
             <artifactId>org.collectionspace.services.contact.service</artifactId>\r
index 7509f23287175e7c77974a0e7307b97303fbe795..e09dd3c2e7fa4f6613541aa7c9d4f4a418ca0f77 100644 (file)
@@ -42,6 +42,7 @@ import org.collectionspace.services.relation.RelationResource;
 import org.collectionspace.services.report.ReportResource;
 import org.collectionspace.services.acquisition.AcquisitionResource;
 import org.collectionspace.services.dimension.DimensionResource;
+import org.collectionspace.services.servicegroup.ServiceGroupResource;
 import org.collectionspace.services.contact.ContactResource;
 import org.collectionspace.services.vocabulary.VocabularyResource;
 import org.collectionspace.services.organization.OrgAuthorityResource;
@@ -97,6 +98,7 @@ public class CollectionSpaceJaxRsApplication extends Application
         singletons.add(new AccountResource());
         singletons.add(new RoleResource());
         singletons.add(new PermissionResource());
+        singletons.add(new ServiceGroupResource());
 
         addResourceToMapAndSingletons(new VocabularyResource());
         addResourceToMapAndSingletons(new PersonAuthorityResource());
index 116cee8f79cb940967f952ac4390b4c525d2ef60..5e169f078876abc53b9c6a87c025bdae0158a8f3 100644 (file)
@@ -23,8 +23,9 @@ log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n
 #\r
 # CollectionSpace log levels\r
 #\r
-log4j.logger.org.collectionspace=INFO\r
+log4j.logger.org.collectionspace=DEBUG\r
 #log4j.logger.org.collectionspace.services.common.vocabulary.nuxeo=TRACE\r
+log4j.logger.org.collectionspace.services.authorization=TRACE\r
 log4j.logger.perf.collectionspace=ERROR\r
 \r
 log4j.logger.org.nuxeo=INFO\r
index 5cb7e9be87b7e5ac9ab4f40944e973fd87c62eb5..c298a97d9f861bec28c2f6165b2bcdd770993750 100644 (file)
         <ant antfile="id/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="note/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="collectionobject/build.xml" target="deploy" inheritAll="false"/>\r
+        <ant antfile="servicegroup/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="group/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="intake/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="imports/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="intake/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="imports/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="group/build.xml" target="undeploy" inheritAll="false"/>\r
+        <ant antfile="servicegroup/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="collectionobject/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="note/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="id/build.xml" target="undeploy" inheritAll="false"/>\r
         <ant antfile="relation/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="id/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="collectionobject/build.xml" target="dist" inheritAll="false"/>\r
+        <ant antfile="servicegroup/build.xml" target="deploy" inheritAll="false"/>\r
         <ant antfile="group/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="intake/build.xml" target="dist" inheritAll="false"/>\r
         <ant antfile="loanin/build.xml" target="dist" inheritAll="false"/>\r
index 7186877de44969f9b5702c30a401813ca493a126..382565066ff71832c74e8f1e0b4d7c5cfbf04636 100644 (file)
     </tenant:serviceBindings>  
     <!-- end id service meta-data -->
         
+    <!-- begin servicegroup service meta-data -->
+               <!-- Servicegroup is a task service that has no representation in the repo, 
+                                but provides tools like keyword search across many types of services. 
+                 -->
+    <tenant:serviceBindings id="servicegroups" name="servicegroups" type="utility" version="0.1">
+           <!-- other URI paths through which this service could be accessed -->
+    </tenant:serviceBindings>
+    <!-- end servicegroup service meta-data -->
+
     <!-- begin collectionobject service meta-data -->
     <tenant:serviceBindings id="CollectionObjects" name="CollectionObjects" type="object" version="0.1">
       <service:uriPath xmlns:service="http://collectionspace.org/services/common/service">/collectionobjects/*/workflow/</service:uriPath>
index 50393361a2eef6c58fdb0449f19151e7c01dc809..a4599ef5033aceaff70af11d6e7050d6205166b9 100644 (file)
@@ -50,6 +50,7 @@
         <module>person</module>
         <module>id</module>
         <module>collectionobject</module>
+        <module>servicegroup</module>
         <module>group</module>
         <module>intake</module>
         <module>loanin</module>
index c4ff91db4a38cc1fd4244f064309958e675d8b33..c5c1e5676272f207e8b844e4c80573bb00b3555d 100644 (file)
             <scope>test</scope>
         </dependency>
 <!-- CollectionSpace dependencies -->
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.authority.jaxb</artifactId>
-            <optional>true</optional>
-            <version>${project.version}</version>
-        </dependency>        
         <dependency>
             <groupId>org.collectionspace.services</groupId>
             <artifactId>org.collectionspace.services.jaxb</artifactId>
             <artifactId>org.collectionspace.services.servicegroup.jaxb</artifactId>
             <version>${project.version}</version>
         </dependency>
-        <dependency>
-            <groupId>org.collectionspace.services</groupId>
-            <artifactId>org.collectionspace.services.person.client</artifactId>
-            <version>${project.version}</version>
-        </dependency>
 <!-- External dependencies -->        
         <dependency>
             <groupId>org.testng</groupId>
index 26ef6c287c1b081b06dea3a10f47f88f043f7715..40f0f36a03ec59a99a83f3a06eeb176fa7603d1c 100644 (file)
@@ -27,6 +27,7 @@ import javax.ws.rs.core.Response;
 
 import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.CollectionSpaceClient;
+import org.collectionspace.services.client.PayloadInputPart;
 import org.collectionspace.services.client.ServiceGroupClient;
 import org.collectionspace.services.client.ServiceGroupProxy;
 import org.collectionspace.services.client.PayloadOutputPart;
@@ -48,12 +49,12 @@ import org.slf4j.LoggerFactory;
  * $LastChangedRevision:  $
  * $LastChangedDate:  $
  */
-public class ServiceGroupServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonList, ServicegroupsCommon> {
+public class ServiceGroupServiceTest extends BaseServiceTest<AbstractCommonList> {
 
     private final String CLASS_NAME = ServiceGroupServiceTest.class.getName();
     private final Logger logger = LoggerFactory.getLogger(CLASS_NAME);
     final String SERVICE_PATH_COMPONENT = "servicegroups";
-    private String knownResourceId = null;
+    private String readGroupName = "procedure";
 
     @Override
        public String getServicePathComponent() {
@@ -74,57 +75,90 @@ public class ServiceGroupServiceTest extends AbstractPoxServiceTestImpl<Abstract
     protected AbstractCommonList getCommonList(ClientResponse<AbstractCommonList> response) {
         return response.getEntity(AbstractCommonList.class);
     }
-
-    // ---------------------------------------------------------------
-    // Utility methods used by tests above
-    // ---------------------------------------------------------------
     
-    @Override
-    protected PoxPayloadOut createInstance(String identifier) {
-       ServiceGroupClient client = new ServiceGroupClient();
-       return createInstance(client.getCommonPartName(), identifier);
-    }
-    
-       @Override
-       protected PoxPayloadOut createInstance(String commonPartName,
-                       String identifier) {
-               return createServiceGroupInstance(identifier);
+       public ServicegroupsCommon extractCommonPartValue(CollectionSpaceClient client,
+                       ClientResponse<String> res) throws Exception {
+               
+               ServicegroupsCommon result = null;
+               PayloadInputPart payloadInputPart = extractPart(res, client.getCommonPartName());
+               if (payloadInputPart != null) {
+                       result = (ServicegroupsCommon) payloadInputPart.getBody();
+               }
+               Assert.assertNotNull(result,
+                               "Part or body of part " + client.getCommonPartName() + " was unexpectedly null.");
+               
+               return result;
        }
-    
-    private PoxPayloadOut createServiceGroupInstance(String uid) {
-        String identifier = "name-" + uid;
-        ServicegroupsCommon servicegroup = new ServicegroupsCommon();
-        servicegroup.setName(identifier);
-        PoxPayloadOut multipart = new PoxPayloadOut(ServiceGroupClient.SERVICE_PAYLOAD_NAME);
-        PayloadOutputPart commonPart = multipart.addPart(servicegroup, MediaType.APPLICATION_XML_TYPE);
-        commonPart.setLabel(new ServiceGroupClient().getCommonPartName());
 
-        if (logger.isDebugEnabled()) {
-            logger.debug("to be created, servicegroup common");
-            logger.debug(objectAsXmlString(servicegroup, ServicegroupsCommon.class));
-        }
-
-        return multipart;
+    protected PayloadInputPart extractPart(ClientResponse<String> res, String partLabel)
+            throws Exception {
+            if (getLogger().isDebugEnabled()) {
+               getLogger().debug("Reading part " + partLabel + " ...");
+            }
+            PoxPayloadIn input = new PoxPayloadIn(res.getEntity());
+            PayloadInputPart payloadInputPart = input.getPart(partLabel);
+            Assert.assertNotNull(payloadInputPart,
+                    "Part " + partLabel + " was unexpectedly null.");
+            return payloadInputPart;
     }
 
-       @Override
-       public void CRUDTests(String testName) {
-               // TODO Auto-generated method stub
-               
-       }
 
-       @Override
-       protected ServicegroupsCommon updateInstance(ServicegroupsCommon servicegroupsCommon) {
-               ServicegroupsCommon result = new ServicegroupsCommon();
-               
-        result.setName("updated-" + servicegroupsCommon.getName());
-               
-               return result;
-       }
+    @Test(dataProvider = "testName", dependsOnMethods = {"readList"})    
+    public void read(String testName) throws Exception {
+        // Perform setup.
+        setupRead();
 
-       @Override
-       protected void compareUpdatedInstances(ServicegroupsCommon original,
-                       ServicegroupsCommon updated) throws Exception {
-               Assert.assertEquals(updated.getName(), original.getName());
-       }
+        // Submit the request to the service and store the response.
+       CollectionSpaceClient client = this.getClientInstance();
+        ClientResponse<String> res = client.read(readGroupName);
+        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(testRequestType.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(testRequestType, statusCode));
+        Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+        ServicegroupsCommon output = extractCommonPartValue(client, res);
+        Assert.assertNotNull(output);
+
+        //
+        // Now compare with the expected field values
+        //
+        Assert.assertEquals(output.getName(), readGroupName, 
+                "Display name in updated object did not match submitted data.");
+    }
+    
+        
+    @Test(dataProvider = "testName")    
+    public void readList(String testName) throws Exception {
+        // Perform setup.
+        setupReadList();
+
+        // Submit the request to the service and store the response.
+        CollectionSpaceClient client = this.getClientInstance();
+        ClientResponse<AbstractCommonList> res = client.readList();
+        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(testRequestType.isValidStatusCode(statusCode),
+                invalidStatusCodeMessage(testRequestType, statusCode));
+        Assert.assertEquals(statusCode, testExpectedStatusCode);
+
+        // Optionally output additional data about list members for debugging.
+        boolean iterateThroughList = true;
+        if (iterateThroughList && logger.isTraceEnabled()) {
+               AbstractCommonListUtils.ListItemsInAbstractCommonList(list, getLogger(), testName);
+        }
+    }
+    
+    
 }
index b8f7a08d6f10bfa9f03beec9b958ccc2e17fb98e..a59bd93fa145cd536dedcd61fd6591407c857aaa 100644 (file)
@@ -33,6 +33,7 @@ import org.collectionspace.services.client.PoxPayloadOut;
 import org.collectionspace.services.client.ServiceGroupClient;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl;
+import org.collectionspace.services.common.ResourceBase;
 import org.collectionspace.services.common.ServiceMessages;
 import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.context.RemoteServiceContextFactory;
@@ -68,6 +69,10 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
         return ServiceGroupClient.SERVICE_NAME;
     }
 
+    public String getServicePathComponent(){
+        return ServiceGroupClient.SERVICE_NAME.toLowerCase();
+    }
+
     @Override
     protected String getVersionString() {
        final String lastChangeRevision = "$LastChangedRevision: 2108 $";
@@ -91,30 +96,37 @@ public class ServiceGroupResource extends AbstractCollectionSpaceResourceImpl {
 
 
     //======================= GET ====================================================
-    /*
+    // NOTE that csid is not a good name for the specifier, but if we name it anything else, 
+    // our AuthZ gets confused!!!
     @GET
-    @Path("{groupname}")
+    @Path("{csid}")
     public byte[] get(
             @Context UriInfo ui,
-            @PathParam("csid") String csid) {
+            @PathParam("csid") String groupname) {
         PoxPayloadOut result = null;
-        ensureCSID(csid, READ);
+        ensureCSID(groupname, ResourceBase.READ);
         try {
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext(queryParams);
-            result = Need to fetch info and prepare it.
+            ServiceContext<PoxPayloadIn, PoxPayloadOut> ctx = createServiceContext();
+            ServicegroupsCommon common = new ServicegroupsCommon();
+            common.setName(groupname);
+            String uri = "/" + getServicePathComponent() + "/" + groupname;
+            common.setUri(uri);
+            result = new PoxPayloadOut(getServicePathComponent());
+            result.addPart("ServicegroupsCommon", common);
+            
+            /* If we cannot get the result, then...
             if (result == null) {
                 Response response = Response.status(Response.Status.NOT_FOUND).entity(
                         ServiceMessages.READ_FAILED + ServiceMessages.resourceNotFoundMsg(csid)).type("text/plain").build();
                 throw new WebApplicationException(response);
             }
+            */
         } catch (Exception e) {
-            throw bigReThrow(e, ServiceMessages.READ_FAILED, csid);
+            throw bigReThrow(e, ServiceMessages.READ_FAILED, groupname);
         }
 
         return result.getBytes();
     }
-    */
 
 
     //======================= GET without specifier: List  =====================================