]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA - Ported Authority cleanup to Location. This also addresses a number of missin...
authorPatrick Schmitz <pschmitz@berkeley.edu>
Sat, 3 Jul 2010 19:24:50 +0000 (19:24 +0000)
committerPatrick Schmitz <pschmitz@berkeley.edu>
Sat, 3 Jul 2010 19:24:50 +0000 (19:24 +0000)
24 files changed:
services/common/src/main/java/org/collectionspace/services/common/vocabulary/AuthorityJAXBSchema.java
services/location/3rdparty/nuxeo-platform-cs-location/src/main/resources/schemas/locations_common.xsd
services/location/client/src/main/java/org/collectionspace/services/client/LocationAuthorityClientUtils.java
services/location/client/src/test/java/org/collectionspace/services/client/test/LocationAuthorityServiceTest.java
services/location/jaxb/pom.xml
services/location/jaxb/src/main/java/org/collectionspace/services/LocationAuthorityJAXBSchema.java [deleted file]
services/location/jaxb/src/main/java/org/collectionspace/services/LocationAuthorityListItemJAXBSchema.java [deleted file]
services/location/jaxb/src/main/java/org/collectionspace/services/LocationJAXBSchema.java
services/location/jaxb/src/main/java/org/collectionspace/services/LocationListItemJAXBSchema.java [deleted file]
services/location/jaxb/src/main/resources/location_common.xsd
services/location/service/src/main/java/org/collectionspace/services/location/LocationAuthorityResource.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationAuthorityDocumentModelHandler.java
services/location/service/src/main/java/org/collectionspace/services/location/nuxeo/LocationDocumentModelHandler.java
services/organization/3rdparty/nuxeo-platform-cs-organization/src/main/resources/schemas/organizations_common.xsd
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityServiceTest.java
services/organization/jaxb/src/main/java/org/collectionspace/services/OrganizationJAXBSchema.java
services/organization/jaxb/src/main/resources/organization_common.xsd
services/organization/service/src/main/java/org/collectionspace/services/organization/OrgAuthorityResource.java
services/person/3rdparty/nuxeo-platform-cs-person/src/main/resources/schemas/persons_common.xsd
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/person/jaxb/src/main/java/org/collectionspace/services/PersonJAXBSchema.java
services/person/jaxb/src/main/resources/person_common.xsd
services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/src/main/resources/schemas/vocabularyitems_common.xsd
services/vocabulary/jaxb/src/main/resources/vocabularyitem_common.xsd

index 456ea65e03467e299fd63e97f529dafc4d71ae63..edbe2ef95dd18cf42dea0a9d7adee24911781f0c 100644 (file)
@@ -33,6 +33,7 @@ public interface AuthorityJAXBSchema {
        final static String REF_NAME = "refName";\r
        final static String VOCAB_TYPE = "vocabType";\r
        final static String CSID = "csid";\r
+    final static String TERM_STATUS = "termStatus";\r
 }\r
 \r
 \r
index 0bc24ef7648b62f21a4e36fec21d646ee1e9c685..54e76a1c913b8df36d13cfd272689fb1e8e89d60 100644 (file)
@@ -25,6 +25,7 @@
     <xs:element name="inAuthority" type="xs:string" />
                <xs:element name="shortIdentifier" type="xs:string"/>
     <xs:element name="refName" type="xs:string"/>
+    <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="displayNameComputed" type="xs:boolean"/>
     <xs:element name="name" type="xs:string"/>
@@ -32,7 +33,6 @@
     <xs:element name="conditionNoteDate" type="xs:string"/>
     <xs:element name="securityNote" type="xs:string"/>
     <xs:element name="locationType" type="xs:string"/>
-    <xs:element name="status" type="xs:string"/>
 
 </xs:schema>
 
