<?xml version="1.0" encoding="UTF-8"?>\r
<project xmlns="http://maven.apache.org/POM/4.0.0"\r
- xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
- xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"\r
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">\r
\r
<parent>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.vocabulary.importer</artifactId>\r
<version>1.0</version>\r
<name>services.vocabulary.importer</name>\r
- \r
+\r
<dependencies>\r
<!-- keep slf4j dependencies on the top -->\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-api</artifactId>\r
+ </dependency>\r
+ <dependency>\r
+ <groupId>org.slf4j</groupId>\r
+ <artifactId>slf4j-log4j12</artifactId>\r
+ </dependency>\r
<dependency>\r
<groupId>org.collectionspace.services</groupId>\r
<artifactId>org.collectionspace.services.vocabulary.jaxb</artifactId>\r
<artifactId>org.collectionspace.services.vocabulary.client</artifactId>\r
<version>${cspace.services.client.version}</version>\r
</dependency>\r
- \r
-<!-- \r
+\r
+ <!--\r
<dependency>\r
<groupId>org.testng</groupId>\r
<artifactId>testng</artifactId>\r
<version>5.6</version>\r
</dependency>\r
- --> \r
- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-api</artifactId>\r
- <version>1.5.2</version>\r
- </dependency>\r
-<!-- <dependency>\r
- <groupId>org.slf4j</groupId>\r
- <artifactId>slf4j-log4j12</artifactId>\r
- <version>1.5.2</version>\r
- </dependency> -->\r
+ -->\r
<dependency>\r
<groupId>org.jboss.resteasy</groupId>\r
<artifactId>resteasy-jaxrs</artifactId>\r
<version>3.1</version>\r
</dependency>\r
</dependencies>\r
- \r
+\r
<build>\r
<finalName>collectionspace-services-vocabulary-importer</finalName>\r
<plugins>\r
- <plugin>\r
- <groupId>org.apache.maven.plugins</groupId>\r
- <artifactId>maven-assembly-plugin</artifactId>\r
- <executions>\r
- <execution>\r
- <goals>\r
- <goal>attached</goal>\r
- </goals>\r
- <phase>package</phase>\r
- <configuration>\r
- <descriptorRefs>\r
- <descriptorRef>jar-with-dependencies</descriptorRef>\r
- </descriptorRefs>\r
- <archive>\r
- <manifest>\r
- <mainClass>org.collectionspace.services.vocabulary.importer.VocabularyBaseImport</mainClass>\r
- </manifest>\r
- </archive>\r
- </configuration>\r
- </execution>\r
- </executions>\r
- </plugin> \r
+ <plugin>\r
+ <groupId>org.apache.maven.plugins</groupId>\r
+ <artifactId>maven-assembly-plugin</artifactId>\r
+ <executions>\r
+ <execution>\r
+ <goals>\r
+ <goal>attached</goal>\r
+ </goals>\r
+ <phase>package</phase>\r
+ <configuration>\r
+ <descriptorRefs>\r
+ <descriptorRef>jar-with-dependencies</descriptorRef>\r
+ </descriptorRefs>\r
+ <archive>\r
+ <manifest>\r
+ <mainClass>org.collectionspace.services.vocabulary.importer.VocabularyBaseImport</mainClass>\r
+ </manifest>\r
+ </archive>\r
+ </configuration>\r
+ </execution>\r
+ </executions>\r
+ </plugin>\r
<plugin>\r
<groupId>org.apache.maven.plugins</groupId>\r
<artifactId>maven-surefire-plugin</artifactId>\r
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-
package org.collectionspace.services.vocabulary.importer;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
-import org.apache.log4j.BasicConfigurator;
import org.collectionspace.services.VocabularyItemJAXBSchema;
import org.collectionspace.services.client.VocabularyClient;
import org.collectionspace.services.client.VocabularyClientUtils;
import org.collectionspace.services.client.test.ServiceRequestType;
-import org.collectionspace.services.vocabulary.VocabulariesCommon;
-import org.collectionspace.services.vocabulary.VocabularyitemsCommon;
import org.jboss.resteasy.client.ClientResponse;
import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;
-import org.jboss.resteasy.plugins.providers.multipart.OutputPart;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
* $LastChangedDate: 2009-09-23 11:03:36 -0700 (Wed, 23 Sep 2009) $
*/
public class VocabularyBaseImport {
- private static final Logger logger =
- LoggerFactory.getLogger(VocabularyBaseImport.class);
+ private static final Logger logger =
+ LoggerFactory.getLogger(VocabularyBaseImport.class);
// Instance variables specific to this test.
private VocabularyClient client = new VocabularyClient();
final String SERVICE_PATH_COMPONENT = "vocabularies";
final String ITEM_SERVICE_PATH_COMPONENT = "items";
- public void createEnumeration(String vocabName, List<String> enumValues ) {
-
- // Expected status code: 201 Created
- int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
- // Type of service request being tested
- ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
-
- if(logger.isDebugEnabled()){
- logger.debug("Import: Create vocabulary: \"" + vocabName +"\"");
- }
- String baseVocabRefName = VocabularyClientUtils.createVocabularyRefName(vocabName, false);
- String fullVocabRefName = baseVocabRefName+"'"+vocabName+"'";
- MultipartOutput multipart = VocabularyClientUtils.createEnumerationInstance(
- vocabName, fullVocabRefName, client.getCommonPartName());
- ClientResponse<Response> res = client.create(multipart);
-
- int statusCode = res.getStatus();
-
- if(!REQUEST_TYPE.isValidStatusCode(statusCode)) {
- throw new RuntimeException("Could not create enumeration: \""+vocabName
- +"\" "+ VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
- }
- if(statusCode != EXPECTED_STATUS_CODE) {
- throw new RuntimeException("Unexpected Status when creating enumeration: \""
- +vocabName +"\", Status:"+ statusCode);
- }
-
- // Store the ID returned from this create operation
- // for additional tests below.
- String newVocabId = VocabularyClientUtils.extractId(res);
- if(logger.isDebugEnabled()){
- logger.debug("Import: Created vocabulary: \"" + vocabName +"\" ID:"
- +newVocabId );
- }
- for(String itemName : enumValues){
+ public void createEnumeration(String vocabName, List<String> enumValues) {
+
+ // Expected status code: 201 Created
+ int EXPECTED_STATUS_CODE = Response.Status.CREATED.getStatusCode();
+ // Type of service request being tested
+ ServiceRequestType REQUEST_TYPE = ServiceRequestType.CREATE;
+
+ if (logger.isDebugEnabled()) {
+ logger.debug("Import: Create vocabulary: \"" + vocabName + "\"");
+ }
+ String baseVocabRefName = VocabularyClientUtils.createVocabularyRefName(vocabName, false);
+ String fullVocabRefName = baseVocabRefName + "'" + vocabName + "'";
+ MultipartOutput multipart = VocabularyClientUtils.createEnumerationInstance(
+ vocabName, fullVocabRefName, client.getCommonPartName());
+ ClientResponse<Response> res = client.create(multipart);
+
+ int statusCode = res.getStatus();
+
+ if (!REQUEST_TYPE.isValidStatusCode(statusCode)) {
+ throw new RuntimeException("Could not create enumeration: \"" + vocabName
+ + "\" " + VocabularyClientUtils.invalidStatusCodeMessage(REQUEST_TYPE, statusCode));
+ }
+ if (statusCode != EXPECTED_STATUS_CODE) {
+ throw new RuntimeException("Unexpected Status when creating enumeration: \""
+ + vocabName + "\", Status:" + statusCode);
+ }
+
+ // Store the ID returned from this create operation
+ // for additional tests below.
+ String newVocabId = VocabularyClientUtils.extractId(res);
+ if (logger.isDebugEnabled()) {
+ logger.debug("Import: Created vocabulary: \"" + vocabName + "\" ID:"
+ + newVocabId);
+ }
+ for (String itemName : enumValues) {
HashMap<String, String> itemInfo = new HashMap<String, String>();
itemInfo.put(VocabularyItemJAXBSchema.DISPLAY_NAME, itemName);
- VocabularyClientUtils.createItemInVocabulary(newVocabId,
- baseVocabRefName, itemInfo, client);
- }
+ VocabularyClientUtils.createItemInVocabulary(newVocabId,
+ baseVocabRefName, itemInfo, client);
+ }
+ }
+
+ public static void main(String[] args) {
+
+ logger.info("VocabularyBaseImport starting...");
+
+ VocabularyBaseImport vbi = new VocabularyBaseImport();
+ final String acquisitionMethodsVocabName = "Acquisition Methods";
+ final String entryMethodsVocabName = "Entry Methods";
+ final String entryReasonsVocabName = "Entry Reasons";
+ final String responsibleDeptsVocabName = "Responsible Departments";
+
+ List<String> acquisitionMethodsEnumValues =
+ Arrays.asList("Gift", "Purchase", "Exchange", "Transfer", "Treasure");
+ List<String> entryMethodsEnumValues =
+ Arrays.asList("In person", "Post", "Found on doorstep");
+ List<String> entryReasonsEnumValues =
+ Arrays.asList("Enquiry", "Commission", "Loan");
+ List<String> respDeptNamesEnumValues =
+ Arrays.asList("Antiquities", "Architecture and Design", "Decorative Arts",
+ "Ethnography", "Herpetology", "Media and Performance Art",
+ "Paintings and Sculpture", "Paleobotany", "Photographs",
+ "Prints and Drawings");
+
+ vbi.createEnumeration(acquisitionMethodsVocabName, acquisitionMethodsEnumValues);
+ vbi.createEnumeration(entryMethodsVocabName, entryMethodsEnumValues);
+ vbi.createEnumeration(entryReasonsVocabName, entryReasonsEnumValues);
+ vbi.createEnumeration(responsibleDeptsVocabName, respDeptNamesEnumValues);
+
+ logger.info("VocabularyBaseImport complete.");
}
-
- public static void main(String[] args) {
-
- BasicConfigurator.configure();
- logger.info("VocabularyBaseImport starting...");
-
- VocabularyBaseImport vbi = new VocabularyBaseImport();
- final String acquisitionMethodsVocabName = "Acquisition Methods";
- final String entryMethodsVocabName = "Entry Methods";
- final String entryReasonsVocabName = "Entry Reasons";
- final String responsibleDeptsVocabName = "Responsible Departments";
-
- List<String> acquisitionMethodsEnumValues =
- Arrays.asList("Gift","Purchase","Exchange","Transfer","Treasure");
- List<String> entryMethodsEnumValues =
- Arrays.asList("In person","Post","Found on doorstep");
- List<String> entryReasonsEnumValues =
- Arrays.asList("Enquiry","Commission","Loan");
- List<String> respDeptNamesEnumValues =
- Arrays.asList("Antiquities","Architecture and Design","Decorative Arts",
- "Ethnography","Herpetology","Media and Performance Art",
- "Paintings and Sculpture","Paleobotany","Photographs",
- "Prints and Drawings");
-
- vbi.createEnumeration(acquisitionMethodsVocabName, acquisitionMethodsEnumValues);
- vbi.createEnumeration(entryMethodsVocabName, entryMethodsEnumValues);
- vbi.createEnumeration(entryReasonsVocabName, entryReasonsEnumValues);
- vbi.createEnumeration(responsibleDeptsVocabName, respDeptNamesEnumValues);
-
- logger.info("VocabularyBaseImport complete.");
- }
}