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
}
@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();
}
@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
}
@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();
}
@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
* $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>();
}
@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");
}
* The repository client then calls handle on the handler
*
*/
-public interface DocumentHandler<T, TL> {
+public interface DocumentHandler<T, TL, WT, WTL> {
public enum Action {
* @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
* @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.
* @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.
* @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
* @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.
* @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
* @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.
* @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
* @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;
/**
* DocumentWrapper wraps DocumentModel (java) or Representation (REST)
*
*/
-public interface DocumentWrapper {
+public interface DocumentWrapper<T> {
/**
* getWrappedObject
* @return wrapped object
*/
- public Object getWrappedObject();
+ public T getWrappedObject();
}
* 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
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;
* $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;
}
@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();
+++ /dev/null
-/**
- * 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;
- }
-
-}
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();
}
@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){
}
@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()){
*/
package org.collectionspace.services.nuxeo.client.java;
-
import java.util.UUID;
import org.collectionspace.services.common.context.ServiceContext;
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;
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);
}
//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) {
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) {
}
}
}
-
+
/**
* getFiltered get all documents for an entity service from the Document repository,
* given filter parameters specified by the handler.
* @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");
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) {
}
}
-
-
/**
* update given document in the Nuxeo repository
*
}
//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();
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");
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);
}
}
public String getWorkspaceId(String tenantDomain, String workspaceName) throws Exception {
String workspaceId = null;
RepositoryInstance repoSession = null;
- try{
+ try {
repoSession = getRepositorySession();
DocumentRef docRef = new PathRef(
"/" + tenantDomain +
"/" + 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);
}
}
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
}
}
-
}
}
@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();
}
@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);
@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
}
@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();