index 09ca4808eb0371c0693a022ffc80c79562d5bcbb..ae878daa891520c17417270efe3ae2946be1a40d 100644 (file)
@@ -83,8 +83,8 @@ public class LocationAuthorityClientUtils {
                location.setSecurityNote(value);\r
         if((value = (String)locationInfo.get(LocationJAXBSchema.LOCATION_TYPE))!=null)\r
                location.setLocationType(value);\r
-        if((value = (String)locationInfo.get(LocationJAXBSchema.STATUS))!=null)\r
-               location.setStatus(value);\r
+        if((value = (String)locationInfo.get(LocationJAXBSchema.TERM_STATUS))!=null)\r
+               location.setTermStatus(value);\r
         MultipartOutput multipart = new MultipartOutput();\r
         OutputPart commonPart = multipart.addPart(location,\r
             MediaType.APPLICATION_XML_TYPE);\r
@@ -132,23 +132,28 @@ public class LocationAuthorityClientUtils {
        MultipartOutput multipart = \r
                createLocationInstance( vcsid, locationAuthorityRefName,\r
                        locationMap, client.getItemCommonPartName() );\r
+       String newID = null;\r
        ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
+        try {\r
+               int statusCode = res.getStatus();\r
+       \r
+               if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+                       throw new RuntimeException("Could not create Item: \""\r
+                                       +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
+                                       +"\" in locationAuthority: \"" + locationAuthorityRefName\r
+                                       +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+               }\r
+               if(statusCode != EXPECTED_STATUS_CODE) {\r
+                       throw new RuntimeException("Unexpected Status when creating Item: \""\r
+                                       +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
+                                       +"\" in locationAuthority: \"" + locationAuthorityRefName +"\", Status:"+ statusCode);\r
+               }\r
+               newID = extractId(res);\r
+        } finally {\r
+               res.releaseConnection();\r
+        }\r
 \r
-       int statusCode = res.getStatus();\r
-\r
-       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
-               throw new RuntimeException("Could not create Item: \""\r
-                               +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
-                               +"\" in locationAuthority: \"" + locationAuthorityRefName\r
-                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
-       }\r
-       if(statusCode != EXPECTED_STATUS_CODE) {\r
-               throw new RuntimeException("Unexpected Status when creating Item: \""\r
-                               +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
-                               +"\" in locationAuthority: \"" + locationAuthorityRefName +"\", Status:"+ statusCode);\r
-       }\r
-\r
-       return extractId(res);\r
+       return newID;\r
     }\r
 \r
     public static MultipartOutput createLocationInstance(\r
@@ -175,21 +180,26 @@ public class LocationAuthorityClientUtils {
        \r
        MultipartOutput multipart = \r
                createLocationInstance( commonPartXML, client.getItemCommonPartName() );\r
+       String newID = null;\r
        ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
+        try {\r
+               int statusCode = res.getStatus();\r
+       \r
+               if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+                       throw new RuntimeException("Could not create Item: \""+commonPartXML\r
+                                       +"\" in locationAuthority: \"" + vcsid\r
+                                       +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+               }\r
+               if(statusCode != EXPECTED_STATUS_CODE) {\r
+                       throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML\r
+                                       +"\" in locationAuthority: \"" + vcsid +"\", Status:"+ statusCode);\r
+               }\r
+               newID = extractId(res);\r
+        } finally {\r
+               res.releaseConnection();\r
+        }\r
 \r
-       int statusCode = res.getStatus();\r
-\r
-       if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
-               throw new RuntimeException("Could not create Item: \""+commonPartXML\r
-                               +"\" in locationAuthority: \"" + vcsid\r
-                               +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
-       }\r
-       if(statusCode != EXPECTED_STATUS_CODE) {\r
-               throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML\r
-                               +"\" in locationAuthority: \"" + vcsid +"\", Status:"+ statusCode);\r
-       }\r
-\r
-       return extractId(res);\r
+       return newID;\r
     }\r
     \r
     /**\r
index 776d270ef806b8af898f27c89cb4be7b79017ea4..e6de389dd040765056c7dbdad6a6b3bf34f8470f 100644 (file)
@@ -162,23 +162,28 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
        MultipartOutput multipart = 
             LocationAuthorityClientUtils.createLocationAuthorityInstance(
            displayName, shortId, client.getCommonPartName());
+       String newID = null;
         ClientResponse<Response> res = client.create(multipart);
-        int statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match
-        // the expected response(s)?
-        //
-        // Specifically:
-        // Does it fall within the set of valid status codes?
-        // Does it exactly match the expected status code?
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match
+               // the expected response(s)?
+               //
+               // Specifically:
+               // Does it fall within the set of valid status codes?
+               // Does it exactly match the expected status code?
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+       
+               newID = LocationAuthorityClientUtils.extractId(res);
+        } finally {
+               res.releaseConnection();
         }
-        Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
-        String newID = LocationAuthorityClientUtils.extractId(res);
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
@@ -231,7 +236,7 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
         shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
         shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
-        shelf1Map.put(LocationJAXBSchema.STATUS, TEST_STATUS);
+        shelf1Map.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
         
         String newID = LocationAuthorityClientUtils.createItemInAuthority(vcsid,
                        authRefName, shelf1Map, client );
@@ -332,25 +337,31 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
+       String newID = null;
         ClientResponse<MultipartInput> res = client.read(knownResourceId);
-        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);
-        //FIXME: remove the following try catch once Aron fixes signatures
         try {
-            MultipartInput input = (MultipartInput) res.getEntity();
-            LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
-                    client.getCommonPartName(), LocationauthoritiesCommon.class);
-            Assert.assertNotNull(locationAuthority);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+               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);
+               //FIXME: remove the following try catch once Aron fixes signatures
+               try {
+                   MultipartInput input = (MultipartInput) res.getEntity();
+                   LocationauthoritiesCommon locationAuthority = 
+                       (LocationauthoritiesCommon) extractPart(input,
+                           client.getCommonPartName(), LocationauthoritiesCommon.class);
+                   Assert.assertNotNull(locationAuthority);
+               } catch (Exception e) {
+                   throw new RuntimeException(e);
+               }
+        } finally {
+               res.releaseConnection();
         }
     }
 
@@ -373,24 +384,28 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res = client.readByName(knownResourceShortIdentifer);
-        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);
-        //FIXME: remove the following try catch once Aron fixes signatures
         try {
-            MultipartInput input = (MultipartInput) res.getEntity();
-            LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
-                    client.getCommonPartName(), LocationauthoritiesCommon.class);
-            Assert.assertNotNull(locationAuthority);
-        } catch (Exception e) {
-            throw new RuntimeException(e);
+               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);
+               //FIXME: remove the following try catch once Aron fixes signatures
+               try {
+                   MultipartInput input = (MultipartInput) res.getEntity();
+                   LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+                           client.getCommonPartName(), LocationauthoritiesCommon.class);
+                   Assert.assertNotNull(locationAuthority);
+               } catch (Exception e) {
+                   throw new RuntimeException(e);
+               }
+        } finally {
+               res.releaseConnection();
         }
     }
 
@@ -414,28 +429,32 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        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);
-
-        // Check whether we've received a location.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        LocationsCommon location = (LocationsCommon) extractPart(input,
-                client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(location);
-        boolean showFull = true;
-        if(showFull && logger.isDebugEnabled()){
-            logger.debug(testName + ": returned payload:");
-            logger.debug(objectAsXmlString(location, LocationsCommon.class));
-        }
-        Assert.assertEquals(location.getInAuthority(), knownResourceId);
+        try {
+               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);
+       
+               // Check whether we've received a location.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               LocationsCommon location = (LocationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(location);
+               boolean showFull = true;
+               if(showFull && logger.isDebugEnabled()){
+                   logger.debug(testName + ": returned payload:");
+                   logger.debug(objectAsXmlString(location, LocationsCommon.class));
+               }
+               Assert.assertEquals(location.getInAuthority(), knownResourceId);
+           } finally {
+               res.releaseConnection();
+           }
 
     }
 
@@ -458,98 +477,104 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        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);
-
-        // Check whether location has expected displayName.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        LocationsCommon location = (LocationsCommon) extractPart(input,
-                client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(location);
-        String displayName = location.getDisplayName();
-        // Make sure displayName matches computed form
-        String expectedDisplayName = 
-            LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
-        Assert.assertNotNull(displayName, expectedDisplayName);
-        
-        // Update the shortName and verify the computed name is updated.
-        location.setCsid(null);
-        location.setDisplayNameComputed(true);
-        location.setName("updated-" + TEST_NAME);
-        expectedDisplayName = 
-            LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getItemCommonPartName());
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        LocationsCommon updatedLocation =
-                (LocationsCommon) extractPart(input,
-                        client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(updatedLocation);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedLocation.getName(), location.getName(),
-            "Updated ForeName in Location did not match submitted data.");
-        // Verify that the updated resource computes the right displayName.
-        Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
-            "Updated ForeName in Location not reflected in computed DisplayName.");
-
-        // Now Update the displayName, not computed and verify the computed name is overriden.
-        location.setDisplayNameComputed(false);
-        expectedDisplayName = "TestName";
-        location.setDisplayName(expectedDisplayName);
-
-        // Submit the updated resource to the service and store the response.
-        output = new MultipartOutput();
-        commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getItemCommonPartName());
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        updatedLocation =
-                (LocationsCommon) extractPart(input,
-                        client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(updatedLocation);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
-                "Updated displayNameComputed in Location did not match submitted data.");
-        // Verify that the updated resource computes the right displayName.
-        Assert.assertEquals(updatedLocation.getDisplayName(),
-                       expectedDisplayName,
-                "Updated DisplayName (not computed) in Location not stored.");
+        try {
+               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);
+       
+               // Check whether location has expected displayName.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               LocationsCommon location = (LocationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(location);
+               String displayName = location.getDisplayName();
+               // Make sure displayName matches computed form
+               String expectedDisplayName = 
+                   LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
+               Assert.assertNotNull(displayName, expectedDisplayName);
+               
+               // Update the shortName and verify the computed name is updated.
+               location.setCsid(null);
+               location.setDisplayNameComputed(true);
+               location.setName("updated-" + TEST_NAME);
+               expectedDisplayName = 
+                   LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getItemCommonPartName());
+               res.releaseConnection();
+               res = client.updateItem(knownResourceId, knownItemResourceId, output);
+               statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               LocationsCommon updatedLocation =
+                       (LocationsCommon) extractPart(input,
+                               client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(updatedLocation);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedLocation.getName(), location.getName(),
+                   "Updated ForeName in Location did not match submitted data.");
+               // Verify that the updated resource computes the right displayName.
+               Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
+                   "Updated ForeName in Location not reflected in computed DisplayName.");
+       
+               // Now Update the displayName, not computed and verify the computed name is overriden.
+               location.setDisplayNameComputed(false);
+               expectedDisplayName = "TestName";
+               location.setDisplayName(expectedDisplayName);
+       
+               // Submit the updated resource to the service and store the response.
+               output = new MultipartOutput();
+               commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getItemCommonPartName());
+               res.releaseConnection();
+               res = client.updateItem(knownResourceId, knownItemResourceId, output);
+               statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               updatedLocation =
+                       (LocationsCommon) extractPart(input,
+                               client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(updatedLocation);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
+                       "Updated displayNameComputed in Location did not match submitted data.");
+               // Verify that the updated resource computes the right displayName.
+               Assert.assertEquals(updatedLocation.getDisplayName(),
+                               expectedDisplayName,
+                       "Updated DisplayName (not computed) in Location not stored.");
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -572,40 +597,45 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        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, Response.Status.OK.getStatusCode());
-
-        // Check whether Location has expected displayName.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        LocationsCommon location = (LocationsCommon) extractPart(input,
-                client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(location);
-        // Try to Update with computed false and no displayName
-        location.setDisplayNameComputed(false);
-        location.setDisplayName(null);
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getItemCommonPartName());
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        try {
+               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, Response.Status.OK.getStatusCode());
+       
+               // Check whether Location has expected displayName.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               LocationsCommon location = (LocationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(location);
+               // Try to Update with computed false and no displayName
+               location.setDisplayNameComputed(false);
+               location.setDisplayName(null);
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getItemCommonPartName());
+               res.releaseConnection();
+               res = client.updateItem(knownResourceId, knownItemResourceId, output);
+               statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+           } finally {
+               res.releaseConnection();
+           }
     }
    
 
@@ -627,16 +657,20 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -657,16 +691,20 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
 
@@ -692,36 +730,40 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<LocationauthoritiesCommonList> res = client.readList();
-        LocationauthoritiesCommonList 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);
-
-        // Optionally output additional data about list members for debugging.
-        boolean iterateThroughList = false;
-        if (iterateThroughList && logger.isDebugEnabled()) {
-            List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
-                    list.getLocationauthorityListItem();
-            int i = 0;
-            for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
-                String csid = item.getCsid();
-                logger.debug(testName + ": list-item[" + i + "] csid=" +
-                        csid);
-                logger.debug(testName + ": list-item[" + i + "] displayName=" +
-                        item.getDisplayName());
-                logger.debug(testName + ": list-item[" + i + "] URI=" +
-                        item.getUri());
-                readItemList(csid, null);
-                i++;
-            }
-        }
+        try {
+               LocationauthoritiesCommonList 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);
+       
+               // Optionally output additional data about list members for debugging.
+               boolean iterateThroughList = false;
+               if (iterateThroughList && logger.isDebugEnabled()) {
+                   List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
+                           list.getLocationauthorityListItem();
+                   int i = 0;
+                   for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
+                       String csid = item.getCsid();
+                       logger.debug(testName + ": list-item[" + i + "] csid=" +
+                               csid);
+                       logger.debug(testName + ": list-item[" + i + "] displayName=" +
+                               item.getDisplayName());
+                       logger.debug(testName + ": list-item[" + i + "] URI=" +
+                               item.getUri());
+                       readItemList(csid, null);
+                       i++;
+                   }
+               }
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -771,52 +813,56 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         } else {
                Assert.fail("readItemList passed null csid and name!");
         }
-        LocationsCommonList 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);
-
-        List<LocationsCommonList.LocationListItem> items =
-            list.getLocationListItem();
-        int nItemsReturned = items.size();
-        // There will be one item created, associated with a
-        // known parent resource, by the createItem test.
-        //
-        // In addition, there will be 'nItemsToCreateInList'
-        // additional items created by the createItemList test,
-        // all associated with the same parent resource.
-        int nExpectedItems = nItemsToCreateInList + 1;
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": Expected "
-                       + nExpectedItems +" items; got: "+nItemsReturned);
-        }
-        Assert.assertEquals(nItemsReturned, nExpectedItems);
-
-        int i = 0;
-        for (LocationsCommonList.LocationListItem item : items) {
-               Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
-               Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
-               // Optionally output additional data about list members for debugging.
-               boolean showDetails = true;
-               if (showDetails && logger.isDebugEnabled()) {
-                logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
-                        item.getCsid());
-                logger.debug("  " + testName + ": list-item[" + i + "] refName=" +
-                        item.getRefName());
-                logger.debug("  " + testName + ": list-item[" + i + "] displayName=" +
-                        item.getDisplayName());
-                logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
-                        item.getUri());
-            }
-            i++;
-        }
+        try {
+               LocationsCommonList 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);
+       
+               List<LocationsCommonList.LocationListItem> items =
+                   list.getLocationListItem();
+               int nItemsReturned = items.size();
+               // There will be one item created, associated with a
+               // known parent resource, by the createItem test.
+               //
+               // In addition, there will be 'nItemsToCreateInList'
+               // additional items created by the createItemList test,
+               // all associated with the same parent resource.
+               int nExpectedItems = nItemsToCreateInList + 1;
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": Expected "
+                               + nExpectedItems +" items; got: "+nItemsReturned);
+               }
+               Assert.assertEquals(nItemsReturned, nExpectedItems);
+       
+               int i = 0;
+               for (LocationsCommonList.LocationListItem item : items) {
+                       Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
+                       Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
+                       // Optionally output additional data about list members for debugging.
+                       boolean showDetails = true;
+                       if (showDetails && logger.isDebugEnabled()) {
+                       logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
+                               item.getCsid());
+                       logger.debug("  " + testName + ": list-item[" + i + "] refName=" +
+                               item.getRefName());
+                       logger.debug("  " + testName + ": list-item[" + i + "] displayName=" +
+                               item.getDisplayName());
+                       logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
+                               item.getUri());
+                   }
+                   i++;
+               }
+           } finally {
+               res.releaseConnection();
+           }
     }
 
 
@@ -843,55 +889,59 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Retrieve the contents of a resource to update.
         LocationAuthorityClient client = new LocationAuthorityClient();
-        ClientResponse<MultipartInput> res =
-                client.read(knownResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
-        }
-        MultipartInput input = (MultipartInput) res.getEntity();
-        LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
-                client.getCommonPartName(), LocationauthoritiesCommon.class);
-        Assert.assertNotNull(locationAuthority);
-
-        // Update the contents of this resource.
-        locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
-        locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
-        if(logger.isDebugEnabled()){
-            logger.debug("to be updated LocationAuthority");
-            logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
-        }
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getCommonPartName());
-        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()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        LocationauthoritiesCommon updatedLocationAuthority =
-                (LocationauthoritiesCommon) extractPart(input,
-                        client.getCommonPartName(), LocationauthoritiesCommon.class);
-        Assert.assertNotNull(updatedLocationAuthority);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
-                locationAuthority.getDisplayName(),
-                "Data in updated object did not match submitted data.");
+        ClientResponse<MultipartInput> res = client.read(knownResourceId);
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
+               }
+               MultipartInput input = (MultipartInput) res.getEntity();
+               LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+                       client.getCommonPartName(), LocationauthoritiesCommon.class);
+               Assert.assertNotNull(locationAuthority);
+       
+               // Update the contents of this resource.
+               locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
+               locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
+               if(logger.isDebugEnabled()){
+                   logger.debug("to be updated LocationAuthority");
+                   logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
+               }
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getCommonPartName());
+               res.releaseConnection();
+               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()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               LocationauthoritiesCommon updatedLocationAuthority =
+                       (LocationauthoritiesCommon) extractPart(input,
+                               client.getCommonPartName(), LocationauthoritiesCommon.class);
+               Assert.assertNotNull(updatedLocationAuthority);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
+                       locationAuthority.getDisplayName(),
+                       "Data in updated object did not match submitted data.");
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -914,55 +964,60 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<MultipartInput> res =
                 client.readItem(knownResourceId, knownItemResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got Location to update with ID: " +
-                knownItemResourceId +
-                " in LocationAuthority: " + knownResourceId );
-        }
-        MultipartInput input = (MultipartInput) res.getEntity();
-        LocationsCommon location = (LocationsCommon) extractPart(input,
-                client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(location);
-
-        // Update the contents of this resource.
-        location.setCsid(null);
-        location.setName("updated-" + location.getName());
-        if(logger.isDebugEnabled()){
-            logger.debug("to be updated Location");
-            logger.debug(objectAsXmlString(location,
-                LocationsCommon.class));
-        }        
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getItemCommonPartName());
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        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);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        LocationsCommon updatedLocation =
-                (LocationsCommon) extractPart(input,
-                        client.getItemCommonPartName(), LocationsCommon.class);
-        Assert.assertNotNull(updatedLocation);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedLocation.getName(), location.getName(),
-                "Data in updated Location did not match submitted data.");
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got Location to update with ID: " +
+                       knownItemResourceId +
+                       " in LocationAuthority: " + knownResourceId );
+               }
+               MultipartInput input = (MultipartInput) res.getEntity();
+               LocationsCommon location = (LocationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(location);
+       
+               // Update the contents of this resource.
+               location.setCsid(null);
+               location.setName("updated-" + location.getName());
+               if(logger.isDebugEnabled()){
+                   logger.debug("to be updated Location");
+                   logger.debug(objectAsXmlString(location,
+                       LocationsCommon.class));
+               }        
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getItemCommonPartName());
+               res.releaseConnection();
+               res = client.updateItem(knownResourceId, knownItemResourceId, output);
+               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);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               LocationsCommon updatedLocation =
+                       (LocationsCommon) extractPart(input,
+                               client.getItemCommonPartName(), LocationsCommon.class);
+               Assert.assertNotNull(updatedLocation);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedLocation.getName(), location.getName(),
+                       "Data in updated Location did not match submitted data.");
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -1013,16 +1068,20 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
                                displayName, "nonEx", client.getCommonPartName());
         ClientResponse<MultipartInput> res =
                 client.update(NON_EXISTENT_ID, multipart);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1049,23 +1108,27 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
         nonexMap.put(LocationJAXBSchema.SHORT_IDENTIFIER, "nonEx");
         nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
-        nonexMap.put(LocationJAXBSchema.STATUS, TEST_STATUS);
+        nonexMap.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
         MultipartOutput multipart = 
        LocationAuthorityClientUtils.createLocationInstance(NON_EXISTENT_ID, 
                        LocationAuthorityClientUtils.createLocationRefName(knownResourceRefName, "nonEx", "Non Existent"), 
                        nonexMap, client.getItemCommonPartName() );
         ClientResponse<MultipartInput> res =
                 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // ---------------------------------------------------------------
@@ -1100,17 +1163,22 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
 
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
-        ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
-        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);
+        ClientResponse<Response> res = 
+               client.deleteItem(knownResourceId, knownItemResourceId);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /* (non-Javadoc)
@@ -1134,16 +1202,20 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<Response> res = client.delete(knownResourceId);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -1164,16 +1236,20 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1194,16 +1270,20 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         LocationAuthorityClient client = new LocationAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // ---------------------------------------------------------------
@@ -1296,12 +1376,14 @@ public class LocationAuthorityServiceTest extends AbstractServiceTestImpl {
             // below are ignored and not reported.
             ClientResponse<Response> res =
                 client.deleteItem(parentResourceId, itemResourceId);
+               res.releaseConnection();
         }
         // Clean up parent resources.
         for (String resourceId : allResourceIdsCreated) {
             // Note: Any non-success responses from the delete operation
             // below are ignored and not reported.
             ClientResponse<Response> res = client.delete(resourceId);
+               res.releaseConnection();
         }
     }
 
index 32483affe0d9b56612e0d642acfde4e83ca41079..dc2d5f6719964dadbe3908b4222ef499698ea264 100644 (file)
     <name>services.location.jaxb</name>
 
     <dependencies>
+        <dependency>
+            <groupId>org.collectionspace.services</groupId>
+            <artifactId>org.collectionspace.services.common</artifactId>
+            <version>${project.version}</version>
+        </dependency>
         <dependency>
             <groupId>com.sun.xml.bind</groupId>
             <artifactId>jaxb-impl</artifactId>
diff --git a/services/location/jaxb/src/main/java/org/collectionspace/services/LocationAuthorityJAXBSchema.java b/services/location/jaxb/src/main/java/org/collectionspace/services/LocationAuthorityJAXBSchema.java
deleted file mode 100644 (file)
index c699bf8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-/**\r
- * \r
- */\r
-package org.collectionspace.services;\r
-\r
-/**\r
- * @author pschmitz\r
- *\r
- */\r
-public interface LocationAuthorityJAXBSchema {\r
-       final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";\r
-       final static String DISPLAY_NAME = "displayName";\r
-       final static String REF_NAME = "refName";\r
-       final static String SHORT_IDENTIFIER = "shortIdentifier";\r
-       final static String VOCAB_TYPE = "vocabType";\r
-       final static String CSID = "csid";\r
-}\r
-\r
-\r
diff --git a/services/location/jaxb/src/main/java/org/collectionspace/services/LocationAuthorityListItemJAXBSchema.java b/services/location/jaxb/src/main/java/org/collectionspace/services/LocationAuthorityListItemJAXBSchema.java
deleted file mode 100644 (file)
index 3e301e4..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.collectionspace.services;\r
-\r
-public interface LocationAuthorityListItemJAXBSchema {\r
-       final static String DISPLAY_NAME = "displayName";\r
-       final static String REF_NAME = "refName";\r
-       final static String SHORT_IDENTIFIER = "shortIdentifier";\r
-       final static String VOCAB_TYPE = "vocabType";\r
-       final static String CSID = "csid";\r
-       final static String URI = "url";\r
-}\r
index 01205e6f91aaf6f638438a45232e1a53b71dedff..dbbe74acb56d25a931cd29d160873da967083b0e 100644 (file)
@@ -2,24 +2,19 @@
  * \r
  */\r
 package org.collectionspace.services;\r
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;\r
 \r
 /**\r
  * @author pschmitz\r
  *\r
  */\r
