]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-6281: Replacing refs of now deprecated ClientResponse<T> with javax.ws.rs...
authorremillet <remillet@yahoo.com>
Fri, 31 Jul 2015 21:01:34 +0000 (14:01 -0700)
committerremillet <remillet@yahoo.com>
Fri, 31 Jul 2015 21:01:34 +0000 (14:01 -0700)
55 files changed:
services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/CollectionSpaceIntegrationTest.java
services/IntegrationTests/src/test/java/org/collectionspace/services/IntegrationTests/test/RelationIntegrationTest.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/CollectionSpacePerformanceTest.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/I1591Multiple.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/I1591OneInst.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/I1591OneInstOneClose.java
services/PerformanceTests/src/test/java/org/collectionspace/services/PerformanceTests/test/PerformanceTest.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionAuthRefsTest.java
services/acquisition/client/src/test/java/org/collectionspace/services/client/test/AcquisitionServiceTest.java
services/batch/service/src/main/java/org/collectionspace/services/batch/nuxeo/UpdateObjectLocationBatchJob.java
services/blob/client/src/test/java/org/collectionspace/services/client/test/BlobAuthRefsTest.java
services/client/src/main/java/org/collectionspace/services/client/AbstractPoxServiceClientImpl.java
services/client/src/main/java/org/collectionspace/services/client/AbstractServiceClientImpl.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpaceClient.java
services/client/src/main/java/org/collectionspace/services/client/CollectionSpacePoxProxy.java
services/client/src/main/java/org/collectionspace/services/client/test/AbstractServiceTestImpl.java
services/client/src/main/java/org/collectionspace/services/client/test/BaseServiceTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectAuthRefsTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectSearchTest.java
services/collectionobject/client/src/test/java/org/collectionspace/services/client/test/CollectionObjectServiceTest.java
services/common/pom.xml
services/common/src/main/java/org/collectionspace/services/common/AbstractCollectionSpaceResourceImpl.java
services/common/src/main/java/org/collectionspace/services/common/CollectionSpaceResource.java
services/common/src/main/java/org/collectionspace/services/common/publicitem/PublicItemResource.java
services/common/src/main/java/org/collectionspace/services/common/security/SecurityInterceptor.java
services/conditioncheck/client/src/test/java/org/collectionspace/services/client/test/ConditioncheckAuthRefsTest.java
services/conditioncheck/client/src/test/java/org/collectionspace/services/client/test/ConditioncheckServiceTest.java
services/contact/client/src/test/java/org/collectionspace/services/client/test/ContactServiceTest.java
services/exhibition/client/src/test/java/org/collectionspace/services/client/test/ExhibitionServiceTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/IntakeAuthRefsTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/OrganizationAuthRefDocsTest.java
services/intake/client/src/test/java/org/collectionspace/services/client/test/PersonAuthRefDocsTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninAuthRefsTest.java
services/loanin/client/src/test/java/org/collectionspace/services/client/test/LoaninServiceTest.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutAuthRefsTest.java
services/loanout/client/src/test/java/org/collectionspace/services/client/test/LoanoutServiceTest.java
services/media/client/src/test/java/org/collectionspace/services/client/test/MediaAuthRefsTest.java
services/media/client/src/test/java/org/collectionspace/services/client/test/MediaServiceTest.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementAuthRefsTest.java
services/movement/client/src/test/java/org/collectionspace/services/client/test/MovementSortByTest.java
services/objectexit/client/src/test/java/org/collectionspace/services/client/test/ObjectExitAuthRefsTest.java
services/organization/client/src/test/java/org/collectionspace/services/client/test/OrgAuthorityAuthRefsTest.java
services/person/client/src/main/java/org/collectionspace/services/client/PersonAuthorityClientUtils.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthoritySearchTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServicePerfTest.java
services/person/client/src/test/java/org/collectionspace/services/client/test/PersonAuthorityServiceTest.java
services/publicitem/client/src/test/java/org/collectionspace/services/client/test/PublicItemServiceTest.java
services/relation/client/src/test/java/org/collectionspace/services/client/test/RelationServiceTest.java
services/report/client/src/test/java/org/collectionspace/services/client/test/ReportServiceTest.java
services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthenticationServiceTest.java
services/security/client/src/test/java/org/collectionspace/services/security/client/test/AuthorizationServiceTest.java
services/security/client/src/test/java/org/collectionspace/services/security/client/test/MultiTenancyTest.java
services/valuationcontrol/client/src/test/java/org/collectionspace/services/client/test/ValuationcontrolServiceTest.java
services/vocabulary/client/pom.xml
services/vocabulary/client/src/test/java/org/collectionspace/services/client/test/VocabularyServiceTest.java

index 209cccf9f856e4ef42720bc32ca5fb5aa80fe86c..c7b598880e3a96c741ecefa44c6ec7eea4657aa5 100644 (file)
@@ -157,6 +157,19 @@ public abstract class CollectionSpaceIntegrationTest {
                
                return result;
        }
