From 5b8f11cad85bede337b62069388c84ad2945b3c7 Mon Sep 17 00:00:00 2001 From: Richard Millet Date: Mon, 7 Dec 2009 18:34:47 +0000 Subject: [PATCH] CSPACE-648: Checking in CRUD operations for Dimension service. You will need to perform an "Ant deploy" to copy over the new Nuxeo doctype jar. --- services/JaxRsServiceProvider/pom.xml | 5 + .../CollectionSpaceJaxRsApplication.java | 3 +- services/build.xml | 2 + .../src/main/config/tenant-bindings.xml | 28 + services/dimension/.classpath | 6 + services/dimension/.project | 23 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/dimension/3rdparty/.classpath | 6 + services/dimension/3rdparty/.project | 23 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/dimension/3rdparty/build.xml | 125 ++++ .../nuxeo-platform-cs-dimension/.classpath | 8 + .../nuxeo-platform-cs-dimension/.project | 23 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + .../nuxeo-platform-cs-dimension/build.xml | 134 ++++ .../nuxeo-platform-cs-dimension/pom.xml | 19 + .../src/main/resources/META-INF/MANIFEST.MF | 22 + .../resources/OSGI-INF/core-types-contrib.xml | 13 + .../OSGI-INF/deployment-fragment.xml | 408 ++++++++++++ .../resources/OSGI-INF/ecm-types-contrib.xml | 28 + .../resources/OSGI-INF/layouts-contrib.xml | 101 +++ .../resources/schemas/dimensions_common.xsd | 31 + services/dimension/3rdparty/pom.xml | 23 + services/dimension/build.xml | 122 ++++ services/dimension/client/.classpath | 10 + services/dimension/client/.project | 26 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/dimension/client/pom.xml | 111 ++++ .../services/client/DimensionClient.java | 131 ++++ .../services/client/DimensionProxy.java | 48 ++ .../client/test/DimensionServiceTest.java | 601 ++++++++++++++++++ .../src/test/resources/log4j.properties | 23 + .../client/temp-testng-customsuite.xml | 8 + services/dimension/jaxb/.classpath | 10 + services/dimension/jaxb/.project | 23 + .../jaxb/.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/dimension/jaxb/pom.xml | 105 +++ .../dimension/DimensionJAXBSchema.java | 19 + .../DimensionListItemJAXBSchema.java | 7 + .../src/main/resources/dimensions-common.xsd | 65 ++ services/dimension/pom.xml | 70 ++ services/dimension/service/.classpath | 11 + services/dimension/service/.project | 25 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/dimension/service/pom.xml | 137 ++++ services/dimension/service/profiles.xml | 4 + .../services/dimension/DimensionResource.java | 246 +++++++ .../dimension/nuxeo/DimensionConstants.java | 35 + .../nuxeo/DimensionDocumentModelHandler.java | 146 +++++ .../nuxeo/DimensionHandlerFactory.java | 55 ++ .../services/test/DimensionServiceTest.java | 13 + .../service/src/test/resources/log4j.xml | 45 ++ services/pom.xml | 1 + 59 files changed, 3211 insertions(+), 1 deletion(-) create mode 100644 services/dimension/.classpath create mode 100644 services/dimension/.project create mode 100644 services/dimension/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/dimension/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/dimension/3rdparty/.classpath create mode 100644 services/dimension/3rdparty/.project create mode 100644 services/dimension/3rdparty/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/dimension/3rdparty/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/dimension/3rdparty/build.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/.classpath create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/.project create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/build.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/pom.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/META-INF/MANIFEST.MF create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/core-types-contrib.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/deployment-fragment.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/ecm-types-contrib.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/layouts-contrib.xml create mode 100644 services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/schemas/dimensions_common.xsd create mode 100644 services/dimension/3rdparty/pom.xml create mode 100644 services/dimension/build.xml create mode 100644 services/dimension/client/.classpath create mode 100644 services/dimension/client/.project create mode 100644 services/dimension/client/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/dimension/client/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/dimension/client/pom.xml create mode 100644 services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionClient.java create mode 100644 services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java create mode 100644 services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java create mode 100644 services/dimension/client/src/test/resources/log4j.properties create mode 100644 services/dimension/client/temp-testng-customsuite.xml create mode 100644 services/dimension/jaxb/.classpath create mode 100644 services/dimension/jaxb/.project create mode 100644 services/dimension/jaxb/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/dimension/jaxb/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/dimension/jaxb/pom.xml create mode 100644 services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionJAXBSchema.java create mode 100644 services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionListItemJAXBSchema.java create mode 100644 services/dimension/jaxb/src/main/resources/dimensions-common.xsd create mode 100644 services/dimension/pom.xml create mode 100644 services/dimension/service/.classpath create mode 100644 services/dimension/service/.project create mode 100644 services/dimension/service/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/dimension/service/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/dimension/service/pom.xml create mode 100644 services/dimension/service/profiles.xml create mode 100644 services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java create mode 100644 services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionConstants.java create mode 100644 services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java create mode 100644 services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionHandlerFactory.java create mode 100644 services/dimension/service/src/test/java/org/collectionspace/services/test/DimensionServiceTest.java create mode 100644 services/dimension/service/src/test/resources/log4j.xml diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index c57d1261a..1b3fe8dd3 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -42,6 +42,11 @@ org.collectionspace.services.intake.service 1.0 + + org.collectionspace.services + org.collectionspace.services.dimension.service + 1.0 + org.collectionspace.services org.collectionspace.services.acquisition.service diff --git a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java index c7196a3dd..b1b272696 100644 --- a/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java +++ b/services/JaxRsServiceProvider/src/main/java/org/collectionspace/services/jaxrs/CollectionSpaceJaxRsApplication.java @@ -6,6 +6,7 @@ import org.collectionspace.services.id.IDResource; import org.collectionspace.services.intake.IntakeResource; import org.collectionspace.services.relation.NewRelationResource; import org.collectionspace.services.acquisition.AcquisitionResource; +import org.collectionspace.services.dimension.DimensionResource; import org.collectionspace.services.vocabulary.VocabularyResource; @@ -28,8 +29,8 @@ public class CollectionSpaceJaxRsApplication extends Application { singletons.add(new IntakeResource()); singletons.add(new AcquisitionResource()); singletons.add(new NewRelationResource()); - singletons.add(new VocabularyResource()); + singletons.add(new DimensionResource()); // singletons.add(new QueryResource()); // singletons.add(new DomainIdentifierResource()); diff --git a/services/build.xml b/services/build.xml index 82d6a92f0..e27881dc2 100644 --- a/services/build.xml +++ b/services/build.xml @@ -122,6 +122,7 @@ + @@ -130,6 +131,7 @@ description="undeploy services from ${jboss.server.cspace}"> + diff --git a/services/common/src/main/config/tenant-bindings.xml b/services/common/src/main/config/tenant-bindings.xml index 70cf8caa9..dbfee3c81 100644 --- a/services/common/src/main/config/tenant-bindings.xml +++ b/services/common/src/main/config/tenant-bindings.xml @@ -220,6 +220,34 @@ + + + nuxeo-java + + + + + + + + + + + + + + + + diff --git a/services/dimension/.classpath b/services/dimension/.classpath new file mode 100644 index 000000000..046988541 --- /dev/null +++ b/services/dimension/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/services/dimension/.project b/services/dimension/.project new file mode 100644 index 000000000..bf35ab41d --- /dev/null +++ b/services/dimension/.project @@ -0,0 +1,23 @@ + + + org.collectionspace.services.dimension + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/services/dimension/.settings/org.eclipse.jdt.core.prefs b/services/dimension/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..4de0af11d --- /dev/null +++ b/services/dimension/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Wed Dec 02 09:42:07 PST 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/dimension/.settings/org.maven.ide.eclipse.prefs b/services/dimension/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..93b6f8a66 --- /dev/null +++ b/services/dimension/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Sep 11 17:00:30 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/dimension/3rdparty/.classpath b/services/dimension/3rdparty/.classpath new file mode 100644 index 000000000..046988541 --- /dev/null +++ b/services/dimension/3rdparty/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/services/dimension/3rdparty/.project b/services/dimension/3rdparty/.project new file mode 100644 index 000000000..47f84edf5 --- /dev/null +++ b/services/dimension/3rdparty/.project @@ -0,0 +1,23 @@ + + + org.collectionspace.services.dimension.3rdparty + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/services/dimension/3rdparty/.settings/org.eclipse.jdt.core.prefs b/services/dimension/3rdparty/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..31e049bf2 --- /dev/null +++ b/services/dimension/3rdparty/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Wed Dec 02 09:42:10 PST 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/dimension/3rdparty/.settings/org.maven.ide.eclipse.prefs b/services/dimension/3rdparty/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..93b6f8a66 --- /dev/null +++ b/services/dimension/3rdparty/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Sep 11 17:00:30 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/dimension/3rdparty/build.xml b/services/dimension/3rdparty/build.xml new file mode 100644 index 000000000..a22c79a72 --- /dev/null +++ b/services/dimension/3rdparty/build.xml @@ -0,0 +1,125 @@ + + + + dimension service 3rdparty + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.classpath b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.classpath new file mode 100644 index 000000000..68e178d98 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.project b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.project new file mode 100644 index 000000000..754d88320 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.project @@ -0,0 +1,23 @@ + + + org.collectionspace.services.dimension.3rdparty.nuxeo + Dimension Nuxeo Document Type + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.eclipse.jdt.core.prefs b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..d00b70311 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Wed Dec 02 09:42:11 PST 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/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.maven.ide.eclipse.prefs b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..93b6f8a66 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Sep 11 17:00:30 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/dimension/3rdparty/nuxeo-platform-cs-dimension/build.xml b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/build.xml new file mode 100644 index 000000000..ae4e4f9b0 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/build.xml @@ -0,0 +1,134 @@ + + + + dimension nuxeo document type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/pom.xml b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/pom.xml new file mode 100644 index 000000000..b10172578 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/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.dimension.3rdparty.nuxeo + jar + services.dimension.3rdparty.nuxeo + + Dimension Nuxeo Document Type + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/META-INF/MANIFEST.MF b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 000000000..1d4f1d6ae --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/META-INF/MANIFEST.MF @@ -0,0 +1,22 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 1 +Bundle-Name: NuxeoCS +Bundle-SymbolicName: org.collectionspace.dimension;singleton:=true +Bundle-Version: 1.0.0 +Bundle-Localization: plugin +Bundle-Vendor: Nuxeo +Require-Bundle: org.nuxeo.runtime, + org.nuxeo.ecm.core.api, + org.nuxeo.ecm.core, + org.nuxeo.ecm.core.api, + org.nuxeo.ecm.platform.types.api, + org.nuxeo.ecm.platform.versioning.api, + org.nuxeo.ecm.platform.ui, + org.nuxeo.ecm.platform.forms.layout.client, + org.nuxeo.ecm.platform.publishing.api, + org.nuxeo.ecm.platform.ws +Provide-Package: org.collectionspace.dimension +Nuxeo-Component: OSGI-INF/core-types-contrib.xml, + OSGI-INF/ecm-types-contrib.xml, + OSGI-INF/layouts-contrib.xml + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/core-types-contrib.xml new file mode 100644 index 000000000..5459babc3 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/core-types-contrib.xml @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/deployment-fragment.xml b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/deployment-fragment.xml new file mode 100644 index 000000000..88b94ffd1 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/deployment-fragment.xml @@ -0,0 +1,408 @@ + + + + + + ${bundle.fileName} + + + + + nuxeo.war + /nuxeo + + + + + + + + + + + + Seam Context Filter + /ws/FileManageWS + + + + Seam Context Filter + /DocumentManagerWS + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{currentServerLocation.name}/#{currentTabAction.label} + + + + Create new document in #{currentDocument.name} + + + + Create new document in #{currentDocument.name} + + + + breadcrumb=command.user_dashboard + + + + breadcrumb=command.manageMembers + + + + breadcrumb=command.manageMembers + + + + breadcrumb=title.vocabularies + + + + breadcrumb=command.advancedSearch + + + + + + en + en_GB + en_US + fr + de + es + it + ar + ru + ja + vn + + + messages + + + + config/addWorkspace.jpdl.xml + + + + + + generic_error_page + /generic_error_page.xhtml + + + + + generic_message_page + /generic_message_page.xhtml + + + + + home + /nxstartup.xhtml + + + + + user_login + /login.xhtml + + + + + user_logout + /logout.xhtml + + + + + view_servers + /view_servers.xhtml + + + + + + + view_domains + /view_domains.xhtml + + + + + select_document_type + /select_document_type.xhtml + + + + + create_document + /create_document.xhtml + + + + + edit_document + /edit_document.xhtml + + + + + view_documents + /view_documents.xhtml + + + + + create_file + /create_file.xhtml + + + + + create_workspace_wizard + /createWorkspaceWizard.xhtml + + + + + send_email + /document_email.xhtml + + + + + + view_workspaces + /view_workspaces.xhtml + + + + + + create_domain + /create_domain.xhtml + + + + + + edit_domain + /edit_domain.xhtml + + + + + + create_workspace + /create_workspace.xhtml + + + + + + edit_workspace + /edit_workspace.xhtml + + + + + + + members_management + /members_management.xhtml + + + + + view_users + /view_users.xhtml + + + + + view_many_users + /view_many_users.xhtml + + + + + edit_user + /edit_user.xhtml + + + + + edit_user_password + /edit_user_password.xhtml + + + + + view_user + /view_user.xhtml + + + + + create_user + /create_user.xhtml + + + + + view_groups + /view_groups.xhtml + + + + + view_group + /view_group.xhtml + + + + + edit_group + /edit_group.xhtml + + + + + create_group + /create_group.xhtml + + + + + view_vocabularies + /view_vocabularies.xhtml + + + + + view_vocabulary + /view_vocabulary.xhtml + + + + + + + search_form + /search/search_form.xhtml + + + + + search_results_nxql + /search/search_results_nxql.xhtml + + + + + search_results_advanced + + /search/search_results_advanced.xhtml + + + + + + search_results_simple + /search/search_results_simple.xhtml + + + + + + + clipboard + /incl/clipboard.xhtml + + + + + user_dashboard + /user_dashboard.xhtml + + + + + select_workspace_template + /select_workspace_template.xhtml + + + + + pdf_generation_error + /pdf_generation_error.xhtml + + + + + mass_edit + /massedit_documents.xhtml + + + + + mass_edit_confirm + /massedit_documents_preview.xhtml + + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/ecm-types-contrib.xml new file mode 100644 index 000000000..2e4e78555 --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/ecm-types-contrib.xml @@ -0,0 +1,28 @@ + + + + + + + view_documents + + + heading + dimension + + + + + + Dimension + + + + + + Dimension + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/layouts-contrib.xml new file mode 100644 index 000000000..089a24bdc --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + dimension + measuredPart + measuredUnit + value + valueDate + valueQualifier + + + + + + + true + + dimension + + + dataInputText + + + + + + + + true + + measuredPart + + + dataInputText + + + + + + + + true + + measuredUnit + + + dataInputText + + + + + + + + true + + value + + + dataInputText + + + + + + + + true + + valueDate + + + dataInputText + + + + + + + + true + + valueQualifier + + + dataInputText + + + + + + diff --git a/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/schemas/dimensions_common.xsd b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/schemas/dimensions_common.xsd new file mode 100644 index 000000000..8dcfa5a7e --- /dev/null +++ b/services/dimension/3rdparty/nuxeo-platform-cs-dimension/src/main/resources/schemas/dimensions_common.xsd @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + diff --git a/services/dimension/3rdparty/pom.xml b/services/dimension/3rdparty/pom.xml new file mode 100644 index 000000000..122b07597 --- /dev/null +++ b/services/dimension/3rdparty/pom.xml @@ -0,0 +1,23 @@ + + + + org.collectionspace.services.dimension + org.collectionspace.services + 1.0 + + 4.0.0 + org.collectionspace.services + 1.0 + org.collectionspace.services.dimension.3rdparty + pom + services.dimension.3rdparty + + 3rd party build for dimension service + + + + nuxeo-platform-cs-dimension + + diff --git a/services/dimension/build.xml b/services/dimension/build.xml new file mode 100644 index 000000000..86d12895f --- /dev/null +++ b/services/dimension/build.xml @@ -0,0 +1,122 @@ + + + + Dimension service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/dimension/client/.classpath b/services/dimension/client/.classpath new file mode 100644 index 000000000..425cd1620 --- /dev/null +++ b/services/dimension/client/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/services/dimension/client/.project b/services/dimension/client/.project new file mode 100644 index 000000000..909c45737 --- /dev/null +++ b/services/dimension/client/.project @@ -0,0 +1,26 @@ + + + org.collectionspace.services.dimension.client + + + org.collectionspace.services.client + org.collectionspace.services.common + org.collectionspace.services.dimension.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/services/dimension/client/.settings/org.eclipse.jdt.core.prefs b/services/dimension/client/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..e46374af8 --- /dev/null +++ b/services/dimension/client/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Wed Dec 02 09:42:09 PST 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/dimension/client/.settings/org.maven.ide.eclipse.prefs b/services/dimension/client/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..93b6f8a66 --- /dev/null +++ b/services/dimension/client/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Sep 11 17:00:30 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/dimension/client/pom.xml b/services/dimension/client/pom.xml new file mode 100644 index 000000000..d78781287 --- /dev/null +++ b/services/dimension/client/pom.xml @@ -0,0 +1,111 @@ + + + + + org.collectionspace.services.dimension + org.collectionspace.services + 1.0 + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.dimension.client + 1.0 + services.dimension.client + + + + + org.slf4j + slf4j-api + test + + + org.slf4j + slf4j-log4j12 + test + + + org.collectionspace.services + org.collectionspace.services.dimension.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-dimension-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/dimension/client/src/main/java/org/collectionspace/services/client/DimensionClient.java b/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionClient.java new file mode 100644 index 000000000..888d14ff5 --- /dev/null +++ b/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionClient.java @@ -0,0 +1,131 @@ +/** + * DimensionClient.java + * + * {Purpose of This Class} + * + * {Other Notes Relating to This Class (Optional)} + * + * $LastChangedBy: $ + * $LastChangedRevision: $ + * $LastChangedDate: $ + * + * 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 (c) 2009 {Contributing Institution} + * + * 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 + */ +package org.collectionspace.services.client; + +import javax.ws.rs.core.Response; + +import org.collectionspace.services.common.context.ServiceContext; +import org.collectionspace.services.dimension.DimensionsCommonList; + +import org.jboss.resteasy.client.ProxyFactory; +import org.jboss.resteasy.plugins.providers.RegisterBuiltin; +import org.jboss.resteasy.client.ClientResponse; +import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; +import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +import org.jboss.resteasy.spi.ResteasyProviderFactory; + +/** + * A DimensionClient. + + * @version $Revision:$ + */ +public class DimensionClient extends BaseServiceClient { + + /* (non-Javadoc) + * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() + */ + public String getServicePathComponent() { + return "dimensions"; + } + + /** + * + */ + private static final DimensionClient instance = new DimensionClient(); + + /** + * + */ + private DimensionProxy dimensionProxy; + + /** + * + * Default constructor for DimensionClient class. + * + */ + public DimensionClient() { + ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance(); + RegisterBuiltin.register(factory); + dimensionProxy = ProxyFactory.create(DimensionProxy.class, getBaseURL()); + } + + /** + * FIXME Comment this + * + * @return + */ + public static DimensionClient getInstance() { + return instance; + } + + /** + * @return + * @see org.collectionspace.services.client.DimensionProxy#getDimension() + */ + public ClientResponse readList() { + return dimensionProxy.readList(); + } + + /** + * @param csid + * @return + * @see org.collectionspace.services.client.DimensionProxy#getDimension(java.lang.String) + */ + + public ClientResponse read(String csid) { + return dimensionProxy.read(csid); + } + + /** + * @param dimension + * @return + * @see org.collectionspace.services.client.DimensionProxy#createDimension(org.collectionspace.services.Dimension) + */ + public ClientResponse create(MultipartOutput multipart) { + return dimensionProxy.create(multipart); + } + + /** + * @param csid + * @param dimension + * @return + * @see org.collectionspace.services.client.DimensionProxy#updateDimension(java.lang.Long, org.collectionspace.services.Dimension) + */ + public ClientResponse update(String csid, MultipartOutput multipart) { + return dimensionProxy.update(csid, multipart); + + } + + /** + * @param csid + * @return + * @see org.collectionspace.services.client.DimensionProxy#deleteDimension(java.lang.Long) + */ + public ClientResponse delete(String csid) { + return dimensionProxy.delete(csid); + } +} diff --git a/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java b/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java new file mode 100644 index 000000000..f66872726 --- /dev/null +++ b/services/dimension/client/src/main/java/org/collectionspace/services/client/DimensionProxy.java @@ -0,0 +1,48 @@ +package org.collectionspace.services.client; + +import javax.ws.rs.Consumes; +import javax.ws.rs.DELETE; +import javax.ws.rs.GET; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.Path; +import javax.ws.rs.PathParam; +import javax.ws.rs.Produces; +import javax.ws.rs.core.Response; + +import org.collectionspace.services.dimension.DimensionsCommonList; +import org.jboss.resteasy.client.ClientResponse; +import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; +import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; + +/** + * @version $Revision:$ + */ +@Path("/dimensions/") +@Produces({"multipart/mixed"}) +@Consumes({"multipart/mixed"}) +public interface DimensionProxy { + + @GET + @Produces({"application/xml"}) + ClientResponse readList(); + + //(C)reate + @POST + ClientResponse create(MultipartOutput multipart); + + //(R)ead + @GET + @Path("/{csid}") + ClientResponse read(@PathParam("csid") String csid); + + //(U)pdate + @PUT + @Path("/{csid}") + ClientResponse update(@PathParam("csid") String csid, MultipartOutput multipart); + + //(D)elete + @DELETE + @Path("/{csid}") + ClientResponse delete(@PathParam("csid") String csid); +} diff --git a/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java b/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java new file mode 100644 index 000000000..6ad4d757a --- /dev/null +++ b/services/dimension/client/src/test/java/org/collectionspace/services/client/test/DimensionServiceTest.java @@ -0,0 +1,601 @@ +/** + * 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 Regents of the University of California + * + * 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.client.test; + +import java.util.List; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.collectionspace.services.client.DimensionClient; +import org.collectionspace.services.dimension.DimensionsCommon; +import org.collectionspace.services.dimension.DimensionsCommonList; + +import org.jboss.resteasy.client.ClientResponse; + +import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; +import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +import org.jboss.resteasy.plugins.providers.multipart.OutputPart; +import org.testng.Assert; +import org.testng.annotations.Test; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * DimensionServiceTest, carries out tests against a + * deployed and running Dimension Service. + * + * $LastChangedRevision: 917 $ + * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $ + */ +public class DimensionServiceTest extends AbstractServiceTest { + + private final Logger logger = + LoggerFactory.getLogger(DimensionServiceTest.class); + + // Instance variables specific to this test. + private DimensionClient client = new DimensionClient(); + final String SERVICE_PATH_COMPONENT = "dimensions"; + private String knownResourceId = null; + + // --------------------------------------------------------------- + // CRUD tests : CREATE tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class) + public void create(String testName) throws Exception { + + // Perform setup, such as initializing the type of service request + // (e.g. CREATE, DELETE), its valid and expected status codes, and + // its associated HTTP method name (e.g. POST, DELETE). + setupCreate(testName); + + // Submit the request to the service and store the response. + String identifier = createIdentifier(); + + MultipartOutput multipart = createDimensionInstance(identifier); + ClientResponse 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); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + + // Store the ID returned from this create operation + // for additional tests below. + knownResourceId = extractId(res); + if(logger.isDebugEnabled()){ + logger.debug(testName + ": knownResourceId=" + knownResourceId); + } + } + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void createList(String testName) throws Exception { + for(int i = 0; i < 3; i++){ + create(testName); + } + } + + // Failure outcomes + // Placeholders until the three tests below can be uncommented. + // See Issue CSPACE-401. + @Override + public void createWithEmptyEntityBody(String testName) throws Exception { + } + + @Override + public void createWithMalformedXml(String testName) throws Exception { + } + + @Override + public void createWithWrongXmlSchema(String testName) throws Exception { + } + + /* + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithEmptyEntityBody(String testName) throws Exception { + + // Perform setup. + setupCreateWithEmptyEntityBody(testName); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("createWithEmptyEntityBody url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithMalformedXml(String testName) throws Exception { + + // Perform setup. + setupCreateWithMalformedXml(testName); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; // Constant from base class. + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "testSubmitRequest"}) + public void createWithWrongXmlSchema(String testName) throws Exception { + + // Perform setup. + setupCreateWithWrongXmlSchema(testName); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getServiceRootURL(); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + */ + + // --------------------------------------------------------------- + // CRUD tests : READ tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create"}) + public void read(String testName) throws Exception { + + // Perform setup. + setupRead(testName); + + // Submit the request to the service and store the response. + ClientResponse 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); + + MultipartInput input = (MultipartInput) res.getEntity(); + DimensionsCommon dimension = (DimensionsCommon) extractPart(input, + client.getCommonPartName(), DimensionsCommon.class); + Assert.assertNotNull(dimension); + } + + // Failure outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readNonExistent(String testName) throws Exception { + + // Perform setup. + setupReadNonExistent(testName); + + // Submit the request to the service and store the response. + ClientResponse 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); + } + + // --------------------------------------------------------------- + // CRUD tests : READ_LIST tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void readList(String testName) throws Exception { + + // Perform setup. + setupReadList(testName); + + // Submit the request to the service and store the response. + ClientResponse res = client.readList(); + DimensionsCommonList 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 items = + list.getDimensionListItem(); + int i = 0; + for(DimensionsCommonList.DimensionListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] csid=" + + item.getCsid()); + logger.debug(testName + ": list-item[" + i + "] objectNumber=" + + item.getDimension()); + logger.debug(testName + ": list-item[" + i + "] URI=" + + item.getUri()); + i++; + } + } + + } + + // Failure outcomes + // None at present. + // --------------------------------------------------------------- + // CRUD tests : UPDATE tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"read"}) + public void update(String testName) throws Exception { + + // Perform setup. + setupUpdate(testName); + + ClientResponse 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 object to update with ID: " + knownResourceId); + } + MultipartInput input = (MultipartInput) res.getEntity(); + DimensionsCommon dimension = (DimensionsCommon) extractPart(input, + client.getCommonPartName(), DimensionsCommon.class); + Assert.assertNotNull(dimension); + + // Update the content of this resource. + // Update the content of this resource. + dimension.setValue("updated-" + dimension.getValue()); + dimension.setValueDate("updated-" + dimension.getValueDate()); + if(logger.isDebugEnabled()){ + logger.debug("to be updated object"); + logger.debug(objectAsXmlString(dimension, DimensionsCommon.class)); + } + // Submit the request to the service and store the response. + MultipartOutput output = new MultipartOutput(); + OutputPart commonPart = output.addPart(dimension, 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); + + + input = (MultipartInput) res.getEntity(); + DimensionsCommon updatedDimension = + (DimensionsCommon) extractPart(input, + client.getCommonPartName(), DimensionsCommon.class); + Assert.assertNotNull(updatedDimension); + + Assert.assertEquals(updatedDimension.getValueDate(), + dimension.getValueDate(), + "Data in updated object did not match submitted data."); + + } + + // Failure outcomes + // Placeholders until the three tests below can be uncommented. + // See Issue CSPACE-401. + @Override + public void updateWithEmptyEntityBody(String testName) throws Exception{ + } + @Override + public void updateWithMalformedXml(String testName) throws Exception { + } + @Override + public void updateWithWrongXmlSchema(String testName) throws Exception { + } + + /* + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithEmptyEntityBody(String testName) throws Exception { + + // Perform setup. + setupUpdateWithEmptyEntityBody(testName); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = ""; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithMalformedXml(String testName) throws Exception { + + // Perform setup. + setupUpdateWithMalformedXml(testName); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = MALFORMED_XML_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "update", "testSubmitRequest"}) + public void updateWithWrongXmlSchema(String testName) throws Exception { + + // Perform setup. + setupUpdateWithWrongXmlSchema(testName); + + // Submit the request to the service and store the response. + String method = REQUEST_TYPE.httpMethodName(); + String url = getResourceURL(knownResourceId); + String mediaType = MediaType.APPLICATION_XML; + final String entity = WRONG_XML_SCHEMA_DATA; + int statusCode = submitRequest(method, url, mediaType, entity); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug(testName + ": url=" + url + + " status=" + statusCode); + } + Assert.assertTrue(REQUEST_TYPE.isValidStatusCode(statusCode), + invalidStatusCodeMessage(REQUEST_TYPE, statusCode)); + Assert.assertEquals(statusCode, EXPECTED_STATUS_CODE); + } + */ + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"update", "testSubmitRequest"}) + public void updateNonExistent(String testName) throws Exception { + + // Perform setup. + setupUpdateNonExistent(testName); + + // Submit the request to the service and store the response. + // Note: The ID used in this 'create' call may be arbitrary. + // The only relevant ID may be the one used in update(), below. + + // The only relevant ID may be the one used in update(), below. + MultipartOutput multipart = createDimensionInstance(NON_EXISTENT_ID); + ClientResponse 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); + } + + // --------------------------------------------------------------- + // CRUD tests : DELETE tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"create", "readList", "testSubmitRequest", "update"}) + public void delete(String testName) throws Exception { + + // Perform setup. + setupDelete(testName); + + // Submit the request to the service and store the response. + ClientResponse 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); + } + + // Failure outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTest.class, + dependsOnMethods = {"delete"}) + public void deleteNonExistent(String testName) throws Exception { + + // Perform setup. + setupDeleteNonExistent(testName); + + // Submit the request to the service and store the response. + ClientResponse 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); + } + + // --------------------------------------------------------------- + // Utility tests : tests of code used in tests above + // --------------------------------------------------------------- + /** + * Tests the code for manually submitting data that is used by several + * of the methods above. + */ + @Test(dependsOnMethods = {"create", "read"}) + public void testSubmitRequest() { + + // Expected status code: 200 OK + final int EXPECTED_STATUS = Response.Status.OK.getStatusCode(); + + // Submit the request to the service and store the response. + String method = ServiceRequestType.READ.httpMethodName(); + String url = getResourceURL(knownResourceId); + int statusCode = submitRequest(method, url); + + // Check the status code of the response: does it match + // the expected response(s)? + if(logger.isDebugEnabled()){ + logger.debug("testSubmitRequest: url=" + url + + " status=" + statusCode); + } + Assert.assertEquals(statusCode, EXPECTED_STATUS); + + } + + // --------------------------------------------------------------- + // Utility methods used by tests above + // --------------------------------------------------------------- + @Override + public String getServicePathComponent() { + return SERVICE_PATH_COMPONENT; + } + + private MultipartOutput createDimensionInstance(String identifier) { + return createDimensionInstance( + "dimensionType-" + identifier, + "entryNumber-" + identifier, + "entryDate-" + identifier); + } + + private MultipartOutput createDimensionInstance(String dimensionType, String entryNumber, String entryDate) { + DimensionsCommon dimension = new DimensionsCommon(); + dimension.setDimension(dimensionType); + dimension.setValue(entryNumber); + dimension.setValueDate(entryDate); + MultipartOutput multipart = new MultipartOutput(); + OutputPart commonPart = + multipart.addPart(dimension, MediaType.APPLICATION_XML_TYPE); + commonPart.getHeaders().add("label", client.getCommonPartName()); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, dimension common"); + logger.debug(objectAsXmlString(dimension, DimensionsCommon.class)); + } + + return multipart; + } +} diff --git a/services/dimension/client/src/test/resources/log4j.properties b/services/dimension/client/src/test/resources/log4j.properties new file mode 100644 index 000000000..18c510350 --- /dev/null +++ b/services/dimension/client/src/test/resources/log4j.properties @@ -0,0 +1,23 @@ +log4j.rootLogger=debug, stdout, R + +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout + +# Pattern to output the caller's file name and line number. +log4j.appender.stdout.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n + +log4j.appender.R=org.apache.log4j.RollingFileAppender +log4j.appender.R.File=target/test-client.log + +log4j.appender.R.MaxFileSize=100KB +# Keep one backup file +log4j.appender.R.MaxBackupIndex=1 + +log4j.appender.R.layout=org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern=%d %-5p [%t] [%c:%L] %m%n + +#packages +log4j.logger.org.collectionspace=DEBUG +log4j.logger.org.apache=INFO +log4j.logger.httpclient=INFO +log4j.logger.org.jboss.resteasy=INFO diff --git a/services/dimension/client/temp-testng-customsuite.xml b/services/dimension/client/temp-testng-customsuite.xml new file mode 100644 index 000000000..9f2480621 --- /dev/null +++ b/services/dimension/client/temp-testng-customsuite.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/services/dimension/jaxb/.classpath b/services/dimension/jaxb/.classpath new file mode 100644 index 000000000..557f8a4e0 --- /dev/null +++ b/services/dimension/jaxb/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/services/dimension/jaxb/.project b/services/dimension/jaxb/.project new file mode 100644 index 000000000..218f53a21 --- /dev/null +++ b/services/dimension/jaxb/.project @@ -0,0 +1,23 @@ + + + org.collectionspace.services.dimension.jaxb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/services/dimension/jaxb/.settings/org.eclipse.jdt.core.prefs b/services/dimension/jaxb/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..e46374af8 --- /dev/null +++ b/services/dimension/jaxb/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Wed Dec 02 09:42:09 PST 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/dimension/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/dimension/jaxb/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..93b6f8a66 --- /dev/null +++ b/services/dimension/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Sep 11 17:00:30 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/dimension/jaxb/pom.xml b/services/dimension/jaxb/pom.xml new file mode 100644 index 000000000..d4a359863 --- /dev/null +++ b/services/dimension/jaxb/pom.xml @@ -0,0 +1,105 @@ + + + + + org.collectionspace.services.dimension + org.collectionspace.services + 1.0 + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.dimension.jaxb + 1.0 + services.dimension.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-dimension-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + generate + + + + + + + javax.activation + activation + 1.1 + + + com.sun.xml.bind + jaxb-impl + 2.1.9 + + + + + -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/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionJAXBSchema.java b/services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionJAXBSchema.java new file mode 100644 index 000000000..b9d4defab --- /dev/null +++ b/services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionJAXBSchema.java @@ -0,0 +1,19 @@ +/** + * + */ +package org.collectionspace.services.dimension; + +/** + * @author remillet + * + */ +public interface DimensionJAXBSchema { + final static String DIMENSION = "dimension"; + final static String MEASURED_PART = "measuredPart"; + final static String MEASURED_UNIT = "measuredUnit"; + final static String VALUE = "value"; + final static String VALUE_DATE = "valueDate"; + final static String VALUE_QUALIFIER = "valueQualifier"; +} + + diff --git a/services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionListItemJAXBSchema.java b/services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionListItemJAXBSchema.java new file mode 100644 index 000000000..c159899c8 --- /dev/null +++ b/services/dimension/jaxb/src/main/java/org/collectionspace/services/dimension/DimensionListItemJAXBSchema.java @@ -0,0 +1,7 @@ +package org.collectionspace.services.dimension; + +public interface DimensionListItemJAXBSchema { + final static String DIMENSION = "dimension"; + final static String CSID = "csid"; + final static String URI = "url"; +} diff --git a/services/dimension/jaxb/src/main/resources/dimensions-common.xsd b/services/dimension/jaxb/src/main/resources/dimensions-common.xsd new file mode 100644 index 000000000..db50b1063 --- /dev/null +++ b/services/dimension/jaxb/src/main/resources/dimensions-common.xsd @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/dimension/pom.xml b/services/dimension/pom.xml new file mode 100644 index 000000000..73a938a0d --- /dev/null +++ b/services/dimension/pom.xml @@ -0,0 +1,70 @@ + + + + + org.collectionspace.services.main + org.collectionspace.services + 1.0 + + 4.0.0 + org.collectionspace.services + 1.0 + org.collectionspace.services.dimension + pom + services.dimension + + + + jaxb + service + 3rdparty + client + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.5 + 1.5 + + + + org.apache.maven.plugins + maven-site-plugin + + /usr/bin/unzip -o > err.txt + + + + org.apache.maven.plugins + maven-war-plugin + 2.0.1 + + WEB-INF/lib/*.jar + + + true + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.0.2 + + 1.6 + 1.6 + + + + + + diff --git a/services/dimension/service/.classpath b/services/dimension/service/.classpath new file mode 100644 index 000000000..1707f3e6f --- /dev/null +++ b/services/dimension/service/.classpath @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/services/dimension/service/.project b/services/dimension/service/.project new file mode 100644 index 000000000..40629c7a4 --- /dev/null +++ b/services/dimension/service/.project @@ -0,0 +1,25 @@ + + + org.collectionspace.services.dimension.service + + + org.collectionspace.services.common + org.collectionspace.services.dimension.jaxb + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/services/dimension/service/.settings/org.eclipse.jdt.core.prefs b/services/dimension/service/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..e46374af8 --- /dev/null +++ b/services/dimension/service/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Wed Dec 02 09:42:09 PST 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/dimension/service/.settings/org.maven.ide.eclipse.prefs b/services/dimension/service/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..93b6f8a66 --- /dev/null +++ b/services/dimension/service/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Fri Sep 11 17:00:30 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/dimension/service/pom.xml b/services/dimension/service/pom.xml new file mode 100644 index 000000000..97ce3ddb2 --- /dev/null +++ b/services/dimension/service/pom.xml @@ -0,0 +1,137 @@ + + + + + org.collectionspace.services.dimension + org.collectionspace.services + 1.0 + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.dimension.service + jar + 1.0 + services.dimension.service + + + + org.collectionspace.services + org.collectionspace.services.common + 1.0 + + + org.collectionspace.services + org.collectionspace.services.dimension.jaxb + 1.0 + + + + junit + junit + 4.1 + test + + + org.testng + testng + 5.6 + + + + + + + + javax.security + jaas + 1.0.01 + provided + + + + dom4j + dom4j + 1.6.1 + provided + + + + + + 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 + + + + + + org.nuxeo.ecm.core + nuxeo-core-api + ${nuxeo.version.1.5} + + + jboss-remoting + jboss + + + + + + org.restlet + org.restlet + 1.0.7 + + + com.noelios.restlet + com.noelios.restlet.ext.httpclient + 1.0.7 + + + com.noelios.restlet + com.noelios.restlet + 1.0.7 + + + + + + collectionspace-services-dimension + + + org.codehaus.mojo + jboss-maven-plugin + + ${jboss.dir} + + + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + true + + + + + + diff --git a/services/dimension/service/profiles.xml b/services/dimension/service/profiles.xml new file mode 100644 index 000000000..347b9df22 --- /dev/null +++ b/services/dimension/service/profiles.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java new file mode 100644 index 000000000..55ed1b806 --- /dev/null +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/DimensionResource.java @@ -0,0 +1,246 @@ +/** + * 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.dimension; + +import javax.ws.rs.Consumes; +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.DELETE; +import javax.ws.rs.POST; +import javax.ws.rs.PUT; +import javax.ws.rs.PathParam; +import javax.ws.rs.WebApplicationException; +import javax.ws.rs.core.Context; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import org.collectionspace.services.common.AbstractCollectionSpaceResource; +import org.collectionspace.services.dimension.DimensionsCommonList.*; + +import org.collectionspace.services.dimension.nuxeo.DimensionHandlerFactory; +import org.collectionspace.services.common.ClientType; +import org.collectionspace.services.common.ServiceMain; +import org.collectionspace.services.common.context.MultipartServiceContext; +import org.collectionspace.services.common.context.MultipartServiceContextFactory; +import org.collectionspace.services.common.context.ServiceContext; +import org.collectionspace.services.common.document.DocumentNotFoundException; +import org.collectionspace.services.common.document.DocumentHandler; +import org.jboss.resteasy.plugins.providers.multipart.MultipartInput; +import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +import org.jboss.resteasy.util.HttpResponseCodes; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +@Path("/dimensions") +@Consumes("multipart/mixed") +@Produces("multipart/mixed") +public class DimensionResource extends AbstractCollectionSpaceResource { + + private final static String serviceName = "dimensions"; + final Logger logger = LoggerFactory.getLogger(DimensionResource.class); + //FIXME retrieve client type from configuration + final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); + + public DimensionResource() { + // do nothing + } + + @Override + public String getServiceName() { + return serviceName; + } + + @Override + public DocumentHandler createDocumentHandler(ServiceContext ctx) throws Exception { + DocumentHandler docHandler = DimensionHandlerFactory.getInstance().getHandler( + ctx.getRepositoryClientType().toString()); + docHandler.setServiceContext(ctx); + if (ctx.getInput() != null) { + Object obj = ((MultipartServiceContext)ctx).getInputPart(ctx.getCommonPartLabel(), DimensionsCommon.class); + if (obj != null) { + docHandler.setCommonPart((DimensionsCommon) obj); + } + } + return docHandler; + } + + @POST + public Response createDimension(MultipartInput input) { + try { + ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(input, getServiceName()); + DocumentHandler handler = createDocumentHandler(ctx); + String csid = getRepositoryClient(ctx).create(ctx, handler); + //dimensionObject.setCsid(csid); + UriBuilder path = UriBuilder.fromResource(DimensionResource.class); + path.path("" + csid); + Response response = Response.created(path.build()).build(); + return response; + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception in createDimension", e); + } + Response response = Response.status( + Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build(); + throw new WebApplicationException(response); + } + } + + @GET + @Path("{csid}") + public MultipartOutput getDimension( + @PathParam("csid") String csid) { + if (logger.isDebugEnabled()) { + logger.debug("getDimension with csid=" + csid); + } + if (csid == null || "".equals(csid)) { + logger.error("getDimension: missing csid!"); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + "get failed on Dimension csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } + MultipartOutput result = null; + try { + ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); + DocumentHandler handler = createDocumentHandler(ctx); + getRepositoryClient(ctx).get(ctx, csid, handler); + result = (MultipartOutput) ctx.getOutput(); + } catch (DocumentNotFoundException dnfe) { + if (logger.isDebugEnabled()) { + logger.debug("getDimension", dnfe); + } + Response response = Response.status(Response.Status.NOT_FOUND).entity( + "Get failed on Dimension csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("getDimension", 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 Dimension CSID:" + csid + ": was not found.").type( + "text/plain").build(); + throw new WebApplicationException(response); + } + return result; + } + + @GET + @Produces("application/xml") + public DimensionsCommonList getDimensionList(@Context UriInfo ui) { + DimensionsCommonList dimensionObjectList = new DimensionsCommonList(); + try { + ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); + DocumentHandler handler = createDocumentHandler(ctx); + getRepositoryClient(ctx).getAll(ctx, handler); + dimensionObjectList = (DimensionsCommonList) handler.getCommonPartList(); + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception in getDimensionList", e); + } + Response response = Response.status( + Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build(); + throw new WebApplicationException(response); + } + return dimensionObjectList; + } + + @PUT + @Path("{csid}") + public MultipartOutput updateDimension( + @PathParam("csid") String csid, + MultipartInput theUpdate) { + if (logger.isDebugEnabled()) { + logger.debug("updateDimension with csid=" + csid); + } + if (csid == null || "".equals(csid)) { + logger.error("updateDimension: missing csid!"); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + "update failed on Dimension csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } + MultipartOutput result = null; + try { + ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(theUpdate, getServiceName()); + DocumentHandler handler = createDocumentHandler(ctx); + getRepositoryClient(ctx).update(ctx, csid, handler); + result = (MultipartOutput) ctx.getOutput(); + } catch (DocumentNotFoundException dnfe) { + if (logger.isDebugEnabled()) { + logger.debug("caugth exception in updateDimension", dnfe); + } + Response response = Response.status(Response.Status.NOT_FOUND).entity( + "Update failed on Dimension 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 + @Path("{csid}") + public Response deleteDimension(@PathParam("csid") String csid) { + + if (logger.isDebugEnabled()) { + logger.debug("deleteDimension with csid=" + csid); + } + if (csid == null || "".equals(csid)) { + logger.error("deleteDimension: missing csid!"); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + "delete failed on Dimension csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } + try { + ServiceContext ctx = MultipartServiceContextFactory.get().createServiceContext(null, getServiceName()); + getRepositoryClient(ctx).delete(ctx, csid); + return Response.status(HttpResponseCodes.SC_OK).build(); + } catch (DocumentNotFoundException dnfe) { + if (logger.isDebugEnabled()) { + logger.debug("caught exception in deleteDimension", dnfe); + } + Response response = Response.status(Response.Status.NOT_FOUND).entity( + "Delete failed on Dimension 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); + } + + } +} diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionConstants.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionConstants.java new file mode 100644 index 000000000..618ecb723 --- /dev/null +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionConstants.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.dimension.nuxeo; + +/** + * IntakeConstants processes CollectionObject document + * + */ +public class DimensionConstants { + + public final static String NUXEO_DOCTYPE = "Dimension"; + public final static String NUXEO_SCHEMA_NAME = "dimension"; + public final static String NUXEO_DC_TITLE = "CollectionSpace-Dimension"; +} diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java new file mode 100644 index 000000000..df4330dfd --- /dev/null +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionDocumentModelHandler.java @@ -0,0 +1,146 @@ +/** + * 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.dimension.nuxeo; + +import java.util.Iterator; +import java.util.List; + +import org.collectionspace.services.dimension.DimensionJAXBSchema; +import org.collectionspace.services.common.document.DocumentHandler.Action; +import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.dimension.DimensionsCommon; +import org.collectionspace.services.dimension.DimensionsCommonList; +import org.collectionspace.services.dimension.DimensionsCommonList.DimensionListItem; + +import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandler; +import org.collectionspace.services.nuxeo.util.NuxeoUtils; +import org.nuxeo.ecm.core.api.DocumentModel; +import org.nuxeo.ecm.core.api.DocumentModelList; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * DimensionDocumentModelHandler + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class DimensionDocumentModelHandler + extends RemoteDocumentModelHandler { + + private final Logger logger = LoggerFactory.getLogger(DimensionDocumentModelHandler.class); + /** + * dimension is used to stash JAXB object to use when handle is called + * for Action.CREATE, Action.UPDATE or Action.GET + */ + private DimensionsCommon dimension; + /** + * intakeList is stashed when handle is called + * for ACTION.GET_ALL + */ + private DimensionsCommonList intakeList; + + @Override + public void prepare(Action action) throws Exception { + //no specific action needed + } + + /** + * getCommonPart get associated dimension + * @return + */ + @Override + public DimensionsCommon getCommonPart() { + return dimension; + } + + /** + * setCommonPart set associated dimension + * @param dimension + */ + @Override + public void setCommonPart(DimensionsCommon dimension) { + this.dimension = dimension; + } + + /** + * getCommonPartList get associated dimension (for index/GET_ALL) + * @return + */ + @Override + public DimensionsCommonList getCommonPartList() { + return intakeList; + } + + @Override + public void setCommonPartList(DimensionsCommonList intakeList) { + this.intakeList = intakeList; + } + + @Override + public DimensionsCommon extractCommonPart(DocumentWrapper wrapDoc) + throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public void fillCommonPart(DimensionsCommon intakeObject, DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + @Override + public DimensionsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + DocumentModelList docList = wrapDoc.getWrappedObject(); + + DimensionsCommonList coList = new DimensionsCommonList(); + List list = coList.getDimensionListItem(); + + //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(); + DimensionListItem ilistItem = new DimensionListItem(); + ilistItem.setDimension((String) docModel.getProperty(getServiceContext().getCommonPartLabel(), + DimensionJAXBSchema.DIMENSION)); + String id = NuxeoUtils.extractId(docModel.getPathAsString()); + ilistItem.setUri(getServiceContextPath() + id); + ilistItem.setCsid(id); + list.add(ilistItem); + } + + return coList; + } + + /** + * getQProperty converts the given property to qualified schema property + * @param prop + * @return + */ + @Override + public String getQProperty(String prop) { + return DimensionConstants.NUXEO_SCHEMA_NAME + ":" + prop; + } +} + diff --git a/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionHandlerFactory.java b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionHandlerFactory.java new file mode 100644 index 000000000..0742a2b07 --- /dev/null +++ b/services/dimension/service/src/main/java/org/collectionspace/services/dimension/nuxeo/DimensionHandlerFactory.java @@ -0,0 +1,55 @@ +/** + * 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.dimension.nuxeo; + +import org.collectionspace.services.common.ClientType; +import org.collectionspace.services.common.document.DocumentHandler; +import org.collectionspace.services.common.document.DocumentHandlerFactory; + +/** + * IntakeHandlerFactory creates handlers for collectionobject based + * on type of Nuxeo client used + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ +public class DimensionHandlerFactory implements DocumentHandlerFactory { + + private static final DimensionHandlerFactory self = new DimensionHandlerFactory(); + + private DimensionHandlerFactory() { + } + + public static DimensionHandlerFactory getInstance() { + return self; + } + + @Override + public DocumentHandler getHandler(String clientType) { + if(ClientType.JAVA.toString().equals(clientType)){ + return new DimensionDocumentModelHandler(); + } + throw new IllegalArgumentException("Not supported client=" + clientType); + } +} diff --git a/services/dimension/service/src/test/java/org/collectionspace/services/test/DimensionServiceTest.java b/services/dimension/service/src/test/java/org/collectionspace/services/test/DimensionServiceTest.java new file mode 100644 index 000000000..5309b1c53 --- /dev/null +++ b/services/dimension/service/src/test/java/org/collectionspace/services/test/DimensionServiceTest.java @@ -0,0 +1,13 @@ +package org.collectionspace.services.test; + +//import org.collectionspace.services.intake.Intake; +//import org.collectionspace.services.intake.IntakeList; + +/** + * A IntakeServiceTest. + * + * @version $Revision:$ + */ +public class DimensionServiceTest { + //empty +} diff --git a/services/dimension/service/src/test/resources/log4j.xml b/services/dimension/service/src/test/resources/log4j.xml new file mode 100644 index 000000000..52121cb83 --- /dev/null +++ b/services/dimension/service/src/test/resources/log4j.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/pom.xml b/services/pom.xml index 06431c474..3f96ea312 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -24,6 +24,7 @@ id collectionobject intake + dimension JaxRsServiceProvider client sdk -- 2.47.3