-public interface LocationJAXBSchema {\r
+public interface LocationJAXBSchema extends AuthorityJAXBSchema {\r
        final static String LOCATIONS_COMMON = "locations_common";\r
-       final static String CSID = "csid";\r
-       final static String SHORT_IDENTIFIER = "shortIdentifier";\r
-       final static String IN_AUTHORITY = "inAuthority";\r
-       final static String REF_NAME = "refName";\r
-       final static String DISPLAY_NAME = "displayName";\r
        final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
        final static String NAME = "name";\r
        final static String CONDITION_NOTE = "conditionNote";\r
        final static String CONDITION_NOTE_DATE = "conditionNoteDate";\r
        final static String SECURITY_NOTE = "securityNote";\r
        final static String LOCATION_TYPE = "locationType";\r
-       final static String STATUS = "status";\r
 }\r
 \r
diff --git a/services/location/jaxb/src/main/java/org/collectionspace/services/LocationListItemJAXBSchema.java b/services/location/jaxb/src/main/java/org/collectionspace/services/LocationListItemJAXBSchema.java
deleted file mode 100644 (file)
index 75d494f..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-package org.collectionspace.services;\r
-\r
-public interface LocationListItemJAXBSchema {\r
-       final static String DISPLAY_NAME = "displayName";\r
-       final static String REF_NAME = "refName";\r
-       final static String CSID = "csid";\r
-       final static String URI = "url";\r
-}\r
index 4ed013b46006c3bfe71d0b2a9d6fac4523c829ff..9b02b2acfa89396cce22efdeb54d5a0e985b5416 100644 (file)
@@ -24,6 +24,7 @@
                                                                <xs:element name="inAuthority" type="xs:string" />
                                                                <xs:element name="shortIdentifier" type="xs:string"/>
                                                                <xs:element name="refName" type="xs:string"/>
+                                                               <xs:element name="termStatus" type="xs:string"/>
                                                                <xs:element name="displayName" type="xs:string"/>
                                                                <xs:element name="displayNameComputed" type="xs:boolean"/>
                                                                <xs:element name="name" type="xs:string"/>
@@ -31,7 +32,6 @@
                                                                <xs:element name="conditionNoteDate" type="xs:string"/>
                                                                <xs:element name="securityNote" type="xs:string"/>
                                                                <xs:element name="locationType" type="xs:string"/>
-                                                               <xs:element name="status" type="xs:string"/>
             </xs:sequence>
         </xs:complexType>
     </xs:element>
index 8685189176aac2ac78ffc4010e9c4c85dd6241bf..4c76be778ff77d8151d965c27733ba6a235c1348 100644 (file)
@@ -41,7 +41,7 @@ import javax.ws.rs.core.Response;
 import javax.ws.rs.core.UriBuilder;
 import javax.ws.rs.core.UriInfo;
 
-import org.collectionspace.services.LocationAuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
 import org.collectionspace.services.LocationJAXBSchema;
 import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
 import org.collectionspace.services.common.ClientType;
@@ -61,14 +61,10 @@ import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.AuthorityResource;
 import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
 import org.collectionspace.services.common.vocabulary.RefNameUtils;
 import org.collectionspace.services.common.query.IQueryManager;
-import org.collectionspace.services.contact.ContactResource;
-import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
-import org.collectionspace.services.contact.ContactJAXBSchema;
-import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler;
 import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
@@ -84,14 +80,15 @@ import org.slf4j.LoggerFactory;
 @Path("/locationauthorities")
 @Consumes("multipart/mixed")
 @Produces("multipart/mixed")
-public class LocationAuthorityResource extends
-               AbstractMultiPartCollectionSpaceResourceImpl {
+public class LocationAuthorityResource 
+       extends AuthorityResource<LocationauthoritiesCommon, LocationauthoritiesCommonList, 
+                                                       LocationsCommon, LocationDocumentModelHandler> {
 
-    /** The Constant locationAuthorityServiceName. */
     private final static String locationAuthorityServiceName = "locationauthorities";
+       private final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";
     
-    /** The Constant locationServiceName. */
     private final static String locationServiceName = "locations";
+       private final static String LOCATIONS_COMMON = "locations_common";
     
     /** The logger. */
     final Logger logger = LoggerFactory.getLogger(LocationAuthorityResource.class);
@@ -103,19 +100,10 @@ public class LocationAuthorityResource extends
      * Instantiates a new location authority resource.
      */
     public LocationAuthorityResource() {
-        // do nothing
+               super(LocationauthoritiesCommon.class, LocationAuthorityResource.class,
+                               LOCATIONAUTHORITIES_COMMON, LOCATIONS_COMMON);
     }
 
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
-     */
-    @Override
-    protected String getVersionString() {
-       /** The last change revision. */
-       final String lastChangeRevision = "$LastChangedRevision: 1850 $";
-       return lastChangeRevision;
-    }
-    
     /* (non-Javadoc)
      * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
      */
@@ -124,11 +112,6 @@ public class LocationAuthorityResource extends
         return locationAuthorityServiceName;
     }
 
-    @Override
-    public Class<LocationauthoritiesCommon> getCommonPartClass() {
-       return LocationauthoritiesCommon.class;
-    }
-    
     /**
      * Gets the item service name.
      * 
@@ -138,726 +121,8 @@ public class LocationAuthorityResource extends
         return locationServiceName;
     }
 
-    /**
- * Creates the item document handler.
- * 
- * @param ctx the ctx
- * @param inAuthority the in authority
- * 
- * @return the document handler
- * 
- * @throws Exception the exception
- */
-    private DocumentHandler createItemDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx,
-            String inAuthority) throws Exception {    
-        LocationDocumentModelHandler docHandler = (LocationDocumentModelHandler)createDocumentHandler(ctx,
-                       ctx.getCommonPartLabel(getItemServiceName()),
-                       LocationsCommon.class);         
-        docHandler.setInAuthority(inAuthority);
-        
-        return docHandler;
-    }
-
-    /**
-     * Creates the location authority.
-     * 
-     * @param input the input
-     * 
-     * @return the response
-     */
-    @POST
-    public Response createLocationAuthority(MultipartInput input) {
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
-            DocumentHandler handler = createDocumentHandler(ctx);
-            String csid = getRepositoryClient(ctx).create(ctx, handler);
-            //locationAuthorityObject.setCsid(csid);
-            UriBuilder path = UriBuilder.fromResource(LocationAuthorityResource.class);
-            path.path("" + csid);
-            Response response = Response.created(path.build()).build();
-            return response;
-        } catch (BadRequestException bre) {
-            Response response = Response.status(
-                    Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Caught exception in createLocationAuthority", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-    }
-
-    /**
-     * Gets the location authority by name.
-     * 
-     * @param specifier the specifier
-     * 
-     * @return the location authority by name
-     */
-    @GET
-    @Path("urn:cspace:name({specifier})")
-    public MultipartOutput getLocationAuthorityByName(@PathParam("specifier") String specifier) {
-        if (specifier == null) {
-            logger.error("getLocationAuthority: missing name!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "get failed on LocationAuthority (missing specifier)").type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        String whereClause =
-               LocationAuthorityJAXBSchema.LOCATIONAUTHORITIES_COMMON+
-               ":"+LocationAuthorityJAXBSchema.SHORT_IDENTIFIER+
-               "='"+specifier+"'";
-        // We only get a single doc - if there are multiple,
-        // it is an error in use.
-
-        if (logger.isDebugEnabled()) {
-            logger.debug("getLocationAuthority with name=" + specifier);
-        } 
-        MultipartOutput result = null;
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
-            DocumentHandler handler = createDocumentHandler(ctx);
-            DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
-            handler.setDocumentFilter(myFilter);
-            getRepositoryClient(ctx).get(ctx, handler);
-            result = (MultipartOutput) ctx.getOutput();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("getLocationAuthority", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Get failed on LocationAuthority spec=" + specifier).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("getLocationAuthority", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (result == null) {
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Get failed, the requested LocationAuthority spec:" + specifier + ": was not found.").type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return result;
-    }
-
-    /**
-     * Gets the entities referencing this Location instance. The service type
-     * can be passed as a query param "type", and must match a configured type
-     * for the service bindings. If not set, the type defaults to
-     * ServiceBindingUtils.SERVICE_TYPE_PROCEDURE.
-     * 
-     * @param csid the parent csid
-     * @param itemcsid the location csid
-     * @param ui the ui
-     * 
-     * @return the info for the referencing objects
-     */
-    @GET
-    @Path("{csid}/items/{itemcsid}/refObjs")
-    @Produces("application/xml")
-    public AuthorityRefDocList getReferencingObjects(
-            @PathParam("csid") String parentcsid,
-            @PathParam("itemcsid") String itemcsid,
-               @Context UriInfo ui) {
-       AuthorityRefDocList authRefDocList = null;
-        if (logger.isDebugEnabled()) {
-            logger.debug("getReferencingObjects with parentcsid=" 
-                       + parentcsid + " and itemcsid=" + itemcsid);
-        }
-        if (parentcsid == null || "".equals(parentcsid)
-                || itemcsid == null || "".equals(itemcsid)) {
-            logger.error("getLocation: missing parentcsid or itemcsid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "get failed on Location with parentcsid=" 
-                       + parentcsid + " and itemcsid=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-    try {
-        // Note that we have to create the service context for the Items, not the main service
-        ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(getItemServiceName());
-        DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-        RepositoryClient repoClient = getRepositoryClient(ctx); 
-        DocumentFilter myFilter = handler.createDocumentFilter();
-        MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-        myFilter.setPagination(queryParams);
-       String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
-        List<String> list = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
-        if (list != null) {
-               serviceType = list.get(0);
-        }
-        DocumentWrapper<DocumentModel> docWrapper = repoClient.getDoc(ctx, itemcsid);
-        DocumentModel docModel = docWrapper.getWrappedObject();
-        String refName = (String)docModel.getPropertyValue(LocationJAXBSchema.REF_NAME);
-
-        authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(ctx, repoClient, 
-                       serviceType, refName,
-                       myFilter.getPageSize(), myFilter.getStartPage(), true );
-    } catch (UnauthorizedException ue) {
-        Response response = Response.status(
-                Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
-        throw new WebApplicationException(response);
-    } catch (DocumentNotFoundException dnfe) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("getReferencingObjects", dnfe);
-        }
-        Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                "GetReferencingObjects failed with parentcsid=" 
-                       + parentcsid + " and itemcsid=" + itemcsid).type(
-                "text/plain").build();
-        throw new WebApplicationException(response);
-    } catch (Exception e) {    // Includes DocumentException
-        if (logger.isDebugEnabled()) {
-            logger.debug("GetReferencingObjects", e);
-        }
-        Response response = Response.status(
-                Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
-        throw new WebApplicationException(response);
-    }
-    if (authRefDocList == null) {
-        Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                "Get failed, the requested Location CSID:" + itemcsid + ": was not found.").type(
-                "text/plain").build();
-        throw new WebApplicationException(response);
-    }
-    return authRefDocList;
-    }
-
-    @GET
-    @Path("{csid}")
-    public MultipartOutput getLocationAuthority(@PathParam("csid") String csid) {
-        if (csid == null) {
-            logger.error("getLocationAuthority: missing csid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "get failed on LocationAuthority csid=" + csid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (logger.isDebugEnabled()) {
-            logger.debug("getLocationAuthority with path(id)=" + csid);
-        } 
-        MultipartOutput result = null;
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
-            DocumentHandler handler = createDocumentHandler(ctx);
-            getRepositoryClient(ctx).get(ctx, csid, handler);
-            result = (MultipartOutput) ctx.getOutput();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("getLocationAuthority", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Get failed on LocationAuthority csid=" + csid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("getLocationAuthority", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (result == null) {
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Get failed, the requested LocationAuthority CSID:" + csid + ": was not found.").type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return result;
-    }
-
-    /**
-     * Gets the location authority list.
-     * 
-     * @param ui the ui
-     * 
-     * @return the location authority list
-     */
-    @GET
-    @Produces("application/xml")
-    public LocationauthoritiesCommonList getLocationAuthorityList(@Context UriInfo ui) {
-        LocationauthoritiesCommonList locationAuthorityObjectList = new LocationauthoritiesCommonList();
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-            DocumentHandler handler = createDocumentHandler(ctx);
-            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
-            myFilter.setPagination(queryParams); //FIXME
-            String nameQ = queryParams.getFirst("refName");
-            if (nameQ != null) {
-                myFilter.setWhereClause("locationauthorities_common:refName='" + nameQ + "'");
-            }
-            handler.setDocumentFilter(myFilter);
-            getRepositoryClient(ctx).getFiltered(ctx, handler);
-            locationAuthorityObjectList = (LocationauthoritiesCommonList) handler.getCommonPartList();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Caught exception in getLocationAuthorityList", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return locationAuthorityObjectList;
-    }
-
-    /**
-     * Update location authority.
-     * 
-     * @param csid the csid
-     * @param theUpdate the the update
-     * 
-     * @return the multipart output
-     */
-    @PUT
-    @Path("{csid}")
-    public MultipartOutput updateLocationAuthority(
-            @PathParam("csid") String csid,
-            MultipartInput theUpdate) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("updateLocationAuthority with csid=" + csid);
-        }
-        if (csid == null || "".equals(csid)) {
-            logger.error("updateLocationAuthority: missing csid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "update failed on LocationAuthority csid=" + csid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        MultipartOutput result = null;
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
-            DocumentHandler handler = createDocumentHandler(ctx);
-            getRepositoryClient(ctx).update(ctx, csid, handler);
-            result = (MultipartOutput) ctx.getOutput();
-        } catch (BadRequestException bre) {
-            Response response = Response.status(
-                    Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("caugth exception in updateLocationAuthority", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Update failed on LocationAuthority csid=" + csid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return result;
-    }
-
-    /**
-     * Delete location authority.
-     * 
-     * @param csid the csid
-     * 
-     * @return the response
-     */
-    @DELETE
-    @Path("{csid}")
-    public Response deleteLocationAuthority(@PathParam("csid") String csid) {
-
-        if (logger.isDebugEnabled()) {
-            logger.debug("deleteLocationAuthority with csid=" + csid);
-        }
-        if (csid == null || "".equals(csid)) {
-            logger.error("deleteLocationAuthority: missing csid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "delete failed on LocationAuthority csid=" + csid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
-            getRepositoryClient(ctx).delete(ctx, csid);
-            return Response.status(HttpResponseCodes.SC_OK).build();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("caught exception in deleteLocationAuthority", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Delete failed on LocationAuthority csid=" + csid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-
-    }
-
-    /*************************************************************************
-     * Location parts - this is a sub-resource of LocationAuthority
-     *************************************************************************/
-    @POST
-    @Path("{csid}/items")
-    public Response createLocation(@PathParam("csid") String parentcsid, MultipartInput input) {
-        try {
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(), input);
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
-            UriBuilder path = UriBuilder.fromResource(LocationAuthorityResource.class);
-            path.path(parentcsid + "/items/" + itemcsid);
-            Response response = Response.created(path.build()).build();
-            return response;
-        } catch (BadRequestException bre) {
-            Response response = Response.status(
-                    Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Caught exception in createLocation", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-    }
-
-    /**
-     * Gets the location.
-     * 
-     * @param parentcsid the parentcsid
-     * @param itemcsid the itemcsid
-     * 
-     * @return the location
-     */
-    @GET
-    @Path("{csid}/items/{itemcsid}")
-    public MultipartOutput getLocation(
-            @PathParam("csid") String parentcsid,
-            @PathParam("itemcsid") String itemcsid) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("getLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
-        }
-        if (parentcsid == null || "".equals(parentcsid)
-            || itemcsid == null || "".equals(itemcsid)) {
-            logger.error("getLocation: missing parentcsid or itemcsid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "get failed on Location with parentcsid=" 
-                       + parentcsid + " and itemcsid=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        MultipartOutput result = null;
-        try {
-            // Note that we have to create the service context for the Items, not the main service
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            getRepositoryClient(ctx).get(ctx, itemcsid, handler);
-            // TODO should we assert that the item is in the passed locationAuthority?
-            result = (MultipartOutput) ctx.getOutput();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("getLocation", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Get failed on Location csid=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("getLocation", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (result == null) {
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Get failed, the requested Location CSID:" + itemcsid + ": was not found.").type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return result;
-    }
-
-    /**
-     * Gets the location list.
-     * 
-     * @param parentcsid the parentcsid
-     * @param partialTerm the partial term
-     * @param ui the ui
-     * 
-     * @return the location list
-     */
-    @GET
-    @Path("{csid}/items")
-    @Produces("application/xml")
-    public LocationsCommonList getLocationList(
-            @PathParam("csid") String parentcsid,
-            @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,            
-            @Context UriInfo ui) {
-        LocationsCommonList locationObjectList = new LocationsCommonList();
-        try {
-            // Note that docType defaults to the ServiceName, so we're fine with that.
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
-                               queryParams);
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            DocumentFilter myFilter = handler.getDocumentFilter();
-
-            // Add the where clause "locations_common:inAuthority='" + parentcsid + "'"
-            myFilter.setWhereClause(LocationJAXBSchema.LOCATIONS_COMMON + ":" +
-                       LocationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
-            
-            // AND locations_common:displayName LIKE '%partialTerm%'
-            if (partialTerm != null && !partialTerm.isEmpty()) {
-               String ptClause = 
-               LocationJAXBSchema.LOCATIONS_COMMON + ":" +
-                       LocationJAXBSchema.DISPLAY_NAME +
-                       " LIKE " +
-                       "'%" + partialTerm + "%'";
-               myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
-            }
-            getRepositoryClient(ctx).getFiltered(ctx, handler);
-            locationObjectList = (LocationsCommonList) handler.getCommonPartList();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Caught exception in getLocationList", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return locationObjectList;
-    }
-    
-
-    /**
-     * Gets the location list by auth name.
-     * 
-     * @param parentSpecifier the parent specifier
-     * @param partialTerm the partial term
-     * @param ui the ui
-     * 
-     * @return the location list by auth name
-     */
-    @GET
-    @Path("urn:cspace:name({specifier})/items")
-    @Produces("application/xml")
-    public LocationsCommonList getLocationListByAuthName(
-               @PathParam("specifier") String parentSpecifier,
-            @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,            
-            @Context UriInfo ui) {
-        LocationsCommonList locationObjectList = new LocationsCommonList();
-        try {
-            MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
-            String whereClause =
-               LocationAuthorityJAXBSchema.LOCATIONAUTHORITIES_COMMON+
-               ":"+LocationAuthorityJAXBSchema.SHORT_IDENTIFIER+
-               "='"+parentSpecifier+"'";
-            // Need to get an Authority by name
-            ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
-            String parentcsid = 
-               getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
-
-            ctx = createServiceContext(getItemServiceName(), queryParams);
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
-            myFilter.setPagination(queryParams); //FIXME
-
-            // Add the where clause "locations_common:inAuthority='" + parentcsid + "'"
-            myFilter.setWhereClause(LocationJAXBSchema.LOCATIONS_COMMON + ":" +
-                       LocationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
-            
-            // AND locations_common:displayName LIKE '%partialTerm%'
-            if (partialTerm != null && !partialTerm.isEmpty()) {
-               String ptClause = // "AND " +
-               LocationJAXBSchema.LOCATIONS_COMMON + ":" +
-                       LocationJAXBSchema.DISPLAY_NAME +
-                       " LIKE " +
-                       "'%" + partialTerm + "%'";
-               myFilter.appendWhereClause(ptClause, "AND");
-            }
-            
-            handler.setDocumentFilter(myFilter);
-            getRepositoryClient(ctx).getFiltered(ctx, handler);
-            locationObjectList = (LocationsCommonList) handler.getCommonPartList();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("Caught exception in getLocationList", e);
-            }
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return locationObjectList;
-    }
-
-    /**
-     * Update location.
-     * 
-     * @param parentcsid the parentcsid
-     * @param itemcsid the itemcsid
-     * @param theUpdate the the update
-     * 
-     * @return the multipart output
-     */
-    @PUT
-    @Path("{csid}/items/{itemcsid}")
-    public MultipartOutput updateLocation(
-            @PathParam("csid") String parentcsid,
-            @PathParam("itemcsid") String itemcsid,
-            MultipartInput theUpdate) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("updateLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
-        }
-        if (parentcsid == null || "".equals(parentcsid)) {
-            logger.error("updateLocation: missing csid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "update failed on Location parentcsid=" + parentcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (itemcsid == null || "".equals(itemcsid)) {
-            logger.error("updateLocation: missing itemcsid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "update failed on Location=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        MultipartOutput result = null;
-        try {
-            // Note that we have to create the service context for the Items, not the main service
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
-                               theUpdate);
-            DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
-            getRepositoryClient(ctx).update(ctx, itemcsid, handler);
-            result = (MultipartOutput) ctx.getOutput();
-        } catch (BadRequestException bre) {
-            Response response = Response.status(
-                    Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("caught exception in updateLocation", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Update failed on Location csid=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        return result;
-    }
-
-    /**
-     * Delete location.
-     * 
-     * @param parentcsid the parentcsid
-     * @param itemcsid the itemcsid
-     * 
-     * @return the response
-     */
-    @DELETE
-    @Path("{csid}/items/{itemcsid}")
-    public Response deleteLocation(
-            @PathParam("csid") String parentcsid,
-            @PathParam("itemcsid") String itemcsid) {
-        if (logger.isDebugEnabled()) {
-            logger.debug("deleteLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
-        }
-        if (parentcsid == null || "".equals(parentcsid)) {
-            logger.error("deleteLocation: missing csid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "delete failed on Location parentcsid=" + parentcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        if (itemcsid == null || "".equals(itemcsid)) {
-            logger.error("deleteLocation: missing itemcsid!");
-            Response response = Response.status(Response.Status.BAD_REQUEST).entity(
-                    "delete failed on Location=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        }
-        try {
-            // Note that we have to create the service context for the Items, not the main service
-               ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
-            getRepositoryClient(ctx).delete(ctx, itemcsid);
-            return Response.status(HttpResponseCodes.SC_OK).build();
-        } catch (UnauthorizedException ue) {
-            Response response = Response.status(
-                    Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (DocumentNotFoundException dnfe) {
-            if (logger.isDebugEnabled()) {
-                logger.debug("caught exception in deleteLocation", dnfe);
-            }
-            Response response = Response.status(Response.Status.NOT_FOUND).entity(
-                    "Delete failed on Location itemcsid=" + itemcsid).type(
-                    "text/plain").build();
-            throw new WebApplicationException(response);
-        } catch (Exception e) {
-            Response response = Response.status(
-                    Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
-            throw new WebApplicationException(response);
-        }
-
+    @Override
+    public Class<LocationauthoritiesCommon> getCommonPartClass() {
+       return LocationauthoritiesCommon.class;
     }
-
 }
index 8990eb7ab1ca1914e99ebfa493c8710d80c4d129..9917dff163118b0dbb0331aef85184a281a15ca6 100644 (file)
@@ -26,10 +26,11 @@ package org.collectionspace.services.location.nuxeo;
 import java.util.Iterator;
 import java.util.List;
 
-import org.collectionspace.services.LocationAuthorityJAXBSchema;
 import org.collectionspace.services.common.document.DocumentHandler.Action;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
 import org.collectionspace.services.location.LocationauthoritiesCommon;
 import org.collectionspace.services.location.LocationauthoritiesCommonList;
 import org.collectionspace.services.location.LocationauthoritiesCommonList.LocationauthorityListItem;
@@ -48,63 +49,7 @@ import org.slf4j.LoggerFactory;
  * $LastChangedDate: $
  */
 public class LocationAuthorityDocumentModelHandler
-        extends RemoteDocumentModelHandlerImpl<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
-
-    private final Logger logger = LoggerFactory.getLogger(LocationAuthorityDocumentModelHandler.class);
-    /**
-     * locationAuthority is used to stash JAXB object to use when handle is called
-     * for Action.CREATE, Action.UPDATE or Action.GET
-     */
-    private LocationauthoritiesCommon locationAuthority;
-    /**
-     * locationAuthorityList is stashed when handle is called
-     * for ACTION.GET_ALL
-     */
-    private LocationauthoritiesCommonList locationAuthorityList;
-
-
-    /**
-     * getCommonPart get associated locationAuthority
-     * @return
-     */
-    @Override
-    public LocationauthoritiesCommon getCommonPart() {
-        return locationAuthority;
-    }
-
-    /**
-     * setCommonPart set associated locationAuthority
-     * @param locationAuthority
-     */
-    @Override
-    public void setCommonPart(LocationauthoritiesCommon locationAuthority) {
-        this.locationAuthority = locationAuthority;
-    }
-
-    /**
-     * getCommonPartList get associated locationAuthority (for index/GET_ALL)
-     * @return
-     */
-    @Override
-    public LocationauthoritiesCommonList getCommonPartList() {
-        return locationAuthorityList;
-    }
-
-    @Override
-    public void setCommonPartList(LocationauthoritiesCommonList locationAuthorityList) {
-        this.locationAuthorityList = locationAuthorityList;
-    }
-
-    @Override
-    public LocationauthoritiesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
-            throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
-    @Override
-    public void fillCommonPart(LocationauthoritiesCommon locationAuthorityObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
-        throw new UnsupportedOperationException();
-    }
+        extends AuthorityDocumentModelHandler<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
 
     @Override
     public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
@@ -114,18 +59,19 @@ public class LocationAuthorityDocumentModelHandler
         //FIXME: iterating over a long list of documents is not a long term
         //strategy...need to change to more efficient iterating in future
         List<LocationauthoritiesCommonList.LocationauthorityListItem> list = coList.getLocationauthorityListItem();
+        String label = getServiceContext().getCommonPartLabel();
         Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
         while(iter.hasNext()){
             DocumentModel docModel = iter.next();
             LocationauthorityListItem ilistItem = new LocationauthorityListItem();
-            ilistItem.setDisplayName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
-                    LocationAuthorityJAXBSchema.DISPLAY_NAME));
-            ilistItem.setRefName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
-                    LocationAuthorityJAXBSchema.REF_NAME));
-            ilistItem.setShortIdentifier((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
-                       LocationAuthorityJAXBSchema.SHORT_IDENTIFIER));
-            ilistItem.setVocabType((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
-                    LocationAuthorityJAXBSchema.VOCAB_TYPE));
+            ilistItem.setDisplayName((String) docModel.getProperty(label,
+                       AuthorityJAXBSchema.DISPLAY_NAME));
+            ilistItem.setRefName((String) docModel.getProperty(label,
+                       AuthorityJAXBSchema.REF_NAME));
+            ilistItem.setShortIdentifier((String) docModel.getProperty(label,
+                       AuthorityJAXBSchema.SHORT_IDENTIFIER));
+            ilistItem.setVocabType((String) docModel.getProperty(label,
+                       AuthorityJAXBSchema.VOCAB_TYPE));
             String id = NuxeoUtils.extractId(docModel.getPathAsString());
             ilistItem.setUri(getServiceContextPath() + id);
             ilistItem.setCsid(id);
index 53de3e74a4c834db37fb89b209f3da0a97e6011e..4dcccdf2767f1ac1140c2a26695588d53ba93b64 100644 (file)
@@ -33,6 +33,7 @@ import org.collectionspace.services.LocationJAXBSchema;
 import org.collectionspace.services.common.document.DocumentFilter;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.service.ObjectPartType;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
 import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.collectionspace.services.location.LocationsCommon;
@@ -54,7 +55,7 @@ import org.slf4j.LoggerFactory;
  *
  */
 public class LocationDocumentModelHandler
-        extends RemoteDocumentModelHandlerImpl<LocationsCommon, LocationsCommonList> {
+        extends AuthorityItemDocumentModelHandler<LocationsCommon, LocationsCommonList> {
 
     /** The logger. */
     private final Logger logger = LoggerFactory.getLogger(LocationDocumentModelHandler.class);
@@ -63,40 +64,9 @@ public class LocationDocumentModelHandler
      */
     private static final String COMMON_PART_LABEL = "locations_common";
     
-    /**
-     * location is used to stash JAXB object to use when handle is called
-     * for Action.CREATE, Action.UPDATE or Action.GET
-     */
-    private LocationsCommon location;
-    /**
-     * locationList is stashed when handle is called
-     * for ACTION.GET_ALL
-     */
-    private LocationsCommonList locationList;
-    
-    /**
-     * inAuthority is the parent OrgAuthority for this context
-     */
-    private String inAuthority;
-
-    /**
-     * Gets the in authority.
-     *
-     * @return the in authority
-     */
-    public String getInAuthority() {
-               return inAuthority;
-       }
-
-       /**
-        * Sets the in authority.
-        *
-        * @param inAuthority the new in authority
-        */
-       public void setInAuthority(String inAuthority) {
-               this.inAuthority = inAuthority;
-       }
-
+    public LocationDocumentModelHandler() {
+       super(COMMON_PART_LABEL);
+    }
        
     /* (non-Javadoc)
      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
@@ -155,75 +125,6 @@ public class LocationDocumentModelHandler
                        return newStr.toString();
     }
     
-    /**
-     * getCommonPart get associated location
-     * @return
-     */
-    @Override
-    public LocationsCommon getCommonPart() {
-        return location;
-    }
-
-    /**
-     * setCommonPart set associated location
-     * @param location
-     */
-    @Override
-    public void setCommonPart(LocationsCommon location) {
-        this.location = location;
-    }
-
-    /**
-     * getCommonPartList get associated location (for index/GET_ALL)
-     * @return
-     */
-    @Override
-    public LocationsCommonList getCommonPartList() {
-        return locationList;
-    }
-
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
-     */
-    @Override
-    public void setCommonPartList(LocationsCommonList locationList) {
-        this.locationList = locationList;
-    }
-
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
-     */
-    @Override
-    protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
-            throws Exception {
-       Map<String, Object> unQObjectProperties = super.extractPart(docModel, schema, partMeta);
-       
-       // Add the CSID to the common part
-       if (partMeta.getLabel().equalsIgnoreCase(COMMON_PART_LABEL)) {
-               String csid = NuxeoUtils.extractId(docModel.getPathAsString());
-               unQObjectProperties.put("csid", csid);
-       }
-       
-       return unQObjectProperties;
-    }
-    
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
-     */
-    @Override
-    public LocationsCommon extractCommonPart(DocumentWrapper wrapDoc)
-            throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
-    /* (non-Javadoc)
-     * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
-     */
-    @Override
-    public void fillCommonPart(LocationsCommon locationObject, DocumentWrapper wrapDoc) throws Exception {
-        throw new UnsupportedOperationException();
-    }
-
     /* (non-Javadoc)
      * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
      */
index 1d234996a685689dc13d769597bdfeede18639ac..8c10c5452397752f197c8a0c70fa210be03e7ef7 100644 (file)
@@ -26,6 +26,7 @@
     <xs:element name="inAuthority" type="xs:string" />
                <xs:element name="shortIdentifier" type="xs:string"/>
     <xs:element name="refName" type="xs:string"/>
+    <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="displayNameComputed" type="xs:boolean"/>
     <xs:element name="shortName" type="xs:string"/>
@@ -39,7 +40,6 @@
     <xs:element name="function" type="xs:string"/>
     <xs:element name="subBody" type="xs:string"/>
     <xs:element name="history" type="xs:string"/>
-    <xs:element name="termStatus" type="xs:string"/>
 
 </xs:schema>
 
index 4ee853c5d3930e6617c04a02289d6a4602812fcc..5f29214faedd131de92fb179af47469a7630a2b8 100644 (file)
@@ -816,40 +816,45 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
-        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, Response.Status.OK.getStatusCode());
-
-        // Check whether organization has expected displayName.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
-                client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(organization);
-        // Try to Update with computed false and no displayName
-       organization.setDisplayNameComputed(false);
-        organization.setDisplayName(null);
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getItemCommonPartName());
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        statusCode = res.getStatus();
-
-        // Check the status code of the response: does it match the expected response(s)?
-        if(logger.isDebugEnabled()){
-            logger.debug("updateItem: status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+        try {
+               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, Response.Status.OK.getStatusCode());
+       
+               // Check whether organization has expected displayName.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), OrganizationsCommon.class);
+               Assert.assertNotNull(organization);
+               // Try to Update with computed false and no displayName
+               organization.setDisplayNameComputed(false);
+               organization.setDisplayName(null);
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getItemCommonPartName());
+               res.releaseConnection();
+               res = client.updateItem(knownResourceId, knownItemResourceId, output);
+               statusCode = res.getStatus();
+       
+               // Check the status code of the response: does it match the expected response(s)?
+               if(logger.isDebugEnabled()){
+                   logger.debug("updateItem: status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -873,30 +878,33 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         ClientResponse<MultipartInput> res =
             client.readContact(knownResourceId, knownItemResourceId,
             knownContactResourceId);
-        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);
-
-        // Check whether we've received a contact.
-        MultipartInput input = (MultipartInput) res.getEntity();
-        ContactsCommon contact = (ContactsCommon) extractPart(input,
-                new ContactClient().getCommonPartName(), ContactsCommon.class);
-        Assert.assertNotNull(contact);
-        boolean showFull = true;
-        if(showFull && logger.isDebugEnabled()){
-            logger.debug(testName + ": returned payload:");
-            logger.debug(objectAsXmlString(contact, ContactsCommon.class));
-        }
-        Assert.assertEquals(contact.getInAuthority(), knownResourceId);
-        Assert.assertEquals(contact.getInItem(), knownItemResourceId);
-
+        try {
+               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);
+       
+               // Check whether we've received a contact.
+               MultipartInput input = (MultipartInput) res.getEntity();
+               ContactsCommon contact = (ContactsCommon) extractPart(input,
+                       new ContactClient().getCommonPartName(), ContactsCommon.class);
+               Assert.assertNotNull(contact);
+               boolean showFull = true;
+               if(showFull && logger.isDebugEnabled()){
+                   logger.debug(testName + ": returned payload:");
+                   logger.debug(objectAsXmlString(contact, ContactsCommon.class));
+               }
+               Assert.assertEquals(contact.getInAuthority(), knownResourceId);
+               Assert.assertEquals(contact.getInItem(), knownItemResourceId);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -917,16 +925,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -947,16 +959,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -978,16 +994,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res =
             client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // ---------------------------------------------------------------
@@ -1012,36 +1032,40 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<OrgauthoritiesCommonList> res = client.readList();
-        OrgauthoritiesCommonList 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);
-
-        // Optionally output additional data about list members for debugging.
-        boolean iterateThroughList = false;
-        if (iterateThroughList && logger.isDebugEnabled()) {
-            List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
-                    list.getOrgauthorityListItem();
-            int i = 0;
-            for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
-                String csid = item.getCsid();
-                logger.debug(testName + ": list-item[" + i + "] csid=" +
-                        csid);
-                logger.debug(testName + ": list-item[" + i + "] displayName=" +
-                        item.getDisplayName());
-                logger.debug(testName + ": list-item[" + i + "] URI=" +
-                        item.getUri());
-                readItemList(csid, null);
-                i++;
-            }
-        }
+        try {
+               OrgauthoritiesCommonList 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);
+       
+               // Optionally output additional data about list members for debugging.
+               boolean iterateThroughList = false;
+               if (iterateThroughList && logger.isDebugEnabled()) {
+                   List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
+                           list.getOrgauthorityListItem();
+                   int i = 0;
+                   for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
+                       String csid = item.getCsid();
+                       logger.debug(testName + ": list-item[" + i + "] csid=" +
+                               csid);
+                       logger.debug(testName + ": list-item[" + i + "] displayName=" +
+                               item.getDisplayName());
+                       logger.debug(testName + ": list-item[" + i + "] URI=" +
+                               item.getUri());
+                       readItemList(csid, null);
+                       i++;
+                   }
+               }
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1086,52 +1110,56 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         } else {
                Assert.fail("readItemList passed null csid and name!");
         }
-        OrganizationsCommonList 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);
-
-        List<OrganizationsCommonList.OrganizationListItem> items =
-            list.getOrganizationListItem();
-        int nItemsReturned = items.size();
-        // There will be one item created, associated with a
-        // known parent resource, by the createItem test.
-        //
-        // In addition, there will be 'nItemsToCreateInList'
-        // additional items created by the createItemList test,
-        // all associated with the same parent resource.
-        int nExpectedItems = nItemsToCreateInList + 1;
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": Expected "
-                       + nExpectedItems +" items; got: "+nItemsReturned);
-        }
-        Assert.assertEquals(nItemsReturned, nExpectedItems);
-
-        int i = 0;
-        for (OrganizationsCommonList.OrganizationListItem item : items) {
-               Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
-               Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
-               // Optionally output additional data about list members for debugging.
-               boolean showDetails = true;
-               if (showDetails && logger.isDebugEnabled()) {
-                logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
-                        item.getCsid());
-                logger.debug("  " + testName + ": list-item[" + i + "] refName=" +
-                        item.getRefName());
-                logger.debug("  " + testName + ": list-item[" + i + "] displayName=" +
-                        item.getDisplayName());
-                logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
-                        item.getUri());
-            }
-            i++;
-        }
+        try {
+               OrganizationsCommonList 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);
+       
+               List<OrganizationsCommonList.OrganizationListItem> items =
+                   list.getOrganizationListItem();
+               int nItemsReturned = items.size();
+               // There will be one item created, associated with a
+               // known parent resource, by the createItem test.
+               //
+               // In addition, there will be 'nItemsToCreateInList'
+               // additional items created by the createItemList test,
+               // all associated with the same parent resource.
+               int nExpectedItems = nItemsToCreateInList + 1;
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": Expected "
+                               + nExpectedItems +" items; got: "+nItemsReturned);
+               }
+               Assert.assertEquals(nItemsReturned, nExpectedItems);
+       
+               int i = 0;
+               for (OrganizationsCommonList.OrganizationListItem item : items) {
+                       Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
+                       Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
+                       // Optionally output additional data about list members for debugging.
+                       boolean showDetails = true;
+                       if (showDetails && logger.isDebugEnabled()) {
+                       logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
+                               item.getCsid());
+                       logger.debug("  " + testName + ": list-item[" + i + "] refName=" +
+                               item.getRefName());
+                       logger.debug("  " + testName + ": list-item[" + i + "] displayName=" +
+                               item.getDisplayName());
+                       logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
+                               item.getUri());
+                   }
+                   i++;
+               }
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1162,48 +1190,52 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         ContactsCommonList list = null;
         ClientResponse<ContactsCommonList> res =
                 client.readContactList(parentcsid, itemcsid);
-        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);
-
-        List<ContactsCommonList.ContactListItem> listitems =
-            list.getContactListItem();
-        int nItemsReturned = listitems.size();
-        // There will be one item created, associated with a
-        // known parent resource, by the createItem test.
-        //
-        // In addition, there will be 'nItemsToCreateInList'
-        // additional items created by the createItemList test,
-        // all associated with the same parent resource.
-        int nExpectedItems = nItemsToCreateInList + 1;
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": Expected "
-                       + nExpectedItems +" items; got: "+nItemsReturned);
-        }
-        Assert.assertEquals(nItemsReturned, nExpectedItems);
-
-        int i = 0;
-        for (ContactsCommonList.ContactListItem listitem : listitems) {
-               // Optionally output additional data about list members for debugging.
-               boolean showDetails = false;
-               if (showDetails && logger.isDebugEnabled()) {
-                logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
-                        listitem.getCsid());
-                logger.debug("  " + testName + ": list-item[" + i + "] addressPlace=" +
-                        listitem.getAddressPlace());
-                logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
-                        listitem.getUri());
-            }
-            i++;
-        }
+        try {
+               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);
+       
+               List<ContactsCommonList.ContactListItem> listitems =
+                   list.getContactListItem();
+               int nItemsReturned = listitems.size();
+               // There will be one item created, associated with a
+               // known parent resource, by the createItem test.
+               //
+               // In addition, there will be 'nItemsToCreateInList'
+               // additional items created by the createItemList test,
+               // all associated with the same parent resource.
+               int nExpectedItems = nItemsToCreateInList + 1;
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": Expected "
+                               + nExpectedItems +" items; got: "+nItemsReturned);
+               }
+               Assert.assertEquals(nItemsReturned, nExpectedItems);
+       
+               int i = 0;
+               for (ContactsCommonList.ContactListItem listitem : listitems) {
+                       // Optionally output additional data about list members for debugging.
+                       boolean showDetails = false;
+                       if (showDetails && logger.isDebugEnabled()) {
+                       logger.debug("  " + testName + ": list-item[" + i + "] csid=" +
+                               listitem.getCsid());
+                       logger.debug("  " + testName + ": list-item[" + i + "] addressPlace=" +
+                               listitem.getAddressPlace());
+                       logger.debug("  " + testName + ": list-item[" + i + "] URI=" +
+                               listitem.getUri());
+                   }
+                   i++;
+               }
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -1231,53 +1263,58 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res =
                 client.read(knownResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
-        }
-        MultipartInput input = (MultipartInput) res.getEntity();
-        OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
-                client.getCommonPartName(), OrgauthoritiesCommon.class);
-        Assert.assertNotNull(orgAuthority);
-
-        // Update the contents of this resource.
-        orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
-        orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
-        if(logger.isDebugEnabled()){
-            logger.debug("to be updated OrgAuthority");
-            logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
-        }
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getCommonPartName());
-        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()){
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
-        Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        OrgauthoritiesCommon updatedOrgAuthority =
-                (OrgauthoritiesCommon) extractPart(input,
-                        client.getCommonPartName(), OrgauthoritiesCommon.class);
-        Assert.assertNotNull(updatedOrgAuthority);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
-                orgAuthority.getDisplayName(),
-                "Data in updated object did not match submitted data.");
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
+               }
+               MultipartInput input = (MultipartInput) res.getEntity();
+               OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+                       client.getCommonPartName(), OrgauthoritiesCommon.class);
+               Assert.assertNotNull(orgAuthority);
+       
+               // Update the contents of this resource.
+               orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
+               orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
+               if(logger.isDebugEnabled()){
+                   logger.debug("to be updated OrgAuthority");
+                   logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+               }
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getCommonPartName());
+               res.releaseConnection();
+               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()){
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+               Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               OrgauthoritiesCommon updatedOrgAuthority =
+                       (OrgauthoritiesCommon) extractPart(input,
+                               client.getCommonPartName(), OrgauthoritiesCommon.class);
+               Assert.assertNotNull(updatedOrgAuthority);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
+                       orgAuthority.getDisplayName(),
+                       "Data in updated object did not match submitted data.");
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1300,56 +1337,61 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res =
                 client.readItem(knownResourceId, knownItemResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got Organization to update with ID: " +
-                knownItemResourceId +
-                " in OrgAuthority: " + knownResourceId );
-        }
-        MultipartInput input = (MultipartInput) res.getEntity();
-        OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
-                client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(organization);
-
-        // Update the contents of this resource.
-        organization.setCsid(null);
-        organization.setShortName("updated-" + organization.getShortName());
-        if(logger.isDebugEnabled()){
-            logger.debug("to be updated Organization");
-            logger.debug(objectAsXmlString(organization,
-                OrganizationsCommon.class));
-        }
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", client.getItemCommonPartName());
-        res = client.updateItem(knownResourceId, knownItemResourceId, output);
-        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);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        OrganizationsCommon updatedOrganization =
-                (OrganizationsCommon) extractPart(input,
-                        client.getItemCommonPartName(), OrganizationsCommon.class);
-        Assert.assertNotNull(updatedOrganization);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedOrganization.getShortName(),
-                organization.getShortName(),
-                "Data in updated Organization did not match submitted data.");
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got Organization to update with ID: " +
+                       knownItemResourceId +
+                       " in OrgAuthority: " + knownResourceId );
+               }
+               MultipartInput input = (MultipartInput) res.getEntity();
+               OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+                       client.getItemCommonPartName(), OrganizationsCommon.class);
+               Assert.assertNotNull(organization);
+       
+               // Update the contents of this resource.
+               organization.setCsid(null);
+               organization.setShortName("updated-" + organization.getShortName());
+               if(logger.isDebugEnabled()){
+                   logger.debug("to be updated Organization");
+                   logger.debug(objectAsXmlString(organization,
+                       OrganizationsCommon.class));
+               }
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", client.getItemCommonPartName());
+               res.releaseConnection();
+               res = client.updateItem(knownResourceId, knownItemResourceId, output);
+               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);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               OrganizationsCommon updatedOrganization =
+                       (OrganizationsCommon) extractPart(input,
+                               client.getItemCommonPartName(), OrganizationsCommon.class);
+               Assert.assertNotNull(updatedOrganization);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedOrganization.getShortName(),
+                       organization.getShortName(),
+                       "Data in updated Organization did not match submitted data.");
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1372,56 +1414,61 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<MultipartInput> res =
                 client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
