]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA refactoring of DocumentWrapper. It is now a generic type. Does not require...
authorSanjay Dalal <sanjay.dalal@berkeley.edu>
Mon, 16 Nov 2009 23:33:04 +0000 (23:33 +0000)
committerSanjay Dalal <sanjay.dalal@berkeley.edu>
Mon, 16 Nov 2009 23:33:04 +0000 (23:33 +0000)
M    services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java
M    services/common/src/main/java/org/collectionspace/services/common/document/DocumentWrapper.java
M    services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java
A    services/common/src/main/java/org/collectionspace/services/common/document/DocumentWrapperImpl.java
M    services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java
D    services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelWrapper.java
M    services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClient.java
M    services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java
D    services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelListWrapper.java
M    services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
M    services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java
M    services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java
_M   services/vocabulary/import
M    services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java
M    services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java

13 files changed:
services/acquisition/service/src/main/java/org/collectionspace/services/acquisition/nuxeo/AcquisitionDocumentModelHandler.java
services/collectionobject/service/src/main/java/org/collectionspace/services/collectionobject/nuxeo/CollectionObjectDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/common/document/AbstractDocumentHandler.java
services/common/src/main/java/org/collectionspace/services/common/document/DocumentHandler.java
services/common/src/main/java/org/collectionspace/services/common/document/DocumentWrapper.java
services/common/src/main/java/org/collectionspace/services/common/document/DocumentWrapperImpl.java [moved from services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelWrapper.java with 62% similarity]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelListWrapper.java [deleted file]
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RemoteDocumentModelHandler.java
services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/RepositoryJavaClient.java
services/intake/service/src/main/java/org/collectionspace/services/intake/nuxeo/IntakeDocumentModelHandler.java
services/relation/service/src/main/java/org/collectionspace/services/relation/nuxeo/RelationDocumentModelHandler.java
services/vocabulary/service/src/main/java/org/collectionspace/services/vocabulary/nuxeo/VocabularyDocumentModelHandler.java

index 2ffea0a222fc922eafcde833ca937aa8ba5eb1ef..a86fdb849e1200b18637e014c2ab7d9f61043269 100644 (file)
@@ -99,20 +99,19 @@ public class AcquisitionDocumentModelHandler
     }
 
     @Override
-    public AcquisitionsCommon extractCommonPart(DocumentWrapper wrapDoc)
+    public AcquisitionsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
             throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void fillCommonPart(AcquisitionsCommon acquisitionObject, DocumentWrapper wrapDoc) throws Exception {
+    public void fillCommonPart(AcquisitionsCommon acquisitionObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public AcquisitionsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
-
+    public AcquisitionsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
         AcquisitionsCommonList coList = new AcquisitionsCommonList();
         List<AcquisitionsCommonList.AcquisitionListItem> list = coList.getAcquisitionListItem();
 
@@ -135,14 +134,14 @@ public class AcquisitionDocumentModelHandler
     }
 
     @Override
-    public void fillAllParts(DocumentWrapper wrapDoc) throws Exception {
+    public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
 
         super.fillAllParts(wrapDoc);
         fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
     }
 
-    private void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
+    private void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
         //FIXME property setter should be dynamically set using schema inspection
         //so it does not require hard coding
         // a default title for the Dublin Core schema
index eea06dde56b420b84b387282694c9034464a36ad..f57c35630efa4dfb39258dded8337492e0124abc 100644 (file)
@@ -92,19 +92,19 @@ public class CollectionObjectDocumentModelHandler
     }
 
     @Override
