<service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.organization.nuxeo.OrgAuthorityDocumentModelHandler
</service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.organization.nuxeo.OrgAuthorityValidatorHandler
+ </service:validatorHandler>
<service:object id="1" name="Orgauthority" version="0.1"
xmlns:service='http://collectionspace.org/services/common/service'>
<service:part id="0" control_group="Managed"
<service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.person.nuxeo.PersonAuthorityDocumentModelHandler
</service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.person.nuxeo.PersonAuthorityValidatorHandler
+ </service:validatorHandler>
<service:object id="1" name="Personauthority" version="0.1"
xmlns:service='http://collectionspace.org/services/common/service'>
<service:part id="0" control_group="Managed"
<service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.location.nuxeo.LocationAuthorityDocumentModelHandler
</service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.location.nuxeo.LocationAuthorityValidatorHandler
+ </service:validatorHandler>
<service:object id="1" name="Locationauthority" version="0.1"
xmlns:service='http://collectionspace.org/services/common/service'>
<service:part id="0" control_group="Managed"
<service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.organization.nuxeo.OrgAuthorityDocumentModelHandler
</service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.organization.nuxeo.OrgAuthorityValidatorHandler
+ </service:validatorHandler>
<service:object id="1" name="Orgauthority" version="0.1"
xmlns:service='http://collectionspace.org/services/common/service'>
<service:part id="0" control_group="Managed"
<service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.person.nuxeo.PersonAuthorityDocumentModelHandler
</service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.person.nuxeo.PersonAuthorityValidatorHandler
+ </service:validatorHandler>
<service:object id="1" name="Personauthority" version="0.1"
xmlns:service='http://collectionspace.org/services/common/service'>
<service:part id="0" control_group="Managed"
<service:documentHandler xmlns:service='http://collectionspace.org/services/common/service'>
org.collectionspace.services.location.nuxeo.LocationAuthorityDocumentModelHandler
</service:documentHandler>
+ <service:validatorHandler xmlns:service='http://collectionspace.org/services/common/service'>
+ org.collectionspace.services.location.nuxeo.LocationAuthorityValidatorHandler
+ </service:validatorHandler>
<service:object id="1" name="Locationauthority" version="0.1"
xmlns:service='http://collectionspace.org/services/common/service'>
<service:part id="0" control_group="Managed"
person.setBirthPlace(value);\r
if((value = (String)personInfo.get(PersonJAXBSchema.DEATH_PLACE))!=null)\r
person.setDeathPlace(value);\r
- if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.GROUPS))!=null) {\r
- GroupList groupsList = new GroupList();\r
- List<String> groups = groupsList.getGroup();\r
- groups.addAll(values);\r
- person.setGroups(groupsList);\r
- }\r
- if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.NATIONALITIES))!=null) {\r
- NationalityList nationalitiesList = new NationalityList();\r
- List<String> nationalities = nationalitiesList.getNationality();\r
- nationalities.addAll(values);\r
- person.setNationalities(nationalitiesList);\r
- }\r
if((value = (String)personInfo.get(PersonJAXBSchema.GENDER))!=null)\r
person.setGender(value);\r
- if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.OCCUPATIONS))!=null) {\r
- OccupationList occupationsList = new OccupationList();\r
- List<String> occupations = occupationsList.getOccupation();\r
- occupations.addAll(values);\r
- person.setOccupations(occupationsList);\r
- }\r
- if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.SCHOOLS_OR_STYLES))!=null) {\r
- SchoolOrStyleList schoolOrStyleList = new SchoolOrStyleList();\r
- List<String> schoolsOrStyles = schoolOrStyleList.getSchoolOrStyle();\r
- schoolsOrStyles.addAll(values);\r
- person.setSchoolsOrStyles(schoolOrStyleList);\r
- }\r
- if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null)\r
+ if((value = (String)personInfo.get(PersonJAXBSchema.BIO_NOTE))!=null)\r
person.setBioNote(value);\r
if((value = (String)personInfo.get(PersonJAXBSchema.NAME_NOTE))!=null)\r
person.setNameNote(value);\r
\r
+ if (personRepeatablesInfo != null) {\r
+ if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.GROUPS))!=null) {\r
+ GroupList groupsList = new GroupList();\r
+ List<String> groups = groupsList.getGroup();\r
+ groups.addAll(values);\r
+ person.setGroups(groupsList);\r
+ }\r
+ if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.NATIONALITIES))!=null) {\r
+ NationalityList nationalitiesList = new NationalityList();\r
+ List<String> nationalities = nationalitiesList.getNationality();\r
+ nationalities.addAll(values);\r
+ person.setNationalities(nationalitiesList);\r
+ }\r
+\r
+ if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.OCCUPATIONS))!=null) {\r
+ OccupationList occupationsList = new OccupationList();\r
+ List<String> occupations = occupationsList.getOccupation();\r
+ occupations.addAll(values);\r
+ person.setOccupations(occupationsList);\r
+ }\r
+ if((values = (List<String>)personRepeatablesInfo.get(PersonJAXBSchema.SCHOOLS_OR_STYLES))!=null) {\r
+ SchoolOrStyleList schoolOrStyleList = new SchoolOrStyleList();\r
+ List<String> schoolsOrStyles = schoolOrStyleList.getSchoolOrStyle();\r
+ schoolsOrStyles.addAll(values);\r
+ person.setSchoolsOrStyles(schoolOrStyleList);\r
+ }\r
+ }\r
+\r
+ \r
MultipartOutput multipart = new MultipartOutput();\r
OutputPart commonPart = multipart.addPart(person,\r
MediaType.APPLICATION_XML_TYPE);\r
*/\r
public static String extractId(ClientResponse<Response> res) {\r
MultivaluedMap<String, Object> mvm = res.getMetadata();\r
+ // FIXME: This may throw an NPE if the Location: header isn't present\r
String uri = (String) ((ArrayList<Object>) mvm.get("Location")).get(0);\r
if(logger.isDebugEnabled()){\r
logger.debug("extractId:uri=" + uri);\r
}
/**
- * Creates the item in authority.
+ * Creates the item with an empty short identifier.
+ *
+ * @param testName the test name
+ */
+ /*
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"create"}, dependsOnMethods = {"create"})
+ public void createItemWithEmptyShortId(String testName) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ setupCreate();
+
+ // Fill the property map
+ String shortId = "";
+ Map<String, String> fieldProperties = new HashMap<String,String>();
+ fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
+ fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, "Rod Beck");
+ fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
+ fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "RodBeck");
+
+ final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
+ String newID = createItemInAuthority(knownResourceId, knownResourceRefName,
+ shortId, fieldProperties, NULL_REPEATABLE_FIELD_PROPERTIES);
+ allResourceIdsCreated.add(newID);
+ }
+*/
+
+ /**
+ * Creates an item in an authority, using test data.
*
* @param vcsid the vcsid
* @param authRefName the auth ref name
logger.debug(testName + ":"+vcsid+"...");
}
- // Submit the request to the service and store the response.
- PersonAuthorityClient client = new PersonAuthorityClient();
-
Map<String, String> johnWayneMap = new HashMap<String,String>();
//
// Fill the property map
johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
johnWayneMap.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, "JohnWayne");
johnWayneMap.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
-
+
johnWayneMap.put(PersonJAXBSchema.FORE_NAME, TEST_FORE_NAME);
johnWayneMap.put(PersonJAXBSchema.SUR_NAME, TEST_SUR_NAME);
johnWayneMap.put(PersonJAXBSchema.GENDER, "male");
johnWayneGroups.add("Scottish");
johnWayneRepeatablesMap.put(PersonJAXBSchema.GROUPS, johnWayneGroups);
+ return createItemInAuthority(vcsid, authRefName, shortId, johnWayneMap, johnWayneRepeatablesMap);
+
+ }
+
+ /**
+ * Creates an item in an authority.
+ *
+ * @param vcsid the vcsid
+ * @param authRefName the auth ref name
+ * @param itemFieldProperties a set of properties specifying the values of fields.
+ * @param itemRepeatableFieldProperties a set of properties specifying the values of repeatable fields.
+ * @return the string
+ */
+ private String createItemInAuthority(String vcsid, String authRefName, String shortId,
+ Map itemFieldProperties, Map itemRepeatableFieldProperties) {
+
+ final String testName = "createItemInAuthority";
+ if(logger.isDebugEnabled()){
+ logger.debug(testName + ":"+vcsid+"...");
+ }
+
+ // Submit the request to the service and store the response.
+ PersonAuthorityClient client = new PersonAuthorityClient();
+
MultipartOutput multipart =
- PersonAuthorityClientUtils.createPersonInstance(vcsid, authRefName, johnWayneMap,
- johnWayneRepeatablesMap, client.getItemCommonPartName() );
+ PersonAuthorityClientUtils.createPersonInstance(vcsid, authRefName, itemFieldProperties,
+ itemRepeatableFieldProperties, client.getItemCommonPartName() );
String newID = null;
ClientResponse<Response> res = client.createItem(vcsid, multipart);
}
*/
+ /**
+ * Attempts to create an authority with an short identifier that contains
+ * non-word characters.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"create", "nonWordCharsInShortId"})
+ public void createWithShortIdNonWordChars(String testName) throws Exception {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
+ REQUEST_TYPE = ServiceRequestType.CREATE;
+ testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+
+ // Create the payload to be included in the body of the request
+ PersonAuthorityClient client = new PersonAuthorityClient();
+ String shortId = createIdentifier() + "*" + createIdentifier();
+ String displayName = "displayName-" + shortId;
+ MultipartOutput multipart =
+ PersonAuthorityClientUtils.createPersonAuthorityInstance(
+ displayName, shortId, client.getCommonPartName());
+
+ // Submit the request to the service and store the response.
+ ClientResponse<Response> res = client.create(multipart);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ try {
+ int statusCode = res.getStatus();
+ 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);
+ } finally {
+ res.releaseConnection();
+ }
+
+ }
+
+ /**
+ * Attempts to create an item with an short identifier that contains
+ * non-word characters.
+ *
+ * @param testName the test name
+ */
+ @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class,
+ groups = {"create", "nonWordCharsInShortId"}, dependsOnMethods = {"create"})
+ public void createItemWithShortIdNonWordChars(String testName) {
+ if (logger.isDebugEnabled()) {
+ logger.debug(testBanner(testName, CLASS_NAME));
+ }
+ EXPECTED_STATUS_CODE = STATUS_BAD_REQUEST;
+ REQUEST_TYPE = ServiceRequestType.CREATE;
+ testSetup(EXPECTED_STATUS_CODE, REQUEST_TYPE);
+
+ PersonAuthorityClient client = new PersonAuthorityClient();
+
+ // Create the payload to be included in the body of the request
+ String shortId = "7-Eleven";
+ Map<String, String> fieldProperties = new HashMap<String,String>();
+ fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME_COMPUTED, "false");
+ fieldProperties.put(PersonJAXBSchema.DISPLAY_NAME, shortId);
+ fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME_COMPUTED, "false");
+ fieldProperties.put(PersonJAXBSchema.SHORT_DISPLAY_NAME, shortId);
+ fieldProperties.put(PersonJAXBSchema.SHORT_IDENTIFIER, shortId);
+ final Map NULL_REPEATABLE_FIELD_PROPERTIES = null;
+ MultipartOutput multipart =
+ PersonAuthorityClientUtils.createPersonInstance(knownResourceId,
+ knownResourceRefName, fieldProperties,
+ NULL_REPEATABLE_FIELD_PROPERTIES, client.getItemCommonPartName());
+
+ // Send the request and receive a response
+ ClientResponse<Response> res = client.createItem(knownResourceId, multipart);
+
+ // Check the status code of the response: does it match
+ // the expected response(s)?
+ 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();
+
+ }
+ }
+
// ---------------------------------------------------------------
// CRUD tests : CREATE LIST tests
// ---------------------------------------------------------------