-        if(logger.isDebugEnabled()){
-            logger.debug(testName + ": read status = " + res.getStatus());
-        }
-        Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
-        if(logger.isDebugEnabled()){
-            logger.debug("got Contact to update with ID: " +
-                knownContactResourceId +
-                " in item: " + knownItemResourceId +
-                " in parent: " + knownResourceId );
-        }
-        MultipartInput input = (MultipartInput) res.getEntity();
-        ContactsCommon contact = (ContactsCommon) extractPart(input,
-                new ContactClient().getCommonPartName(), ContactsCommon.class);
-        Assert.assertNotNull(contact);
-
-        // Update the contents of this resource.
-        contact.setAddressPlace("updated-" + contact.getAddressPlace());
-        if(logger.isDebugEnabled()){
-            logger.debug("to be updated Contact");
-            logger.debug(objectAsXmlString(contact,
-                ContactsCommon.class));
-        }
-
-        // Submit the updated resource to the service and store the response.
-        MultipartOutput output = new MultipartOutput();
-        OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
-        commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
-        res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
-        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);
-
-        // Retrieve the updated resource and verify that its contents exist.
-        input = (MultipartInput) res.getEntity();
-        ContactsCommon updatedContact =
-                (ContactsCommon) extractPart(input,
-                        new ContactClient().getCommonPartName(), ContactsCommon.class);
-        Assert.assertNotNull(updatedContact);
-
-        // Verify that the updated resource received the correct data.
-        Assert.assertEquals(updatedContact.getAddressPlace(),
-                contact.getAddressPlace(),
-                "Data in updated Contact did not match submitted data.");
+        try {
+               if(logger.isDebugEnabled()){
+                   logger.debug(testName + ": read status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+       
+               if(logger.isDebugEnabled()){
+                   logger.debug("got Contact to update with ID: " +
+                       knownContactResourceId +
+                       " in item: " + knownItemResourceId +
+                       " in parent: " + knownResourceId );
+               }
+               MultipartInput input = (MultipartInput) res.getEntity();
+               ContactsCommon contact = (ContactsCommon) extractPart(input,
+                       new ContactClient().getCommonPartName(), ContactsCommon.class);
+               Assert.assertNotNull(contact);
+       
+               // Update the contents of this resource.
+               contact.setAddressPlace("updated-" + contact.getAddressPlace());
+               if(logger.isDebugEnabled()){
+                   logger.debug("to be updated Contact");
+                   logger.debug(objectAsXmlString(contact,
+                       ContactsCommon.class));
+               }
+       
+               // Submit the updated resource to the service and store the response.
+               MultipartOutput output = new MultipartOutput();
+               OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
+               commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
+               res.releaseConnection();
+               res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
+               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);
+       
+               // Retrieve the updated resource and verify that its contents exist.
+               input = (MultipartInput) res.getEntity();
+               ContactsCommon updatedContact =
+                       (ContactsCommon) extractPart(input,
+                               new ContactClient().getCommonPartName(), ContactsCommon.class);
+               Assert.assertNotNull(updatedContact);
+       
+               // Verify that the updated resource received the correct data.
+               Assert.assertEquals(updatedContact.getAddressPlace(),
+                       contact.getAddressPlace(),
+                       "Data in updated Contact did not match submitted data.");
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -1560,16 +1607,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                                new OrgAuthorityClient().getCommonPartName());
         ClientResponse<MultipartInput> res =
                 client.update(NON_EXISTENT_ID, multipart);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1601,16 +1652,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
                        nonexOrgMap, client.getItemCommonPartName() );
         ClientResponse<MultipartInput> res =
                 client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1659,16 +1714,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<Response> res =
             client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
    /**
@@ -1695,16 +1754,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /* (non-Javadoc)
@@ -1728,16 +1791,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<Response> res = client.delete(knownResourceId);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -1758,16 +1825,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1788,16 +1859,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1819,16 +1894,20 @@ public class OrgAuthorityServiceTest extends AbstractServiceTestImpl {
         OrgAuthorityClient client = new OrgAuthorityClient();
         ClientResponse<Response> res =
             client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
-        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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // ---------------------------------------------------------------
index 08e6f88ec6290d1377df5fd18aa9f32072131a3d..8dd893c627aea085d1e58b025e3f2a1bd0fc2fe1 100644 (file)
@@ -22,7 +22,6 @@ public interface OrganizationJAXBSchema extends AuthorityJAXBSchema {
        final static String FUNCTION = "function";\r
     final static String SUB_BODY = "subBody";\r
        final static String HISTORY = "history";\r
-    final static String TERM_STATUS = "termStatus";\r
 }\r
 \r
 \r
index 1f6738c973da081311ddab5c22afc63b21d8a057..5288b135d23b2a12b6c6521d68d249a6c90d5d0f 100644 (file)
@@ -23,6 +23,7 @@
                 <xs:element name="inAuthority" type="xs:string" />
                                                                <xs:element name="shortIdentifier" type="xs:string"/>
                 <xs:element name="refName" type="xs:string"/>
+                <xs:element name="termStatus" type="xs:string"/>
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="displayNameComputed" type="xs:boolean"/>
                 <xs:element name="shortName" type="xs:string"/>
@@ -36,7 +37,6 @@
                 <xs:element name="function" type="xs:string"/>
                 <xs:element name="subBody" type="xs:string"/>
                 <xs:element name="history" type="xs:string"/>
-                <xs:element name="termStatus" type="xs:string"/>
             </xs:sequence>
         </xs:complexType>
     </xs:element>
index 41c8ad9c38db9bd996469abff40f314cf4d068f6..8c418b21a89cc0bf7609a2cc9510c35fcd2d4260 100644 (file)
@@ -80,19 +80,13 @@ public class OrgAuthorityResource extends
        AuthorityResource<OrgauthoritiesCommon, OrgauthoritiesCommonList, OrganizationsCommon,
        OrganizationDocumentModelHandler> {
 
-    /** The Constant orgAuthorityServiceName. */
     private final static String orgAuthorityServiceName = "orgauthorities";
        private final static String ORGAUTHORITIES_COMMON = "orgauthorities_common";
     