-    public CollectionobjectsCommon extractCommonPart(DocumentWrapper wrapDoc)
+    public CollectionobjectsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
             throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void fillCommonPart(CollectionobjectsCommon co, DocumentWrapper wrapDoc) throws Exception {
+    public void fillCommonPart(CollectionobjectsCommon co, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public CollectionobjectsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
+    public CollectionobjectsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
 
         CollectionobjectsCommonList coList = new CollectionobjectsCommonList();
         List<CollectionobjectsCommonList.CollectionObjectListItem> list = coList.getCollectionObjectListItem();
@@ -127,14 +127,14 @@ public class CollectionObjectDocumentModelHandler
     }
 
     @Override
-    public void fillAllParts(DocumentWrapper wrapDoc) throws Exception {
+    public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
 
         super.fillAllParts(wrapDoc);
         fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
     }
 
-    private void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
+    private void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
         //FIXME property setter should be dynamically set using schema inspection
         //so it does not require hard coding
         // a default title for the Dublin Core schema
index 4dbab9200e9ea1ce1eb6d6510b0e645592c0d217..bb9690a1b28e4eba0b8125b7168c5a9cbedaeccb 100644 (file)
@@ -38,8 +38,8 @@ import org.slf4j.LoggerFactory;
  * $LastChangedRevision: $
  * $LastChangedDate: $
  */
-public abstract class AbstractDocumentHandler<T, TL>
-        implements DocumentHandler<T, TL> {
+public abstract class AbstractDocumentHandler<T, TL, WT, WTL>
+        implements DocumentHandler<T, TL, WT, WTL> {
 
     private final Logger logger = LoggerFactory.getLogger(AbstractDocumentHandler.class);
     private Map<String, Object> properties = new HashMap<String, Object>();
@@ -97,76 +97,76 @@ public abstract class AbstractDocumentHandler<T, TL>
     }
 
     @Override
-    public void handle(Action action, DocumentWrapper wrapDoc) throws Exception {
+    public void handle(Action action, DocumentWrapper<?> wrapDoc) throws Exception {
         switch(action){
             case CREATE:
-                handleCreate(wrapDoc);
+                handleCreate((DocumentWrapper<WT>)wrapDoc);
                 break;
 
             case UPDATE:
-                handleUpdate(wrapDoc);
+                handleUpdate((DocumentWrapper<WT>)wrapDoc);
                 break;
 
             case GET:
-                handleGet(wrapDoc);
+                handleGet((DocumentWrapper<WT>)wrapDoc);
                 break;
 
             case GET_ALL:
-                handleGetAll(wrapDoc);
+                handleGetAll((DocumentWrapper<WTL>)wrapDoc);
                 break;
 
         }
     }
 
     @Override
-    public abstract void handleCreate(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void handleCreate(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     @Override
-    public abstract void handleUpdate(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void handleUpdate(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     @Override
-    public abstract void handleGet(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void handleGet(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     @Override
-    public abstract void handleGetAll(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void handleGetAll(DocumentWrapper<WTL> wrapDoc) throws Exception;
 
     @Override
-    public void complete(Action action, DocumentWrapper wrapDoc) throws Exception {
+    public void complete(Action action, DocumentWrapper<?> wrapDoc) throws Exception {
         switch(action){
             //TODO: add more actions if needed
             case UPDATE:
-                completeUpdate(wrapDoc);
+                completeUpdate((DocumentWrapper<WT>)wrapDoc);
                 break;
         }
     }
 
     @Override
-    public void completeUpdate(DocumentWrapper wrapDoc) throws Exception {
+    public void completeUpdate(DocumentWrapper<WT> wrapDoc) throws Exception {
         //no specific action needed
     }
 
     @Override
-    public abstract void extractAllParts(DocumentWrapper wrapDoc)
+    public abstract void extractAllParts(DocumentWrapper<WT> wrapDoc)
             throws Exception;
 
     @Override
-    public abstract void fillAllParts(DocumentWrapper wrapDoc)
+    public abstract void fillAllParts(DocumentWrapper<WT> wrapDoc)
             throws Exception;
 
     @Override
-    public abstract T extractCommonPart(DocumentWrapper wrapDoc)
+    public abstract T extractCommonPart(DocumentWrapper<WT> wrapDoc)
             throws Exception;
 
     @Override
-    public abstract void fillCommonPart(T obj, DocumentWrapper wrapDoc)
+    public abstract void fillCommonPart(T obj, DocumentWrapper<WT> wrapDoc)
             throws Exception;
 
     @Override
-    public abstract TL extractCommonPartList(DocumentWrapper wrapDoc)
+    public abstract TL extractCommonPartList(DocumentWrapper<WTL> wrapDoc)
             throws Exception;
 
     @Override
-    final public void fillCommonPartList(TL obj, DocumentWrapper wrapDoc) throws Exception {
+    final public void fillCommonPartList(TL obj, DocumentWrapper<WTL> wrapDoc) throws Exception {
         throw new UnsupportedOperationException("bulk create/update not yet supported");
     }
 
index 0972256bcd6e0de42d8d2bfa3ef26f1448450b03..5fbda3564d7d39c95301dc6b224eacb63144eb10 100644 (file)
@@ -33,7 +33,7 @@ import org.collectionspace.services.common.context.ServiceContext;
  * The repository client then calls handle on the handler
  *
  */
-public interface DocumentHandler<T, TL> {
+public interface DocumentHandler<T, TL, WT, WTL> {
 
     public enum Action {
 
@@ -73,35 +73,35 @@ public interface DocumentHandler<T, TL> {
      * @param doc wrapped doc
      * @throws Exception
      */
-    public void handle(Action action, DocumentWrapper docWrap) throws Exception;
+    public void handle(Action action, DocumentWrapper<?> docWrap) throws Exception;
 
     /**
      * handleCreate processes documents before creating document in repository
      * @param wrapDoc
      * @throws Exception
      */
-    public void handleCreate(DocumentWrapper wrapDoc) throws Exception;
+    public void handleCreate(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     /**
      * handleUpdate processes documents for the update of document in repository
      * @param wrapDoc
      * @throws Exception
      */
-    public void handleUpdate(DocumentWrapper wrapDoc) throws Exception;
+    public void handleUpdate(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     /**
      * handleGet processes documents from repository before responding to consumer
      * @param wrapDoc
      * @throws Exception
      */
-    public void handleGet(DocumentWrapper wrapDoc) throws Exception;
+    public void handleGet(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     /**
      * handleGetAll processes documents from repository before responding to consumer
      * @param wrapDoc
      * @throws Exception
      */
-    public void handleGetAll(DocumentWrapper wrapDoc) throws Exception;
+    public void handleGetAll(DocumentWrapper<WTL> wrapDoc) throws Exception;
 
     /**
      * complete is called by the client to provide an opportunity to the handler
@@ -110,7 +110,7 @@ public interface DocumentHandler<T, TL> {
      * @param wrapDoc
      * @throws Exception
      */
-    public void complete(Action action, DocumentWrapper wrapDoc) throws Exception;
+    public void complete(Action action, DocumentWrapper<?> wrapDoc) throws Exception;
 
     /**
      * completeUpdate is called by the client to indicate completion of the update call.
@@ -118,7 +118,7 @@ public interface DocumentHandler<T, TL> {
      * @param wrapDoc
      * @throws Exception
      */
-    public void completeUpdate(DocumentWrapper wrapDoc) throws Exception;
+    public void completeUpdate(DocumentWrapper<WT> wrapDoc) throws Exception;
 
     /**
      * extractAllParts extracts all parts of a CS object from given document.
@@ -127,7 +127,7 @@ public interface DocumentHandler<T, TL> {
      * @param docWrap document
      * @throws Exception
      */
-    public void extractAllParts(DocumentWrapper docWrap) throws Exception;
+    public void extractAllParts(DocumentWrapper<WT> docWrap) throws Exception;
 
     /**
      * fillAllParts sets parts of CS object into given document
@@ -137,7 +137,7 @@ public interface DocumentHandler<T, TL> {
      * @param docWrap target document
      * @throws Exception
      */
-    public void fillAllParts(DocumentWrapper docWrap) throws Exception;
+    public void fillAllParts(DocumentWrapper<WT> docWrap) throws Exception;
 
     /**
      * extractCommonPart extracts common part of a CS object from given document.
@@ -147,7 +147,7 @@ public interface DocumentHandler<T, TL> {
      * @return common part of CS object
      * @throws Exception
      */
-    public T extractCommonPart(DocumentWrapper docWrap) throws Exception;
+    public T extractCommonPart(DocumentWrapper<WT> docWrap) throws Exception;
 
     /**
      * fillCommonPart sets common part of CS object into given document
@@ -157,7 +157,7 @@ public interface DocumentHandler<T, TL> {
      * @param docWrap target document
      * @throws Exception
      */
-    public void fillCommonPart(T obj, DocumentWrapper docWrap) throws Exception;
+    public void fillCommonPart(T obj, DocumentWrapper<WT> docWrap) throws Exception;
 
     /**
      * extractCommonPart extracts common part of a CS object from given document.
@@ -167,7 +167,7 @@ public interface DocumentHandler<T, TL> {
      * @return common part of CS object
      * @throws Exception
      */
-    public TL extractCommonPartList(DocumentWrapper docWrap) throws Exception;
+    public TL extractCommonPartList(DocumentWrapper<WTL> docWrap) throws Exception;
 
     /**
      * fillCommonPartList sets list common part of CS object into given document
@@ -177,7 +177,7 @@ public interface DocumentHandler<T, TL> {
      * @param docWrap target document
      * @throws Exception
      */
-    public void fillCommonPartList(TL obj, DocumentWrapper docWrap) throws Exception;
+    public void fillCommonPartList(TL obj, DocumentWrapper<WTL> docWrap) throws Exception;
 
 
     /**
index 76e0d3a5b6e46b9d44faa317b7e6b340bfc82cfd..b5ca45f1e921c1b53a93cbea8e9f7bab532cb1bc 100644 (file)
@@ -29,12 +29,12 @@ package org.collectionspace.services.common.document;
  * DocumentWrapper wraps DocumentModel (java) or Representation (REST)
  *
  */
-public interface DocumentWrapper {
+public interface DocumentWrapper<T> {
 
     /**
      * getWrappedObject
      * @return wrapped object
      */
-    public Object getWrappedObject();
+    public T getWrappedObject();
 
 }
similarity index 62%
rename from services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelWrapper.java
rename to services/common/src/main/java/org/collectionspace/services/common/document/DocumentWrapperImpl.java
index d12a93202ed2122d1e4a46989378bdbabca263bf..e3083b79ed1ff21d810df995ab766b0392f9e630 100644 (file)
  *  limitations under the License.
  */
 
-package org.collectionspace.services.nuxeo.client.java;
+package org.collectionspace.services.common.document;
 
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.nuxeo.ecm.core.api.DocumentModel;
+public class DocumentWrapperImpl<T> implements DocumentWrapper<T>{
 
-/**
-* DocumentModelWrapper wraps Nuxeo DocumentModel
-*
-* $LastChangedRevision: $
-* $LastChangedDate: $
-*/
-public class DocumentModelWrapper implements DocumentWrapper {
-
-    private DocumentModel docModel;
+    private T wrappedObject;
 
-    public DocumentModelWrapper(DocumentModel docModel) {
-        this.docModel = docModel;
-    }
-    
-    @Override
-    public Object getWrappedObject() {
-        return docModel;
+    public DocumentWrapperImpl(T obj) {
+        this.wrappedObject = obj;
     }
 
-}
+    public T getWrappedObject() {
+        return wrappedObject;
+    }
+}
\ No newline at end of file
index ec5cec310ce14507613771a2423882eb87c714d7..d929813aaac4553892fad761c56ecbb5ba9bd11f 100644 (file)
@@ -26,6 +26,8 @@ package org.collectionspace.services.nuxeo.client.java;
 import org.collectionspace.services.common.document.DocumentWrapper;
 import org.collectionspace.services.common.document.AbstractDocumentHandler;
 import org.collectionspace.services.nuxeo.client.*;
+import org.nuxeo.ecm.core.api.DocumentModel;
+import org.nuxeo.ecm.core.api.DocumentModelList;
 import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -38,7 +40,7 @@ import org.slf4j.LoggerFactory;
  * $LastChangedDate: $
  */
 public abstract class DocumentModelHandler<T, TL>
-        extends AbstractDocumentHandler<T, TL> {
+        extends AbstractDocumentHandler<T, TL, DocumentModel, DocumentModelList> {
 
     private final Logger logger = LoggerFactory.getLogger(DocumentModelHandler.class);
     private RepositoryInstance repositorySession;
@@ -61,42 +63,42 @@ public abstract class DocumentModelHandler<T, TL>
     }
 
     @Override
-    public void handleCreate(DocumentWrapper wrapDoc) throws Exception {
+    public void handleCreate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         fillAllParts(wrapDoc);
     }
 
     @Override
-    public void handleUpdate(DocumentWrapper wrapDoc) throws Exception {
+    public void handleUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         fillAllParts(wrapDoc);
     }
 
     @Override
-    public void handleGet(DocumentWrapper wrapDoc) throws Exception {
+    public void handleGet(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         extractAllParts(wrapDoc);
     }
 
     @Override
-    public void handleGetAll(DocumentWrapper wrapDoc) throws Exception {
+    public void handleGetAll(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
         setCommonPartList(extractCommonPartList(wrapDoc));
     }
 
     @Override
-    public abstract void completeUpdate(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
 
     @Override
-    public abstract void extractAllParts(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
 
     @Override
-    public abstract T extractCommonPart(DocumentWrapper wrapDoc) throws Exception;
+    public abstract T extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
 
     @Override
-    public abstract void fillAllParts(DocumentWrapper wrapDoc) throws Exception;
+    public abstract void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
 
     @Override
-    public abstract void fillCommonPart(T obj, DocumentWrapper wrapDoc) throws Exception;
+    public abstract void fillCommonPart(T obj, DocumentWrapper<DocumentModel> wrapDoc) throws Exception;
 
     @Override
-    public abstract TL extractCommonPartList(DocumentWrapper wrapDoc) throws Exception;
+    public abstract TL extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception;
 
     @Override
     public abstract T getCommonPart();
diff --git a/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelListWrapper.java b/services/common/src/main/java/org/collectionspace/services/nuxeo/client/java/DocumentModelListWrapper.java
deleted file mode 100644 (file)
index c2b0096..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- *  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.nuxeo.client.java;
-
-import org.collectionspace.services.common.document.DocumentWrapper;
-import org.nuxeo.ecm.core.api.DocumentModelList;
-
-/**
-* DocumentModelListWrapper wraps Nuxeo DocumentModel
-*
-* $LastChangedRevision: $
-* $LastChangedDate: $
-*/
-public class DocumentModelListWrapper implements DocumentWrapper {
-
-    private DocumentModelList docModelList;
-
-    public DocumentModelListWrapper(DocumentModelList docModelList) {
-        this.docModelList = docModelList;
-    }
-    
-    @Override
-    public Object getWrappedObject() {
-        return docModelList;
-    }
-
-}
index ffb96279f780759c8ed16a68a471e1d4a4d75f20..af09b24274e6e41a580d5d9ec52e439535f73448 100644 (file)
@@ -68,8 +68,8 @@ public abstract class RemoteDocumentModelHandler<T, TL>
     public abstract String getDocumentType();
 
     @Override
-    public void completeUpdate(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
+    public void completeUpdate(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
         //return at least those document part(s) that were received
         Map<String, ObjectPartType> partsMetaMap = getServiceContext().getPartsMetadata();
         RemoteServiceContext ctx = (RemoteServiceContext) getServiceContext();
@@ -82,9 +82,9 @@ public abstract class RemoteDocumentModelHandler<T, TL>
     }
 
     @Override
-    public void extractAllParts(DocumentWrapper wrapDoc) throws Exception {
+    public void extractAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
 
-        DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
+        DocumentModel docModel = wrapDoc.getWrappedObject();
         String[] schemas = docModel.getDeclaredSchemas();
         Map<String, ObjectPartType> partsMetaMap = getServiceContext().getPartsMetadata();
         for(String schema : schemas){
@@ -97,12 +97,12 @@ public abstract class RemoteDocumentModelHandler<T, TL>
     }
 
     @Override
-    public void fillAllParts(DocumentWrapper wrapDoc) throws Exception {
+    public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
 
         //TODO filling extension parts should be dynamic
         //Nuxeo APIs lack to support stream/byte[] input, get/setting properties is
         //not an ideal way of populating objects.
-        DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
+        DocumentModel docModel = wrapDoc.getWrappedObject();
         RemoteServiceContext ctx = (RemoteServiceContext) getServiceContext();
         MultipartInput input = ctx.getInput();
         if(input.getParts().isEmpty()){
index 1a521eb6bf110919199ba92db935a9a6549bf191..9ccb51be18f9603be1e3f25cbc1afd1cb0cf1457 100644 (file)
@@ -17,7 +17,6 @@
  */
 package org.collectionspace.services.nuxeo.client.java;
 
-
 import java.util.UUID;
 
 import org.collectionspace.services.common.context.ServiceContext;
@@ -28,6 +27,8 @@ import org.collectionspace.services.common.document.DocumentHandler;
 import org.collectionspace.services.common.document.DocumentNotFoundException;
 import org.collectionspace.services.common.repository.RepositoryClient;
 import org.collectionspace.services.common.document.DocumentHandler.Action;
+import org.collectionspace.services.common.document.DocumentWrapper;
+import org.collectionspace.services.common.document.DocumentWrapperImpl;
 import org.collectionspace.services.nuxeo.util.NuxeoUtils;
 import org.nuxeo.common.utils.IdUtils;
 import org.nuxeo.ecm.core.api.ClientException;
@@ -99,7 +100,7 @@ public class RepositoryJavaClient implements RepositoryClient {
             DocumentModel doc = repoSession.createDocumentModel(wspacePath, id,
                     ctx.getDocumentType());
             ((DocumentModelHandler) handler).setRepositorySession(repoSession);
-            DocumentModelWrapper wrapDoc = new DocumentModelWrapper(doc);
+            DocumentWrapper<DocumentModel> wrapDoc = new DocumentWrapperImpl<DocumentModel>(doc);
             handler.handle(Action.CREATE, wrapDoc);
             // create document with documentmodel
             doc = repoSession.createDocument(doc);
@@ -153,7 +154,7 @@ public class RepositoryJavaClient implements RepositoryClient {
             }
             //set reposession to handle the document
             ((DocumentModelHandler) handler).setRepositorySession(repoSession);
-            DocumentModelWrapper wrapDoc = new DocumentModelWrapper(doc);
+            DocumentWrapper<DocumentModel> wrapDoc = new DocumentWrapperImpl<DocumentModel>(doc);
             handler.handle(Action.GET, wrapDoc);
             handler.complete(Action.GET, wrapDoc);
         } catch (IllegalArgumentException iae) {
@@ -205,8 +206,7 @@ public class RepositoryJavaClient implements RepositoryClient {
             DocumentModelList docList = repoSession.getChildren(wsDocRef);
             //set reposession to handle the document
             ((DocumentModelHandler) handler).setRepositorySession(repoSession);
-            DocumentModelListWrapper wrapDoc = new DocumentModelListWrapper(
-                    docList);
+            DocumentWrapper<DocumentModelList> wrapDoc = new DocumentWrapperImpl<DocumentModelList>(docList);
             handler.handle(Action.GET_ALL, wrapDoc);
             handler.complete(Action.GET_ALL, wrapDoc);
         } catch (DocumentException de) {
@@ -222,7 +222,7 @@ public class RepositoryJavaClient implements RepositoryClient {
             }
         }
     }
-    
+
     /**
      * getFiltered get all documents for an entity service from the Document repository,
      * given filter parameters specified by the handler. 
@@ -231,8 +231,8 @@ public class RepositoryJavaClient implements RepositoryClient {
      * @throws DocumentNotFoundException if workspace not found
      * @throws DocumentException
      */
-    public void getFiltered(ServiceContext ctx, DocumentHandler handler) 
-       throws DocumentNotFoundException, DocumentException {
+    public void getFiltered(ServiceContext ctx, DocumentHandler handler)
+            throws DocumentNotFoundException, DocumentException {
         if (handler == null) {
             throw new IllegalArgumentException(
                     "RemoteRepositoryClient.getFiltered: handler is missing");
@@ -258,23 +258,23 @@ public class RepositoryJavaClient implements RepositoryClient {
             repoSession = getRepositorySession();
             StringBuilder query = new StringBuilder("SELECT * FROM ");
             query.append(docType);
-            String where = docFilter.getWhereClause(); 
+            String where = docFilter.getWhereClause();
             // TODO This is a slow method for tenant-filter
             // We should make this a property that is indexed.
-               query.append(" WHERE ecm:path STARTSWITH '/"+domain+"'");
-            if((null!=where)&&(where.length()>0))
-               query.append(" AND "+where);
+            query.append(" WHERE ecm:path STARTSWITH '/" + domain + "'");
+            if ((null != where) && (where.length() > 0)) {
+                query.append(" AND " + where);
+            }
             DocumentModelList docList = null;
-            if((docFilter.getOffset()>0)||(docFilter.getPageSize()>0)) {
-               docList = repoSession.query(query.toString(), null, 
-                                               docFilter.getPageSize(), docFilter.getOffset(), false);
+            if ((docFilter.getOffset() > 0) || (docFilter.getPageSize() > 0)) {
+                docList = repoSession.query(query.toString(), null,
+                        docFilter.getPageSize(), docFilter.getOffset(), false);
             } else {
-               docList = repoSession.query(query.toString());
+                docList = repoSession.query(query.toString());
             }
             //set repoSession to handle the document
             ((DocumentModelHandler) handler).setRepositorySession(repoSession);
-            DocumentModelListWrapper wrapDoc = new DocumentModelListWrapper(
-                    docList);
+            DocumentWrapper<DocumentModelList> wrapDoc = new DocumentWrapperImpl<DocumentModelList>(docList);
             handler.handle(Action.GET_ALL, wrapDoc);
             handler.complete(Action.GET_ALL, wrapDoc);
         } catch (DocumentException de) {
@@ -291,8 +291,6 @@ public class RepositoryJavaClient implements RepositoryClient {
         }
     }
 
-    
-
     /**
      * update given document in the Nuxeo repository
      *
@@ -331,7 +329,7 @@ public class RepositoryJavaClient implements RepositoryClient {
             }
             //set reposession to handle the document
             ((DocumentModelHandler) handler).setRepositorySession(repoSession);
-            DocumentModelWrapper wrapDoc = new DocumentModelWrapper(doc);
+            DocumentWrapper<DocumentModel> wrapDoc = new DocumentWrapperImpl<DocumentModel>(doc);
             handler.handle(Action.UPDATE, wrapDoc);
             repoSession.saveDocument(doc);
             repoSession.save();
@@ -394,8 +392,8 @@ public class RepositoryJavaClient implements RepositoryClient {
     public String createWorkspace(String tenantDomain, String workspaceName) throws Exception {
         RepositoryInstance repoSession = null;
         String workspaceId = null;
-        try{
-            repoSession= getRepositorySession();
+        try {
+            repoSession = getRepositorySession();
             DocumentRef docRef = new PathRef(
                     "/" + tenantDomain +
                     "/" + "workspaces");
@@ -408,17 +406,17 @@ public class RepositoryJavaClient implements RepositoryClient {
             doc = repoSession.createDocument(doc);
             workspaceId = doc.getId();
             repoSession.save();
-            if(logger.isDebugEnabled()){
+            if (logger.isDebugEnabled()) {
                 logger.debug("created workspace name=" + workspaceName +
                         " id=" + workspaceId);
             }
-        }catch(Exception e){
-            if(logger.isDebugEnabled()){
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
                 logger.debug("createWorkspace caught exception ", e);
             }
             throw e;
-        }finally{
-            if(repoSession != null){
+        } finally {
+            if (repoSession != null) {
                 releaseRepositorySession(repoSession);
             }
         }
@@ -429,7 +427,7 @@ public class RepositoryJavaClient implements RepositoryClient {
     public String getWorkspaceId(String tenantDomain, String workspaceName) throws Exception {
         String workspaceId = null;
         RepositoryInstance repoSession = null;
-        try{
+        try {
             repoSession = getRepositorySession();
             DocumentRef docRef = new PathRef(
                     "/" + tenantDomain +
@@ -437,15 +435,15 @@ public class RepositoryJavaClient implements RepositoryClient {
                     "/" + workspaceName);
             DocumentModel workspace = repoSession.getDocument(docRef);
             workspaceId = workspace.getId();
-        }catch(DocumentException de){
+        } catch (DocumentException de) {
             throw de;
-        }catch(Exception e){
-            if(logger.isDebugEnabled()){
+        } catch (Exception e) {
+            if (logger.isDebugEnabled()) {
                 logger.debug("Caught exception ", e);
             }
             throw new DocumentException(e);
-        }finally{
-            if(repoSession != null){
+        } finally {
+            if (repoSession != null) {
                 releaseRepositorySession(repoSession);
             }
         }
@@ -470,8 +468,7 @@ public class RepositoryJavaClient implements RepositoryClient {
             client.releaseRepository(repoSession);
         } catch (Exception e) {
             logger.error("Could not close the repository session", e);
-            // no need to throw this service specific exception
+        // no need to throw this service specific exception
         }
     }
-
 }
index f3057a2ffd939afeff96f235ee2e89180db0aba3..2a6e36fe0b1a640c6d82983324eae88429fecd47 100644 (file)
@@ -99,19 +99,19 @@ public class IntakeDocumentModelHandler
     }
 
     @Override
-    public IntakesCommon extractCommonPart(DocumentWrapper wrapDoc)
+    public IntakesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
             throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void fillCommonPart(IntakesCommon intakeObject, DocumentWrapper wrapDoc) throws Exception {
+    public void fillCommonPart(IntakesCommon intakeObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public IntakesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
+    public IntakesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
 
         IntakesCommonList coList = new IntakesCommonList();
         List<IntakesCommonList.IntakeListItem> list = coList.getIntakeListItem();
index 1c12971e88c5283eeeb6cf4e9552b4d9445a153f..aabd73ce5bc420f8e7272c10994326884914bf16 100644 (file)
@@ -102,19 +102,19 @@ public class RelationDocumentModelHandler
     }
 
     @Override
-    public RelationsCommon extractCommonPart(DocumentWrapper wrapDoc)
+    public RelationsCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
             throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void fillCommonPart(RelationsCommon relation, DocumentWrapper wrapDoc) throws Exception {
+    public void fillCommonPart(RelationsCommon relation, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public RelationsCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
+    public RelationsCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
 
         Map propsFromResource = this.getProperties();
         String subjectCsid = (String) propsFromResource.get(IRelationsManager.SUBJECT);
@@ -142,13 +142,13 @@ public class RelationDocumentModelHandler
   
 
     @Override
-    public void fillAllParts(DocumentWrapper wrapDoc) throws Exception {
+    public void fillAllParts(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         super.fillAllParts(wrapDoc);
         fillDublinCoreObject(wrapDoc); //dublincore might not be needed in future
     }
 
-    private void fillDublinCoreObject(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModel docModel = (DocumentModel) wrapDoc.getWrappedObject();
+    private void fillDublinCoreObject(DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
+        DocumentModel docModel = wrapDoc.getWrappedObject();
         //FIXME property setter should be dynamically set using schema inspection
         //so it does not require hard coding
         // a default title for the Dublin Core schema
index a6fc7845b7d0f8acfdfeb9a3ca232682eb427f7c..4dbf3c87bd06ce320ec491be817085be3689eaab 100644 (file)
@@ -99,19 +99,19 @@ public class VocabularyDocumentModelHandler
     }
 
     @Override
-    public VocabulariesCommon extractCommonPart(DocumentWrapper wrapDoc)
+    public VocabulariesCommon extractCommonPart(DocumentWrapper<DocumentModel> wrapDoc)
             throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public void fillCommonPart(VocabulariesCommon vocabularyObject, DocumentWrapper wrapDoc) throws Exception {
+    public void fillCommonPart(VocabulariesCommon vocabularyObject, DocumentWrapper<DocumentModel> wrapDoc) throws Exception {
         throw new UnsupportedOperationException();
     }
 
     @Override
-    public VocabulariesCommonList extractCommonPartList(DocumentWrapper wrapDoc) throws Exception {
-        DocumentModelList docList = (DocumentModelList) wrapDoc.getWrappedObject();
+    public VocabulariesCommonList extractCommonPartList(DocumentWrapper<DocumentModelList> wrapDoc) throws Exception {
+        DocumentModelList docList = wrapDoc.getWrappedObject();
 
         VocabulariesCommonList coList = new VocabulariesCommonList();
         List<VocabulariesCommonList.VocabularyListItem> list = coList.getVocabularyListItem();