From 83c7da7eed19e61947613fd8b922d38a5b4b28fc Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Thu, 8 Oct 2009 16:22:08 +0000 Subject: [PATCH] CSPACE-451 Some files missed in the last checkin. --- .../nuxeo-platform-cs-vocabulary/.classpath | 9 + .../nuxeo-platform-cs-vocabulary/.project | 23 +++ .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + .../nuxeo-platform-cs-vocabulary/build.xml | 130 +++++++++++++++ .../nuxeo-platform-cs-vocabulary/pom.xml | 19 +++ services/vocabulary/client/.classpath | 10 ++ services/vocabulary/client/.project | 23 +++ services/vocabulary/client/pom.xml | 111 +++++++++++++ services/vocabulary/jaxb/.classpath | 9 + services/vocabulary/jaxb/.project | 23 +++ .../jaxb/.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/vocabulary/jaxb/pom.xml | 105 ++++++++++++ .../vocabulary/nuxeo/VocabularyConstants.java | 35 ++++ .../nuxeo/VocabularyDocumentModelHandler.java | 156 ++++++++++++++++++ .../nuxeo/VocabularyHandlerFactory.java | 56 +++++++ .../services/test/VocabularyServiceTest.java | 13 ++ .../service/src/test/resources/log4j.xml | 45 +++++ 19 files changed, 795 insertions(+) create mode 100644 services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.classpath create mode 100644 services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.project create mode 100644 services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/build.xml create mode 100644 services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/pom.xml create mode 100644 services/vocabulary/client/.classpath create mode 100644 services/vocabulary/client/.project create mode 100644 services/vocabulary/client/pom.xml create mode 100644 services/vocabulary/jaxb/.classpath create mode 100644 services/vocabulary/jaxb/.project create mode 100644 services/vocabulary/jaxb/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/vocabulary/jaxb/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/vocabulary/jaxb/pom.xml create mode 100644 services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyConstants.java create mode 100644 services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java create mode 100644 services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyHandlerFactory.java create mode 100644 services/vocabulary/service/src/test/java/org/collectionspace/services/test/VocabularyServiceTest.java create mode 100644 services/vocabulary/service/src/test/resources/log4j.xml diff --git a/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.classpath b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.classpath new file mode 100644 index 000000000..a92b24a87 --- /dev/null +++ b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.project b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.project new file mode 100644 index 000000000..8388db443 --- /dev/null +++ b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.project @@ -0,0 +1,23 @@ + + + nuxeo-platform-collectionspace + Nuxeo Enterprise Platform: CS extensions + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.eclipse.jdt.core.prefs b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..2c883044b --- /dev/null +++ b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Tue Oct 06 13:26:44 PDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.maven.ide.eclipse.prefs b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..552ddbfcf --- /dev/null +++ b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Tue Oct 06 13:25:17 PDT 2009 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/build.xml b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/build.xml new file mode 100644 index 000000000..a9e56c3f7 --- /dev/null +++ b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/build.xml @@ -0,0 +1,130 @@ + + + + vocabulary nuxeo document type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/pom.xml b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/pom.xml new file mode 100644 index 000000000..43cbbbc93 --- /dev/null +++ b/services/vocabulary/3rdparty/nuxeo-platform-cs-vocabulary/pom.xml @@ -0,0 +1,19 @@ + + + org.collectionspace.services + nuxeo-platform-collectionspace + 1.0 + + + 4.0.0 + org.collectionspace.services + 1.0 + org.collectionspace.services.vocabulary.3rdparty.nuxeo + jar + services.vocabulary.3rdparty.nuxeo + + Vocabulary Nuxeo Document Type + + diff --git a/services/vocabulary/client/.classpath b/services/vocabulary/client/.classpath new file mode 100644 index 000000000..425cd1620 --- /dev/null +++ b/services/vocabulary/client/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/services/vocabulary/client/.project b/services/vocabulary/client/.project new file mode 100644 index 000000000..f44220ec1 --- /dev/null +++ b/services/vocabulary/client/.project @@ -0,0 +1,23 @@ + + + javaee-addressbook-client + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/services/vocabulary/client/pom.xml b/services/vocabulary/client/pom.xml new file mode 100644 index 000000000..ad4103cd5 --- /dev/null +++ b/services/vocabulary/client/pom.xml @@ -0,0 +1,111 @@ + + + + + org.collectionspace.services.vocabulary + org.collectionspace.services + 1.0 + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.vocabulary.client + 1.0 + services.vocabulary.client + + + + + org.slf4j + slf4j-api + test + + + org.slf4j + slf4j-log4j12 + test + + + org.collectionspace.services + org.collectionspace.services.vocabulary.jaxb + 1.0 + + + org.collectionspace.services + org.collectionspace.services.client + 1.0 + + + + org.testng + testng + 5.6 + + + org.slf4j + slf4j-api + 1.5.2 + + + org.slf4j + slf4j-log4j12 + 1.5.2 + + + org.jboss.resteasy + resteasy-jaxrs + 1.0.2.GA + + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + 1.0.2.GA + + + org.jboss.resteasy + resteasy-multipart-provider + 1.0.2.GA + + + commons-httpclient + commons-httpclient + 3.1 + + + + + collectionspace-services-vocabulary-client + + + org.apache.maven.plugins + maven-surefire-plugin + + + + log4j.configuration + file:target/test-classes/log4j.properties + + + + + + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + + + diff --git a/services/vocabulary/jaxb/.classpath b/services/vocabulary/jaxb/.classpath new file mode 100644 index 000000000..842ef51bb --- /dev/null +++ b/services/vocabulary/jaxb/.classpath @@ -0,0 +1,9 @@ + + + + + + + + + diff --git a/services/vocabulary/jaxb/.project b/services/vocabulary/jaxb/.project new file mode 100644 index 000000000..db1c789f7 --- /dev/null +++ b/services/vocabulary/jaxb/.project @@ -0,0 +1,23 @@ + + + javaee-addressbook-jaxb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/services/vocabulary/jaxb/.settings/org.eclipse.jdt.core.prefs b/services/vocabulary/jaxb/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..0b4dbbea4 --- /dev/null +++ b/services/vocabulary/jaxb/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon Oct 05 17:07:09 PDT 2009 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/services/vocabulary/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/vocabulary/jaxb/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..528843671 --- /dev/null +++ b/services/vocabulary/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Oct 05 17:07:08 PDT 2009 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +includeModules=false +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/services/vocabulary/jaxb/pom.xml b/services/vocabulary/jaxb/pom.xml new file mode 100644 index 000000000..80c4cdd20 --- /dev/null +++ b/services/vocabulary/jaxb/pom.xml @@ -0,0 +1,105 @@ + + + + + org.collectionspace.services.vocabulary + org.collectionspace.services + 1.0 + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.vocabulary.jaxb + 1.0 + services.vocabulary.jaxb + + + + com.sun.xml.bind + jaxb-impl + 2.0.2 + + + org.jvnet.jaxb2-commons + property-listener-injector + 1.0 + + + org.jvnet.jaxb2_commons + runtime + 0.4.1.4 + + + + collectionspace-services-vocabulary-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + generate + + + + + + + javax.activation + activation + 1.1 + + + com.sun.xml.bind + jaxb-impl + 2.1.2 + + + + + -XtoString + -Xinject-listener-code + + + + + + + org.jvnet.jaxb2_commons + + basic + 0.4.1 + + + + org.jvnet.jaxb2-commons + + + property-listener-injector + + 1.0 + + + + + + + + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + + + diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyConstants.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyConstants.java new file mode 100644 index 000000000..bded5e86b --- /dev/null +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyConstants.java @@ -0,0 +1,35 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.vocabulary.nuxeo; + +/** + * VocabularyConstants processes CollectionObject document + * + */ +public class VocabularyConstants { + + public final static String NUXEO_DOCTYPE = "Vocabulary"; + public final static String NUXEO_SCHEMA_NAME = "vocabulary"; + public final static String NUXEO_DC_TITLE = "CollectionSpace-Vocabulary"; +} diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java new file mode 100644 index 000000000..7dbd83569 --- /dev/null +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java @@ -0,0 +1,156 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.vocabulary.nuxeo; + +import java.util.Iterator; +import java.util.List; + +import org.collectionspace.services.VocabularyJAXBSchema; +import org.collectionspace.services.common.repository.DocumentHandler.Action; +import org.collectionspace.services.common.repository.DocumentWrapper; +import org.collectionspace.services.vocabulary.VocabulariesCommon; +import org.collectionspace.services.vocabulary.VocabulariesCommonList; +import org.collectionspace.services.vocabulary.VocabulariesCommonList.VocabularyListItem; + +import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandler; +import org.nuxeo.ecm.core.api.DocumentModel; +import org.nuxeo.ecm.core.api.DocumentModelList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * VocabularyDocumentModelHandler + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class VocabularyDocumentModelHandler + extends RemoteDocumentModelHandler { + + private final Logger logger = LoggerFactory.getLogger(VocabularyDocumentModelHandler.class); + /** + * vocabulary is used to stash JAXB object to use when handle is called + * for Action.CREATE, Action.UPDATE or Action.GET + */ + private VocabulariesCommon vocabulary; + /** + * vocabularyList is stashed when handle is called + * for ACTION.GET_ALL + */ + private VocabulariesCommonList vocabularyList; + + @Override + public void prepare(Action action) throws Exception { + //no specific action needed + } + + /** + * getCommonPart get associated vocabulary + * @return + */ + @Override + public VocabulariesCommon getCommonPart() { + return vocabulary; + } + + /** + * setCommonPart set associated vocabulary + * @param vocabulary + */ + @Override + public void setCommonPart(VocabulariesCommon vocabulary) { + this.vocabulary = vocabulary; + } + + /** + * getCommonPartList get associated vocabulary (for index/GET_ALL) + * @return + */ + @Override + public VocabulariesCommonList getCommonPartList() { + return vocabularyList; + } + + @Override + public void setCommonPartList(VocabulariesCommonList vocabularyList) { + this.vocabularyList = vocabularyList; + } + + @Override + public VocabulariesCommon extractCommonPart(DocumentWrapper wrapDoc) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public void fillCommonPart(VocabulariesCommon vocabularyObject, DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public VocabulariesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject(); + + VocabulariesCommonList coList = new VocabulariesCommonList(); + List list = coList.getVocabularyListItem(); + + //FIXME: iterating over a long list of documents is not a long term + //strategy...need to change to more efficient iterating in future + Iterator iter = docList.iterator(); + while(iter.hasNext()){ + DocumentModel docModel = iter.next(); + VocabularyListItem ilistItem = new VocabularyListItem(); + ilistItem.setDisplayName((String) docModel.getProperty(getServiceContext().getCommonPartLabel(), + VocabularyJAXBSchema.DISPLAY_NAME)); + ilistItem.setVocabType((String) docModel.getProperty(getServiceContext().getCommonPartLabel(), + VocabularyJAXBSchema.VOCAB_TYPE)); + String id = docModel.getId(); + ilistItem.setUri(getServiceContextPath() + id); + ilistItem.setCsid(id); + list.add(ilistItem); + } + + return coList; + } + + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getDocumentType() + */ + @Override + public String getDocumentType() { + return VocabularyConstants.NUXEO_DOCTYPE; + } + + /** + * getQProperty converts the given property to qualified schema property + * @param prop + * @return + */ + @Override + public String getQProperty(String prop) { + return VocabularyConstants.NUXEO_SCHEMA_NAME + ":" + prop; + } +} + diff --git a/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyHandlerFactory.java b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyHandlerFactory.java new file mode 100644 index 000000000..721c30083 --- /dev/null +++ b/services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyHandlerFactory.java @@ -0,0 +1,56 @@ +/** + * This document is a part of the source code and related artifacts + * for CollectionSpace, an open source collections management system + * for museums and related institutions: + + * http://www.collectionspace.org + * http://wiki.collectionspace.org + + * Copyright 2009 University of California at Berkeley + + * Licensed under the Educational Community License (ECL), Version 2.0. + * You may not use this file except in compliance with this License. + + * You may obtain a copy of the ECL 2.0 License at + + * https://source.collectionspace.org/collection-space/LICENSE.txt + + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.collectionspace.services.vocabulary.nuxeo; + +import org.collectionspace.services.common.ClientType; +import org.collectionspace.services.common.repository.DocumentHandler; +import org.collectionspace.services.common.repository.DocumentHandlerFactory; + + +/** + * VocabularyHandlerFactory creates handlers for collectionobject based + * on type of Nuxeo client used + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class VocabularyHandlerFactory implements DocumentHandlerFactory { + + private static final VocabularyHandlerFactory self = new VocabularyHandlerFactory(); + + private VocabularyHandlerFactory() { + } + + public static VocabularyHandlerFactory getInstance() { + return self; + } + + @Override + public DocumentHandler getHandler(String clientType) { + if(ClientType.JAVA.toString().equals(clientType)){ + return new VocabularyDocumentModelHandler(); + } + throw new IllegalArgumentException("Not supported client=" + clientType); + } +} diff --git a/services/vocabulary/service/src/test/java/org/collectionspace/services/test/VocabularyServiceTest.java b/services/vocabulary/service/src/test/java/org/collectionspace/services/test/VocabularyServiceTest.java new file mode 100644 index 000000000..557d4495d --- /dev/null +++ b/services/vocabulary/service/src/test/java/org/collectionspace/services/test/VocabularyServiceTest.java @@ -0,0 +1,13 @@ +package org.collectionspace.services.test; + +//import org.collectionspace.services.intake.Vocabulary; +//import org.collectionspace.services.intake.VocabularyList; + +/** + * A VocabularyServiceTest. + * + * @version $Revision:$ + */ +public class VocabularyServiceTest { + //empty +} diff --git a/services/vocabulary/service/src/test/resources/log4j.xml b/services/vocabulary/service/src/test/resources/log4j.xml new file mode 100644 index 000000000..52121cb83 --- /dev/null +++ b/services/vocabulary/service/src/test/resources/log4j.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.47.3