final static String REF_NAME = "refName";\r
final static String VOCAB_TYPE = "vocabType";\r
final static String CSID = "csid";\r
+ final static String TERM_STATUS = "termStatus";\r
}\r
\r
\r
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="conditionNoteDate" type="xs:string"/>
<xs:element name="securityNote" type="xs:string"/>
<xs:element name="locationType" type="xs:string"/>
- <xs:element name="status" type="xs:string"/>
</xs:schema>
location.setSecurityNote(value);\r
if((value = (String)locationInfo.get(LocationJAXBSchema.LOCATION_TYPE))!=null)\r
location.setLocationType(value);\r
- if((value = (String)locationInfo.get(LocationJAXBSchema.STATUS))!=null)\r
- location.setStatus(value);\r
+ if((value = (String)locationInfo.get(LocationJAXBSchema.TERM_STATUS))!=null)\r
+ location.setTermStatus(value);\r
MultipartOutput multipart = new MultipartOutput();\r
OutputPart commonPart = multipart.addPart(location,\r
MediaType.APPLICATION_XML_TYPE);\r
MultipartOutput multipart = \r
createLocationInstance( vcsid, locationAuthorityRefName,\r
locationMap, client.getItemCommonPartName() );\r
+ String newID = null;\r
ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
+ try {\r
+ int statusCode = res.getStatus();\r
+ \r
+ if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+ throw new RuntimeException("Could not create Item: \""\r
+ +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
+ +"\" in locationAuthority: \"" + locationAuthorityRefName\r
+ +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+ }\r
+ if(statusCode != EXPECTED_STATUS_CODE) {\r
+ throw new RuntimeException("Unexpected Status when creating Item: \""\r
+ +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
+ +"\" in locationAuthority: \"" + locationAuthorityRefName +"\", Status:"+ statusCode);\r
+ }\r
+ newID = extractId(res);\r
+ } finally {\r
+ res.releaseConnection();\r
+ }\r
\r
- int statusCode = res.getStatus();\r
-\r
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
- throw new RuntimeException("Could not create Item: \""\r
- +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
- +"\" in locationAuthority: \"" + locationAuthorityRefName\r
- +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- }\r
- if(statusCode != EXPECTED_STATUS_CODE) {\r
- throw new RuntimeException("Unexpected Status when creating Item: \""\r
- +locationMap.get(LocationJAXBSchema.SHORT_IDENTIFIER)\r
- +"\" in locationAuthority: \"" + locationAuthorityRefName +"\", Status:"+ statusCode);\r
- }\r
-\r
- return extractId(res);\r
+ return newID;\r
}\r
\r
public static MultipartOutput createLocationInstance(\r
\r
MultipartOutput multipart = \r
createLocationInstance( commonPartXML, client.getItemCommonPartName() );\r
+ String newID = null;\r
ClientResponse<Response> res = client.createItem(vcsid, multipart);\r
+ try {\r
+ int statusCode = res.getStatus();\r
+ \r
+ if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
+ throw new RuntimeException("Could not create Item: \""+commonPartXML\r
+ +"\" in locationAuthority: \"" + vcsid\r
+ +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
+ }\r
+ if(statusCode != EXPECTED_STATUS_CODE) {\r
+ throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML\r
+ +"\" in locationAuthority: \"" + vcsid +"\", Status:"+ statusCode);\r
+ }\r
+ newID = extractId(res);\r
+ } finally {\r
+ res.releaseConnection();\r
+ }\r
\r
- int statusCode = res.getStatus();\r
-\r
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {\r
- throw new RuntimeException("Could not create Item: \""+commonPartXML\r
- +"\" in locationAuthority: \"" + vcsid\r
- +"\" "+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));\r
- }\r
- if(statusCode != EXPECTED_STATUS_CODE) {\r
- throw new RuntimeException("Unexpected Status when creating Item: \""+commonPartXML\r
- +"\" in locationAuthority: \"" + vcsid +"\", Status:"+ statusCode);\r
- }\r
-\r
- return extractId(res);\r
+ return newID;\r
}\r
\r
/**\r
MultipartOutput multipart =
LocationAuthorityClientUtils.createLocationAuthorityInstance(
displayName, shortId, client.getCommonPartName());
+ String newID = null;
ClientResponse<Response> res = client.create(multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- //
- // Specifically:
- // Does it fall within the set of valid status codes?
- // Does it exactly match the expected status code?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ //
+ // Specifically:
+ // Does it fall within the set of valid status codes?
+ // Does it exactly match the expected status code?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
+
+ newID = LocationAuthorityClientUtils.extractId(res);
+ } finally {
+ res.releaseConnection();
}
- Assert.assertTrue(this.REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(this.REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, this.EXPECTED_STATUS_CODE);
-
- String newID = LocationAuthorityClientUtils.extractId(res);
// Store the ID returned from the first resource created
// for additional tests below.
if (knownResourceId == null){
shelf1Map.put(LocationJAXBSchema.CONDITION_NOTE_DATE, TEST_CONDITION_NOTE_DATE);
shelf1Map.put(LocationJAXBSchema.SECURITY_NOTE, TEST_SECURITY_NOTE);
shelf1Map.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
- shelf1Map.put(LocationJAXBSchema.STATUS, TEST_STATUS);
+ shelf1Map.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
String newID = LocationAuthorityClientUtils.createItemInAuthority(vcsid,
authRefName, shelf1Map, client );
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
+ String newID = null;
ClientResponse<MultipartInput> res = client.read(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
try {
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(locationAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //FIXME: remove the following try catch once Aron fixes signatures
+ try {
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon locationAuthority =
+ (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(locationAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } finally {
+ res.releaseConnection();
}
}
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res = client.readByName(knownResourceShortIdentifer);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
- //FIXME: remove the following try catch once Aron fixes signatures
try {
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(locationAuthority);
- } catch (Exception e) {
- throw new RuntimeException(e);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ //FIXME: remove the following try catch once Aron fixes signatures
+ try {
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(locationAuthority);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } finally {
+ res.releaseConnection();
}
}
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether we've received a location.
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
- boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(location, LocationsCommon.class));
- }
- Assert.assertEquals(location.getInAuthority(), knownResourceId);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a location.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ boolean showFull = true;
+ if(showFull && logger.isDebugEnabled()){
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(location, LocationsCommon.class));
+ }
+ Assert.assertEquals(location.getInAuthority(), knownResourceId);
+ } finally {
+ res.releaseConnection();
+ }
}
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether location has expected displayName.
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
- String displayName = location.getDisplayName();
- // Make sure displayName matches computed form
- String expectedDisplayName =
- LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
- Assert.assertNotNull(displayName, expectedDisplayName);
-
- // Update the shortName and verify the computed name is updated.
- location.setCsid(null);
- location.setDisplayNameComputed(true);
- location.setName("updated-" + TEST_NAME);
- expectedDisplayName =
- LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- LocationsCommon updatedLocation =
- (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(updatedLocation);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocation.getName(), location.getName(),
- "Updated ForeName in Location did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
- "Updated ForeName in Location not reflected in computed DisplayName.");
-
- // Now Update the displayName, not computed and verify the computed name is overriden.
- location.setDisplayNameComputed(false);
- expectedDisplayName = "TestName";
- location.setDisplayName(expectedDisplayName);
-
- // Submit the updated resource to the service and store the response.
- output = new MultipartOutput();
- commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- updatedLocation =
- (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(updatedLocation);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
- "Updated displayNameComputed in Location did not match submitted data.");
- // Verify that the updated resource computes the right displayName.
- Assert.assertEquals(updatedLocation.getDisplayName(),
- expectedDisplayName,
- "Updated DisplayName (not computed) in Location not stored.");
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether location has expected displayName.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ String displayName = location.getDisplayName();
+ // Make sure displayName matches computed form
+ String expectedDisplayName =
+ LocationAuthorityClientUtils.prepareDefaultDisplayName(TEST_NAME);
+ Assert.assertNotNull(displayName, expectedDisplayName);
+
+ // Update the shortName and verify the computed name is updated.
+ location.setCsid(null);
+ location.setDisplayNameComputed(true);
+ location.setName("updated-" + TEST_NAME);
+ expectedDisplayName =
+ LocationAuthorityClientUtils.prepareDefaultDisplayName("updated-" + TEST_NAME);
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ LocationsCommon updatedLocation =
+ (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.getName(), location.getName(),
+ "Updated ForeName in Location did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedLocation.getDisplayName(), expectedDisplayName,
+ "Updated ForeName in Location not reflected in computed DisplayName.");
+
+ // Now Update the displayName, not computed and verify the computed name is overriden.
+ location.setDisplayNameComputed(false);
+ expectedDisplayName = "TestName";
+ location.setDisplayName(expectedDisplayName);
+
+ // Submit the updated resource to the service and store the response.
+ output = new MultipartOutput();
+ commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ updatedLocation =
+ (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.isDisplayNameComputed(), false,
+ "Updated displayNameComputed in Location did not match submitted data.");
+ // Verify that the updated resource computes the right displayName.
+ Assert.assertEquals(updatedLocation.getDisplayName(),
+ expectedDisplayName,
+ "Updated DisplayName (not computed) in Location not stored.");
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
- // Check whether Location has expected displayName.
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
- // Try to Update with computed false and no displayName
- location.setDisplayNameComputed(false);
- location.setDisplayName(null);
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ // Check whether Location has expected displayName.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+ // Try to Update with computed false and no displayName
+ location.setDisplayNameComputed(false);
+ location.setDisplayName(null);
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<LocationauthoritiesCommonList> res = client.readList();
- LocationauthoritiesCommonList list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
- list.getLocationauthorityListItem();
- int i = 0;
- for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- csid);
- logger.debug(testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- readItemList(csid, null);
- i++;
- }
- }
+ try {
+ LocationauthoritiesCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ List<LocationauthoritiesCommonList.LocationauthorityListItem> items =
+ list.getLocationauthorityListItem();
+ int i = 0;
+ for (LocationauthoritiesCommonList.LocationauthorityListItem item : items) {
+ String csid = item.getCsid();
+ logger.debug(testName + ": list-item[" + i + "] csid=" +
+ csid);
+ logger.debug(testName + ": list-item[" + i + "] displayName=" +
+ item.getDisplayName());
+ logger.debug(testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ readItemList(csid, null);
+ i++;
+ }
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
/**
} else {
Assert.fail("readItemList passed null csid and name!");
}
- LocationsCommonList list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- List<LocationsCommonList.LocationListItem> items =
- list.getLocationListItem();
- int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- int i = 0;
- for (LocationsCommonList.LocationListItem item : items) {
- Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
- Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
- // Optionally output additional data about list members for debugging.
- boolean showDetails = true;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
- item.getRefName());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- }
- i++;
- }
+ try {
+ LocationsCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ List<LocationsCommonList.LocationListItem> items =
+ list.getLocationListItem();
+ int nItemsReturned = items.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": Expected "
+ + nExpectedItems +" items; got: "+nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ int i = 0;
+ for (LocationsCommonList.LocationListItem item : items) {
+ Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
+ Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
+ // Optionally output additional data about list members for debugging.
+ boolean showDetails = true;
+ if (showDetails && logger.isDebugEnabled()) {
+ logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
+ item.getCsid());
+ logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
+ item.getRefName());
+ logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
+ item.getDisplayName());
+ logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ }
+ i++;
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
// Retrieve the contents of a resource to update.
LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<MultipartInput> res =
- client.read(knownResourceId);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
- }
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(locationAuthority);
-
- // Update the contents of this resource.
- locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
- locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated LocationAuthority");
- logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- LocationauthoritiesCommon updatedLocationAuthority =
- (LocationauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), LocationauthoritiesCommon.class);
- Assert.assertNotNull(updatedLocationAuthority);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
- locationAuthority.getDisplayName(),
- "Data in updated object did not match submitted data.");
+ ClientResponse<MultipartInput> res = client.read(knownResourceId);
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got LocationAuthority to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon locationAuthority = (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(locationAuthority);
+
+ // Update the contents of this resource.
+ locationAuthority.setDisplayName("updated-" + locationAuthority.getDisplayName());
+ locationAuthority.setVocabType("updated-" + locationAuthority.getVocabType());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated LocationAuthority");
+ logger.debug(objectAsXmlString(locationAuthority, LocationauthoritiesCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(locationAuthority, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getCommonPartName());
+ res.releaseConnection();
+ res = client.update(knownResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ LocationauthoritiesCommon updatedLocationAuthority =
+ (LocationauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), LocationauthoritiesCommon.class);
+ Assert.assertNotNull(updatedLocationAuthority);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocationAuthority.getDisplayName(),
+ locationAuthority.getDisplayName(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
/**
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<MultipartInput> res =
client.readItem(knownResourceId, knownItemResourceId);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Location to update with ID: " +
- knownItemResourceId +
- " in LocationAuthority: " + knownResourceId );
- }
- MultipartInput input = (MultipartInput) res.getEntity();
- LocationsCommon location = (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(location);
-
- // Update the contents of this resource.
- location.setCsid(null);
- location.setName("updated-" + location.getName());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated Location");
- logger.debug(objectAsXmlString(location,
- LocationsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- LocationsCommon updatedLocation =
- (LocationsCommon) extractPart(input,
- client.getItemCommonPartName(), LocationsCommon.class);
- Assert.assertNotNull(updatedLocation);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedLocation.getName(), location.getName(),
- "Data in updated Location did not match submitted data.");
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got Location to update with ID: " +
+ knownItemResourceId +
+ " in LocationAuthority: " + knownResourceId );
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ LocationsCommon location = (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(location);
+
+ // Update the contents of this resource.
+ location.setCsid(null);
+ location.setName("updated-" + location.getName());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated Location");
+ logger.debug(objectAsXmlString(location,
+ LocationsCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(location, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ LocationsCommon updatedLocation =
+ (LocationsCommon) extractPart(input,
+ client.getItemCommonPartName(), LocationsCommon.class);
+ Assert.assertNotNull(updatedLocation);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedLocation.getName(), location.getName(),
+ "Data in updated Location did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
displayName, "nonEx", client.getCommonPartName());
ClientResponse<MultipartInput> res =
client.update(NON_EXISTENT_ID, multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
nonexMap.put(LocationJAXBSchema.NAME, TEST_NAME);
nonexMap.put(LocationJAXBSchema.SHORT_IDENTIFIER, "nonEx");
nonexMap.put(LocationJAXBSchema.LOCATION_TYPE, TEST_LOCATION_TYPE);
- nonexMap.put(LocationJAXBSchema.STATUS, TEST_STATUS);
+ nonexMap.put(LocationJAXBSchema.TERM_STATUS, TEST_STATUS);
MultipartOutput multipart =
LocationAuthorityClientUtils.createLocationInstance(NON_EXISTENT_ID,
LocationAuthorityClientUtils.createLocationRefName(knownResourceRefName, "nonEx", "Non Existent"),
nonexMap, client.getItemCommonPartName() );
ClientResponse<MultipartInput> res =
client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
- ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ ClientResponse<Response> res =
+ client.deleteItem(knownResourceId, knownItemResourceId);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/* (non-Javadoc)
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
LocationAuthorityClient client = new LocationAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
// below are ignored and not reported.
ClientResponse<Response> res =
client.deleteItem(parentResourceId, itemResourceId);
+ res.releaseConnection();
}
// Clean up parent resources.
for (String resourceId : allResourceIdsCreated) {
// Note: Any non-success responses from the delete operation
// below are ignored and not reported.
ClientResponse<Response> res = client.delete(resourceId);
+ res.releaseConnection();
}
}
<name>services.location.jaxb</name>
<dependencies>
+ <dependency>
+ <groupId>org.collectionspace.services</groupId>
+ <artifactId>org.collectionspace.services.common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
+++ /dev/null
-/**\r
- * \r
- */\r
-package org.collectionspace.services;\r
-\r
-/**\r
- * @author pschmitz\r
- *\r
- */\r
-public interface LocationAuthorityJAXBSchema {\r
- final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String REF_NAME = "refName";\r
- final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String VOCAB_TYPE = "vocabType";\r
- final static String CSID = "csid";\r
-}\r
-\r
-\r
+++ /dev/null
-package org.collectionspace.services;\r
-\r
-public interface LocationAuthorityListItemJAXBSchema {\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String REF_NAME = "refName";\r
- final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String VOCAB_TYPE = "vocabType";\r
- final static String CSID = "csid";\r
- final static String URI = "url";\r
-}\r
* \r
*/\r
package org.collectionspace.services;\r
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;\r
\r
/**\r
* @author pschmitz\r
*\r
*/\r
-public interface LocationJAXBSchema {\r
+public interface LocationJAXBSchema extends AuthorityJAXBSchema {\r
final static String LOCATIONS_COMMON = "locations_common";\r
- final static String CSID = "csid";\r
- final static String SHORT_IDENTIFIER = "shortIdentifier";\r
- final static String IN_AUTHORITY = "inAuthority";\r
- final static String REF_NAME = "refName";\r
- final static String DISPLAY_NAME = "displayName";\r
final static String DISPLAY_NAME_COMPUTED = "displayNameComputed";\r
final static String NAME = "name";\r
final static String CONDITION_NOTE = "conditionNote";\r
final static String CONDITION_NOTE_DATE = "conditionNoteDate";\r
final static String SECURITY_NOTE = "securityNote";\r
final static String LOCATION_TYPE = "locationType";\r
- final static String STATUS = "status";\r
}\r
\r
+++ /dev/null
-package org.collectionspace.services;\r
-\r
-public interface LocationListItemJAXBSchema {\r
- final static String DISPLAY_NAME = "displayName";\r
- final static String REF_NAME = "refName";\r
- final static String CSID = "csid";\r
- final static String URI = "url";\r
-}\r
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="name" type="xs:string"/>
<xs:element name="conditionNoteDate" type="xs:string"/>
<xs:element name="securityNote" type="xs:string"/>
<xs:element name="locationType" type="xs:string"/>
- <xs:element name="status" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
import javax.ws.rs.core.UriBuilder;
import javax.ws.rs.core.UriInfo;
-import org.collectionspace.services.LocationAuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
import org.collectionspace.services.LocationJAXBSchema;
import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl;
import org.collectionspace.services.common.ClientType;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.repository.RepositoryClient;
import org.collectionspace.services.common.security.UnauthorizedException;
+import org.collectionspace.services.common.vocabulary.AuthorityResource;
import org.collectionspace.services.common.vocabulary.RefNameServiceUtils;
import org.collectionspace.services.common.vocabulary.RefNameUtils;
import org.collectionspace.services.common.query.IQueryManager;
-import org.collectionspace.services.contact.ContactResource;
-import org.collectionspace.services.contact.ContactsCommon;
-import org.collectionspace.services.contact.ContactsCommonList;
-import org.collectionspace.services.contact.ContactJAXBSchema;
-import org.collectionspace.services.contact.nuxeo.ContactDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.location.nuxeo.LocationDocumentModelHandler;
import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;
@Path("/locationauthorities")
@Consumes("multipart/mixed")
@Produces("multipart/mixed")
-public class LocationAuthorityResource extends
- AbstractMultiPartCollectionSpaceResourceImpl {
+public class LocationAuthorityResource
+ extends AuthorityResource<LocationauthoritiesCommon, LocationauthoritiesCommonList,
+ LocationsCommon, LocationDocumentModelHandler> {
- /** The Constant locationAuthorityServiceName. */
private final static String locationAuthorityServiceName = "locationauthorities";
+ private final static String LOCATIONAUTHORITIES_COMMON = "locationauthorities_common";
- /** The Constant locationServiceName. */
private final static String locationServiceName = "locations";
+ private final static String LOCATIONS_COMMON = "locations_common";
/** The logger. */
final Logger logger = LoggerFactory.getLogger(LocationAuthorityResource.class);
* Instantiates a new location authority resource.
*/
public LocationAuthorityResource() {
- // do nothing
+ super(LocationauthoritiesCommon.class, LocationAuthorityResource.class,
+ LOCATIONAUTHORITIES_COMMON, LOCATIONS_COMMON);
}
- /* (non-Javadoc)
- * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString()
- */
- @Override
- protected String getVersionString() {
- /** The last change revision. */
- final String lastChangeRevision = "$LastChangedRevision: 1850 $";
- return lastChangeRevision;
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName()
*/
return locationAuthorityServiceName;
}
- @Override
- public Class<LocationauthoritiesCommon> getCommonPartClass() {
- return LocationauthoritiesCommon.class;
- }
-
/**
* Gets the item service name.
*
return locationServiceName;
}
- /**
- * Creates the item document handler.
- *
- * @param ctx the ctx
- * @param inAuthority the in authority
- *
- * @return the document handler
- *
- * @throws Exception the exception
- */
- private DocumentHandler createItemDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx,
- String inAuthority) throws Exception {
- LocationDocumentModelHandler docHandler = (LocationDocumentModelHandler)createDocumentHandler(ctx,
- ctx.getCommonPartLabel(getItemServiceName()),
- LocationsCommon.class);
- docHandler.setInAuthority(inAuthority);
-
- return docHandler;
- }
-
- /**
- * Creates the location authority.
- *
- * @param input the input
- *
- * @return the response
- */
- @POST
- public Response createLocationAuthority(MultipartInput input) {
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(input);
- DocumentHandler handler = createDocumentHandler(ctx);
- String csid = getRepositoryClient(ctx).create(ctx, handler);
- //locationAuthorityObject.setCsid(csid);
- UriBuilder path = UriBuilder.fromResource(LocationAuthorityResource.class);
- path.path("" + csid);
- Response response = Response.created(path.build()).build();
- return response;
- } catch (BadRequestException bre) {
- Response response = Response.status(
- Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in createLocationAuthority", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- }
-
- /**
- * Gets the location authority by name.
- *
- * @param specifier the specifier
- *
- * @return the location authority by name
- */
- @GET
- @Path("urn:cspace:name({specifier})")
- public MultipartOutput getLocationAuthorityByName(@PathParam("specifier") String specifier) {
- if (specifier == null) {
- logger.error("getLocationAuthority: missing name!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "get failed on LocationAuthority (missing specifier)").type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- String whereClause =
- LocationAuthorityJAXBSchema.LOCATIONAUTHORITIES_COMMON+
- ":"+LocationAuthorityJAXBSchema.SHORT_IDENTIFIER+
- "='"+specifier+"'";
- // We only get a single doc - if there are multiple,
- // it is an error in use.
-
- if (logger.isDebugEnabled()) {
- logger.debug("getLocationAuthority with name=" + specifier);
- }
- MultipartOutput result = null;
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
- DocumentHandler handler = createDocumentHandler(ctx);
- DocumentFilter myFilter = new DocumentFilter(whereClause, 0, 1);
- handler.setDocumentFilter(myFilter);
- getRepositoryClient(ctx).get(ctx, handler);
- result = (MultipartOutput) ctx.getOutput();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocationAuthority", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed on LocationAuthority spec=" + specifier).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocationAuthority", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- if (result == null) {
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed, the requested LocationAuthority spec:" + specifier + ": was not found.").type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
-
- /**
- * Gets the entities referencing this Location instance. The service type
- * can be passed as a query param "type", and must match a configured type
- * for the service bindings. If not set, the type defaults to
- * ServiceBindingUtils.SERVICE_TYPE_PROCEDURE.
- *
- * @param csid the parent csid
- * @param itemcsid the location csid
- * @param ui the ui
- *
- * @return the info for the referencing objects
- */
- @GET
- @Path("{csid}/items/{itemcsid}/refObjs")
- @Produces("application/xml")
- public AuthorityRefDocList getReferencingObjects(
- @PathParam("csid") String parentcsid,
- @PathParam("itemcsid") String itemcsid,
- @Context UriInfo ui) {
- AuthorityRefDocList authRefDocList = null;
- if (logger.isDebugEnabled()) {
- logger.debug("getReferencingObjects with parentcsid="
- + parentcsid + " and itemcsid=" + itemcsid);
- }
- if (parentcsid == null || "".equals(parentcsid)
- || itemcsid == null || "".equals(itemcsid)) {
- logger.error("getLocation: missing parentcsid or itemcsid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "get failed on Location with parentcsid="
- + parentcsid + " and itemcsid=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- try {
- // Note that we have to create the service context for the Items, not the main service
- ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(getItemServiceName());
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- RepositoryClient repoClient = getRepositoryClient(ctx);
- DocumentFilter myFilter = handler.createDocumentFilter();
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- myFilter.setPagination(queryParams);
- String serviceType = ServiceBindingUtils.SERVICE_TYPE_PROCEDURE;
- List<String> list = queryParams.remove(ServiceBindingUtils.SERVICE_TYPE_PROP);
- if (list != null) {
- serviceType = list.get(0);
- }
- DocumentWrapper<DocumentModel> docWrapper = repoClient.getDoc(ctx, itemcsid);
- DocumentModel docModel = docWrapper.getWrappedObject();
- String refName = (String)docModel.getPropertyValue(LocationJAXBSchema.REF_NAME);
-
- authRefDocList = RefNameServiceUtils.getAuthorityRefDocs(ctx, repoClient,
- serviceType, refName,
- myFilter.getPageSize(), myFilter.getStartPage(), true );
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("getReferencingObjects", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "GetReferencingObjects failed with parentcsid="
- + parentcsid + " and itemcsid=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) { // Includes DocumentException
- if (logger.isDebugEnabled()) {
- logger.debug("GetReferencingObjects", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- if (authRefDocList == null) {
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed, the requested Location CSID:" + itemcsid + ": was not found.").type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- return authRefDocList;
- }
-
- @GET
- @Path("{csid}")
- public MultipartOutput getLocationAuthority(@PathParam("csid") String csid) {
- if (csid == null) {
- logger.error("getLocationAuthority: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "get failed on LocationAuthority csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- if (logger.isDebugEnabled()) {
- logger.debug("getLocationAuthority with path(id)=" + csid);
- }
- MultipartOutput result = null;
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
- DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).get(ctx, csid, handler);
- result = (MultipartOutput) ctx.getOutput();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocationAuthority", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed on LocationAuthority csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocationAuthority", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- if (result == null) {
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed, the requested LocationAuthority CSID:" + csid + ": was not found.").type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
-
- /**
- * Gets the location authority list.
- *
- * @param ui the ui
- *
- * @return the location authority list
- */
- @GET
- @Produces("application/xml")
- public LocationauthoritiesCommonList getLocationAuthorityList(@Context UriInfo ui) {
- LocationauthoritiesCommonList locationAuthorityObjectList = new LocationauthoritiesCommonList();
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- DocumentHandler handler = createDocumentHandler(ctx);
- DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
- myFilter.setPagination(queryParams); //FIXME
- String nameQ = queryParams.getFirst("refName");
- if (nameQ != null) {
- myFilter.setWhereClause("locationauthorities_common:refName='" + nameQ + "'");
- }
- handler.setDocumentFilter(myFilter);
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- locationAuthorityObjectList = (LocationauthoritiesCommonList) handler.getCommonPartList();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in getLocationAuthorityList", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return locationAuthorityObjectList;
- }
-
- /**
- * Update location authority.
- *
- * @param csid the csid
- * @param theUpdate the the update
- *
- * @return the multipart output
- */
- @PUT
- @Path("{csid}")
- public MultipartOutput updateLocationAuthority(
- @PathParam("csid") String csid,
- MultipartInput theUpdate) {
- if (logger.isDebugEnabled()) {
- logger.debug("updateLocationAuthority with csid=" + csid);
- }
- if (csid == null || "".equals(csid)) {
- logger.error("updateLocationAuthority: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "update failed on LocationAuthority csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- MultipartOutput result = null;
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(theUpdate);
- DocumentHandler handler = createDocumentHandler(ctx);
- getRepositoryClient(ctx).update(ctx, csid, handler);
- result = (MultipartOutput) ctx.getOutput();
- } catch (BadRequestException bre) {
- Response response = Response.status(
- Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("caugth exception in updateLocationAuthority", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Update failed on LocationAuthority csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
-
- /**
- * Delete location authority.
- *
- * @param csid the csid
- *
- * @return the response
- */
- @DELETE
- @Path("{csid}")
- public Response deleteLocationAuthority(@PathParam("csid") String csid) {
-
- if (logger.isDebugEnabled()) {
- logger.debug("deleteLocationAuthority with csid=" + csid);
- }
- if (csid == null || "".equals(csid)) {
- logger.error("deleteLocationAuthority: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "delete failed on LocationAuthority csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext();
- getRepositoryClient(ctx).delete(ctx, csid);
- return Response.status(HttpResponseCodes.SC_OK).build();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("caught exception in deleteLocationAuthority", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Delete failed on LocationAuthority csid=" + csid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
-
- }
-
- /*************************************************************************
- * Location parts - this is a sub-resource of LocationAuthority
- *************************************************************************/
- @POST
- @Path("{csid}/items")
- public Response createLocation(@PathParam("csid") String parentcsid, MultipartInput input) {
- try {
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(), input);
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- String itemcsid = getRepositoryClient(ctx).create(ctx, handler);
- UriBuilder path = UriBuilder.fromResource(LocationAuthorityResource.class);
- path.path(parentcsid + "/items/" + itemcsid);
- Response response = Response.created(path.build()).build();
- return response;
- } catch (BadRequestException bre) {
- Response response = Response.status(
- Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Create failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in createLocation", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- }
-
- /**
- * Gets the location.
- *
- * @param parentcsid the parentcsid
- * @param itemcsid the itemcsid
- *
- * @return the location
- */
- @GET
- @Path("{csid}/items/{itemcsid}")
- public MultipartOutput getLocation(
- @PathParam("csid") String parentcsid,
- @PathParam("itemcsid") String itemcsid) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
- }
- if (parentcsid == null || "".equals(parentcsid)
- || itemcsid == null || "".equals(itemcsid)) {
- logger.error("getLocation: missing parentcsid or itemcsid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "get failed on Location with parentcsid="
- + parentcsid + " and itemcsid=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- MultipartOutput result = null;
- try {
- // Note that we have to create the service context for the Items, not the main service
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- getRepositoryClient(ctx).get(ctx, itemcsid, handler);
- // TODO should we assert that the item is in the passed locationAuthority?
- result = (MultipartOutput) ctx.getOutput();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Get failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocation", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed on Location csid=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("getLocation", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Get failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- if (result == null) {
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Get failed, the requested Location CSID:" + itemcsid + ": was not found.").type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
-
- /**
- * Gets the location list.
- *
- * @param parentcsid the parentcsid
- * @param partialTerm the partial term
- * @param ui the ui
- *
- * @return the location list
- */
- @GET
- @Path("{csid}/items")
- @Produces("application/xml")
- public LocationsCommonList getLocationList(
- @PathParam("csid") String parentcsid,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @Context UriInfo ui) {
- LocationsCommonList locationObjectList = new LocationsCommonList();
- try {
- // Note that docType defaults to the ServiceName, so we're fine with that.
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
- queryParams);
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- DocumentFilter myFilter = handler.getDocumentFilter();
-
- // Add the where clause "locations_common:inAuthority='" + parentcsid + "'"
- myFilter.setWhereClause(LocationJAXBSchema.LOCATIONS_COMMON + ":" +
- LocationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
-
- // AND locations_common:displayName LIKE '%partialTerm%'
- if (partialTerm != null && !partialTerm.isEmpty()) {
- String ptClause =
- LocationJAXBSchema.LOCATIONS_COMMON + ":" +
- LocationJAXBSchema.DISPLAY_NAME +
- " LIKE " +
- "'%" + partialTerm + "%'";
- myFilter.appendWhereClause(ptClause, IQueryManager.SEARCH_QUALIFIER_AND);
- }
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- locationObjectList = (LocationsCommonList) handler.getCommonPartList();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in getLocationList", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return locationObjectList;
- }
-
-
- /**
- * Gets the location list by auth name.
- *
- * @param parentSpecifier the parent specifier
- * @param partialTerm the partial term
- * @param ui the ui
- *
- * @return the location list by auth name
- */
- @GET
- @Path("urn:cspace:name({specifier})/items")
- @Produces("application/xml")
- public LocationsCommonList getLocationListByAuthName(
- @PathParam("specifier") String parentSpecifier,
- @QueryParam (IQueryManager.SEARCH_TYPE_PARTIALTERM) String partialTerm,
- @Context UriInfo ui) {
- LocationsCommonList locationObjectList = new LocationsCommonList();
- try {
- MultivaluedMap<String, String> queryParams = ui.getQueryParameters();
- String whereClause =
- LocationAuthorityJAXBSchema.LOCATIONAUTHORITIES_COMMON+
- ":"+LocationAuthorityJAXBSchema.SHORT_IDENTIFIER+
- "='"+parentSpecifier+"'";
- // Need to get an Authority by name
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(queryParams);
- String parentcsid =
- getRepositoryClient(ctx).findDocCSID(ctx, whereClause);
-
- ctx = createServiceContext(getItemServiceName(), queryParams);
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- DocumentFilter myFilter = handler.createDocumentFilter(); //new DocumentFilter();
- myFilter.setPagination(queryParams); //FIXME
-
- // Add the where clause "locations_common:inAuthority='" + parentcsid + "'"
- myFilter.setWhereClause(LocationJAXBSchema.LOCATIONS_COMMON + ":" +
- LocationJAXBSchema.IN_AUTHORITY + "='" + parentcsid + "'");
-
- // AND locations_common:displayName LIKE '%partialTerm%'
- if (partialTerm != null && !partialTerm.isEmpty()) {
- String ptClause = // "AND " +
- LocationJAXBSchema.LOCATIONS_COMMON + ":" +
- LocationJAXBSchema.DISPLAY_NAME +
- " LIKE " +
- "'%" + partialTerm + "%'";
- myFilter.appendWhereClause(ptClause, "AND");
- }
-
- handler.setDocumentFilter(myFilter);
- getRepositoryClient(ctx).getFiltered(ctx, handler);
- locationObjectList = (LocationsCommonList) handler.getCommonPartList();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Index failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- if (logger.isDebugEnabled()) {
- logger.debug("Caught exception in getLocationList", e);
- }
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return locationObjectList;
- }
-
- /**
- * Update location.
- *
- * @param parentcsid the parentcsid
- * @param itemcsid the itemcsid
- * @param theUpdate the the update
- *
- * @return the multipart output
- */
- @PUT
- @Path("{csid}/items/{itemcsid}")
- public MultipartOutput updateLocation(
- @PathParam("csid") String parentcsid,
- @PathParam("itemcsid") String itemcsid,
- MultipartInput theUpdate) {
- if (logger.isDebugEnabled()) {
- logger.debug("updateLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
- }
- if (parentcsid == null || "".equals(parentcsid)) {
- logger.error("updateLocation: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "update failed on Location parentcsid=" + parentcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- if (itemcsid == null || "".equals(itemcsid)) {
- logger.error("updateLocation: missing itemcsid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "update failed on Location=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- MultipartOutput result = null;
- try {
- // Note that we have to create the service context for the Items, not the main service
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName(),
- theUpdate);
- DocumentHandler handler = createItemDocumentHandler(ctx, parentcsid);
- getRepositoryClient(ctx).update(ctx, itemcsid, handler);
- result = (MultipartOutput) ctx.getOutput();
- } catch (BadRequestException bre) {
- Response response = Response.status(
- Response.Status.BAD_REQUEST).entity("Create failed reason " + bre.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Update failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("caught exception in updateLocation", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Update failed on Location csid=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Update failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
- return result;
- }
-
- /**
- * Delete location.
- *
- * @param parentcsid the parentcsid
- * @param itemcsid the itemcsid
- *
- * @return the response
- */
- @DELETE
- @Path("{csid}/items/{itemcsid}")
- public Response deleteLocation(
- @PathParam("csid") String parentcsid,
- @PathParam("itemcsid") String itemcsid) {
- if (logger.isDebugEnabled()) {
- logger.debug("deleteLocation with parentcsid=" + parentcsid + " and itemcsid=" + itemcsid);
- }
- if (parentcsid == null || "".equals(parentcsid)) {
- logger.error("deleteLocation: missing csid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "delete failed on Location parentcsid=" + parentcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- if (itemcsid == null || "".equals(itemcsid)) {
- logger.error("deleteLocation: missing itemcsid!");
- Response response = Response.status(Response.Status.BAD_REQUEST).entity(
- "delete failed on Location=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- }
- try {
- // Note that we have to create the service context for the Items, not the main service
- ServiceContext<MultipartInput, MultipartOutput> ctx = createServiceContext(getItemServiceName());
- getRepositoryClient(ctx).delete(ctx, itemcsid);
- return Response.status(HttpResponseCodes.SC_OK).build();
- } catch (UnauthorizedException ue) {
- Response response = Response.status(
- Response.Status.UNAUTHORIZED).entity("Delete failed reason " + ue.getErrorReason()).type("text/plain").build();
- throw new WebApplicationException(response);
- } catch (DocumentNotFoundException dnfe) {
- if (logger.isDebugEnabled()) {
- logger.debug("caught exception in deleteLocation", dnfe);
- }
- Response response = Response.status(Response.Status.NOT_FOUND).entity(
- "Delete failed on Location itemcsid=" + itemcsid).type(
- "text/plain").build();
- throw new WebApplicationException(response);
- } catch (Exception e) {
- Response response = Response.status(
- Response.Status.INTERNAL_SERVER_ERROR).entity("Delete failed").type("text/plain").build();
- throw new WebApplicationException(response);
- }
-
+ @Override
+ public Class<LocationauthoritiesCommon> getCommonPartClass() {
+ return LocationauthoritiesCommon.class;
}
-
}
import java.util.Iterator;
import java.util.List;
-import org.collectionspace.services.LocationAuthorityJAXBSchema;
import org.collectionspace.services.common.document.DocumentHandler.Action;
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.vocabulary.AuthorityJAXBSchema;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityDocumentModelHandler;
import org.collectionspace.services.location.LocationauthoritiesCommon;
import org.collectionspace.services.location.LocationauthoritiesCommonList;
import org.collectionspace.services.location.LocationauthoritiesCommonList.LocationauthorityListItem;
* $LastChangedDate: $
*/
public class LocationAuthorityDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
-
- private final Logger logger = LoggerFactory.getLogger(LocationAuthorityDocumentModelHandler.class);
- /**
- * locationAuthority is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- private LocationauthoritiesCommon locationAuthority;
- /**
- * locationAuthorityList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- private LocationauthoritiesCommonList locationAuthorityList;
-
-
- /**
- * getCommonPart get associated locationAuthority
- * @return
- */
- @Override
- public LocationauthoritiesCommon getCommonPart() {
- return locationAuthority;
- }
-
- /**
- * setCommonPart set associated locationAuthority
- * @param locationAuthority
- */
- @Override
- public void setCommonPart(LocationauthoritiesCommon locationAuthority) {
- this.locationAuthority = locationAuthority;
- }
-
- /**
- * getCommonPartList get associated locationAuthority (for index/GET_ALL)
- * @return
- */
- @Override
- public LocationauthoritiesCommonList getCommonPartList() {
- return locationAuthorityList;
- }
-
- @Override
- public void setCommonPartList(LocationauthoritiesCommonList locationAuthorityList) {
- this.locationAuthorityList = locationAuthorityList;
- }
-
- @Override
- public LocationauthoritiesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- @Override
- public void fillCommonPart(LocationauthoritiesCommon locationAuthorityObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
+ extends AuthorityDocumentModelHandler<LocationauthoritiesCommon, LocationauthoritiesCommonList> {
@Override
public LocationauthoritiesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
//FIXME: iterating over a long list of documents is not a long term
//strategy...need to change to more efficient iterating in future
List<LocationauthoritiesCommonList.LocationauthorityListItem> list = coList.getLocationauthorityListItem();
+ String label = getServiceContext().getCommonPartLabel();
Iterator<DocumentModel> iter = wrapDoc.getWrappedObject().iterator();
while(iter.hasNext()){
DocumentModel docModel = iter.next();
LocationauthorityListItem ilistItem = new LocationauthorityListItem();
- ilistItem.setDisplayName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- LocationAuthorityJAXBSchema.DISPLAY_NAME));
- ilistItem.setRefName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- LocationAuthorityJAXBSchema.REF_NAME));
- ilistItem.setShortIdentifier((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- LocationAuthorityJAXBSchema.SHORT_IDENTIFIER));
- ilistItem.setVocabType((String) docModel.getProperty(getServiceContext().getCommonPartLabel(),
- LocationAuthorityJAXBSchema.VOCAB_TYPE));
+ ilistItem.setDisplayName((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.DISPLAY_NAME));
+ ilistItem.setRefName((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.REF_NAME));
+ ilistItem.setShortIdentifier((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.SHORT_IDENTIFIER));
+ ilistItem.setVocabType((String) docModel.getProperty(label,
+ AuthorityJAXBSchema.VOCAB_TYPE));
String id = NuxeoUtils.extractId(docModel.getPathAsString());
ilistItem.setUri(getServiceContextPath() + id);
ilistItem.setCsid(id);
import org.collectionspace.services.common.document.DocumentFilter;
import org.collectionspace.services.common.document.DocumentWrapper;
import org.collectionspace.services.common.service.ObjectPartType;
+import org.collectionspace.services.common.vocabulary.nuxeo.AuthorityItemDocumentModelHandler;
import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl;
import org.collectionspace.services.nuxeo.util.NuxeoUtils;
import org.collectionspace.services.location.LocationsCommon;
*
*/
public class LocationDocumentModelHandler
- extends RemoteDocumentModelHandlerImpl<LocationsCommon, LocationsCommonList> {
+ extends AuthorityItemDocumentModelHandler<LocationsCommon, LocationsCommonList> {
/** The logger. */
private final Logger logger = LoggerFactory.getLogger(LocationDocumentModelHandler.class);
*/
private static final String COMMON_PART_LABEL = "locations_common";
- /**
- * location is used to stash JAXB object to use when handle is called
- * for Action.CREATE, Action.UPDATE or Action.GET
- */
- private LocationsCommon location;
- /**
- * locationList is stashed when handle is called
- * for ACTION.GET_ALL
- */
- private LocationsCommonList locationList;
-
- /**
- * inAuthority is the parent OrgAuthority for this context
- */
- private String inAuthority;
-
- /**
- * Gets the in authority.
- *
- * @return the in authority
- */
- public String getInAuthority() {
- return inAuthority;
- }
-
- /**
- * Sets the in authority.
- *
- * @param inAuthority the new in authority
- */
- public void setInAuthority(String inAuthority) {
- this.inAuthority = inAuthority;
- }
-
+ public LocationDocumentModelHandler() {
+ super(COMMON_PART_LABEL);
+ }
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#handleCreate(org.collectionspace.services.common.document.DocumentWrapper)
return newStr.toString();
}
- /**
- * getCommonPart get associated location
- * @return
- */
- @Override
- public LocationsCommon getCommonPart() {
- return location;
- }
-
- /**
- * setCommonPart set associated location
- * @param location
- */
- @Override
- public void setCommonPart(LocationsCommon location) {
- this.location = location;
- }
-
- /**
- * getCommonPartList get associated location (for index/GET_ALL)
- * @return
- */
- @Override
- public LocationsCommonList getCommonPartList() {
- return locationList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object)
- */
- @Override
- public void setCommonPartList(LocationsCommonList locationList) {
- this.locationList = locationList;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl#extractPart(org.nuxeo.ecm.core.api.DocumentModel, java.lang.String, org.collectionspace.services.common.service.ObjectPartType)
- */
- @Override
- protected Map<String, Object> extractPart(DocumentModel docModel, String schema, ObjectPartType partMeta)
- throws Exception {
- Map<String, Object> unQObjectProperties = super.extractPart(docModel, schema, partMeta);
-
- // Add the CSID to the common part
- if (partMeta.getLabel().equalsIgnoreCase(COMMON_PART_LABEL)) {
- String csid = NuxeoUtils.extractId(docModel.getPathAsString());
- unQObjectProperties.put("csid", csid);
- }
-
- return unQObjectProperties;
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public LocationsCommon extractCommonPart(DocumentWrapper wrapDoc)
- throws Exception {
- throw new UnsupportedOperationException();
- }
-
- /* (non-Javadoc)
- * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper)
- */
- @Override
- public void fillCommonPart(LocationsCommon locationObject, DocumentWrapper wrapDoc) throws Exception {
- throw new UnsupportedOperationException();
- }
-
/* (non-Javadoc)
* @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper)
*/
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="shortName" type="xs:string"/>
<xs:element name="function" type="xs:string"/>
<xs:element name="subBody" type="xs:string"/>
<xs:element name="history" type="xs:string"/>
- <xs:element name="termStatus" type="xs:string"/>
</xs:schema>
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res = client.readItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
-
- // Check whether organization has expected displayName.
- MultipartInput input = (MultipartInput) res.getEntity();
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
- // Try to Update with computed false and no displayName
- organization.setDisplayNameComputed(false);
- organization.setDisplayName(null);
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug("updateItem: status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, Response.Status.OK.getStatusCode());
+
+ // Check whether organization has expected displayName.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(organization);
+ // Try to Update with computed false and no displayName
+ organization.setDisplayNameComputed(false);
+ organization.setDisplayName(null);
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug("updateItem: status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
ClientResponse<MultipartInput> res =
client.readContact(knownResourceId, knownItemResourceId,
knownContactResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Check whether we've received a contact.
- MultipartInput input = (MultipartInput) res.getEntity();
- ContactsCommon contact = (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(contact);
- boolean showFull = true;
- if(showFull && logger.isDebugEnabled()){
- logger.debug(testName + ": returned payload:");
- logger.debug(objectAsXmlString(contact, ContactsCommon.class));
- }
- Assert.assertEquals(contact.getInAuthority(), knownResourceId);
- Assert.assertEquals(contact.getInItem(), knownItemResourceId);
-
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Check whether we've received a contact.
+ MultipartInput input = (MultipartInput) res.getEntity();
+ ContactsCommon contact = (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(contact);
+ boolean showFull = true;
+ if(showFull && logger.isDebugEnabled()){
+ logger.debug(testName + ": returned payload:");
+ logger.debug(objectAsXmlString(contact, ContactsCommon.class));
+ }
+ Assert.assertEquals(contact.getInAuthority(), knownResourceId);
+ Assert.assertEquals(contact.getInItem(), knownItemResourceId);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res = client.read(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res = client.readItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res =
client.readContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<OrgauthoritiesCommonList> res = client.readList();
- OrgauthoritiesCommonList list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Optionally output additional data about list members for debugging.
- boolean iterateThroughList = false;
- if (iterateThroughList && logger.isDebugEnabled()) {
- List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
- list.getOrgauthorityListItem();
- int i = 0;
- for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
- String csid = item.getCsid();
- logger.debug(testName + ": list-item[" + i + "] csid=" +
- csid);
- logger.debug(testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- readItemList(csid, null);
- i++;
- }
- }
+ try {
+ OrgauthoritiesCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Optionally output additional data about list members for debugging.
+ boolean iterateThroughList = false;
+ if (iterateThroughList && logger.isDebugEnabled()) {
+ List<OrgauthoritiesCommonList.OrgauthorityListItem> items =
+ list.getOrgauthorityListItem();
+ int i = 0;
+ for (OrgauthoritiesCommonList.OrgauthorityListItem item : items) {
+ String csid = item.getCsid();
+ logger.debug(testName + ": list-item[" + i + "] csid=" +
+ csid);
+ logger.debug(testName + ": list-item[" + i + "] displayName=" +
+ item.getDisplayName());
+ logger.debug(testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ readItemList(csid, null);
+ i++;
+ }
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
/**
} else {
Assert.fail("readItemList passed null csid and name!");
}
- OrganizationsCommonList list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- List<OrganizationsCommonList.OrganizationListItem> items =
- list.getOrganizationListItem();
- int nItemsReturned = items.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- int i = 0;
- for (OrganizationsCommonList.OrganizationListItem item : items) {
- Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
- Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
- // Optionally output additional data about list members for debugging.
- boolean showDetails = true;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- item.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
- item.getRefName());
- logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
- item.getDisplayName());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- item.getUri());
- }
- i++;
- }
+ try {
+ OrganizationsCommonList list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ List<OrganizationsCommonList.OrganizationListItem> items =
+ list.getOrganizationListItem();
+ int nItemsReturned = items.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": Expected "
+ + nExpectedItems +" items; got: "+nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ int i = 0;
+ for (OrganizationsCommonList.OrganizationListItem item : items) {
+ Assert.assertTrue((null != item.getRefName()), "Item refName is null!");
+ Assert.assertTrue((null != item.getDisplayName()), "Item displayName is null!");
+ // Optionally output additional data about list members for debugging.
+ boolean showDetails = true;
+ if (showDetails && logger.isDebugEnabled()) {
+ logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
+ item.getCsid());
+ logger.debug(" " + testName + ": list-item[" + i + "] refName=" +
+ item.getRefName());
+ logger.debug(" " + testName + ": list-item[" + i + "] displayName=" +
+ item.getDisplayName());
+ logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
+ item.getUri());
+ }
+ i++;
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
/**
ContactsCommonList list = null;
ClientResponse<ContactsCommonList> res =
client.readContactList(parentcsid, itemcsid);
- list = res.getEntity();
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- List<ContactsCommonList.ContactListItem> listitems =
- list.getContactListItem();
- int nItemsReturned = listitems.size();
- // There will be one item created, associated with a
- // known parent resource, by the createItem test.
- //
- // In addition, there will be 'nItemsToCreateInList'
- // additional items created by the createItemList test,
- // all associated with the same parent resource.
- int nExpectedItems = nItemsToCreateInList + 1;
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": Expected "
- + nExpectedItems +" items; got: "+nItemsReturned);
- }
- Assert.assertEquals(nItemsReturned, nExpectedItems);
-
- int i = 0;
- for (ContactsCommonList.ContactListItem listitem : listitems) {
- // Optionally output additional data about list members for debugging.
- boolean showDetails = false;
- if (showDetails && logger.isDebugEnabled()) {
- logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
- listitem.getCsid());
- logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
- listitem.getAddressPlace());
- logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
- listitem.getUri());
- }
- i++;
- }
+ try {
+ list = res.getEntity();
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ List<ContactsCommonList.ContactListItem> listitems =
+ list.getContactListItem();
+ int nItemsReturned = listitems.size();
+ // There will be one item created, associated with a
+ // known parent resource, by the createItem test.
+ //
+ // In addition, there will be 'nItemsToCreateInList'
+ // additional items created by the createItemList test,
+ // all associated with the same parent resource.
+ int nExpectedItems = nItemsToCreateInList + 1;
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": Expected "
+ + nExpectedItems +" items; got: "+nItemsReturned);
+ }
+ Assert.assertEquals(nItemsReturned, nExpectedItems);
+
+ int i = 0;
+ for (ContactsCommonList.ContactListItem listitem : listitems) {
+ // Optionally output additional data about list members for debugging.
+ boolean showDetails = false;
+ if (showDetails && logger.isDebugEnabled()) {
+ logger.debug(" " + testName + ": list-item[" + i + "] csid=" +
+ listitem.getCsid());
+ logger.debug(" " + testName + ": list-item[" + i + "] addressPlace=" +
+ listitem.getAddressPlace());
+ logger.debug(" " + testName + ": list-item[" + i + "] URI=" +
+ listitem.getUri());
+ }
+ i++;
+ }
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res =
client.read(knownResourceId);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
- }
- MultipartInput input = (MultipartInput) res.getEntity();
- OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(orgAuthority);
-
- // Update the contents of this resource.
- orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
- orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated OrgAuthority");
- logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getCommonPartName());
- res = client.update(knownResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- OrgauthoritiesCommon updatedOrgAuthority =
- (OrgauthoritiesCommon) extractPart(input,
- client.getCommonPartName(), OrgauthoritiesCommon.class);
- Assert.assertNotNull(updatedOrgAuthority);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
- orgAuthority.getDisplayName(),
- "Data in updated object did not match submitted data.");
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got OrgAuthority to update with ID: " + knownResourceId);
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ OrgauthoritiesCommon orgAuthority = (OrgauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), OrgauthoritiesCommon.class);
+ Assert.assertNotNull(orgAuthority);
+
+ // Update the contents of this resource.
+ orgAuthority.setDisplayName("updated-" + orgAuthority.getDisplayName());
+ orgAuthority.setVocabType("updated-" + orgAuthority.getVocabType());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated OrgAuthority");
+ logger.debug(objectAsXmlString(orgAuthority, OrgauthoritiesCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(orgAuthority, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getCommonPartName());
+ res.releaseConnection();
+ res = client.update(knownResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ OrgauthoritiesCommon updatedOrgAuthority =
+ (OrgauthoritiesCommon) extractPart(input,
+ client.getCommonPartName(), OrgauthoritiesCommon.class);
+ Assert.assertNotNull(updatedOrgAuthority);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedOrgAuthority.getDisplayName(),
+ orgAuthority.getDisplayName(),
+ "Data in updated object did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
/**
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res =
client.readItem(knownResourceId, knownItemResourceId);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Organization to update with ID: " +
- knownItemResourceId +
- " in OrgAuthority: " + knownResourceId );
- }
- MultipartInput input = (MultipartInput) res.getEntity();
- OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(organization);
-
- // Update the contents of this resource.
- organization.setCsid(null);
- organization.setShortName("updated-" + organization.getShortName());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated Organization");
- logger.debug(objectAsXmlString(organization,
- OrganizationsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", client.getItemCommonPartName());
- res = client.updateItem(knownResourceId, knownItemResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- OrganizationsCommon updatedOrganization =
- (OrganizationsCommon) extractPart(input,
- client.getItemCommonPartName(), OrganizationsCommon.class);
- Assert.assertNotNull(updatedOrganization);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedOrganization.getShortName(),
- organization.getShortName(),
- "Data in updated Organization did not match submitted data.");
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got Organization to update with ID: " +
+ knownItemResourceId +
+ " in OrgAuthority: " + knownResourceId );
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ OrganizationsCommon organization = (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(organization);
+
+ // Update the contents of this resource.
+ organization.setCsid(null);
+ organization.setShortName("updated-" + organization.getShortName());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated Organization");
+ logger.debug(objectAsXmlString(organization,
+ OrganizationsCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(organization, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", client.getItemCommonPartName());
+ res.releaseConnection();
+ res = client.updateItem(knownResourceId, knownItemResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ OrganizationsCommon updatedOrganization =
+ (OrganizationsCommon) extractPart(input,
+ client.getItemCommonPartName(), OrganizationsCommon.class);
+ Assert.assertNotNull(updatedOrganization);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedOrganization.getShortName(),
+ organization.getShortName(),
+ "Data in updated Organization did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
/**
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<MultipartInput> res =
client.readContact(knownResourceId, knownItemResourceId, knownContactResourceId);
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": read status = " + res.getStatus());
- }
- Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
-
- if(logger.isDebugEnabled()){
- logger.debug("got Contact to update with ID: " +
- knownContactResourceId +
- " in item: " + knownItemResourceId +
- " in parent: " + knownResourceId );
- }
- MultipartInput input = (MultipartInput) res.getEntity();
- ContactsCommon contact = (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(contact);
-
- // Update the contents of this resource.
- contact.setAddressPlace("updated-" + contact.getAddressPlace());
- if(logger.isDebugEnabled()){
- logger.debug("to be updated Contact");
- logger.debug(objectAsXmlString(contact,
- ContactsCommon.class));
- }
-
- // Submit the updated resource to the service and store the response.
- MultipartOutput output = new MultipartOutput();
- OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
- commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
- res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
-
- // Retrieve the updated resource and verify that its contents exist.
- input = (MultipartInput) res.getEntity();
- ContactsCommon updatedContact =
- (ContactsCommon) extractPart(input,
- new ContactClient().getCommonPartName(), ContactsCommon.class);
- Assert.assertNotNull(updatedContact);
-
- // Verify that the updated resource received the correct data.
- Assert.assertEquals(updatedContact.getAddressPlace(),
- contact.getAddressPlace(),
- "Data in updated Contact did not match submitted data.");
+ try {
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": read status = " + res.getStatus());
+ }
+ Assert.assertEquals(res.getStatus(), EXPECTED_STATUS_CODE);
+
+ if(logger.isDebugEnabled()){
+ logger.debug("got Contact to update with ID: " +
+ knownContactResourceId +
+ " in item: " + knownItemResourceId +
+ " in parent: " + knownResourceId );
+ }
+ MultipartInput input = (MultipartInput) res.getEntity();
+ ContactsCommon contact = (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(contact);
+
+ // Update the contents of this resource.
+ contact.setAddressPlace("updated-" + contact.getAddressPlace());
+ if(logger.isDebugEnabled()){
+ logger.debug("to be updated Contact");
+ logger.debug(objectAsXmlString(contact,
+ ContactsCommon.class));
+ }
+
+ // Submit the updated resource to the service and store the response.
+ MultipartOutput output = new MultipartOutput();
+ OutputPart commonPart = output.addPart(contact, MediaType.APPLICATION_XML_TYPE);
+ commonPart.getHeaders().add("label", new ContactClient().getCommonPartName());
+ res.releaseConnection();
+ res = client.updateContact(knownResourceId, knownItemResourceId, knownContactResourceId, output);
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+
+ // Retrieve the updated resource and verify that its contents exist.
+ input = (MultipartInput) res.getEntity();
+ ContactsCommon updatedContact =
+ (ContactsCommon) extractPart(input,
+ new ContactClient().getCommonPartName(), ContactsCommon.class);
+ Assert.assertNotNull(updatedContact);
+
+ // Verify that the updated resource received the correct data.
+ Assert.assertEquals(updatedContact.getAddressPlace(),
+ contact.getAddressPlace(),
+ "Data in updated Contact did not match submitted data.");
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
new OrgAuthorityClient().getCommonPartName());
ClientResponse<MultipartInput> res =
client.update(NON_EXISTENT_ID, multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
nonexOrgMap, client.getItemCommonPartName() );
ClientResponse<MultipartInput> res =
client.updateItem(knownResourceId, NON_EXISTENT_ID, multipart);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/* (non-Javadoc)
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
OrgAuthorityClient client = new OrgAuthorityClient();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
final static String FUNCTION = "function";\r
final static String SUB_BODY = "subBody";\r
final static String HISTORY = "history";\r
- final static String TERM_STATUS = "termStatus";\r
}\r
\r
\r
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="shortName" type="xs:string"/>
<xs:element name="function" type="xs:string"/>
<xs:element name="subBody" type="xs:string"/>
<xs:element name="history" type="xs:string"/>
- <xs:element name="termStatus" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
AuthorityResource<OrgauthoritiesCommon, OrgauthoritiesCommonList, OrganizationsCommon,
OrganizationDocumentModelHandler> {
- /** The Constant orgAuthorityServiceName. */
private final static String orgAuthorityServiceName = "orgauthorities";
private final static String ORGAUTHORITIES_COMMON = "orgauthorities_common";
- /** The Constant organizationServiceName. */
private final static String organizationServiceName = "organizations";
private final static String ORGANIZATIONS_COMMON = "organizations_common";
- /** The logger. */
final Logger logger = LoggerFactory.getLogger(OrgAuthorityResource.class);
- //FIXME retrieve client type from configuration
- /** The Constant CLIENT_TYPE. */
- //final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType();
/** The contact resource. */
private ContactResource contactResource = new ContactResource();
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="foreName" type="xs:string"/>
<xs:element name="schoolOrStyle" type="xs:string"/>
<xs:element name="bioNote" type="xs:string"/>
<xs:element name="nameNote" type="xs:string"/>
- <xs:element name="termStatus" type="xs:string"/>
</xs:schema>
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, knownContactResourceId);
- int statusCode = res.getStatus();
- res.releaseConnection();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, knownItemResourceId);
- int statusCode = res.getStatus();
- res.releaseConnection();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/* (non-Javadoc)
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.delete(knownResourceId);
- int statusCode = res.getStatus();
- res.releaseConnection();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// Failure outcomes
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.delete(NON_EXISTENT_ID);
- int statusCode = res.getStatus();
- res.releaseConnection();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
// Submit the request to the service and store the response.
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res = client.deleteItem(knownResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
- res.releaseConnection();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
/**
PersonAuthorityClient client = new PersonAuthorityClient();
ClientResponse<Response> res =
client.deleteContact(knownResourceId, knownItemResourceId, NON_EXISTENT_ID);
- int statusCode = res.getStatus();
- res.releaseConnection();
-
- // Check the status code of the response: does it match
- // the expected response(s)?
- if(logger.isDebugEnabled()){
- logger.debug(testName + ": status = " + statusCode);
- }
- Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
- invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ try {
+ int statusCode = res.getStatus();
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ": status = " + statusCode);
+ }
+ Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode),
+ invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE);
+ } finally {
+ res.releaseConnection();
+ }
}
// ---------------------------------------------------------------
final static String SCHOOL_OR_STYLE = "schoolOrStyle";\r
final static String BIO_NOTE = "bioNote";\r
final static String NAME_NOTE = "nameNote";\r
- final static String TERM_STATUS = "termStatus";\r
}\r
\r
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string"/>
<xs:element name="refName" type="xs:string" />
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
<xs:element name="displayNameComputed" type="xs:boolean"/>
<xs:element name="foreName" type="xs:string"/>
<xs:element name="schoolOrStyle" type="xs:string"/>
<xs:element name="bioNote" type="xs:string"/>
<xs:element name="nameNote" type="xs:string"/>
- <xs:element name="termStatus" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="inAuthority" type="xs:string" />
<xs:element name="refName" type="xs:string"/>
<xs:element name="shortIdentifier" type="xs:string"/>
+ <xs:element name="termStatus" type="xs:string"/>
<xs:element name="displayName" type="xs:string"/>
- <xs:element name="status" type="xs:string"/>
</xs:schema>
<xs:element name="displayName" type="xs:string" />
<xs:element name="shortIdentifier" type="xs:string" />
<xs:element name="refName" type="xs:string" />
- <xs:element name="status" type="xs:string" />
+ <xs:element name="termStatus" type="xs:string" />
</xs:sequence>
</xs:complexType>
</xs:element>