-    /** The Constant organizationServiceName. */
     private final static String organizationServiceName = "organizations";
        private final static String ORGANIZATIONS_COMMON = "organizations_common";
     
-    /** The logger. */
     final Logger logger = LoggerFactory.getLogger(OrgAuthorityResource.class);
-    //FIXME retrieve client type from configuration
-    /** The Constant CLIENT_TYPE. */
-    //final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
     
     /** The contact resource. */
     private ContactResource contactResource = new ContactResource();
index dfe77455ba2eab4d2c2e2ab6226b71fc323b9b30..6be3d6b637e16517e015af030d7d9ea44dc16815 100644 (file)
@@ -25,6 +25,7 @@
     <xs:element name="inAuthority" type="xs:string" />
                <xs:element name="shortIdentifier" type="xs:string"/>
     <xs:element name="refName" type="xs:string"/>
+    <xs:element name="termStatus" type="xs:string"/>
     <xs:element name="displayName" type="xs:string"/>
     <xs:element name="displayNameComputed" type="xs:boolean"/>
     <xs:element name="foreName" type="xs:string"/>
@@ -45,7 +46,6 @@
     <xs:element name="schoolOrStyle" type="xs:string"/>
     <xs:element name="bioNote" type="xs:string"/>
     <xs:element name="nameNote" type="xs:string"/>