+       
+       String extractId(Response res) {
+               String result = null;
+               
+               MultivaluedMap mvm = res.getMetadata();
+               String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
+               verbose("extractId:uri=" + uri);
+               String[] segments = uri.split("/");
+               result = segments[segments.length - 1];
+               verbose("id=" + result);
+               
+               return result;
+       }       
 
        /**
         * Extract part.
index ba17076571d8cbd08c75f7ae332573d84dab689a..1c1c6af86f0f5dc0c1e82e1505a3b8b477bf9b83 100644 (file)
@@ -144,14 +144,14 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
                
                // Make the "create" call and check the response
-               ClientResponse<Response> response = collectionObjectClient.create(multipart);
+               Response response = collectionObjectClient.create(multipart);
                String collectionObjectCsid = null;
                try {
                        Assert.assertEquals(response.getStatus(), Response.Status.CREATED
                                        .getStatusCode());
                        collectionObjectCsid = extractId(response);
                } finally {
-                       response.releaseConnection();
+                       response.close();
                }
                
                // Create a new dimension record
@@ -163,7 +163,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    dimensionCsid1 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            // Relate the entities, by creating a new relation object
@@ -181,7 +181,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    relationCsid1 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }       
            
            // Now lock the dimension record.
@@ -197,7 +197,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            try {
                    Assert.assertEquals(response.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            // Also, try to soft-delete.  This should also fail.
@@ -215,14 +215,14 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                PayloadOutputPart commonPart = multipart.addPart(collectionObjectClient.getCommonPartName(), co);
                
                // Make the create call and check the response
-               ClientResponse<Response> response = collectionObjectClient.create(multipart);
+               Response response = collectionObjectClient.create(multipart);
                String collectionObjectCsid = null;
                try {
                        Assert.assertEquals(response.getStatus(), Response.Status.CREATED
                                        .getStatusCode());
                        collectionObjectCsid = extractId(response);
                } finally {
-                       response.releaseConnection();
+                       response.close();
                }
                
                //Next, create the first of three Dimension records to relate the collection object record
@@ -234,7 +234,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    dimensionCsid1 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
                //Next, create a the second Dimension record
@@ -246,7 +246,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    dimensionCsid2 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
                //Next, create a the 3rd Dimension record
@@ -258,7 +258,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    dimensionCsid3 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            // Relate the entities, by creating a new relation object
@@ -277,7 +277,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    relationCsid1 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            // Wait 1 second and create the second relationship
            try {
@@ -302,7 +302,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    relationCsid2 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            // Wait 1 second and create the 3rd relationship
            try {
@@ -327,7 +327,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    relationCsid3 = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }               
        }    
        
@@ -344,14 +344,14 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                commonPart.setLabel(collectionObjectClient.getCommonPartName());
                
                // Make the create call and check the response
-               ClientResponse<Response> response = collectionObjectClient.create(multipart);
+               Response response = collectionObjectClient.create(multipart);
                String collectionObjectCsid = null;
                try {
                        Assert.assertEquals(response.getStatus(), Response.Status.CREATED
                                        .getStatusCode());
                        collectionObjectCsid = extractId(response);
                } finally {
-                       response.releaseConnection();
+                       response.close();
                }
                
                //Next, create a Dimension record to relate the collection object to
@@ -363,7 +363,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    dimensionCsid = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            @SuppressWarnings("unused")
@@ -381,16 +381,14 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            commonPart.setLabel(relationClient.getCommonPartName());
 
            // Make the call to crate
-           ClientResponse<Response> relationresponse = relationClient.create(multipart);
-           @SuppressWarnings("unused")
+           Response relationresponse = relationClient.create(multipart);
                String relationCsid = null;
            try {
                    Assert.assertEquals(relationresponse.getStatus(), Response.Status.BAD_REQUEST.getStatusCode());
                    relationCsid = extractId(response);
            } finally {
-               relationresponse.releaseConnection();
+               relationresponse.close();
            }
-           
        }
        
        @Test
@@ -407,14 +405,14 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                commonPart.setLabel(collectionObjectClient.getCommonPartName());
                
                // Make the create call and check the response
-               ClientResponse<Response> response = collectionObjectClient.create(multipart);
+               Response response = collectionObjectClient.create(multipart);
                String collectionObjectCsid = null;
                try {
                        Assert.assertEquals(response.getStatus(), Response.Status.CREATED
                                        .getStatusCode());
                        collectionObjectCsid = extractId(response);
                } finally {
-                       response.releaseConnection();
+                       response.close();
                }
            
            
@@ -433,7 +431,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    intakeCsid = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            // Lastly, relate the two entities, by creating a new relation object
@@ -453,7 +451,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    relationCsid = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            //
@@ -471,7 +469,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
                relationList = resultResponse.getEntity();
            } finally {
-               resultResponse.releaseConnection();
+               resultResponse.close();
            }
            
            //
@@ -498,7 +496,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                } catch (Exception e) {
                        e.printStackTrace();
                } finally {
-                       multiPartResponse.releaseConnection();
+                       multiPartResponse.close();
                }
                
                Assert.assertEquals(resultRelation.getSubjectCsid(), collectionObjectCsid);
@@ -530,7 +528,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                        commonPart.setLabel(collectionObjectClient.getCommonPartName());
                        
                        // Make the create call and check the response
-                       ClientResponse<Response> response = collectionObjectClient.create(multipart);
+                       Response response = collectionObjectClient.create(multipart);
                        String collectionObjectCsid = null;
                        try {
                                Assert.assertEquals(response.getStatus(), Response.Status.CREATED
@@ -538,7 +536,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                                collectionObjectCsid = extractId(response);
                                collectionObjectIDList.add(collectionObjectCsid);
                        } finally {
-                               response.releaseConnection();
+                               response.close();
                        }
                }
            
@@ -552,13 +550,13 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
            commonPart.setLabel(intakeClient.getCommonPartName());
 
            // Make the call to create and check the response
-           ClientResponse<Response> response = intakeClient.create(multipart);
+           Response response = intakeClient.create(multipart);
            String intakeCsid = null;
            try {
                    Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                    intakeCsid = extractId(response);
            } finally {
-               response.releaseConnection();
+               response.close();
            }
            
            // Lastly, relate the two entities, by creating a new relation object
@@ -580,7 +578,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                            Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                            relationCsid = extractId(response);
                    } finally {
-                       response.releaseConnection();
+                       response.close();
                    }
            }
            
@@ -601,7 +599,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                        Assert.assertEquals(resultResponse.getStatus(), Response.Status.OK.getStatusCode());
                        relationList = resultResponse.getEntity();
                    } finally {
-                       resultResponse.releaseConnection();
+                       resultResponse.close();
                    }
            
                    //
@@ -627,7 +625,7 @@ public class RelationIntegrationTest extends CollectionSpaceIntegrationTest {
                        } catch (Exception e) {
                                e.printStackTrace();
                        } finally {
-                               multiPartResponse.releaseConnection();
+                               multiPartResponse.close();
                        }
        
                        Assert.assertEquals(resultRelation.getSubjectCsid(), intakeCsid);
index cdefbad9e7bd756f8abaa3081cf264f78d5129a3..282013877c24b5a9c7ebfead72985eb88addf742 100644 (file)
@@ -158,6 +158,19 @@ public abstract class CollectionSpacePerformanceTest {
                
                return result;
        }
+       
+       String extractId(Response res) {
+               String result = null;
+               
+               MultivaluedMap mvm = res.getMetadata();
+               String uri = (String) ((ArrayList) mvm.get("Location")).get(0);
+               verbose("extractId:uri=" + uri);
+               String[] segments = uri.split("/");
+               result = segments[segments.length - 1];
+               verbose("id=" + result);
+               
+               return result;
+       }       
 
        /**
         * Extract part.
index d77d03b3d376a0b7bcf69f70e258e8c9ea4ec92d..5e6c9f67fbc9b8d61892ebdbe59b8e268687177a 100644 (file)
@@ -91,15 +91,15 @@ public class I1591Multiple extends CollectionSpacePerformanceTest {
         commonPart.setLabel(collectionObjectClient.getCommonPartName());
 
         // Make a create call with that payload and check the response.
-        ClientResponse<Response> response = collectionObjectClient.create(multipart);
+        Response response = collectionObjectClient.create(multipart);
         try {
             Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
             resourceId = extractId(response);
-        // Since failed Asserts can throw an Exception, ensure
-        // that the underlying HTTP connection is explicitly closed
-        // under all circumstances.
+               // Since failed Asserts can throw an Exception, ensure
+               // that the underlying HTTP connection is explicitly closed
+               // under all circumstances.
         } finally {
-            response.releaseConnection();
+            response.close();
         }
 
         // Return the ID of the newly-created CollectionObject resource.
index 6dfb2d1b70f9cd34e66cb72b5220cb3e59eaa046..e20b3f77fc9b50df6bb7c02c8d51e5d81d786232 100644 (file)
@@ -92,7 +92,7 @@ public class I1591OneInst extends CollectionSpacePerformanceTest {
             commonPart.setLabel(collectionObjectClient.getCommonPartName());
 
             // Make a create call with that payload and check the response.
-            ClientResponse<Response> response = collectionObjectClient.create(multipart);
+            Response response = collectionObjectClient.create(multipart);
             try {
                 Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
                 coList[i] = extractId(response);
@@ -107,7 +107,7 @@ public class I1591OneInst extends CollectionSpacePerformanceTest {
             // that the underlying HTTP connection is explicitly closed
             // under all circumstances.
             } finally {
-                response.releaseConnection();
+                response.close();
             }
 
             if (logger.isDebugEnabled() == true) {
index 1e7eccb08295885f3906aaf342cfe528897a10f6..e2418267c71e2d56b268c771e467e394c721ff89 100644 (file)
@@ -78,10 +78,8 @@ public class I1591OneInstOneClose extends CollectionSpacePerformanceTest {
         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
         long identifier = 0;
         int i = 0;
-        ClientResponse<Response> response = null;
 
         try {
-
             for (i = 0; i <= numberOfObjects; i++) {
 
                 // Create a CollectionObject instance.
@@ -95,31 +93,23 @@ public class I1591OneInstOneClose extends CollectionSpacePerformanceTest {
                 commonPart.setLabel(collectionObjectClient.getCommonPartName());
 
                 // Make a create call with that payload and check the response.
-                response = collectionObjectClient.create(multipart);
-
-                Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
-                coList[i] = extractId(response);
-
-                if (logger.isDebugEnabled() == true) {
-                    logger.debug("Created CollectionObject #: " + i);
+                Response response = collectionObjectClient.create(multipart);
+                try {
+                       Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
+                       coList[i] = extractId(response);
+                       if (logger.isDebugEnabled() == true) {
+                           logger.debug("Created CollectionObject #: " + i);
+                       }
+                } finally {
+                       response.close();
                 }
-
             }
-
         } catch (AssertionError e) {
             if (logger.isDebugEnabled() == true) {
-                logger.debug("FAILURE: Created " + i +
-                    " of " + numberOfObjects +
-                    " before failing.");
+                logger.debug("FAILURE: Created " + i + " of " + numberOfObjects + " before failing.");
             }
             Assert.assertTrue(false);
-        // Since failed Asserts can throw an Exception, ensure
-        // that the underlying HTTP connection is explicitly closed
-        // under all circumstances.
-        } finally {
-            response.releaseConnection();
         }
-        
     }
 
     @AfterClass(alwaysRun=true)
index e1ec5a2c3f68137b2d3b70f8cd79bfd3437813a6..56357790340b9b6c8b59d4d03f55c6de39482ef5 100644 (file)
@@ -174,7 +174,7 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
             PoxPayloadOut multipart) {
         String result = null;
         // Make the create call and check the response
-        ClientResponse<Response> response = collectionObjectClient.create(multipart);
+        Response response = collectionObjectClient.create(multipart);
         try {
             int responseStatus = response.getStatus();
             if (logger.isDebugEnabled() == true) {
@@ -187,7 +187,7 @@ public class PerformanceTest extends CollectionSpacePerformanceTest {
             Assert.assertEquals(response.getStatus(), Response.Status.CREATED.getStatusCode());
             result = extractId(response);
         } finally {
-            response.releaseConnection();
+            response.close();
         }
 
         return result;
index 4a6ebbc9a73aa31ba8a91241c2e774728bb85aac..fca3d94245ebfe56e3e2800c63c5fd6c1cc6ea52 100644 (file)
@@ -121,7 +121,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest<AbstractCommonList>
                                acquisitionSourcesRefNames);
 
                AcquisitionClient acquisitionClient = new AcquisitionClient();
-               ClientResponse<Response> res = acquisitionClient.create(multipart);
+               Response res = acquisitionClient.create(multipart);
 
                int statusCode = res.getStatus();
 
@@ -156,7 +156,7 @@ public class AcquisitionAuthRefsTest extends BaseServiceTest<AbstractCommonList>
                PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
                PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
                                PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-               ClientResponse<Response> res = personAuthClient.create(multipart);
+               Response res = personAuthClient.create(multipart);
                int statusCode = res.getStatus();
 
                Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
index 18ed56d7eba06047046473cec210281b669cb3c9..14c08f28380b324e4d44aab2eac44448df589d18 100644 (file)
@@ -103,7 +103,7 @@ public class AcquisitionServiceTest extends AbstractPoxServiceTestImpl<AbstractC
 
         AcquisitionClient client = new AcquisitionClient();
         PoxPayloadOut multipart = createAcquisitionInstance(identifier);
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
 
         int statusCode = res.getStatus();
 
@@ -791,7 +791,7 @@ public class AcquisitionServiceTest extends AbstractPoxServiceTestImpl<AbstractC
             multipart = createAcquisitionInstanceFromRawXml(testName,
                     client.getCommonPartName(), fileName);
         }
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         int statusCode = res.getStatus();
 
         if (logger.isDebugEnabled()) {
index 8a80800a01b2414fa270e7287a6e5d0aabc871bd..0f2dddc9b0c77113c7d2adfa004140389eb81eb4 100644 (file)
@@ -9,9 +9,12 @@ import java.util.Collections;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+
 import javax.ws.rs.core.PathSegment;
 import javax.ws.rs.core.UriInfo;
+
 import org.collectionspace.services.batch.AbstractBatchInvocable;
+import org.collectionspace.services.batch.UriInfoImpl;
 import org.collectionspace.services.client.AbstractCommonListUtils;
 import org.collectionspace.services.client.CollectionObjectClient;
 import org.collectionspace.services.client.IQueryManager;
@@ -25,7 +28,7 @@ import org.collectionspace.services.common.api.Tools;
 import org.collectionspace.services.common.invocable.InvocationResults;
 import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.dom4j.DocumentException;
-import org.jboss.resteasy.specimpl.UriInfoImpl;
+//import org.jboss.resteasy.specimpl.UriInfoImpl;
 import org.jdom.Document;
 import org.jdom.Element;
 import org.jdom.Namespace;
@@ -391,7 +394,7 @@ public class UpdateObjectLocationBatchJob extends AbstractBatchInvocable {
         return createUriInfo("");
     }
 
-    protected UriInfo createUriInfo(String queryString) throws URISyntaxException {
+    private UriInfo createUriInfo(String queryString) throws URISyntaxException {
         URI absolutePath = new URI("");
         URI baseUri = new URI("");
         return new UriInfoImpl(absolutePath, baseUri, "", queryString, Collections.<PathSegment>emptyList());
index b8a54739456bdcb7e7e6c169ae14422b1b099ee2..c91bcad956f82504009965cc0b4a68a9219dda17 100644 (file)
@@ -110,7 +110,7 @@ public class BlobAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         //    references, and will refer to Person resources by their refNames.
         BlobClient blobClient = new BlobClient();
         PoxPayloadOut multipart = createBlobInstance(depositorRefName);
-        ClientResponse<Response> res = blobClient.create(multipart);
+        Response res = blobClient.create(multipart);
         try {
                assertStatusCode(res, testName);
                if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
@@ -119,7 +119,7 @@ public class BlobAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                blobIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
     }
@@ -128,7 +128,7 @@ public class BlobAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
+        Response res = personAuthClient.create(multipart);
         try {
                assertStatusCode(res, "createPersonRefs (not a surefire test)");
                personAuthCSID = extractId(res);
@@ -145,7 +145,7 @@ public class BlobAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                depositorRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
     }
index b326a2cfbfa333d131fafbb00fce74e199845647..91fc655d5386480803f741c24ac9fcd8cab0c017 100644 (file)
@@ -14,7 +14,7 @@ public abstract class AbstractPoxServiceClientImpl<CLT extends AbstractCommonLis
        implements CollectionSpacePoxClient<CLT, P> {
        
     @Override
-    public ClientResponse<Response> create(PoxPayloadOut xmlPayload) {
+       public Response create(PoxPayloadOut xmlPayload) {
         return getProxy().create(xmlPayload.getBytes());
     }
                
index 2b85244e7e14016a7d17c1ed36e64059f6d71c05..2b6d0c5f9b8b5da1d743fe6a3a4902edce4cc16a 100644 (file)
  */
 package org.collectionspace.services.client;
 
