]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
CSPACE-1349, 1422, 1428, 1469, 1470, 1473: Adding pagination support for default...
authorRichard Millet <richard.millet@berkeley.edu>
Fri, 16 Apr 2010 16:54:13 +0000 (16:54 +0000)
committerRichard Millet <richard.millet@berkeley.edu>
Fri, 16 Apr 2010 16:54:13 +0000 (16:54 +0000)
Passes *ALL* current tests and merged with the latest set of sources.

services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java [new file with mode: 0644]
services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java [new file with mode: 0644]

diff --git a/services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java b/services/common/src/main/java/org/collectionspace/services/common/AbstractMultiPartCollectionSpaceResourceImpl.java
new file mode 100644 (file)
index 0000000..8c1acf1
--- /dev/null
@@ -0,0 +1,96 @@
+/**    \r
+ * AbstractMultiPartCollectionSpaceResourceImpl.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright © 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
+package org.collectionspace.services.common;\r
+\r
+import org.collectionspace.services.common.context.MultipartServiceContext;\r
+import org.collectionspace.services.common.context.MultipartServiceContextFactory;\r
+import org.collectionspace.services.common.context.ServiceContext;\r
+import org.collectionspace.services.common.context.ServiceContextFactory;\r
+import org.collectionspace.services.common.document.DocumentHandler;\r
+\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
+\r
+/**\r
+ * The Class AbstractMultiPartCollectionSpaceResourceImpl.\r
+ */\r
+public abstract class AbstractMultiPartCollectionSpaceResourceImpl extends\r
+               AbstractCollectionSpaceResourceImpl<MultipartInput, MultipartOutput> {\r
+\r
+    @Override\r
+    public ServiceContextFactory<MultipartInput, MultipartOutput> getServiceContextFactory() {\r
+       return (ServiceContextFactory<MultipartInput, MultipartOutput>)MultipartServiceContextFactory.get();\r
+    }\r
+\r
+    @Override\r
+    public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> ctx) throws Exception {\r
+       DocumentHandler docHandler = createDocumentHandler(ctx, ctx.getCommonPartLabel(),\r
+                       getCommonPartClass());\r
+       return docHandler;\r
+    }\r
+    \r
+    /**\r
+     * Creates the document handler.\r
+     * \r
+     * @param serviceContext the service context\r
+     * @param schemaName the schema name\r
+     * @param commonClass the common class\r
+     * \r
+     * @return the document handler\r
+     * \r
+     * @throws Exception the exception\r
+     */\r
+    public DocumentHandler createDocumentHandler(ServiceContext<MultipartInput, MultipartOutput> serviceContext,\r
+               String schemaName, \r
+               Class<?> commonClass) throws Exception {\r
+       MultipartServiceContext ctx = (MultipartServiceContext)serviceContext;\r
+       Object commonPart = null;\r
+       if (ctx.getInput() != null) {\r
+               commonPart = ctx.getInputPart(schemaName, commonClass);\r
+        }\r
+        DocumentHandler docHandler = super.createDocumentHandler(ctx, commonPart);\r
+        \r
+        return docHandler;\r
+    }\r
+    \r
+    /**\r
+     * Creates the document handler.\r
+     * \r
+     * @param ctx the ctx\r
+     * @param commonClass the common class\r
+     * \r
+     * @return the document handler\r
+     * \r
+     * @throws Exception the exception\r
+     */\r
+    public DocumentHandler createDocumentHandler(\r
+               ServiceContext<MultipartInput, MultipartOutput> ctx,\r
+               Class<Object> commonClass) throws Exception {\r
+       return createDocumentHandler(ctx, ctx.getCommonPartLabel(), commonClass);\r
+    }\r
+    \r
+}\r
diff --git a/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java b/services/common/src/main/java/org/collectionspace/services/common/context/RemoteServiceContextFactory.java
new file mode 100644 (file)
index 0000000..46be9f7
--- /dev/null
@@ -0,0 +1,108 @@
+/**    \r
+ * RemoteServiceContextFactory.java\r
+ *\r
+ * {Purpose of This Class}\r
+ *\r
+ * {Other Notes Relating to This Class (Optional)}\r
+ *\r
+ * $LastChangedBy: $\r
+ * $LastChangedRevision: $\r
+ * $LastChangedDate: $\r
+ *\r
+ * This document is a part of the source code and related artifacts\r
+ * for CollectionSpace, an open source collections management system\r
+ * for museums and related institutions:\r
+ *\r
+ * http://www.collectionspace.org\r
+ * http://wiki.collectionspace.org\r
+ *\r
+ * Copyright © 2009 {Contributing Institution}\r
+ *\r
+ * Licensed under the Educational Community License (ECL), Version 2.0.\r
+ * You may not use this file except in compliance with this License.\r
+ *\r
+ * You may obtain a copy of the ECL 2.0 License at\r
+ * https://source.collectionspace.org/collection-space/LICENSE.txt\r
+ */\r
+package org.collectionspace.services.common.context;\r
+\r
+import javax.ws.rs.core.MultivaluedMap;\r
+\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartInput;\r
+import org.jboss.resteasy.plugins.providers.multipart.MultipartOutput;\r
+\r
+/**\r
+ * A factory for creating RemoteServiceContext objects.\r
+ */\r
+public class RemoteServiceContextFactory<IT, OT>\r
+       implements ServiceContextFactory<IT, OT>{\r
+       \r
+       // create a Factory singleton\r
+       /** The Constant self. */\r
+       final private static RemoteServiceContextFactory self = new RemoteServiceContextFactory();\r
+       \r
+       /**\r
+        * Instantiates a new remote service context factory.\r
+        */\r
+       private RemoteServiceContextFactory() {} // private constructor\r
+    \r
+    /**\r
+     * Gets the.\r
+     * \r
+     * @return the remote service context factory\r
+     */\r
+    public static RemoteServiceContextFactory get() {\r
+        return self;\r
+    }\r
+\r
+    /* (non-Javadoc)\r
+     * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String)\r
+     */\r
+    @Override\r
+    public ServiceContext<IT, OT> createServiceContext(String serviceName) throws Exception {\r
+       RemoteServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName);\r
+       return ctx;\r
+    }\r
+    \r
+    /* (non-Javadoc)\r
+     * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object)\r
+     */\r
+    @Override\r
+    public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
+               IT theInput) throws Exception {\r
+       RemoteServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName, theInput);\r
+        return ctx;\r
+    }\r
+    \r
+    /* (non-Javadoc)\r
+     * @see org.collectionspace.services.common.context.ServiceContextFactory#createServiceContext(java.lang.String, java.lang.Object, javax.ws.rs.core.MultivaluedMap)\r
+     */\r
+    @Override\r
+    public ServiceContext<IT, OT> createServiceContext(\r
+               String serviceName,\r
+               IT theInput, \r
+               MultivaluedMap<String, String> queryParams) throws Exception {\r
+       ServiceContext<IT, OT> ctx = new RemoteServiceContextImpl<IT, OT>(serviceName,\r
+                       theInput,\r
+                       queryParams);\r
+       \r
+        return ctx;\r
+    }\r
+\r
+    @Override\r
+    public ServiceContext<IT, OT> createServiceContext(String serviceName,\r
+               IT input, \r
+               MultivaluedMap<String, String> queryParams,\r
+               String documentType,\r
+               String entityName) throws Exception {\r
+       ServiceContext<IT, OT> ctx = createServiceContext(\r
+                       serviceName,\r
+                       input,\r
+                       queryParams);\r
+        ctx.setDocumentType(documentType); //persistence unit\r
+        ctx.setProperty("entity-name", entityName);\r
+        \r
+        return ctx;\r
+    }\r
+    \r
+}\r