From e2ab5735b0aa4b1d13db109812ee306f53a9868e Mon Sep 17 00:00:00 2001 From: Patrick Schmitz Date: Tue, 25 May 2010 01:05:22 +0000 Subject: [PATCH] CSPACE-1895 Working on the repeating sections of Location, and general support for this. --- .../resources/OSGI-INF/core-types-contrib.xml | 9 + .../resources/OSGI-INF/ecm-types-contrib.xml | 24 + .../resources/OSGI-INF/layouts-contrib.xml | 56 +++ .../src/main/resources/schemas/subitem.xsd | 22 + services/JaxRsServiceProvider/pom.xml | 5 + .../CollectionSpaceJaxRsApplication.java | 2 + .../import-data/import-permissions-roles.xml | 73 ++- .../import-data/import-permissions.xml | 100 +++- services/build.xml | 2 + .../main/config/services/tenant-bindings.xml | 33 ++ services/jaxb/src/main/resources/subitem.xsd | 34 ++ services/note/.classpath | 6 + services/note/.project | 23 + .../note/.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/note/3rdparty/.classpath | 6 + services/note/3rdparty/.project | 23 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/note/3rdparty/build.xml | 125 +++++ .../nuxeo-platform-cs-note/.classpath | 8 + .../3rdparty/nuxeo-platform-cs-note/.project | 17 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + .../3rdparty/nuxeo-platform-cs-note/build.xml | 144 ++++++ .../3rdparty/nuxeo-platform-cs-note/pom.xml | 37 ++ .../src/main/resources/META-INF/MANIFEST.MF | 22 + .../resources/OSGI-INF/core-types-contrib.xml | 15 + .../OSGI-INF/deployment-fragment.xml | 408 +++++++++++++++ .../resources/OSGI-INF/ecm-types-contrib.xml | 30 ++ .../resources/OSGI-INF/layouts-contrib.xml | 61 +++ .../main/resources/schemas/notes_common.xsd | 26 + services/note/3rdparty/pom.xml | 23 + services/note/build.xml | 122 +++++ services/note/client/.classpath | 10 + services/note/client/.project | 21 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/note/client/pom.xml | 73 +++ .../services/client/NoteClient.java | 140 ++++++ .../services/client/NoteClientUtils.java | 54 ++ .../services/client/NoteProxy.java | 48 ++ .../services/client/test/NoteServiceTest.java | 464 ++++++++++++++++++ .../src/test/resources/log4j.properties | 23 + services/note/jaxb/.classpath | 10 + services/note/jaxb/.project | 17 + .../jaxb/.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/note/jaxb/pom.xml | 47 ++ .../services/note/NoteJAXBSchema.java | 20 + .../services/note/NoteListItemJAXBSchema.java | 7 + .../jaxb/src/main/resources/notes-common.xsd | 88 ++++ services/note/pom.xml | 24 + services/note/service/.classpath | 10 + services/note/service/.project | 21 + .../.settings/org.eclipse.jdt.core.prefs | 5 + .../.settings/org.maven.ide.eclipse.prefs | 9 + services/note/service/pom.xml | 90 ++++ services/note/service/profiles.xml | 4 + .../services/note/NoteResource.java | 299 +++++++++++ .../services/note/nuxeo/NoteConstants.java | 35 ++ .../note/nuxeo/NoteDocumentModelHandler.java | 159 ++++++ .../services/test/NoteServiceTest.java | 11 + .../note/service/src/test/resources/log4j.xml | 45 ++ services/pom.xml | 3 +- 65 files changed, 3222 insertions(+), 41 deletions(-) create mode 100644 3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/subitem.xsd create mode 100644 services/jaxb/src/main/resources/subitem.xsd create mode 100644 services/note/.classpath create mode 100644 services/note/.project create mode 100644 services/note/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/note/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/note/3rdparty/.classpath create mode 100644 services/note/3rdparty/.project create mode 100644 services/note/3rdparty/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/note/3rdparty/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/note/3rdparty/build.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/.classpath create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/.project create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/build.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/pom.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/META-INF/MANIFEST.MF create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/core-types-contrib.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/deployment-fragment.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/ecm-types-contrib.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/layouts-contrib.xml create mode 100644 services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/schemas/notes_common.xsd create mode 100644 services/note/3rdparty/pom.xml create mode 100644 services/note/build.xml create mode 100644 services/note/client/.classpath create mode 100644 services/note/client/.project create mode 100644 services/note/client/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/note/client/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/note/client/pom.xml create mode 100644 services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java create mode 100644 services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java create mode 100644 services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java create mode 100644 services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java create mode 100644 services/note/client/src/test/resources/log4j.properties create mode 100644 services/note/jaxb/.classpath create mode 100644 services/note/jaxb/.project create mode 100644 services/note/jaxb/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/note/jaxb/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/note/jaxb/pom.xml create mode 100644 services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteJAXBSchema.java create mode 100644 services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteListItemJAXBSchema.java create mode 100644 services/note/jaxb/src/main/resources/notes-common.xsd create mode 100644 services/note/pom.xml create mode 100644 services/note/service/.classpath create mode 100644 services/note/service/.project create mode 100644 services/note/service/.settings/org.eclipse.jdt.core.prefs create mode 100644 services/note/service/.settings/org.maven.ide.eclipse.prefs create mode 100644 services/note/service/pom.xml create mode 100644 services/note/service/profiles.xml create mode 100644 services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java create mode 100644 services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteConstants.java create mode 100644 services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteDocumentModelHandler.java create mode 100644 services/note/service/src/test/java/org/collectionspace/services/test/NoteServiceTest.java create mode 100644 services/note/service/src/test/resources/log4j.xml diff --git a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/core-types-contrib.xml b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/core-types-contrib.xml index c19ad0ad2..df22ac00c 100644 --- a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/core-types-contrib.xml +++ b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/core-types-contrib.xml @@ -2,6 +2,7 @@ + @@ -10,4 +11,12 @@ + + + + + + + + diff --git a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/ecm-types-contrib.xml index 687a5a239..eb081760d 100644 --- a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/ecm-types-contrib.xml +++ b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/ecm-types-contrib.xml @@ -24,4 +24,28 @@ + + + + + view_documents + + + heading + subitem + + + + + + Subitem + + + + + + Subitem + + + diff --git a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/layouts-contrib.xml b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/layouts-contrib.xml index 279de1553..bd77c10cb 100644 --- a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/layouts-contrib.xml +++ b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -28,4 +28,60 @@ + + + + + + + + + owner + isPrimary + order + + + + + + + true + + owner + + + dataInputText + + + + + + + + true + + isPrimary + + + dataInputText + + + + + + + + true + + order + + + dataInputText + + + + + + diff --git a/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/subitem.xsd b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/subitem.xsd new file mode 100644 index 000000000..75b6087cf --- /dev/null +++ b/3rdparty/nuxeo/nuxeo-platform-collectionspace/src/main/resources/schemas/subitem.xsd @@ -0,0 +1,22 @@ + + + + + + + + + + + + diff --git a/services/JaxRsServiceProvider/pom.xml b/services/JaxRsServiceProvider/pom.xml index 5f21896c0..b0c8175b0 100644 --- a/services/JaxRsServiceProvider/pom.xml +++ b/services/JaxRsServiceProvider/pom.xml @@ -75,6 +75,11 @@ org.collectionspace.services.collectionobject.service ${project.version} + + org.collectionspace.services + org.collectionspace.services.note.service + ${project.version} + org.collectionspace.services org.collectionspace.services.id.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 b2bf8358d..63d40c056 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 @@ -25,6 +25,7 @@ package org.collectionspace.services.jaxrs; import org.collectionspace.services.account.AccountResource; import org.collectionspace.services.collectionobject.CollectionObjectResource; import org.collectionspace.services.id.IDResource; +import org.collectionspace.services.note.NoteResource; import org.collectionspace.services.intake.IntakeResource; import org.collectionspace.services.loanin.LoaninResource; import org.collectionspace.services.loanout.LoanoutResource; @@ -68,6 +69,7 @@ public class CollectionSpaceJaxRsApplication extends Application { singletons.add(new PermissionResource()); singletons.add(new CollectionObjectResource()); singletons.add(new IDResource()); + singletons.add(new NoteResource()); singletons.add(new IntakeResource()); singletons.add(new LoaninResource()); singletons.add(new LoanoutResource()); diff --git a/services/authorization-mgt/import/src/main/resources/import-data/import-permissions-roles.xml b/services/authorization-mgt/import/src/main/resources/import-data/import-permissions-roles.xml index f90ba976b..5b1f5fe91 100644 --- a/services/authorization-mgt/import/src/main/resources/import-data/import-permissions-roles.xml +++ b/services/authorization-mgt/import/src/main/resources/import-data/import-permissions-roles.xml @@ -3,7 +3,7 @@ ROLE - a4017e3d-1eef-42b1-bdb7-8443d681707c + c254348f-e5d0-4db9-8634-ed0b47887826 collectionobjects @@ -14,7 +14,7 @@ ROLE - 66d54998-a1a1-4c64-9728-2b6d8b9b61df + 964b5187-fda0-4e2d-8873-0c235acf1796 intakes @@ -25,7 +25,7 @@ ROLE - 07e47d8a-1aa6-440b-b30b-a2d42d8023a1 + e1eff972-65f0-4213-9d91-e5eaad58fd5d loansin @@ -36,7 +36,7 @@ ROLE - 476a773b-83ad-4383-8761-c92930bf527c + ded1f92e-6b57-43ee-bc94-19e32bae9822 loansout @@ -47,7 +47,7 @@ ROLE - b0144782-e289-4847-bb67-e9b5c0412887 + 428a7c8c-a3cf-4616-a439-65ce41566fba movements @@ -58,7 +58,7 @@ ROLE - 8cc25692-4d52-40e2-afbc-b95a79db3b0a + e2189ea7-1710-443a-a2a9-0c3d8ee256b1 vocabularies @@ -69,7 +69,7 @@ ROLE - d2f87bd9-9ea6-4b39-aebe-6a0fc6d96594 + 9d132fbd-0f5a-42cb-bae3-117b2f71dff8 vocabularyitems @@ -80,7 +80,7 @@ ROLE - 80e32ee8-4740-4b48-a3ba-aec706172146 + 293a5a44-4e91-4bee-b85e-ceacd6e213bb orgauthorities @@ -91,7 +91,7 @@ ROLE - 49167e68-8001-45b4-abef-c042032e488e + c1a81f3f-e95d-4e04-bbdd-54b9f5c8ff86 organizations @@ -102,7 +102,7 @@ ROLE - 3c69a90d-35b9-4bc0-9360-46977368f86f + 986a2192-13cf-4985-a1ce-bf38337a1d2c personauthorities @@ -113,7 +113,7 @@ ROLE - 3cd1d1b5-1d7b-4795-9e74-26511325720f + a82b6feb-6dce-4029-9046-f2830f8b64fc persons @@ -124,7 +124,29 @@ ROLE - 0ec19a72-a210-44b9-a10e-817fea57276f + 314b45b4-b3d0-4b0c-bd9b-c9d4f41bf963 + locationauthorities + + + 1 + ROLE_ADMINISTRATOR + + + + ROLE + + fd66abf5-6022-4e21-8f83-750ba5dc79be + locations + + + 1 + ROLE_ADMINISTRATOR + + + + ROLE + + 10b20df4-d9bc-4b51-88bb-9051342c05c9 acquisitions @@ -135,7 +157,7 @@ ROLE - 808c7f90-16a1-42a6-a24b-06327728b2e4 + 0f606175-cf1f-4c8b-9216-8fac556db213 relations @@ -146,7 +168,7 @@ ROLE - 5840f553-3fa1-4254-8442-7f4e76dfbd08 + 2537caa4-4859-43f4-a92b-630b38336f62 accounts @@ -157,7 +179,7 @@ ROLE - fc89633a-56c6-4d20-9022-dbf7919afe0c + a1c13748-f404-4a72-a7b2-e0599316828c dimensions @@ -168,7 +190,7 @@ ROLE - f0806b7f-5dca-4aed-bae9-b25fba378f95 + ab6d047b-a685-4f7d-b708-846a155f1fea contacts @@ -179,7 +201,18 @@ ROLE - 173a185c-b2d6-4fae-8c33-89b2e34dbeea + d5f1cb1e-1aa7-48a2-a32b-4b9cca3b3169 + notes + + + 1 + ROLE_ADMINISTRATOR + + + + ROLE + + eea3a150-0eb7-4061-937d-d35fbe11f55a authorization/roles @@ -190,7 +223,7 @@ ROLE - d82cdea5-6643-4aac-a94b-5b5808a6d0e8 + d694674b-fe0c-4769-8615-9e7f482bbbdc authorization/permissions @@ -201,7 +234,7 @@ ROLE - 9955709b-267a-4da1-a569-76a2520af6e7 + d712beb5-bd4c-435f-a631-ab5eccae0462 authorization/permroles @@ -212,7 +245,7 @@ ROLE - 8c816fa9-d1df-4c8c-95a0-7972d214ae09 + 85a25c1b-0cb7-4df1-a447-eee665e693f9 accounts/accountroles diff --git a/services/authorization-mgt/import/src/main/resources/import-data/import-permissions.xml b/services/authorization-mgt/import/src/main/resources/import-data/import-permissions.xml index 22fb69b4c..f4b8757f0 100644 --- a/services/authorization-mgt/import/src/main/resources/import-data/import-permissions.xml +++ b/services/authorization-mgt/import/src/main/resources/import-data/import-permissions.xml @@ -1,6 +1,6 @@ - + collectionobjects CREATE @@ -20,7 +20,7 @@ PERMIT 1 - + intakes CREATE @@ -40,7 +40,7 @@ PERMIT 1 - + loansin CREATE @@ -60,7 +60,7 @@ PERMIT 1 - + loansout CREATE @@ -80,7 +80,7 @@ PERMIT 1 - + movements CREATE @@ -100,7 +100,7 @@ PERMIT 1 - + vocabularies CREATE @@ -120,7 +120,7 @@ PERMIT 1 - + vocabularyitems CREATE @@ -140,7 +140,7 @@ PERMIT 1 - + orgauthorities CREATE @@ -160,7 +160,7 @@ PERMIT 1 - + organizations CREATE @@ -180,7 +180,7 @@ PERMIT 1 - + personauthorities CREATE @@ -200,7 +200,7 @@ PERMIT 1 - + persons CREATE @@ -220,7 +220,47 @@ PERMIT 1 - + + locationauthorities + + CREATE + + + READ + + + UPDATE + + + DELETE + + + SEARCH + + PERMIT + 1 + + + locations + + CREATE + + + READ + + + UPDATE + + + DELETE + + + SEARCH + + PERMIT + 1 + + acquisitions CREATE @@ -240,7 +280,7 @@ PERMIT 1 - + relations CREATE @@ -260,7 +300,7 @@ PERMIT 1 - + accounts CREATE @@ -280,7 +320,7 @@ PERMIT 1 - + dimensions CREATE @@ -300,7 +340,7 @@ PERMIT 1 - + contacts CREATE @@ -320,7 +360,27 @@ PERMIT 1 - + + notes + + CREATE + + + READ + + + UPDATE + + + DELETE + + + SEARCH + + PERMIT + 1 + + authorization/roles CREATE @@ -340,7 +400,7 @@ PERMIT 1 - + authorization/permissions CREATE @@ -360,7 +420,7 @@ PERMIT 1 - + authorization/permroles CREATE @@ -380,7 +440,7 @@ PERMIT 1 - + accounts/accountroles CREATE diff --git a/services/build.xml b/services/build.xml index 01869f002..649eb068d 100644 --- a/services/build.xml +++ b/services/build.xml @@ -149,6 +149,7 @@ + @@ -180,6 +181,7 @@ + diff --git a/services/common/src/main/config/services/tenant-bindings.xml b/services/common/src/main/config/services/tenant-bindings.xml index aa1b25de4..ce489d328 100644 --- a/services/common/src/main/config/services/tenant-bindings.xml +++ b/services/common/src/main/config/services/tenant-bindings.xml @@ -724,6 +724,39 @@ + + + + nuxeo-java + + + org.collectionspace.services.note.nuxeo.NoteDocumentModelHandler + + + + + + + + + + + + + + + + + diff --git a/services/jaxb/src/main/resources/subitem.xsd b/services/jaxb/src/main/resources/subitem.xsd new file mode 100644 index 000000000..e4d86a312 --- /dev/null +++ b/services/jaxb/src/main/resources/subitem.xsd @@ -0,0 +1,34 @@ + + + + + + + + + + + + + + + diff --git a/services/note/.classpath b/services/note/.classpath new file mode 100644 index 000000000..046988541 --- /dev/null +++ b/services/note/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/services/note/.project b/services/note/.project new file mode 100644 index 000000000..0b6b693f2 --- /dev/null +++ b/services/note/.project @@ -0,0 +1,23 @@ + + + org.collectionspace.services.note + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/services/note/.settings/org.eclipse.jdt.core.prefs b/services/note/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..9d7c02829 --- /dev/null +++ b/services/note/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon Dec 28 10:23:41 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/note/.settings/org.maven.ide.eclipse.prefs b/services/note/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..8bf82a11f --- /dev/null +++ b/services/note/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Dec 28 10:22:09 PST 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/note/3rdparty/.classpath b/services/note/3rdparty/.classpath new file mode 100644 index 000000000..046988541 --- /dev/null +++ b/services/note/3rdparty/.classpath @@ -0,0 +1,6 @@ + + + + + + diff --git a/services/note/3rdparty/.project b/services/note/3rdparty/.project new file mode 100644 index 000000000..469b6a016 --- /dev/null +++ b/services/note/3rdparty/.project @@ -0,0 +1,23 @@ + + + org.collectionspace.services.note.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/note/3rdparty/.settings/org.eclipse.jdt.core.prefs b/services/note/3rdparty/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..793c378bb --- /dev/null +++ b/services/note/3rdparty/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon Dec 28 10:23:45 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/note/3rdparty/.settings/org.maven.ide.eclipse.prefs b/services/note/3rdparty/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..8bf82a11f --- /dev/null +++ b/services/note/3rdparty/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Dec 28 10:22:09 PST 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/note/3rdparty/build.xml b/services/note/3rdparty/build.xml new file mode 100644 index 000000000..82e81732c --- /dev/null +++ b/services/note/3rdparty/build.xml @@ -0,0 +1,125 @@ + + + + note service 3rdparty + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/.classpath b/services/note/3rdparty/nuxeo-platform-cs-note/.classpath new file mode 100644 index 000000000..199bbbbdb --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/.project b/services/note/3rdparty/nuxeo-platform-cs-note/.project new file mode 100644 index 000000000..65504f9a5 --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/.project @@ -0,0 +1,17 @@ + + org.collectionspace.services.note.3rdparty.nuxeo + Note Nuxeo Document Type + + + + org.eclipse.jdt.core.javabuilder + + + org.maven.ide.eclipse.maven2Builder + + + + org.eclipse.jdt.core.javanature + org.maven.ide.eclipse.maven2Nature + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.eclipse.jdt.core.prefs b/services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..92296e2b1 --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon May 24 11:37:38 PDT 2010 +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/note/3rdparty/nuxeo-platform-cs-note/.settings/org.maven.ide.eclipse.prefs b/services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..8bf82a11f --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Dec 28 10:22:09 PST 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/note/3rdparty/nuxeo-platform-cs-note/build.xml b/services/note/3rdparty/nuxeo-platform-cs-note/build.xml new file mode 100644 index 000000000..9d9262e0b --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/build.xml @@ -0,0 +1,144 @@ + + + + note nuxeo document type + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/pom.xml b/services/note/3rdparty/nuxeo-platform-cs-note/pom.xml new file mode 100644 index 000000000..faef217fc --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/pom.xml @@ -0,0 +1,37 @@ + + + org.collectionspace.services + org.collectionspace.services.note.3rdparty + 0.7-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.note.3rdparty.nuxeo + services.note.3rdparty.nuxeo + jar + + note Nuxeo Document Type + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + src/main/resources/META-INF/MANIFEST.MF + + ${eclipseVersion} + 2 + + + + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/META-INF/MANIFEST.MF b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/META-INF/MANIFEST.MF new file mode 100644 index 000000000..bfac8ce58 --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/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.note;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.note +Nuxeo-Component: OSGI-INF/core-types-contrib.xml, + OSGI-INF/ecm-types-contrib.xml, + OSGI-INF/layouts-contrib.xml + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/core-types-contrib.xml b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/core-types-contrib.xml new file mode 100644 index 000000000..e82f5f6c4 --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/core-types-contrib.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/deployment-fragment.xml b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/deployment-fragment.xml new file mode 100644 index 000000000..ee899e66a --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/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/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/ecm-types-contrib.xml b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/ecm-types-contrib.xml new file mode 100644 index 000000000..c175ecc30 --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/ecm-types-contrib.xml @@ -0,0 +1,30 @@ + + + + + + + view_documents + + + heading + collectionspace_core + subitem + cs_note + + + + + + Note + + + + + + Note + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/layouts-contrib.xml b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/layouts-contrib.xml new file mode 100644 index 000000000..fba057674 --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/OSGI-INF/layouts-contrib.xml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + content + author + date + + + + + + + true + + content + + + dataInputText + + + + + + + + true + + author + + + dataInputText + + + + + + + + true + + date + + + dataInputText + + + + + + + diff --git a/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/schemas/notes_common.xsd b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/schemas/notes_common.xsd new file mode 100644 index 000000000..f12eed3eb --- /dev/null +++ b/services/note/3rdparty/nuxeo-platform-cs-note/src/main/resources/schemas/notes_common.xsd @@ -0,0 +1,26 @@ + + + + + + + + + + + + diff --git a/services/note/3rdparty/pom.xml b/services/note/3rdparty/pom.xml new file mode 100644 index 000000000..880dd1688 --- /dev/null +++ b/services/note/3rdparty/pom.xml @@ -0,0 +1,23 @@ + + + + org.collectionspace.services + org.collectionspace.services.note + 0.7-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.note.3rdparty + services.note.3rdparty + pom + + 3rd party build for note service + + + + nuxeo-platform-cs-note + + diff --git a/services/note/build.xml b/services/note/build.xml new file mode 100644 index 000000000..e7a9bd68c --- /dev/null +++ b/services/note/build.xml @@ -0,0 +1,122 @@ + + + + note service + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/note/client/.classpath b/services/note/client/.classpath new file mode 100644 index 000000000..425cd1620 --- /dev/null +++ b/services/note/client/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/services/note/client/.project b/services/note/client/.project new file mode 100644 index 000000000..7dc76b048 --- /dev/null +++ b/services/note/client/.project @@ -0,0 +1,21 @@ + + org.collectionspace.services.note.client + + + org.collectionspace.services.common + org.collectionspace.services.client + org.collectionspace.services.note.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/note/client/.settings/org.eclipse.jdt.core.prefs b/services/note/client/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..92296e2b1 --- /dev/null +++ b/services/note/client/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon May 24 11:37:38 PDT 2010 +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/note/client/.settings/org.maven.ide.eclipse.prefs b/services/note/client/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..8bf82a11f --- /dev/null +++ b/services/note/client/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Dec 28 10:22:09 PST 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/note/client/pom.xml b/services/note/client/pom.xml new file mode 100644 index 000000000..fd94433fe --- /dev/null +++ b/services/note/client/pom.xml @@ -0,0 +1,73 @@ + + + + org.collectionspace.services.note + org.collectionspace.services + 0.7-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.note.client + services.note.client + + + + + org.slf4j + slf4j-api + + + org.slf4j + slf4j-log4j12 + + + + org.collectionspace.services + org.collectionspace.services.note.jaxb + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.client + ${project.version} + + + + org.testng + testng + 5.6 + + + org.jboss.resteasy + resteasy-jaxrs + + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + commons-httpclient + commons-httpclient + 3.1 + + + + + collectionspace-services-note-client + + + diff --git a/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java new file mode 100644 index 000000000..1a75b176f --- /dev/null +++ b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClient.java @@ -0,0 +1,140 @@ +/** + * 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 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 + */ +package org.collectionspace.services.client; + +import javax.ws.rs.core.Response; + +import org.collectionspace.services.note.NotesCommonList; + +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; + +/** + * NoteClient.java + * + * $LastChangedRevision: $ + * $LastChangedDate: $ + */ + +public class NoteClient extends AbstractServiceClientImpl { + + /* (non-Javadoc) + * @see org.collectionspace.services.client.BaseServiceClient#getServicePathComponent() + */ + public String getServicePathComponent() { + return "notes"; + } + + /** + * + */ +// private static final NoteClient instance = new NoteClient(); + + /** + * + */ + private NoteProxy noteProxy; + + /** + * + * Default constructor for NoteClient class. + * + */ + public NoteClient() { + ResteasyProviderFactory factory = ResteasyProviderFactory.getInstance(); + RegisterBuiltin.register(factory); + setProxy(); + } + + @Override + public CollectionSpaceProxy getProxy() { + return this.noteProxy; + } + + /** + * allow to reset proxy as per security needs + */ + public void setProxy() { + if (useAuth()) { + noteProxy = ProxyFactory.create(NoteProxy.class, + getBaseURL(), getHttpClient()); + } else { + noteProxy = ProxyFactory.create(NoteProxy.class, + getBaseURL()); + } + } + + /** + * FIXME Comment this + * + * @return + */ +// public static NoteClient getInstance() { +// return instance; +// } + + /** + * @return + * @see org.collectionspace.services.client.Note#getNote() + */ + public ClientResponse readList() { + return noteProxy.readList(); + } + + /** + * @param csid + * @return + * @see org.collectionspace.services.client.Note#getNote(java.lang.String) + */ + + public ClientResponse read(String csid) { + return noteProxy.read(csid); + } + + /** + * @param note + * @return + * @see org.collectionspace.services.client.Note#createNote(org.collectionspace.services.Note) + */ + public ClientResponse create(MultipartOutput multipart) { + return noteProxy.create(multipart); + } + + /** + * @param csid + * @param note + * @return + * @see org.collectionspace.services.client.Note#updateNote(java.lang.Long, org.collectionspace.services.Note) + */ + public ClientResponse update(String csid, MultipartOutput multipart) { + return noteProxy.update(csid, multipart); + + } + + /** + * @param csid + * @return + * @see org.collectionspace.services.client.Note#deleteNote(java.lang.Long) + */ + public ClientResponse delete(String csid) { + return noteProxy.delete(csid); + } +} diff --git a/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java new file mode 100644 index 000000000..6422f8b29 --- /dev/null +++ b/services/note/client/src/main/java/org/collectionspace/services/client/NoteClientUtils.java @@ -0,0 +1,54 @@ +package org.collectionspace.services.client; + +import javax.ws.rs.core.MediaType; + +import org.collectionspace.services.client.NoteClient; +import org.collectionspace.services.note.NotesCommon; +import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput; +import org.jboss.resteasy.plugins.providers.multipart.OutputPart; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class NoteClientUtils { + + private static final Logger logger = + LoggerFactory.getLogger(NoteClientUtils.class); + + public static MultipartOutput createNoteInstance( + String owner, String identifier, String headerLabel) { + return createNoteInstance( + owner, + false, 0, + "content-" + identifier, + "author-" + identifier, + "date-" + identifier, + headerLabel); + } + + public static MultipartOutput createNoteInstance( + String owner, boolean isPrimary, int order, + String content, String author, String date, String headerLabel) { + NotesCommon note = new NotesCommon(); + note.setOwner(owner); + note.setIsPrimary(isPrimary); + note.setOrder(order); + note.setContent(content); + note.setAuthor(author); + note.setDate(date); + MultipartOutput multipart = new MultipartOutput(); + OutputPart commonPart = + multipart.addPart(note, MediaType.APPLICATION_XML_TYPE); + NoteClient client = new NoteClient(); + commonPart.getHeaders().add("label", headerLabel); + + if(logger.isDebugEnabled()){ + logger.debug("to be created, note common"); + // logger.debug(objectAsXmlString(note, NotesCommon.class)); + } + + return multipart; + } + + +} diff --git a/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java b/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.java new file mode 100644 index 000000000..6d05d6800 --- /dev/null +++ b/services/note/client/src/main/java/org/collectionspace/services/client/NoteProxy.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.note.NotesCommonList; +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("/notes/") +@Produces({"multipart/mixed"}) +@Consumes({"multipart/mixed"}) +public interface NoteProxy extends CollectionSpaceProxy { + + @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/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java b/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java new file mode 100644 index 000000000..c325bae75 --- /dev/null +++ b/services/note/client/src/test/java/org/collectionspace/services/client/test/NoteServiceTest.java @@ -0,0 +1,464 @@ +/** + * 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.ArrayList; +import java.util.List; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; + +import org.collectionspace.services.client.CollectionSpaceClient; +import org.collectionspace.services.client.NoteClient; +import org.collectionspace.services.client.NoteClientUtils; +import org.collectionspace.services.note.NotesCommon; +import org.collectionspace.services.note.NotesCommonList; +import org.collectionspace.services.jaxb.AbstractCommonList; + +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.AfterClass; +import org.testng.annotations.Test; + +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * NoteServiceTest, carries out tests against a + * deployed and running Note Service. + * + * $LastChangedRevision: 917 $ + * $LastChangedDate: 2009-11-06 12:20:28 -0800 (Fri, 06 Nov 2009) $ + */ +public class NoteServiceTest extends AbstractServiceTestImpl { + + private final Logger logger = + LoggerFactory.getLogger(NoteServiceTest.class); + + // Instance variables specific to this test. + final String SERVICE_PATH_COMPONENT = "notes"; + private String knownResourceId = null; + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getClientInstance() + */ + @Override + protected CollectionSpaceClient getClientInstance() { + return new NoteClient(); + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.BaseServiceTest#getAbstractCommonList(org.jboss.resteasy.client.ClientResponse) + */ + @Override + protected AbstractCommonList getAbstractCommonList( + ClientResponse response) { + return response.getEntity(NotesCommonList.class); + } + + // --------------------------------------------------------------- + // CRUD tests : CREATE tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.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. + NoteClient client = new NoteClient(); + String identifier = createIdentifier(); + MultipartOutput multipart = + NoteClientUtils.createNoteInstance("owner"+identifier, identifier, + client.getCommonPartName()); + 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 the first resource created + // for additional tests below. + if (knownResourceId == null){ + knownResourceId = extractId(res); + if (logger.isDebugEnabled()) { + logger.debug(testName + ": knownResourceId=" + knownResourceId); + } + } + + // Store the IDs from every resource created by tests, + // so they can be deleted after tests have been run. + allResourceIdsCreated.add(extractId(res)); + } + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.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 { + //Should this really be empty? + } + + @Override + public void createWithMalformedXml(String testName) throws Exception { + //Should this really be empty?? + } + + @Override + public void createWithWrongXmlSchema(String testName) throws Exception { + //Should this really be empty?? + } + + + // --------------------------------------------------------------- + // CRUD tests : READ tests + // --------------------------------------------------------------- + // Success outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, + dependsOnMethods = {"create"}) + public void read(String testName) throws Exception { + + // Perform setup. + setupRead(testName); + + // Submit the request to the service and store the response. + NoteClient client = new NoteClient(); + 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(); + NotesCommon note = (NotesCommon) extractPart(input, + client.getCommonPartName(), NotesCommon.class); + Assert.assertNotNull(note); + } + + // Failure outcomes + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.class, + dependsOnMethods = {"read"}) + public void readNonExistent(String testName) throws Exception { + + // Perform setup. + setupReadNonExistent(testName); + + // Submit the request to the service and store the response. + NoteClient client = new NoteClient(); + 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=AbstractServiceTestImpl.class, + dependsOnMethods = {"read"}) + public void readList(String testName) throws Exception { + + // Perform setup. + setupReadList(testName); + + // Submit the request to the service and store the response. + NoteClient client = new NoteClient(); + ClientResponse res = client.readList(); + NotesCommonList 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.getNoteListItem(); + int i = 0; + for(NotesCommonList.NoteListItem item : items){ + logger.debug(testName + ": list-item[" + i + "] csid=" + + item.getCsid()); + logger.debug(testName + ": list-item[" + i + "] content=" + + item.getContent()); + 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=AbstractServiceTestImpl.class, + dependsOnMethods = {"read"}) + public void update(String testName) throws Exception { + + // Perform setup. + setupUpdate(testName); + + // Submit the request to the service and store the response. + NoteClient client = new NoteClient(); + 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(); + NotesCommon note = (NotesCommon) extractPart(input, + client.getCommonPartName(), NotesCommon.class); + Assert.assertNotNull(note); + + // Update the content of this resource. + note.setContent("updated-" + note.getContent()); + note.setAuthor("updated-" + note.getAuthor()); + if(logger.isDebugEnabled()){ + logger.debug("to be updated object"); + logger.debug(objectAsXmlString(note, NotesCommon.class)); + } + // Submit the request to the service and store the response. + MultipartOutput output = new MultipartOutput(); + OutputPart commonPart = output.addPart(note, 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(); + NotesCommon updatedNote = + (NotesCommon) extractPart(input, + client.getCommonPartName(), NotesCommon.class); + Assert.assertNotNull(updatedNote); + + Assert.assertEquals(updatedNote.getContent(), + note.getContent(), + "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 { + //Should this really be empty?? + } + + /* (non-Javadoc) + * @see org.collectionspace.services.client.test.AbstractServiceTestImpl#updateWithMalformedXml(java.lang.String) + */ + @Override + public void updateWithMalformedXml(String testName) throws Exception { + //Should this really be empty?? + } + + @Override + public void updateWithWrongXmlSchema(String testName) throws Exception { + //Should this really be empty?? + } + + + @Override + @Test(dataProvider="testName", dataProviderClass=AbstractServiceTestImpl.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. + NoteClient client = new NoteClient(); + MultipartOutput multipart = + NoteClientUtils.createNoteInstance(NON_EXISTENT_ID, NON_EXISTENT_ID, client.getCommonPartName()); + 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=AbstractServiceTestImpl.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. + NoteClient client = new NoteClient(); + 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=AbstractServiceTestImpl.class, + dependsOnMethods = {"delete"}) + public void deleteNonExistent(String testName) throws Exception { + + // Perform setup. + setupDeleteNonExistent(testName); + + // Submit the request to the service and store the response. + NoteClient client = new NoteClient(); + 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; + } +} diff --git a/services/note/client/src/test/resources/log4j.properties b/services/note/client/src/test/resources/log4j.properties new file mode 100644 index 000000000..18c510350 --- /dev/null +++ b/services/note/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/note/jaxb/.classpath b/services/note/jaxb/.classpath new file mode 100644 index 000000000..425cd1620 --- /dev/null +++ b/services/note/jaxb/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/services/note/jaxb/.project b/services/note/jaxb/.project new file mode 100644 index 000000000..3148d1189 --- /dev/null +++ b/services/note/jaxb/.project @@ -0,0 +1,17 @@ + + org.collectionspace.services.note.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/note/jaxb/.settings/org.eclipse.jdt.core.prefs b/services/note/jaxb/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..adb6edbc4 --- /dev/null +++ b/services/note/jaxb/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon Dec 28 10:23:42 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/note/jaxb/.settings/org.maven.ide.eclipse.prefs b/services/note/jaxb/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..8bf82a11f --- /dev/null +++ b/services/note/jaxb/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Dec 28 10:22:09 PST 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/note/jaxb/pom.xml b/services/note/jaxb/pom.xml new file mode 100644 index 000000000..81bdf1e27 --- /dev/null +++ b/services/note/jaxb/pom.xml @@ -0,0 +1,47 @@ + + + + org.collectionspace.services + org.collectionspace.services.note + 0.7-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.note.jaxb + services.note.jaxb + + + + com.sun.xml.bind + jaxb-impl + + + org.jvnet.jaxb2-commons + property-listener-injector + + + org.jvnet.jaxb2_commons + runtime + + + org.collectionspace.services + org.collectionspace.services.jaxb + ${project.version} + + + + + collectionspace-services-note-jaxb + install + + + org.jvnet.jaxb2.maven2 + maven-jaxb2-plugin + + + + + diff --git a/services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteJAXBSchema.java b/services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteJAXBSchema.java new file mode 100644 index 000000000..5d0d6d7a4 --- /dev/null +++ b/services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteJAXBSchema.java @@ -0,0 +1,20 @@ +/** + * + */ +package org.collectionspace.services.note; + +/** + * + */ +public interface NoteJAXBSchema { + final static String NOTES_COMMON = "notes_common"; + final static String CSID = "csid"; + final static String OWNER = "owner"; + final static String IS_PRIMARY ="isPrimary"; + final static String ORDER = "order"; + final static String CONTENT = "content"; + final static String AUTHOR = "author"; + final static String DATE = "date"; +} + + diff --git a/services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteListItemJAXBSchema.java b/services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteListItemJAXBSchema.java new file mode 100644 index 000000000..58b82133d --- /dev/null +++ b/services/note/jaxb/src/main/java/org/collectionspace/services/note/NoteListItemJAXBSchema.java @@ -0,0 +1,7 @@ +package org.collectionspace.services.note; + +public interface NoteListItemJAXBSchema { + final static String CONTENT = "content"; + final static String CSID = "csid"; + final static String URI = "url"; +} diff --git a/services/note/jaxb/src/main/resources/notes-common.xsd b/services/note/jaxb/src/main/resources/notes-common.xsd new file mode 100644 index 000000000..9511c6b4e --- /dev/null +++ b/services/note/jaxb/src/main/resources/notes-common.xsd @@ -0,0 +1,88 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/note/pom.xml b/services/note/pom.xml new file mode 100644 index 000000000..a2c412b50 --- /dev/null +++ b/services/note/pom.xml @@ -0,0 +1,24 @@ + + + + + org.collectionspace.services.main + org.collectionspace.services + 0.7-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.note + services.note + pom + + + jaxb + service + 3rdparty + client + + + + diff --git a/services/note/service/.classpath b/services/note/service/.classpath new file mode 100644 index 000000000..3a317acf0 --- /dev/null +++ b/services/note/service/.classpath @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/services/note/service/.project b/services/note/service/.project new file mode 100644 index 000000000..e58ed0c27 --- /dev/null +++ b/services/note/service/.project @@ -0,0 +1,21 @@ + + org.collectionspace.services.note.service + + + org.collectionspace.services.note.jaxb + org.collectionspace.services.common + org.collectionspace.services.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/note/service/.settings/org.eclipse.jdt.core.prefs b/services/note/service/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..67e7e5364 --- /dev/null +++ b/services/note/service/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,5 @@ +#Mon Dec 28 10:23:43 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/note/service/.settings/org.maven.ide.eclipse.prefs b/services/note/service/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..8bf82a11f --- /dev/null +++ b/services/note/service/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,9 @@ +#Mon Dec 28 10:22:09 PST 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/note/service/pom.xml b/services/note/service/pom.xml new file mode 100644 index 000000000..2ad3de237 --- /dev/null +++ b/services/note/service/pom.xml @@ -0,0 +1,90 @@ + + + + org.collectionspace.services.note + org.collectionspace.services + 0.7-SNAPSHOT + + + 4.0.0 + org.collectionspace.services + org.collectionspace.services.note.service + services.note.service + jar + + + + org.collectionspace.services + org.collectionspace.services.common + ${project.version} + + + org.collectionspace.services + org.collectionspace.services.note.jaxb + ${project.version} + + + + org.testng + testng + 5.6 + + + + + + javax.security + jaas + 1.0.01 + provided + + + + dom4j + dom4j + 1.6.1 + provided + + + + + + org.jboss.resteasy + resteasy-jaxrs + + + tjws + webserver + + + + + org.jboss.resteasy + resteasy-jaxb-provider + + + org.jboss.resteasy + resteasy-multipart-provider + + + + + + org.nuxeo.ecm.core + nuxeo-core-api + ${nuxeo.version.1.5} + + + jboss-remoting + jboss + + + + + + + + collectionspace-services-note + + + diff --git a/services/note/service/profiles.xml b/services/note/service/profiles.xml new file mode 100644 index 000000000..12051b851 --- /dev/null +++ b/services/note/service/profiles.xml @@ -0,0 +1,4 @@ + + + \ No newline at end of file diff --git a/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java b/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java new file mode 100644 index 000000000..08752b218 --- /dev/null +++ b/services/note/service/src/main/java/org/collectionspace/services/note/NoteResource.java @@ -0,0 +1,299 @@ +/** + * 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.note; + +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.MultivaluedMap; +import javax.ws.rs.core.Response; +import javax.ws.rs.core.UriBuilder; +import javax.ws.rs.core.UriInfo; + +import org.collectionspace.services.common.AbstractMultiPartCollectionSpaceResourceImpl; +import org.collectionspace.services.common.ClientType; +import org.collectionspace.services.common.ServiceMain; +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; + +/** + * The Class NoteResource. + */ +@Path("/notes") +@Consumes("multipart/mixed") +@Produces("multipart/mixed") +public class NoteResource extends + AbstractMultiPartCollectionSpaceResourceImpl { + + /** The Constant serviceName. */ + private final static String serviceName = "notes"; + + /** The logger. */ + final Logger logger = LoggerFactory.getLogger(NoteResource.class); + //FIXME retrieve client type from configuration + /** The Constant CLIENT_TYPE. */ + final static ClientType CLIENT_TYPE = ServiceMain.getInstance().getClientType(); + + /** + * Instantiates a new note resource. + */ + public NoteResource() { + // do nothing + } + + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getVersionString() + */ + @Override + protected String getVersionString() { + /** The last change revision. */ + final String lastChangeRevision = "$LastChangedRevision: 1982 $"; + return lastChangeRevision; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.common.AbstractCollectionSpaceResourceImpl#getServiceName() + */ + @Override + public String getServiceName() { + return serviceName; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.common.CollectionSpaceResource#getCommonPartClass() + */ + @Override + public Class getCommonPartClass() { + return NotesCommon.class; + } + + + /** + * Creates the note. + * + * @param input the input + * + * @return the response + */ + @POST + public Response createNote(MultipartInput input) { + try { + ServiceContext ctx = createServiceContext(input); + DocumentHandler handler = createDocumentHandler(ctx); + String csid = getRepositoryClient(ctx).create(ctx, handler); + UriBuilder path = UriBuilder.fromResource(NoteResource.class); + path.path("" + csid); + Response response = Response.created(path.build()).build(); + return response; + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception in createNote", e); + } + Response response = Response.status( + Response.Status.INTERNAL_SERVER_ERROR).entity("Create failed").type("text/plain").build(); + throw new WebApplicationException(response); + } + } + + /** + * Gets the note. + * + * @param csid the csid + * + * @return the note + */ + @GET + @Path("{csid}") + public MultipartOutput getNote( + @PathParam("csid") String csid) { + if (logger.isDebugEnabled()) { + logger.debug("getNote with csid=" + csid); + } + if (csid == null || "".equals(csid)) { + logger.error("getNote: missing csid!"); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + "Get failed on Note csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } + MultipartOutput result = null; + try { + ServiceContext ctx = createServiceContext(); + DocumentHandler handler = createDocumentHandler(ctx); + getRepositoryClient(ctx).get(ctx, csid, handler); + result = (MultipartOutput) ctx.getOutput(); + } catch (DocumentNotFoundException dnfe) { + if (logger.isDebugEnabled()) { + logger.debug("getNote", dnfe); + } + Response response = Response.status(Response.Status.NOT_FOUND).entity( + "Get failed on Note csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("getNote", 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 Note CSID:" + csid + ": was not found.").type( + "text/plain").build(); + throw new WebApplicationException(response); + } + return result; + } + + /** + * Gets the note list. + * + * @param ui the ui + * + * @return the note list + */ + @GET + @Produces("application/xml") + public NotesCommonList getNoteList(@Context UriInfo ui) { + MultivaluedMap queryParams = ui.getQueryParameters(); + NotesCommonList noteObjectList = new NotesCommonList(); + try { + ServiceContext ctx = createServiceContext(queryParams); + DocumentHandler handler = createDocumentHandler(ctx); + getRepositoryClient(ctx).getFiltered(ctx, handler); + noteObjectList = (NotesCommonList) handler.getCommonPartList(); + } catch (Exception e) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception in getNoteList", e); + } + Response response = Response.status( + Response.Status.INTERNAL_SERVER_ERROR).entity("Index failed").type("text/plain").build(); + throw new WebApplicationException(response); + } + return noteObjectList; + } + + /** + * Update note. + * + * @param csid the csid + * @param theUpdate the the update + * + * @return the multipart output + */ + @PUT + @Path("{csid}") + public MultipartOutput updateNote( + @PathParam("csid") String csid, + MultipartInput theUpdate) { + if (logger.isDebugEnabled()) { + logger.debug("updateNote with csid=" + csid); + } + if (csid == null || "".equals(csid)) { + logger.error("updateNote: missing csid!"); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + "update failed on Note csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } + MultipartOutput result = null; + try { + ServiceContext ctx = createServiceContext(theUpdate); + DocumentHandler handler = createDocumentHandler(ctx); + getRepositoryClient(ctx).update(ctx, csid, handler); + result = (MultipartOutput) ctx.getOutput(); + } catch (DocumentNotFoundException dnfe) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception in updateNote", dnfe); + } + Response response = Response.status(Response.Status.NOT_FOUND).entity( + "Update failed on Note 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 note. + * + * @param csid the csid + * + * @return the response + */ + @DELETE + @Path("{csid}") + public Response deleteNote(@PathParam("csid") String csid) { + + if (logger.isDebugEnabled()) { + logger.debug("deleteNote with csid=" + csid); + } + if (csid == null || "".equals(csid)) { + logger.error("deleteNote: missing csid!"); + Response response = Response.status(Response.Status.BAD_REQUEST).entity( + "Delete failed on Note csid=" + csid).type( + "text/plain").build(); + throw new WebApplicationException(response); + } + try { + ServiceContext ctx = createServiceContext(); + getRepositoryClient(ctx).delete(ctx, csid); + return Response.status(HttpResponseCodes.SC_OK).build(); + } catch (DocumentNotFoundException dnfe) { + if (logger.isDebugEnabled()) { + logger.debug("Caught exception in deleteNote", dnfe); + } + Response response = Response.status(Response.Status.NOT_FOUND).entity( + "Delete failed on Note 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/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteConstants.java b/services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteConstants.java new file mode 100644 index 000000000..d1bf29ed2 --- /dev/null +++ b/services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteConstants.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.note.nuxeo; + +/** + * NoteConstants, stores constants related to Note documents + * + */ +public class NoteConstants { + + public final static String NUXEO_DOCTYPE = "Note"; + public final static String NUXEO_SCHEMA_NAME = "note"; + public final static String NUXEO_DC_TITLE = "CollectionSpace-Note"; +} diff --git a/services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteDocumentModelHandler.java b/services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteDocumentModelHandler.java new file mode 100644 index 000000000..8a6a12d4b --- /dev/null +++ b/services/note/service/src/main/java/org/collectionspace/services/note/nuxeo/NoteDocumentModelHandler.java @@ -0,0 +1,159 @@ +/** + * 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.note.nuxeo; + +import java.util.Iterator; +import java.util.List; + +import org.collectionspace.services.note.NoteJAXBSchema; +import org.collectionspace.services.common.document.DocumentHandler.Action; +import org.collectionspace.services.common.document.DocumentWrapper; +import org.collectionspace.services.note.NotesCommon; +import org.collectionspace.services.note.NotesCommonList; +import org.collectionspace.services.note.NotesCommonList.NoteListItem; + +import org.collectionspace.services.nuxeo.client.java.RemoteDocumentModelHandlerImpl; +import org.collectionspace.services.nuxeo.client.java.RemoteSubItemDocumentModelHandlerImpl; +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; + +/** + * The Class NoteDocumentModelHandler. + */ +public class NoteDocumentModelHandler + extends RemoteSubItemDocumentModelHandlerImpl { + + /** The logger. */ + private final Logger logger = LoggerFactory.getLogger(NoteDocumentModelHandler.class); + + /** The note. */ + private NotesCommon note; + + /** The note list. */ + private NotesCommonList noteList; + + /** The owner. */ + private String owner; + + /** + * Gets the owner. + * + * @return the owner + */ + public String getOwner() { + return owner; + } + + /** + * Sets the owner. + * + * @param owner the new owner + */ + public void setInAuthority(String owner) { + this.owner = owner; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPart() + */ + @Override + public NotesCommon getCommonPart() { + return note; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPart(java.lang.Object) + */ + @Override + public void setCommonPart(NotesCommon note) { + this.note = note; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#getCommonPartList() + */ + @Override + public NotesCommonList getCommonPartList() { + return noteList; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#setCommonPartList(java.lang.Object) + */ + @Override + public void setCommonPartList(NotesCommonList noteList) { + this.noteList = noteList; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPart(org.collectionspace.services.common.document.DocumentWrapper) + */ + @Override + public NotesCommon extractCommonPart(DocumentWrapper wrapDoc) + throws Exception { + throw new UnsupportedOperationException(); + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#fillCommonPart(java.lang.Object, org.collectionspace.services.common.document.DocumentWrapper) + */ + @Override + public void fillCommonPart(NotesCommon noteObject, DocumentWrapper wrapDoc) throws Exception { + throw new UnsupportedOperationException(); + } + + /* (non-Javadoc) + * @see org.collectionspace.services.nuxeo.client.java.DocumentModelHandler#extractCommonPartList(org.collectionspace.services.common.document.DocumentWrapper) + */ + @Override + public NotesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception { + NotesCommonList coList = extractPagingInfo(new NotesCommonList(), wrapDoc); + List list = coList.getNoteListItem(); + Iterator iter = wrapDoc.getWrappedObject().iterator(); + while(iter.hasNext()){ + DocumentModel docModel = iter.next(); + NoteListItem clistItem = new NoteListItem(); + clistItem.setContent((String) docModel.getProperty(getServiceContext().getCommonPartLabel(), + NoteJAXBSchema.CONTENT)); + String id = NuxeoUtils.extractId(docModel.getPathAsString()); + clistItem.setUri(getServiceContextPath() + id); + clistItem.setCsid(id); + list.add(clistItem); + } + + return coList; + } + + /* (non-Javadoc) + * @see org.collectionspace.services.common.document.AbstractMultipartDocumentHandlerImpl#getQProperty(java.lang.String) + */ + @Override + public String getQProperty(String prop) { + return NoteConstants.NUXEO_SCHEMA_NAME + ":" + prop; + } +} + diff --git a/services/note/service/src/test/java/org/collectionspace/services/test/NoteServiceTest.java b/services/note/service/src/test/java/org/collectionspace/services/test/NoteServiceTest.java new file mode 100644 index 000000000..a8393860e --- /dev/null +++ b/services/note/service/src/test/java/org/collectionspace/services/test/NoteServiceTest.java @@ -0,0 +1,11 @@ +package org.collectionspace.services.test; + + +/** + * NoteServiceTest + * + * @version $Revision:$ + */ +public class NoteServiceTest { + //empty +} diff --git a/services/note/service/src/test/resources/log4j.xml b/services/note/service/src/test/resources/log4j.xml new file mode 100644 index 000000000..6881ae6dd --- /dev/null +++ b/services/note/service/src/test/resources/log4j.xml @@ -0,0 +1,45 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/services/pom.xml b/services/pom.xml index 936eac0ce..1163736e4 100644 --- a/services/pom.xml +++ b/services/pom.xml @@ -18,6 +18,7 @@ client jaxb common + note authorization-mgt common-test account @@ -304,4 +305,4 @@ - \ No newline at end of file + -- 2.47.3