-    <xs:element name="termStatus" type="xs:string"/>
 
 </xs:schema>
 
index 47ded8b7c92a79da883712f9cc50e6ea8cfb6e05..ae1ac06361119ef9cebe73fc536f2c7939d31b6f 100644 (file)
@@ -1805,17 +1805,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res =
             client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
-        int statusCode = res.getStatus();
-        res.releaseConnection();
-
-        // 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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
    /**
@@ -1842,17 +1845,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
-        int statusCode = res.getStatus();
-        res.releaseConnection();
-
-        // 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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /* (non-Javadoc)
@@ -1876,17 +1882,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.delete(knownResourceId);
-        int statusCode = res.getStatus();
-        res.releaseConnection();
-
-        // 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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // Failure outcomes
@@ -1907,17 +1916,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-        res.releaseConnection();
-
-        // 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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1938,17 +1950,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         // Submit the request to the service and store the response.
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-        res.releaseConnection();
-
-        // 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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     /**
@@ -1970,17 +1985,20 @@ public class PersonAuthorityServiceTest extends AbstractServiceTestImpl {
         PersonAuthorityClient client = new PersonAuthorityClient();
         ClientResponse<Response> res =
             client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
-        res.releaseConnection();
-
-        // 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);
+        try {
+               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);
+           } finally {
+               res.releaseConnection();
+           }
     }
 
     // ---------------------------------------------------------------
index 353ea4d2b5b7f7bd386de6b5acb1106613ded466..7653c917e1b9e496a373232801e55e0b5a9f97d3 100644 (file)
@@ -29,6 +29,5 @@ public interface PersonJAXBSchema extends AuthorityJAXBSchema {
        final static String SCHOOL_OR_STYLE = "schoolOrStyle";\r
        final static String BIO_NOTE = "bioNote";\r
        final static String NAME_NOTE = "nameNote";\r
-    final static String TERM_STATUS = "termStatus";\r
 }\r
 \r
index a41450d88dc6c5f5f6e1b332d92a4829d8569028..b095c30fcb046d4d7077f7caf571ea22e05d30ed 100644 (file)
@@ -35,6 +35,7 @@
                 <xs:element name="inAuthority" type="xs:string" />
                                                                <xs:element name="shortIdentifier" type="xs:string"/>
                 <xs:element name="refName" type="xs:string" />
+                <xs:element name="termStatus" type="xs:string"/>
                 <xs:element name="displayName" type="xs:string"/>
                 <xs:element name="displayNameComputed" type="xs:boolean"/>
                 <xs:element name="foreName" type="xs:string"/>
@@ -55,7 +56,6 @@
                 <xs:element name="schoolOrStyle" type="xs:string"/>
                 <xs:element name="bioNote" type="xs:string"/>
                 <xs:element name="nameNote" type="xs:string"/>
-                <xs:element name="termStatus" type="xs:string"/>
             </xs:sequence>
         </xs:complexType>
     </xs:element>
index 0f920f11170ff2cadea4a37050a81689dc4b3608..7202c731e877c467c2eb226c529b9f33035177ab 100644 (file)
@@ -25,8 +25,8 @@
                <xs:element name="inAuthority" type="xs:string" />
                <xs:element name="refName" type="xs:string"/>
                <xs:element name="shortIdentifier" type="xs:string"/>
+               <xs:element name="termStatus" type="xs:string"/>
                <xs:element name="displayName" type="xs:string"/>
-                <xs:element name="status" type="xs:string"/>
 
 </xs:schema>
 
index 77211d048303f6ce117ab8a2c25bc811b048cfac..4e7af77c078b5d21be4d96e7e029e3400e03436a 100644 (file)
@@ -25,7 +25,7 @@
                                <xs:element name="displayName" type="xs:string" />
                                <xs:element name="shortIdentifier" type="xs:string" />
                                <xs:element name="refName" type="xs:string" />
-                               <xs:element name="status" type="xs:string" />
+                               <xs:element name="termStatus" type="xs:string" />
                        </xs:sequence>
                </xs:complexType>
        </xs:element>