+import java.io.IOException;
 import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.net.URL;
 import java.util.Properties;
 
 import javax.ws.rs.PathParam;
+import javax.ws.rs.client.ClientBuilder;
+import javax.ws.rs.client.ClientRequestContext;
+import javax.ws.rs.client.ClientRequestFilter;
+import javax.ws.rs.core.MultivaluedMap;
 import javax.ws.rs.core.Response;
+import javax.xml.bind.DatatypeConverter;
 
 import org.apache.commons.httpclient.HttpClient;
 import org.apache.commons.httpclient.UsernamePasswordCredentials;
@@ -40,12 +46,48 @@ import org.collectionspace.services.jaxb.AbstractCommonList;
 import org.jboss.resteasy.client.ClientResponse; //import org.collectionspace.services.common.context.ServiceContext;
 import org.jboss.resteasy.client.ProxyFactory;
 import org.jboss.resteasy.client.core.executors.ApacheHttpClient4Executor;
+import org.jboss.resteasy.client.jaxrs.ResteasyClient;
 //import org.jboss.resteasy.client.core.executors.ApacheHttpClientExecutor;
 import org.jboss.resteasy.plugins.providers.RegisterBuiltin;
 import org.jboss.resteasy.spi.ResteasyProviderFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+/**
+ * Private class for JAX-RS authentication
+ */
+class Authenticator implements ClientRequestFilter {
+
+    private final String user;
+    private final String password;
+
+    public Authenticator(String user, String password) {
+        this.user = user;
+        this.password = password;
+    }
+
+    @Override
+    public void filter(ClientRequestContext requestContext) throws IOException {
+        MultivaluedMap<String, Object> headers = requestContext.getHeaders();
+        final String basicAuthentication = getBasicAuthentication();
+        headers.add("Authorization", basicAuthentication);
+
+    }
+
+    private String getBasicAuthentication() {
+       String result = null;
+        String token = this.user + ":" + this.password;
+        try {
+            result = "Basic " + DatatypeConverter.printBase64Binary(token.getBytes("UTF-8"));
+        } catch (UnsupportedEncodingException ex) {
+            throw new IllegalStateException("Cannot encode with UTF-8", ex);
+        }
+        
+        return result;
+    }
+}
+
+
 /**
  * BaseServiceClient is an abstract base client of all service clients FIXME:
  * http://issues.collectionspace.org/browse/CSPACE-1684
@@ -405,6 +447,26 @@ public abstract class AbstractServiceClientImpl<CLT, REQUEST_PT, RESPONSE_PT, P
      */
     @Override
        public void setProxy() {
+       ResteasyClient client = null;
+        String urlString = url.toString();
+       Class<P> proxyClass = this.getProxyClass();
+       
+        if (useAuth()) {
+            String user = properties.getProperty(USER_PROPERTY);
+            String password = properties.getProperty(PASSWORD_PROPERTY);
+               client = (ResteasyClient)ClientBuilder.newClient().register(new Authenticator(user, password));
+        } else {
+               client = (ResteasyClient)ClientBuilder.newClient();
+        }
+        
+        proxy = client.target(urlString).proxy(proxyClass);
+    }
+    
+    /**
+     * allow to reset proxy as per security needs
+     */
+    @Deprecated
+       public void _setProxy() {
        Class<P> proxyClass = this.getProxyClass();
         if (useAuth()) {
             proxy = ProxyFactory.create(proxyClass,
index cf960100fee6e5dcf5edbb25a794f8626409671b..5f3e557724d41f817a7cd900e808138c4692e843 100644 (file)
@@ -178,7 +178,7 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
      * Common proxied service calls
      */
 
-       public ClientResponse<Response> create(REQUEST_TYPE payload);
+       public Response create(REQUEST_TYPE payload);
        
        public ClientResponse<RESPONSE_TYPE> read(String csid);
 
@@ -234,5 +234,5 @@ public interface CollectionSpaceClient<CLT, REQUEST_TYPE, RESPONSE_TYPE, P exten
      * @param csid the csid
      * @return the client response
      */
-    public ClientResponse<Response> delete(String csid);
+    public Response delete(String csid);
 }
index 5fd88ad3383d9fd3ac8361325cff79b2fa1d4b8e..e8aade4eac62946bb8b6ff823af899c59a2b63d9 100644 (file)
@@ -18,7 +18,7 @@ public interface CollectionSpacePoxProxy<LT extends AbstractCommonList> extends
 
        // (C)reate
        @POST
-       ClientResponse<Response> create(byte[] payload);
+       Response create(byte[] payload);
 
        // (R)ead
        @GET
index 9a1abdaaf8bb4bfaa36f7ce885e1b688d8de94f8..6d6550f44e2f0076cff594946d081ec9979deaa7 100644 (file)
@@ -156,7 +156,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
        setupCreate();
        CollectionSpaceClient client = this.getClientInstance();
         REQUEST_TYPE payload = createInstance(client.getCommonPartName(), identifier);
-        ClientResponse<Response> res = client.create(payload);
+        Response res = client.create(payload);
        try {
                int statusCode = res.getStatus();
                if (logger.isDebugEnabled()) {
@@ -171,7 +171,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
                // so they can be deleted after tests have been run.
                allResourceIdsCreated.add(result);
        } finally {
-               res.releaseConnection();
+               res.close();
        }
        
        return result;
@@ -212,9 +212,14 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
     public void delete(String testName) throws Exception {
         setupDelete();
        CollectionSpaceClient client = this.getClientInstance();
-        ClientResponse<Response> res = client.delete(getKnowResourceId());
-        int statusCode = res.getStatus();
-
+        Response res = client.delete(getKnowResourceId());
+        int statusCode;
+        try {
+               statusCode = res.getStatus();
+        } finally {
+               res.close();
+        }
+        
         // Check the status code of the response: does it match
         // the expected response(s)?
         if (logger.isDebugEnabled()) {
@@ -257,8 +262,13 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
 
         // Submit the request to the service and store the response.
        CollectionSpaceClient client = this.getClientInstance();
-        ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
-        int statusCode = res.getStatus();
+        Response res = client.delete(NON_EXISTENT_ID);
+        int statusCode;
+        try {
+               statusCode = res.getStatus();
+        } finally {
+               res.close();
+        }
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -999,7 +1009,7 @@ public abstract class AbstractServiceTestImpl<CLT, CPT, REQUEST_TYPE, RESPONSE_T
 
         CollectionSpaceClient client = getClientInstance();
         REQUEST_TYPE payload = createInstance(identifier);
-        ClientResponse<Response> res = client.create(payload);
+        Response res = client.create(payload);
 
         int statusCode = res.getStatus();
         Assert.assertEquals(statusCode, STATUS_CREATED);
index 383bdcd4651096e8d4860d9e23aa547a2dab514b..6852ab9c8618b13516917e5f4497fd31b4b67bbe 100644 (file)
@@ -399,6 +399,27 @@ public abstract class BaseServiceTest<CLT> {
         }
         return id;
     }
+    
+    /**
+     * Extract id.
+     *
+     * @param res the res
+     * @return the string
+     */
+    static protected String extractId(Response res) {
+        MultivaluedMap<String, Object> mvm = res.getMetadata();
+        String uri = (String) ((List<Object>) mvm.get("Location")).get(0);
+        if (logger.isDebugEnabled()) {
+            logger.debug("extractId:uri=" + uri);
+        }
+        String[] segments = uri.split("/");
+        String id = segments[segments.length - 1];
+        if (logger.isDebugEnabled()) {
+            logger.debug("id=" + id);
+        }
+        return id;
+    }
+    
  
     /**
      * Tests can override this method to customize their identifiers.
@@ -668,6 +689,18 @@ public abstract class BaseServiceTest<CLT> {
         
         return statusCode;
     }
+    
+    public int assertStatusCode(Response res, String testName) {
+        int statusCode = res.getStatus();
+        
+        // Check the status code of the response: does it match the expected response(s)?
+        logger.debug(testName + ": status = " + statusCode);
+        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+        Assert.assertEquals(statusCode, testExpectedStatusCode);
+        
+        return statusCode;
+    }    
 
     public static String getUTF8DataFragment() {
         return UTF8_DATA_FRAGMENT;
@@ -729,7 +762,7 @@ public abstract class BaseServiceTest<CLT> {
         //
         for (String resourceId : allResourceIdsCreated) {
             // Note: Any non-success responses are ignored and not reported.
-            client.delete(resourceId).releaseConnection();
+            client.delete(resourceId).close();
         }
     }
        
index 4fe61a3fb1677b3a23781c5f4dfcb92e8b879d53..dc5eeb6a68d617530ddbb7d5d94c96dcda66e6da 100644 (file)
@@ -190,14 +190,14 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest<AbstractCommon
         // Submit the request to the service and store the response.
         CollectionObjectClient collectionObjectClient = new CollectionObjectClient();
         testSetup(STATUS_CREATED, ServiceRequestType.CREATE);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
+        Response res = collectionObjectClient.create(multipart);
         String newCsid = null;
         try {
                assertStatusCode(res, testName);
                newCsid = extractId(res);
         } finally {
                if (res != null) {
-                       res.releaseConnection();
+                       res.close();
                }
         }
         // Store the ID returned from the first resource created
@@ -225,14 +225,17 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest<AbstractCommon
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
                        displayName, shortIdentifier, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
+        Response res = personAuthClient.create(multipart);
         int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
-        personAuthRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
+        try {
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+               personAuthRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
+        } finally {
+               res.close();
+        }
     }
 
     /**
@@ -325,14 +328,18 @@ public class CollectionObjectAuthRefsTest extends BaseServiceTest<AbstractCommon
         OrgAuthorityClient orgAuthClient = new OrgAuthorityClient();
         PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
                        displayName, shortIdentifier, orgAuthClient.getCommonPartName());
-        ClientResponse<Response> res = orgAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        orgAuthCSID = extractId(res);
-        orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
+        Response res = orgAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+       
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               orgAuthCSID = extractId(res);
+               orgAuthRefName = OrgAuthorityClientUtils.getAuthorityRefName(orgAuthCSID, null);
+        } finally {
+               res.close();
+        }
     }
 
     /**
index 28df7e0fb8048353070f11123d0432f90ca04b07..94d44e92184ccea579aaaf9fde9fda41fd227960 100644 (file)
@@ -461,7 +461,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                for (long i = 0; i < numToCreate; i++) {
                        PoxPayloadOut multipart = createCollectionObjectInstance(i,
                                        keywords, keywordsInSameField);
-                       ClientResponse<Response> res = client.create(multipart);
+                       Response res = client.create(multipart);
                        try {
                                int statusCode = res.getStatus();
                                Assert.assertEquals(statusCode, testExpectedStatusCode);
@@ -472,7 +472,7 @@ public class CollectionObjectSearchTest extends BaseServiceTest<AbstractCommonLi
                                                        + id);
                                }
                        } finally {
-                               res.releaseConnection();
+                               res.close();
                        }
                }
        }
index 1ab3c75d3dc9ea2270faae1adcf130e6b5fdccd5..00fc275061a54a29e9a70fb428f04df9ddc59218 100644 (file)
@@ -479,17 +479,20 @@ public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<Abst
         CollectionObjectClient client = new CollectionObjectClient();
         PoxPayloadOut multipart =
                 createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
-        ClientResponse<Response> res = client.create(multipart);
-        int statusCode = res.getStatus();
-
-        // Read the response and verify that the create attempt failed.
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
+        Response res = client.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+               // Read the response and verify that the create attempt failed.
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
-
+        
         // FIXME: Consider splitting off the following into its own test method.
         
         // Build a payload with invalid content, by setting a value to the
@@ -507,18 +510,21 @@ public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<Abst
         collectionObject.setObjectNameList(objNameList);
 
         // Submit the request to the service and store the response.
-        multipart =
-            createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
+        multipart = createCollectionObjectInstance(client.getCommonPartName(), collectionObject, null);
         res = client.create(multipart);
-        statusCode = res.getStatus();
-
-        // Read the response and verify that the create attempt failed.
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
+        try {
+               int statusCode = res.getStatus();
+       
+               // Read the response and verify that the create attempt failed.
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.BAD_REQUEST.getStatusCode());
     }
     
     /**
@@ -847,8 +853,8 @@ public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<Abst
     // Utility methods used by tests above
     // ---------------------------------------------------------------
         
-    private ClientResponse<Response> newCollectionObject() {
-       ClientResponse<Response> result = null;
+    private Response newCollectionObject() {
+       Response result = null;
        
         CollectionObjectClient client = new CollectionObjectClient();
         String identifier = createIdentifier();
@@ -862,13 +868,13 @@ public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<Abst
     private String newCollectionObject(boolean assertStatus) {
        String result = null;
        
-       ClientResponse<Response> res = newCollectionObject();
+       Response res = newCollectionObject();
        try {
                int statusCode = res.getStatus();
                Assert.assertEquals(statusCode, STATUS_CREATED);
                result = extractId(res);
        } finally {
-               res.releaseConnection();
+               res.close();
        }
 
        return result;
@@ -1112,17 +1118,23 @@ public class CollectionObjectServiceTest extends AbstractPoxServiceTestImpl<Abst
             multipart = createCollectionObjectInstanceFromRawXml(testName,
                     client.getCommonPartName(), fileName);
         }
-        ClientResponse<Response> res = client.create(multipart);
-        int statusCode = res.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
+        
+        Response res = client.create(multipart);
+        String newId = null;
+        try {
+               int statusCode = res.getStatus();
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+               newId = extractId(res);
+               allResourceIdsCreated.add(newId);
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, testExpectedStatusCode);
-        String newId = extractId(res);
-        allResourceIdsCreated.add(newId);
+        
         return newId;
     }
 
index f5457f43f6f94f535740feff4235a0f2ab327f63..84e9127ea769b6fbc0df1dd115f608434383d712 100644 (file)
                        <groupId>org.nuxeo.ecm.core</groupId>
                        <artifactId>nuxeo-opencmis-bindings</artifactId>
                        <version>${nuxeo.core.version}</version>
+                       <exclusions>
+                               <exclusion>
+                                       <artifactId>jsr311-api</artifactId>
+                                       <groupId>javax.ws.rs</groupId>
+                               </exclusion>
+                       </exclusions>
                </dependency>
                <dependency>
                        <groupId>org.apache.chemistry.opencmis</groupId>
index d9361b40adf83bcee1275e0951048162bb78ce54..db4da7375d50b1108663e943feef30197013e4ce 100644 (file)
@@ -23,6 +23,7 @@
  */
 package org.collectionspace.services.common;
 
+import java.lang.reflect.Method;
 import java.util.List;
 
 import javax.ws.rs.GET;
@@ -46,6 +47,7 @@ import org.collectionspace.services.common.repository.RepositoryClientFactory;
 import org.collectionspace.services.common.security.UnauthorizedException;
 import org.collectionspace.services.common.storage.StorageClient;
 import org.collectionspace.services.common.storage.jpa.JpaStorageClientImpl;
+import org.jboss.resteasy.core.ResourceMethodInvoker;
 //import org.jboss.resteasy.core.ResourceMethod;
 import org.jboss.resteasy.spi.HttpRequest;
 import org.jboss.resteasy.spi.metadata.ResourceMethod;
@@ -503,7 +505,7 @@ public abstract class AbstractCollectionSpaceResourceImpl<IT, OT>
     
        @Override
        public boolean allowAnonymousAccess(HttpRequest request,
-                       ResourceMethod method) {
+                       Class<?> resourceClass) {
                return false;
        }    
 }
index 9a56bf45846d29d2ccca725e7a586171e12d9c69..41b6be8108be0eef139ccd5082154b28f5113442 100644 (file)
@@ -97,6 +97,6 @@ public interface CollectionSpaceResource<IT, OT> {
      */
 //                     <sec:filter-chain pattern="/publicitems/*/*/content"
 //                              filters="none"/>
-       public boolean allowAnonymousAccess(HttpRequest request, Method method);
+       public boolean allowAnonymousAccess(HttpRequest request, Class<?> resourceClass);
     
 }
index f105b0c112c47f6c2fa0273fe5602cde0d1d9e72..7d61387019a17317b86e89cd87b66f609b11b536 100644 (file)
@@ -77,7 +77,7 @@ public class PublicItemResource extends NuxeoBasedResource {
 
        @Override
        public boolean allowAnonymousAccess(HttpRequest request,
-                       Method method) {
+                       Class<?> resourceClass) {
                return true;
        }
        
index 2f16595921e166b60c765f425fc3f0ecd125f44f..8e907a1d18fd97324d31435923cc53dc8007f2ba 100644 (file)
@@ -89,13 +89,13 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
     private static final String ERROR_NUXEO_LOGOUT = "Attempt to logout when Nuxeo login context was null";
     private static final String ERROR_UNBALANCED_LOGINS = "The number of Logins vs Logouts to the Nuxeo framework was unbalanced.";    
            
-    private boolean isAnonymousRequest(HttpRequest request, Method resourceMethod) {
+    private boolean isAnonymousRequest(HttpRequest request, ResourceMethodInvoker resourceMethodInvoker) {
        boolean result = false;
        
-               Class<?> resourceClass = resourceMethod.getClass();
+               Class<?> resourceClass = resourceMethodInvoker.getResourceClass();
                try {
                        CollectionSpaceResource resourceInstance = (CollectionSpaceResource)resourceClass.newInstance();
-                       result = resourceInstance.allowAnonymousAccess(request, resourceMethod);
+                       result = resourceInstance.allowAnonymousAccess(request, resourceClass);
                } catch (InstantiationException e) {
                        logger.error("isAnonymousRequest: ", e);
                } catch (IllegalAccessException e) {
@@ -104,7 +104,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
 
        return result;
     }
-    
+        
        /* (non-Javadoc)
         * @see org.jboss.resteasy.spi.interception.PreProcessInterceptor#preProcess(org.jboss.resteasy.spi.HttpRequest, org.jboss.resteasy.core.ResourceMethod)
         */
@@ -115,10 +115,10 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                Method resourceMethod = resourceMethodInvoker.getMethod();
                
                try {
-                       if (isAnonymousRequest(request, resourceMethod) == true) {
+                       if (isAnonymousRequest(request, resourceMethodInvoker) == true) {
                                // We don't need to check credentials for anonymous requests.  Just login to Nuxeo and
                                // exit
-                               nuxeoPreProcess(request, resourceMethod);
+                               nuxeoPreProcess(request, resourceMethodInvoker);
        
                                return result;
                        }
@@ -184,7 +184,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
                                //
                                // Login to Nuxeo
                                //
-                               nuxeoPreProcess(request, resourceMethod);
+                               nuxeoPreProcess(request, resourceMethodInvoker);
                                
                                //
                                // We've passed all the checks.  Now just log the results
@@ -269,7 +269,7 @@ public class SecurityInterceptor implements PreProcessInterceptor, PostProcessIn
        //
        // Nuxeo login support
        //
-       public ServerResponse nuxeoPreProcess(HttpRequest request, Method resourceMethod)
+       public ServerResponse nuxeoPreProcess(HttpRequest request, ResourceMethodInvoker resourceMethodInvoker)
                        throws Failure, CSWebApplicationException {
                try {
                        nuxeoLogin();
index 9071f3534e8aab9f3bdaf4b09f5f772c9b795efe..7d8a018d1fd1f7fdef7e0db85ac5f88a1a26d44c 100644 (file)
@@ -113,7 +113,7 @@ public class ConditioncheckAuthRefsTest extends BaseServiceTest<AbstractCommonLi
         PoxPayloadOut multipart = createConditioncheckInstance(
                 "conditionCheckRefNumber-" + identifier,
                 conditionCheckerRefName);
-        ClientResponse<Response> response = conditioncheckClient.create(multipart);
+        Response response = conditioncheckClient.create(multipart);
         int statusCode = response.getStatus();
         try {
             // Check the status code of the response: does it match
@@ -142,27 +142,28 @@ public class ConditioncheckAuthRefsTest extends BaseServiceTest<AbstractCommonLi
             // so they can be deleted after tests have been run.
             conditioncheckIdsCreated.add(extractId(response));
         } finally {
-            response.releaseConnection();
+            response.close();
         }
     }
     
     protected void createPersonRefs(){
-
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Create a temporary PersonAuthority resource, and its corresponding
         // refName by which it can be identified.
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
             PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                   invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
 
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
-        
         // Create temporary Person resources, and their corresponding refNames
         // by which they can be identified.
         String csid = createPerson("Carrie", "ConditionChecker1", "carrieConditionChecker", authRefName);
index 68d2919e27dddacb88f81d253effafd4dda5b52a..e8cd3b9337edaa38a6459a8b7731d53a5aedfa9e 100644 (file)
@@ -105,7 +105,7 @@ public class ConditioncheckServiceTest extends AbstractPoxServiceTestImpl<Abstra
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createConditioncheckInstance(identifier);
         String newID = null;
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
             int statusCode = res.getStatus();
 
@@ -125,7 +125,7 @@ public class ConditioncheckServiceTest extends AbstractPoxServiceTestImpl<Abstra
             newID = extractId(res);
         } finally {
             if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
 
index 2d0025aeed4852019fb82f53edb85c23828bf04b..c98c10d3954b60a04f356ccb917d750317b1805c 100644 (file)
@@ -113,27 +113,32 @@ public class ContactServiceTest extends AbstractPoxServiceTestImpl<AbstractCommo
         String identifier = createIdentifier();
         PoxPayloadOut multipart =
                 ContactClientUtils.createContactInstance(identifier, client.getCommonPartName());
-        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);
+        Response res = client.create(multipart);
+        String newId = null;
+        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(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+               newId = extractId(res);
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, testExpectedStatusCode);
 
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null) {
-            knownResourceId = extractId(res);
+            knownResourceId = newId;
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
@@ -141,7 +146,7 @@ public class ContactServiceTest extends AbstractPoxServiceTestImpl<AbstractCommo
 
         // Store the IDs from every resource created by tests,
         // so they can be deleted after tests have been run.
-        allResourceIdsCreated.add(extractId(res));
+        allResourceIdsCreated.add(newId);
     }
 
     @Override
index 5a824ed9d4bcc2fd74031afc4bbb1ad67201ba62..20287fb8d3c9ce2265e124a887762d3121a2a85c 100644 (file)
@@ -95,7 +95,7 @@ public class ExhibitionServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createExhibitionInstance(identifier);
         String newID = null;
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
             int statusCode = res.getStatus();
 
@@ -115,7 +115,7 @@ public class ExhibitionServiceTest extends AbstractPoxServiceTestImpl<AbstractCo
             newID = extractId(res);
         } finally {
             if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
 
index be7fbdff1310ca4003d79f16199b96d8bfd94214..d6e5277674cae5b5704db7558695217a4b8c6c53 100644 (file)
@@ -131,27 +131,32 @@ public class IntakeAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                 conditionCheckerOrAssessorRefName,
                 insurerRefName,
                 valuerRefName );
-        ClientResponse<Response> res = intakeClient.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);
+        String newId = null;
+        Response res = intakeClient.create(multipart);
+        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(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+               newId = extractId(res);
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, testExpectedStatusCode);
 
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
-            knownResourceId = extractId(res);
+            knownResourceId = newId;
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
@@ -159,23 +164,28 @@ public class IntakeAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         
         // Store the IDs from every resource created by tests,
         // so they can be deleted after tests have been run.
-        intakeIdsCreated.add(extractId(res));
+        intakeIdsCreated.add(newId);
     }
     
-    protected void createPersonRefs(){
+    protected void createPersonRefs() {
+       //
+       // First, create a new person authority
+       //
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
                        PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
         
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
-        
         String csid = createPerson("Olivier", "Owner", "olivierOwner", authRefName);
         currentOwnerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
         personIdsCreated.add(csid);
index be59cc2522ef4d805bed565043469a97d46e6de5..02284dbd9b46704a673afb3a88cb43ae6caffd52 100644 (file)
@@ -134,7 +134,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest<AbstractCommonL
                 insurerRefName,
                 valuerRefName );
 
-        ClientResponse<Response> res = intakeClient.create(multipart);
+        Response res = intakeClient.create(multipart);
         try {
                int statusCode = res.getStatus();
        
@@ -151,7 +151,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest<AbstractCommonL
                        invalidStatusCodeMessage(testRequestType, statusCode));
                Assert.assertEquals(statusCode, testExpectedStatusCode);
         } finally {
-               res.releaseConnection();
+               res.close();
         }
 
         // Store the ID returned from the first resource created
@@ -177,7 +177,7 @@ public class OrganizationAuthRefDocsTest extends BaseServiceTest<AbstractCommonL
        //      OrgAuthorityClientUtils.createOrgAuthRefName(ORGANIZATION_AUTHORITY_NAME, null);
         PoxPayloadOut multipart = OrgAuthorityClientUtils.createOrgAuthorityInstance(
                        ORGANIZATION_AUTHORITY_NAME, ORGANIZATION_AUTHORITY_NAME, orgAuthClient.getCommonPartName());
-        ClientResponse<Response> res = orgAuthClient.create(multipart);
+        Response res = orgAuthClient.create(multipart);
         int statusCode = res.getStatus();
 
         Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
index d1fd4b6a6b3b8089113387c43e5b1401e1da29a0..9f81cccb3f77cbb2b96a8f11fefea843439905bb 100644 (file)
@@ -134,7 +134,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest<AbstractCommonList> {
                 insurerRefName,
                 valuerRefName);
 
-        ClientResponse<Response> res = intakeClient.create(multipart);
+        Response res = intakeClient.create(multipart);
         try {
             int statusCode = res.getStatus();
 
@@ -151,7 +151,7 @@ public class PersonAuthRefDocsTest extends BaseServiceTest<AbstractCommonList> {
                     invalidStatusCodeMessage(testRequestType, statusCode));
             Assert.assertEquals(statusCode, testExpectedStatusCode);
         } finally {
-            res.releaseConnection();
+            res.close();
         }
 
         // Store the ID returned from the first resource created
@@ -175,13 +175,16 @@ public class PersonAuthRefDocsTest extends BaseServiceTest<AbstractCommonList> {
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
                 PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
 
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
 
@@ -220,7 +223,6 @@ public class PersonAuthRefDocsTest extends BaseServiceTest<AbstractCommonList> {
         }
         Assert.assertNotNull(valuerRefName);
         personIdsCreated.add(csid);
-
     }
 
     protected String createPerson(String firstName, String surName, String shortId, String authRefName) {
index 9837fe0a1f677375cdcad359dba1a883b0cc13fb..7322af4d27ca418b6e71c607faec492688614534 100644 (file)
@@ -127,9 +127,10 @@ public class LoaninAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                 lendersContactRefName,
                 borrowersContactRefName,
                 borrowersAuthorizerRefName);
-        ClientResponse<Response> response = loaninClient.create(multipart);
-        int statusCode = response.getStatus();
+        String newId = null;
+        Response response = loaninClient.create(multipart);
         try {
+            int statusCode = response.getStatus();
                // Check the status code of the response: does it match
                // the expected response(s)?
                //
@@ -142,22 +143,23 @@ public class LoaninAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
                        invalidStatusCodeMessage(testRequestType, statusCode));
                Assert.assertEquals(statusCode, testExpectedStatusCode);
-       
-               // Store the ID returned from the first resource created
-               // for additional tests below.
-               if (knownResourceId == null){
-                   knownResourceId = extractId(response);
-                   if (logger.isDebugEnabled()) {
-                       logger.debug(testName + ": knownResourceId=" + knownResourceId);
-                   }
-               }
-               
-               // Store the IDs from every resource created by tests,
-               // so they can be deleted after tests have been run.
-               loaninIdsCreated.add(extractId(response));
+               newId = extractId(response);
         } finally {
-               response.releaseConnection();
+               response.close();
         }
+       
+        // Store the ID returned from the first resource created
+        // for additional tests below.
+        if (knownResourceId == null){
+            knownResourceId = newId;
+            if (logger.isDebugEnabled()) {
+                logger.debug(testName + ": knownResourceId=" + knownResourceId);
+            }
+        }
+        
+        // Store the IDs from every resource created by tests,
+        // so they can be deleted after tests have been run.
+        loaninIdsCreated.add(newId);
     }
     
     protected void createPersonRefs(){
@@ -167,13 +169,17 @@ public class LoaninAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         // refName by which it can be identified.
        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
            PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+       
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                   invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
 
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
         
index 9cf4a86dbe9a48aaf6989f6963b16771bced5939..75a223331776a0ea28bed4fe020999e8329e5ae8 100644 (file)
@@ -105,7 +105,7 @@ public class LoaninServiceTest extends AbstractPoxServiceTestImpl<AbstractCommon
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createLoaninInstance(identifier);
         String newID = null;
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
             int statusCode = res.getStatus();
 
@@ -125,7 +125,7 @@ public class LoaninServiceTest extends AbstractPoxServiceTestImpl<AbstractCommon
             newID = extractId(res);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
 
index 2a4869438bd6a1bd88d7da26cae254975f8abcf5..a881a3921e2aae406dc79112074b77af2cb41dc0 100644 (file)
@@ -128,26 +128,32 @@ public class LoanoutAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                 borrowersContactRefName,
                 lendersAuthorizerRefName,
                 lendersContactRefName);
-        ClientResponse<Response> res = loanoutClient.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);
+        String newId = null;
+        Response res = loanoutClient.create(multipart);
+        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(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+               newId = extractId(res);
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, testExpectedStatusCode);
 
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
-            knownResourceId = extractId(res);
+            knownResourceId = newId;
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
@@ -155,7 +161,7 @@ public class LoanoutAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         
         // Store the IDs from every resource created by tests,
         // so they can be deleted after tests have been run.
-        loanoutIdsCreated.add(extractId(res));
+        loanoutIdsCreated.add(newId);
     }
 
     protected void createPersonRefs(){
@@ -165,22 +171,23 @@ public class LoanoutAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         // refName by which it can be identified.
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
            PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                   invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
         
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
 
         // Create temporary Person resources, and their corresponding refNames
         // by which they can be identified.
 
-        String csid = "";
-
-        csid = createPerson("Betty", "Borrower", "bettyBorrower", authRefName);
+        String csid = createPerson("Betty", "Borrower", "bettyBorrower", authRefName);
         personIdsCreated.add(csid);
         borrowerRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
 
@@ -195,7 +202,6 @@ public class LoanoutAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         csid = createPerson("Larry", "Lenderscontact", "larryLenderscontact", authRefName);
         personIdsCreated.add(csid);
         lendersContactRefName = PersonAuthorityClientUtils.getPersonRefName(personAuthCSID, csid, null);
-    
     }
     
     protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
index ce50a7b9b245c10d300a3e7cdded64a6b4a769f5..41d46a08cda1f67db625b987e35f3eaccb517134 100644 (file)
@@ -98,27 +98,32 @@ public class LoanoutServiceTest extends AbstractPoxServiceTestImpl<AbstractCommo
         LoanoutClient client = new LoanoutClient();
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createLoanoutInstance(identifier);
-        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);
+        String newId = null;
+        Response res = client.create(multipart);
+        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(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+               newId = extractId(res);
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, testExpectedStatusCode);
 
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null) {
-            knownResourceId = extractId(res);
+            knownResourceId = newId;
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
@@ -126,7 +131,7 @@ public class LoanoutServiceTest extends AbstractPoxServiceTestImpl<AbstractCommo
 
         // Store the IDs from every resource created by tests,
         // so they can be deleted after tests have been run.
-        allResourceIdsCreated.add(extractId(res));
+        allResourceIdsCreated.add(newId);
     }
 
     /* (non-Javadoc)
index e69847e6b5b0eadc99d7d67cb211e25a585f6b05..0d05432f2a6b30eb3529aa34ddf3b6b44855ce3b 100644 (file)
@@ -109,7 +109,7 @@ public class MediaAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         //    references, and will refer to Person resources by their refNames.
         MediaClient mediaClient = new MediaClient();
         PoxPayloadOut multipart = createMediaInstance(depositorRefName, "media.title-" + identifier);
-        ClientResponse<Response> res = mediaClient.create(multipart);
+        Response res = mediaClient.create(multipart);
         try {
                assertStatusCode(res, testName);
                if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
@@ -118,7 +118,7 @@ public class MediaAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                mediaIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
     }
@@ -128,13 +128,13 @@ public class MediaAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         // Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
                        PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
+        Response res = personAuthClient.create(multipart);
         try {
                assertStatusCode(res, "createPersonRefs (not a surefire test)");
                personAuthCSID = extractId(res);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
index d491d90d683024693286f01204edcc93aff4ae2c..347757dc17f7f9ce1be94e26b9b1982d071fbb7d 100644 (file)
@@ -116,14 +116,14 @@ public class MediaServiceTest extends AbstractPoxServiceTestImpl<AbstractCommonL
                //
                MediaClient client = new MediaClient();
                PoxPayloadOut multipart = createMediaInstance(createIdentifier());
-               ClientResponse<Response> mediaRes = client.create(multipart);
+               Response mediaRes = client.create(multipart);
                String mediaCsid = null;
                try {
                        assertStatusCode(mediaRes, testName);
                        mediaCsid = extractId(mediaRes);
                } finally {
                        if (mediaRes != null) {
-                               mediaRes.releaseConnection();
+                               mediaRes.close();
                        }
                }
                //
index 325266c82e5e5bcd066d5867cd06e0b65bda548d..73f373e169e97f7a364e24de43365d313880f3db 100644 (file)
@@ -120,26 +120,31 @@ public class MovementAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
                 "movementReferenceNumber-" + identifier,
                 GregorianCalendarDateTimeUtils.timestampUTC(),
                 movementContactRefName);
-        ClientResponse<Response> res = movementClient.create(multipart);
+        String newId = null;
+        Response res = movementClient.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 {
+               // 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(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, testExpectedStatusCode);
+               newId = extractId(res);
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, testExpectedStatusCode);
 
         // Store the ID returned from the first resource created
         // for additional tests below.
         if (knownResourceId == null){
-            knownResourceId = extractId(res);
+            knownResourceId = newId;
             if (logger.isDebugEnabled()) {
                 logger.debug(testName + ": knownResourceId=" + knownResourceId);
             }
@@ -147,23 +152,26 @@ public class MovementAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
         
         // Store the IDs from every resource created by tests,
         // so they can be deleted after tests have been run.
-        movementIdsCreated.add(extractId(res));
+        movementIdsCreated.add(newId);
     }
 
     protected void createPersonRefs(){
-
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Create a temporary PersonAuthority resource, and its corresponding
         // refName by which it can be identified.
        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
            PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-            invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+       
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                   invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
 
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
         
@@ -175,6 +183,8 @@ public class MovementAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
     }
     
     protected String createPerson(String firstName, String surName, String shortId, String authRefName ) {
+       String result = null;
+       
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         Map<String, String> personInfo = new HashMap<String,String>();
         personInfo.put(PersonJAXBSchema.FORE_NAME, firstName);
@@ -189,13 +199,18 @@ public class MovementAuthRefsTest extends BaseServiceTest<AbstractCommonList> {
        PoxPayloadOut multipart =
                PersonAuthorityClientUtils.createPersonInstance(personAuthCSID, 
                                authRefName, personInfo, personTerms, personAuthClient.getItemCommonPartName());
-        ClientResponse<Response> res = personAuthClient.createItem(personAuthCSID, multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-       return extractId(res);
+        Response res = personAuthClient.createItem(personAuthCSID, multipart);
+        try {
+               int statusCode = res.getStatus();
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               result = extractId(res);
+        } finally {
+               res.close();
+        }
+        
+       return result;
     }
 
     // Success outcomes
index d4886b29fc0b020d50a3e86c919c965aaa6cab2d..54841b467c00207c01fc07239cee930aa270580b 100644 (file)
@@ -609,7 +609,7 @@ public class MovementSortByTest extends BaseServiceTest<AbstractCommonList> {
         PoxPayloadOut multipart = createMovementInstance(createIdentifier(),
                 movementNote, locationDate);
         MovementClient client = new MovementClient();
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
                assertStatusCode(res, testName);
             // Store the IDs from every resource created by tests,
@@ -617,7 +617,7 @@ public class MovementSortByTest extends BaseServiceTest<AbstractCommonList> {
                result = extractId(res);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         
index c517d0b83a72c94974a1e93779306f406b1026cf..a98bbf47a9c3eb7249fe08c3fb943c317a0f1391 100644 (file)
@@ -124,7 +124,7 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest<AbstractCommonList>
         ObjectExitClient objectexitClient = new ObjectExitClient();
         PoxPayloadOut multipart = createObjectExitInstance(depositorRefName,
                 "exitNumber-" + identifier, CURRENT_DATE_UTC);
-        ClientResponse<Response> res = objectexitClient.create(multipart);
+        Response res = objectexitClient.create(multipart);
         try {
                assertStatusCode(res, testName);
                if (knownResourceId == null) {// Store the ID returned from the first resource created for additional tests below.
@@ -132,7 +132,7 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest<AbstractCommonList>
                }
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         objectexitIdsCreated.add(extractId(res));// Store the IDs from every resource created; delete on cleanup
@@ -142,13 +142,13 @@ public class ObjectExitAuthRefsTest extends BaseServiceTest<AbstractCommonList>
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         // Create a temporary PersonAuthority resource, and its corresponding refName by which it can be identified.
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
+        Response res = personAuthClient.create(multipart);
         try {
                assertStatusCode(res, "createPersonRefs (not a surefire test)");
                personAuthCSID = extractId(res);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
index 7e5f25e5802cf06a9c3731deb95be4e73aabb932..9b3b6275fa91470888975b27e855c5eafedd0656 100644 (file)
@@ -148,7 +148,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
                                displayName, shortId, orgAuthClient.getCommonPartName());
 
         // Submit the request to the service and store the response.
-        ClientResponse<Response> res = orgAuthClient.create(multipart);
+        Response res = orgAuthClient.create(multipart);
         try {
                int statusCode = res.getStatus();
                // Check the status code of the response: does it match
@@ -168,11 +168,11 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
                // so they can be deleted after tests have been run.
                String newId = extractId(res);
                if (knownResourceId == null){
-                       setKnownResource( newId, null ); //baseRefName );
+                       setKnownResource(newId, null ); //baseRefName );
                }
                allResourceIdsCreated.add(newId);
         } finally {
-            res.releaseConnection();
+            res.close();
         }        
 
         // Create all the person refs and entities
@@ -217,7 +217,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
        PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
            PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
         
-       ClientResponse<Response> res = personAuthClient.create(multipart);
+       Response res = personAuthClient.create(multipart);
         try {
             int statusCode = res.getStatus();
             Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
@@ -225,7 +225,7 @@ public class OrgAuthorityAuthRefsTest extends BaseServiceTest<AbstractCommonList
             Assert.assertEquals(statusCode, STATUS_CREATED);
             personAuthCSID = extractId(res);
         } finally {
-            res.releaseConnection();
+            res.close();
         }
 
         //String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
index bfe8ff3bfd566daa4dc933828ad8f05067b88048..23c963b705807a4a52856673443c5a8534e45b26 100644 (file)
@@ -369,6 +369,21 @@ public class PersonAuthorityClientUtils {
      * @param res the res
      * @return the string
      */
+    public static String extractId(Response res) {
+        MultivaluedMap<String, Object> mvm = res.getMetadata();
+        // FIXME: This may throw an NPE if the Location: header isn't present
+        String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);
+        if(logger.isDebugEnabled()){
+               logger.debug("extractId:uri=" + uri);
+        }
+        String[] segments = uri.split("/");
+        String id = segments[segments.length - 1];
+        if(logger.isDebugEnabled()){
+               logger.debug("id=" + id);
+        }
+        return id;
+    }
+    
     public static String extractId(ClientResponse<Response> res) {
         MultivaluedMap<String, Object> mvm = res.getMetadata();
         // FIXME: This may throw an NPE if the Location: header isn't present
@@ -384,6 +399,7 @@ public class PersonAuthorityClientUtils {
         return id;
     }
     
+    
     /**
      * Returns an error message indicating that the status code returned by a
      * specific call to a service does not fall within a set of valid status
index a9b1cf7dc0673726eda6de52f7c42d1e38e9f010..5d0013f6df3925fd35e3bf0c510d27342cddf319 100644 (file)
@@ -559,13 +559,13 @@ public class PersonAuthoritySearchTest extends BaseServiceTest<AbstractCommonLis
            displayName, shortId, client.getCommonPartName());
 
        String newID = null;
-       ClientResponse<Response> res = client.create(multipart);
+       Response res = client.create(multipart);
         try {
             assertStatusCode(res, testName);
             newID = PersonAuthorityClientUtils.extractId(res);
        } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
        }
         // Store the refname from the first resource created
index 158326ae18c08e360259531dc63fe5b6cd508721..217e1722ebce8658fded2ba20f784629d18d5b1e 100644 (file)
@@ -162,14 +162,14 @@ public class PersonAuthorityServicePerfTest extends BaseServiceTest<AbstractComm
            displayName, shortId, client.getCommonPartName());
 
        String newID = null;
-       ClientResponse<Response> res = client.create(multipart);
+       Response res = client.create(multipart);
         try {
             assertStatusCode(res, testName);
             newID = PersonAuthorityClientUtils.extractId(res);
             logger.info("{}: succeeded.", testName);
        } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
        }
         // Store the refname from the first resource created
index e86d8265f58ff46d22112f409ea50748ea9516f6..1269e3c1779e43973cbaf773e45e4c5d0deb9245 100644 (file)
@@ -151,13 +151,13 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
                 displayName, shortId, client.getCommonPartName());
 
         String newID = null;
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
                assertStatusCode(res, testName);
             newID = extractId(res);
         } finally {
                if (res != null) {
-                       res.releaseConnection();
+                       res.close();
                }
         }
         // Save values for additional tests
@@ -399,7 +399,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
                 displayName, shortId, client.getCommonPartName());
 
         // Submit the request to the service and store the response.
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
 
         // Check the status code of the response: does it match
         // the expected response(s)?
@@ -407,7 +407,7 @@ public class PersonAuthorityServiceTest extends AbstractAuthorityServiceTest<Per
                assertStatusCode(res, testName);
         } finally {
                if (res != null) {
-                       res.releaseConnection();
+                       res.close();
                }
         }
     }
index 2cab8f920b80c07f265d516d3c81166ad52767ca..60401bf9ea1d8202d54551ee31731803bd5569c5 100644 (file)
@@ -113,7 +113,7 @@ public class PublicItemServiceTest extends
                String identifier = createIdentifier();
                PoxPayloadOut multipart = createPublicItemInstance(identifier);
                String newID = null;
-               ClientResponse<Response> res = client.create(multipart);
+               Response res = client.create(multipart);
                try {
                        int statusCode = res.getStatus();
 
@@ -133,7 +133,7 @@ public class PublicItemServiceTest extends
                        newID = extractId(res);
                } finally {
                        if (res != null) {
-                               res.releaseConnection();
+                               res.close();
                        }
                }
 
index f93001a0ac48dd56f10ad1e204ec98f0046a32d1..18a92de8dbaef8ac513fcf9da6d5a570b00410db 100644 (file)
@@ -103,16 +103,19 @@ public class RelationServiceTest extends AbstractPoxServiceTestImpl<RelationsCom
         PersonAuthorityClient personAuthClient = new PersonAuthorityClient();
         PoxPayloadOut multipart = PersonAuthorityClientUtils.createPersonAuthorityInstance(
                 PERSON_AUTHORITY_NAME, PERSON_AUTHORITY_NAME, personAuthClient.getCommonPartName());
-        ClientResponse<Response> res = personAuthClient.create(multipart);
-        int statusCode = res.getStatus();
-
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, STATUS_CREATED);
-        personAuthCSID = extractId(res);
-
+        Response res = personAuthClient.create(multipart);
+        try {
+               int statusCode = res.getStatus();
+       
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, STATUS_CREATED);
+               personAuthCSID = extractId(res);
+        } finally {
+               res.close();
+        }
+        
         String authRefName = PersonAuthorityClientUtils.getAuthorityRefName(personAuthCSID, null);
-
         String csid = createPerson("Sam", "Subject", "samSubject", authRefName);
         Assert.assertNotNull(csid);
         samSubjectPersonCSID = csid;
@@ -166,9 +169,14 @@ public class RelationServiceTest extends AbstractPoxServiceTestImpl<RelationsCom
         // Make the subject ID equal to the object ID
         relationsCommon.setSubjectCsid(relationsCommon.getObjectCsid());
         PoxPayloadOut multipart = createRelationInstance(relationsCommon);
-        ClientResponse<Response> res = client.create(multipart);
-        int statusCode = res.getStatus();
-
+        Response res = client.create(multipart);
+        int statusCode;
+        try {
+               statusCode = res.getStatus();
+        } finally {
+               res.close();
+        }
+        
         // Check the status code of the response: does it match
         // the expected response(s)?
         //
index ad6852558179d66780aeceb3a486f9a264beb134..03cf451777b8d21d3101e1e7ec56ed559bc61217 100644 (file)
@@ -88,7 +88,7 @@ public class ReportServiceTest extends AbstractPoxServiceTestImpl<AbstractCommon
        
         PoxPayloadOut poxPayloadOut = new PoxPayloadOut(AcquisitionClient.SERVICE_PAYLOAD_NAME);
         PayloadOutputPart commonPart = poxPayloadOut.addPart(acquisitionClient.getCommonPartName(), acquisitionsCommon);
-        ClientResponse<Response> res = acquisitionClient.create(poxPayloadOut);
+        Response res = acquisitionClient.create(poxPayloadOut);
        try {
             setupCreate();
                int statusCode = res.getStatus();
@@ -104,7 +104,7 @@ public class ReportServiceTest extends AbstractPoxServiceTestImpl<AbstractCommon
                // so they can be deleted after tests have been run.
                allResourceIdsCreated.add(result);
        } finally {
-               res.releaseConnection();
+               res.close();
        }
        
        return result;
index fc3341251a3d340d5b51caf070c117477fc2c1bf..c5f4e40ca8add086c632b65134ac0f56f9e4a77c 100644 (file)
@@ -197,19 +197,22 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug("create: status = " + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug("create: status = " + res.getStatus());
+               }
+               //so it does not have any permissions out-of-the-box to create a
+               //collection object
+               Assert.assertEquals(res.getStatus(),
+                       Response.Status.FORBIDDEN.getStatusCode(), "expected "
+                       + Response.Status.FORBIDDEN.getStatusCode());
+       
+               // Store the ID returned from this create operation for additional tests
+               // below.
+        } finally {
+               res.close();
         }
-        //so it does not have any permissions out-of-the-box to create a
-        //collection object
-        Assert.assertEquals(res.getStatus(),
-                Response.Status.FORBIDDEN.getStatusCode(), "expected "
-                + Response.Status.FORBIDDEN.getStatusCode());
-
-        // Store the ID returned from this create operation for additional tests
-        // below.
-        res.releaseConnection();
 
     }
 
@@ -225,15 +228,17 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug("create: status = " + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug("create: status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(),
+                       Response.Status.UNAUTHORIZED.getStatusCode(), "expected "
+                       + Response.Status.UNAUTHORIZED.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(),
-                Response.Status.UNAUTHORIZED.getStatusCode(), "expected "
-                + Response.Status.UNAUTHORIZED.getStatusCode());
-        res.releaseConnection();
-
     }
 
     @Test(dataProvider = "testName",
@@ -245,14 +250,17 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
 
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(),
+                       Response.Status.FORBIDDEN.getStatusCode(), "expected "
+                       + Response.Status.FORBIDDEN.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(),
-                Response.Status.FORBIDDEN.getStatusCode(), "expected "
-                + Response.Status.FORBIDDEN.getStatusCode());
-        res.releaseConnection();
     }
 
     /**
@@ -267,12 +275,15 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
-        res.releaseConnection();
     }
 
     /**
@@ -286,12 +297,15 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
-        res.releaseConnection();
     }
 
     /**
@@ -306,12 +320,15 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
-        res.releaseConnection();
     }
 
     /**
@@ -324,13 +341,15 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = "
-                    + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
-        res.releaseConnection();
     }
 
     /**
@@ -343,13 +362,15 @@ public class AuthenticationServiceTest extends BaseServiceTest<AbstractCommonLis
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createCollectionObjectInstance(
                 collectionObjectClient.getCommonPartName(), identifier);
-        ClientResponse<Response> res = collectionObjectClient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = "
-                    + res.getStatus());
+        Response res = collectionObjectClient.create(multipart);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + res.getStatus());
+               }
+               Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertEquals(res.getStatus(), Response.Status.UNAUTHORIZED.getStatusCode(), "expected " + Response.Status.UNAUTHORIZED.getStatusCode());
-        res.releaseConnection();
     }
 
     @Test(dataProvider = "testName",
index 65f66e498df67526dd27d9fa1648a57fcebcfa1b..2d9bb5981136107b2bcbb0ae6a8d912970de82a0 100644 (file)
@@ -244,6 +244,7 @@ public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList
 
     @Test(dataProvider = "testName")
     public void create(String testName) throws Exception {
+        int statusCode;
         setupCreate();
 
         // Submit the request to the service and store the response.
@@ -257,33 +258,38 @@ public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList
         dimension.setValueDate(new Date().toString());
         PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
                 dimension);
-        ClientResponse<Response> res = client.create(multipart);
-
-        int statusCode = res.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
-        knownResourceId = extractId(res);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": knownResourceId=" + knownResourceId);
+        Response res = client.create(multipart);
+        try {
+               statusCode = res.getStatus();
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
+               knownResourceId = extractId(res);
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": knownResourceId=" + knownResourceId);
+               }
+        } finally {
+               res.close();
         }
-        
+                
         // Now verify that elmo cannot create
         client = new DimensionClient();
         client.setAuth(true, "elmo2010", true, "elmo2010", true);
         res = client.create(multipart);
-
-        statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + " (verify not allowed): status = " + statusCode);
+        try {
+               statusCode = res.getStatus();
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + " (verify not allowed): status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
         
         //Finally, verify that elmo has no access to Intakes
         // Submit the request to the service and store the response.
@@ -294,13 +300,16 @@ public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList
                 "entryDate-" + identifier,
                 "depositor-" + identifier);
         res = iclient.create(multipart);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
+        try {
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + " (verify create intake not allowed): status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
-        
     }
     
     /**
@@ -320,8 +329,7 @@ public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList
         intake.setDepositor(depositor);
 
         PoxPayloadOut multipart = new PoxPayloadOut(IntakeClient.SERVICE_PAYLOAD_NAME);
-        PayloadOutputPart commonPart =
-            multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
+        PayloadOutputPart commonPart = multipart.addPart(intake, MediaType.APPLICATION_XML_TYPE);
         commonPart.setLabel(new IntakeClient().getCommonPartName());
 
         if(logger.isDebugEnabled()){
@@ -335,6 +343,7 @@ public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList
     @Test(dataProvider = "testName",
            dependsOnMethods = {"delete"})
     public void verifyCreateWithFlippedRoles(String testName) throws Exception {
+       int statusCode;
         setupCreate();
 
         // Submit the request to the service and store the response.
@@ -352,32 +361,39 @@ public class AuthorizationServiceTest extends BaseServiceTest<AbstractCommonList
         dimension.setValueDate(new Date().toString());
         PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
                 dimension);
-        ClientResponse<Response> res = client.create(multipart);
-
-        int statusCode = res.getStatus();
-
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": status = " + statusCode);
-        }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
-        knownResourceId = extractId(res);
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + ": knownResourceId=" + knownResourceId);
+        Response res = client.create(multipart);
+        try {
+               statusCode = res.getStatus();
+       
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.CREATED.getStatusCode());
+               knownResourceId = extractId(res);
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + ": knownResourceId=" + knownResourceId);
+               }
+        } finally {
+               res.close();
         }
         
         //bigbird no longer allowed to create
         client.setAuth(true, "bigbird2010", true, "bigbird2010", true);
         res = client.create(multipart);
-
-        statusCode = res.getStatus();
-        if (logger.isDebugEnabled()) {
-            logger.debug(testName + " (verify not allowed): status = " + statusCode);
+        try {
+               statusCode = res.getStatus();
+               if (logger.isDebugEnabled()) {
+                   logger.debug(testName + " (verify not allowed): status = " + statusCode);
+               }
+               Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
+                       invalidStatusCodeMessage(testRequestType, statusCode));
+               Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+        } finally {
+               res.close();
         }
-        Assert.assertTrue(testRequestType.isValidStatusCode(statusCode),
-                invalidStatusCodeMessage(testRequestType, statusCode));
-        Assert.assertEquals(statusCode, Response.Status.FORBIDDEN.getStatusCode());
+        
         restoreInitialAccountRoles();
     }
 
index da5dbce9311203df6b0586886b942b9b614a9a47..56a4cd762a0cd05cc98fd82064b709de0c24d5f1 100644 (file)
@@ -320,13 +320,13 @@ public class MultiTenancyTest extends BaseServiceTest<AbstractCommonList> {
         //
         PoxPayloadOut multipart = DimensionFactory.createDimensionInstance(client.getCommonPartName(),
                 dimension);
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
                assertStatusCode(res, testName);
                result = extractId(res);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
 
index 7a49b8b3681a9ef450cb9c0084874f2b9ca404a2..c7d103f196b391acb6eaf6dbce8c1ecabe1710df 100644 (file)
@@ -95,7 +95,7 @@ public class ValuationcontrolServiceTest extends AbstractPoxServiceTestImpl<Abst
         String identifier = createIdentifier();
         PoxPayloadOut multipart = createValuationcontrolInstance(identifier);
         String newID = null;
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
             int statusCode = res.getStatus();
 
@@ -115,7 +115,7 @@ public class ValuationcontrolServiceTest extends AbstractPoxServiceTestImpl<Abst
             newID = extractId(res);
         } finally {
             if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
 
index 27f5ee33b639fadbbf7f3659345a918ea01b8140..d502095b36684cc033eb829540a28d997dde4668 100644 (file)
             <groupId>org.collectionspace.services</groupId>
             <artifactId>org.collectionspace.services.vocabulary.jaxb</artifactId>
             <version>${project.version}</version>
+            <exclusions>
+               <exclusion>
+                       <artifactId>jsr311-api</artifactId>
+                       <groupId>javax.ws.rs</groupId>
+               </exclusion>
+            </exclusions>
         </dependency>
         <dependency>
             <groupId>org.collectionspace.services</groupId>
index 0ed1d47b48e2a1935ced3b4e90b99f3efc3575c1..6efc7126272aa967bb6bf92583d9495087a31157 100644 (file)
@@ -92,12 +92,12 @@ public class VocabularyServiceTest extends AbstractAuthorityServiceTest<Vocabula
         VocabularyClient client = new VocabularyClient();
         PoxPayloadOut multipart = VocabularyClientUtils.createEnumerationInstance(
                 "Vocab with Bad Short Id", "Bad Short Id!", client.getCommonPartName());
-        ClientResponse<Response> res = client.create(multipart);
+        Response res = client.create(multipart);
         try {
                assertStatusCode(res, testName);
         } finally {
                if (res != null) {
-                res.releaseConnection();
+                res.close();
             }
         }
     }