diff --git a/config/alfresco/opencmis-context.xml b/config/alfresco/opencmis-context.xml
index 925245c797..16a59e0cd8 100644
--- a/config/alfresco/opencmis-context.xml
+++ b/config/alfresco/opencmis-context.xml
@@ -68,6 +68,7 @@
+
diff --git a/source/java/org/alfresco/cmis/CMISPropertyAccessor.java b/source/java/org/alfresco/cmis/CMISPropertyAccessor.java
new file mode 100644
index 0000000000..9437fa1594
--- /dev/null
+++ b/source/java/org/alfresco/cmis/CMISPropertyAccessor.java
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.cmis;
+
+import java.io.Serializable;
+
+import org.alfresco.service.cmr.repository.AssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.namespace.QName;
+
+/**
+ * CMIS Property Accessor (get and set property values)
+ *
+ * @author davidc
+ */
+public interface CMISPropertyAccessor
+{
+ /**
+ * Get the CMIS Property Name
+ *
+ * @return
+ */
+ String getName();
+
+ /**
+ * Get the (directly) mapped Alfresco property (if a direct mapping exists)
+ *
+ * @return
+ */
+ QName getMappedProperty();
+
+ /**
+ * Get the property value for a node or an association
+ *
+ * @param nodeRef
+ * @return
+ */
+ public Serializable getValue(NodeRef nodeRef);
+
+ /**
+ * Set the property value for a node
+ *
+ * @param nodeRef
+ * @Param value
+ */
+ void setValue(NodeRef nodeRef, Serializable value);
+
+ /**
+ * Get the property value for an association
+ *
+ * @param nodeRef
+ * @return
+ */
+ public Serializable getValue(AssociationRef assocRef);
+}
diff --git a/source/java/org/alfresco/cmis/CMISPropertyDefinition.java b/source/java/org/alfresco/cmis/CMISPropertyDefinition.java
index cbcc324dcc..0b897aeec0 100644
--- a/source/java/org/alfresco/cmis/CMISPropertyDefinition.java
+++ b/source/java/org/alfresco/cmis/CMISPropertyDefinition.java
@@ -20,10 +20,8 @@ package org.alfresco.cmis;
import java.util.Collection;
-import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
-
/**
* CMIS Property Definition
*
@@ -47,10 +45,11 @@ public interface CMISPropertyDefinition
/**
* Get the query name
+ *
* @return
*/
public String getQueryName();
-
+
/**
* Get the display name
*
@@ -80,14 +79,16 @@ public interface CMISPropertyDefinition
public CMISCardinalityEnum getCardinality();
/**
- * Get the choices available as values for this property TODO: not implemented yet
+ * Get the choices available as values for this property TODO: not
+ * implemented yet
*
* @return
*/
public Collection getChoices();
/**
- * Is this a choice where a user can enter other values (ie a list with common options)
+ * Is this a choice where a user can enter other values (ie a list with
+ * common options)
*
* @return
*/
@@ -127,7 +128,7 @@ public interface CMISPropertyDefinition
* @return
*/
public boolean isOrderable();
-
+
/**
* For variable length properties, get the maximum length allowed.
*
@@ -141,21 +142,21 @@ public interface CMISPropertyDefinition
* @return
*/
public Double getMinValue();
-
+
/**
* For Integer and Decimal properties, get the maximum value allowed
*
* @return
*/
public Double getMaxValue();
-
+
/**
* Gets the property accessor (for reading / writing values)
*
* @return
*/
public CMISPropertyAccessor getPropertyAccessor();
-
+
/**
* Gets the property Lucene builder
*
diff --git a/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java b/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java
index 1c7227d607..e3ace5c872 100644
--- a/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java
+++ b/source/java/org/alfresco/cmis/dictionary/CMISBasePropertyDefinition.java
@@ -26,13 +26,13 @@ import org.alfresco.cmis.CMISCardinalityEnum;
import org.alfresco.cmis.CMISChoice;
import org.alfresco.cmis.CMISDataTypeEnum;
import org.alfresco.cmis.CMISDictionaryModel;
+import org.alfresco.cmis.CMISPropertyAccessor;
import org.alfresco.cmis.CMISPropertyDefinition;
import org.alfresco.cmis.CMISPropertyId;
import org.alfresco.cmis.CMISTypeDefinition;
import org.alfresco.cmis.CMISUpdatabilityEnum;
import org.alfresco.cmis.mapping.AbstractProperty;
import org.alfresco.cmis.mapping.CMISMapping;
-import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
import org.alfresco.repo.dictionary.IndexTokenisationMode;
import org.alfresco.repo.dictionary.constraint.ListOfValuesConstraint;
@@ -77,9 +77,9 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
private CMISCardinalityEnum cardinality;
private Double minValue = null;
-
- private Double maxValue = null;
-
+
+ private Double maxValue = null;
+
private int maximumLength = -1;
private Collection choices = new HashSet();
@@ -106,7 +106,8 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
* @param propDef
* @param typeDef
*/
- public CMISBasePropertyDefinition(CMISMapping cmisMapping, CMISPropertyId propertyId, PropertyDefinition propDef, CMISTypeDefinition typeDef)
+ public CMISBasePropertyDefinition(CMISMapping cmisMapping, CMISPropertyId propertyId, PropertyDefinition propDef,
+ CMISTypeDefinition typeDef)
{
this.propertyId = propertyId;
this.typeDef = typeDef;
@@ -142,14 +143,13 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
}
required = propDef.isMandatory();
defaultValue = propDef.getDefaultValue();
- if (propertyId.getId().equals(CMISDictionaryModel.PROP_OBJECT_TYPE_ID) ||
- propertyId.getId().equals(CMISDictionaryModel.PROP_SOURCE_ID) ||
- propertyId.getId().equals(CMISDictionaryModel.PROP_TARGET_ID))
+ if (propertyId.getId().equals(CMISDictionaryModel.PROP_OBJECT_TYPE_ID)
+ || propertyId.getId().equals(CMISDictionaryModel.PROP_SOURCE_ID)
+ || propertyId.getId().equals(CMISDictionaryModel.PROP_TARGET_ID))
{
// Fix http://issues.alfresco.com/jira/browse/ALF-2637
updatability = CMISUpdatabilityEnum.ON_CREATE;
- }
- else
+ } else
{
updatability = propDef.isProtected() ? CMISUpdatabilityEnum.READ_ONLY : CMISUpdatabilityEnum.READ_AND_WRITE;
}
@@ -172,30 +172,29 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
case TRUE:
default:
String analyserClassName = propDef.resolveAnalyserClassName();
- if(propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN))
+ if (propDef.getDataType().getName().equals(DataTypeDefinition.BOOLEAN))
{
orderable = true;
- }
- else if (analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName())
+ } else if (analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName())
|| analyserClassName.equals(DateAnalyser.class.getCanonicalName())
- || analyserClassName.equals(DoubleAnalyser.class.getCanonicalName()) || analyserClassName.equals(FloatAnalyser.class.getCanonicalName())
- || analyserClassName.equals(IntegerAnalyser.class.getCanonicalName()) || analyserClassName.equals(LongAnalyser.class.getCanonicalName())
- || analyserClassName.equals(PathAnalyser.class.getCanonicalName()) || analyserClassName.equals(VerbatimAnalyser.class.getCanonicalName()))
+ || analyserClassName.equals(DoubleAnalyser.class.getCanonicalName())
+ || analyserClassName.equals(FloatAnalyser.class.getCanonicalName())
+ || analyserClassName.equals(IntegerAnalyser.class.getCanonicalName())
+ || analyserClassName.equals(LongAnalyser.class.getCanonicalName())
+ || analyserClassName.equals(PathAnalyser.class.getCanonicalName())
+ || analyserClassName.equals(VerbatimAnalyser.class.getCanonicalName()))
{
orderable = true;
- }
- else
+ } else
{
orderable = false;
}
}
- }
- else
+ } else
{
orderable = false;
}
- }
- else
+ } else
{
orderable = false;
}
@@ -273,7 +272,8 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
}
/**
- * For variable length properties, get the maximum length allowed. Unsupported.
+ * For variable length properties, get the maximum length allowed.
+ * Unsupported.
*
* @return
*/
@@ -282,24 +282,29 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
return maximumLength;
}
- /* (non-Javadoc)
+ /*
+ * (non-Javadoc)
+ *
* @see org.alfresco.cmis.CMISPropertyDefinition#getMinValue()
*/
public Double getMinValue()
{
return minValue;
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see org.alfresco.cmis.CMISPropertyDefinition#getMaxValue()
*/
public Double getMaxValue()
{
return maxValue;
}
-
+
/**
- * Get the choices available as values for this property TODO: not implemented yet
+ * Get the choices available as values for this property TODO: not
+ * implemented yet
*
* @return
*/
@@ -309,7 +314,8 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
}
/**
- * Is this a choice where a user can enter other values (ie a list with common options)
+ * Is this a choice where a user can enter other values (ie a list with
+ * common options)
*
* @return
*/
@@ -390,6 +396,7 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
/*
* (non-Javadoc)
+ *
* @see java.lang.Object#toString()
*/
@Override
diff --git a/source/java/org/alfresco/cmis/mapping/AbstractProperty.java b/source/java/org/alfresco/cmis/mapping/AbstractProperty.java
index 487664ba6a..f130444b37 100644
--- a/source/java/org/alfresco/cmis/mapping/AbstractProperty.java
+++ b/source/java/org/alfresco/cmis/mapping/AbstractProperty.java
@@ -21,7 +21,7 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import java.util.Collection;
-import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
+import org.alfresco.cmis.CMISPropertyAccessor;
import org.alfresco.opencmis.dictionary.CMISPropertyLuceneBuilder;
import org.alfresco.repo.search.impl.lucene.AbstractLuceneQueryParser;
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
@@ -37,7 +37,7 @@ import org.apache.lucene.search.Query;
* Base class for all property accessors
*
* @author andyh
- *
+ *
*/
public abstract class AbstractProperty implements CMISPropertyAccessor, CMISPropertyLuceneBuilder
{
@@ -57,7 +57,7 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
}
/**
- * @return service registry
+ * @return service registry
*/
protected ServiceRegistry getServiceRegistry()
{
@@ -66,6 +66,7 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
/*
* (non-Javadoc)
+ *
* @see org.alfresco.cmis.property.PropertyAccessor#getName()
*/
public String getName()
@@ -75,6 +76,7 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
/*
* (non-Javadoc)
+ *
* @see org.alfresco.cmis.property.PropertyAccessor#getMappedProperty()
*/
public QName getMappedProperty()
@@ -82,8 +84,8 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
return null;
}
-
- public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
+ public Query buildLuceneEquality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
+ LuceneFunction luceneFunction) throws ParseException
{
return null;
}
@@ -93,32 +95,38 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
return null;
}
- public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
+ public Query buildLuceneGreaterThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
+ LuceneFunction luceneFunction) throws ParseException
{
return null;
}
- public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
+ public Query buildLuceneGreaterThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
+ LuceneFunction luceneFunction) throws ParseException
{
return null;
}
- public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection values, Boolean not, PredicateMode mode) throws ParseException
+ public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection values, Boolean not,
+ PredicateMode mode) throws ParseException
{
return null;
}
- public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
+ public Query buildLuceneInequality(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
+ LuceneFunction luceneFunction) throws ParseException
{
return null;
}
- public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
+ public Query buildLuceneLessThan(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
+ LuceneFunction luceneFunction) throws ParseException
{
return null;
}
- public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode, LuceneFunction luceneFunction) throws ParseException
+ public Query buildLuceneLessThanOrEquals(AbstractLuceneQueryParser lqp, Serializable value, PredicateMode mode,
+ LuceneFunction luceneFunction) throws ParseException
{
return null;
}
@@ -142,12 +150,12 @@ public abstract class AbstractProperty implements CMISPropertyAccessor, CMISProp
{
throw new UnsupportedOperationException();
}
-
+
public void setValue(NodeRef nodeRef, Serializable value)
{
throw new UnsupportedOperationException();
}
-
+
public Serializable getValue(AssociationRef assocRef)
{
throw new UnsupportedOperationException();
diff --git a/source/java/org/alfresco/opencmis/AlfrescoCmisService.java b/source/java/org/alfresco/opencmis/AlfrescoCmisService.java
index b92ab126af..be8d27ed25 100644
--- a/source/java/org/alfresco/opencmis/AlfrescoCmisService.java
+++ b/source/java/org/alfresco/opencmis/AlfrescoCmisService.java
@@ -40,7 +40,8 @@ import javax.transaction.UserTransaction;
import org.alfresco.cmis.CMISInvalidArgumentException;
import org.alfresco.model.ContentModel;
-import org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
+import org.alfresco.opencmis.dictionary.CMISObjectVariant;
import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
@@ -64,7 +65,6 @@ import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentWriter;
-import org.alfresco.service.cmr.repository.EntityRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.search.QueryParameterDefinition;
@@ -146,10 +146,12 @@ public class AlfrescoCmisService extends AbstractCmisService
private CMISConnector connector;
private CallContext context;
private UserTransaction txn;
+ private Map nodeInfoMap;
public AlfrescoCmisService(CMISConnector connector)
{
this.connector = connector;
+ nodeInfoMap = new HashMap();
}
public void beginCall(CallContext context)
@@ -225,6 +227,9 @@ public class AlfrescoCmisService extends AbstractCmisService
{
AuthenticationUtil.popAuthentication();
context = null;
+ nodeInfoMap.clear();
+
+ super.close();
}
}
@@ -270,6 +275,50 @@ public class AlfrescoCmisService extends AbstractCmisService
}
}
+ protected CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef)
+ {
+ CMISNodeInfoImpl result = connector.createNodeInfo(nodeRef);
+ nodeInfoMap.put(result.getObjectId(), result);
+
+ return result;
+ }
+
+ protected CMISNodeInfo createNodeInfo(AssociationRef assocRef)
+ {
+ CMISNodeInfoImpl result = connector.createNodeInfo(assocRef);
+ nodeInfoMap.put(result.getObjectId(), result);
+
+ return result;
+ }
+
+ protected CMISNodeInfoImpl getOrCreateNodeInfo(String objectId)
+ {
+ CMISNodeInfoImpl result = nodeInfoMap.get(objectId);
+ if (result == null)
+ {
+ result = connector.createNodeInfo(objectId);
+ nodeInfoMap.put(objectId, result);
+ }
+
+ return result;
+ }
+
+ protected CMISNodeInfoImpl getOrCreateNodeInfo(String objectId, String what)
+ {
+ CMISNodeInfoImpl result = getOrCreateNodeInfo(objectId);
+ result.checkIfUseful(what);
+
+ return result;
+ }
+
+ protected CMISNodeInfoImpl getOrCreateFolderInfo(String folderId, String what)
+ {
+ CMISNodeInfoImpl result = getOrCreateNodeInfo(folderId);
+ result.checkIfFolder(what);
+
+ return result;
+ }
+
// --- repository service ---
@Override
@@ -436,7 +485,7 @@ public class AlfrescoCmisService extends AbstractCmisService
result.setObjects(list);
// get the children references
- NodeRef folderNodeRef = connector.getFolderNodeRef("Folder", folderId);
+ NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
// lucene part
QName PARAM_PARENT = QName.createQName(NamespaceService.CONTENT_MODEL_1_0_URI, "parent");
@@ -481,9 +530,10 @@ public class AlfrescoCmisService extends AbstractCmisService
for (int i = skip; i <= lastIndex; i++)
{
NodeRef child = childrenList.get(i);
+ CMISNodeInfo ni = createNodeInfo(child);
// create a child CMIS object
- ObjectData object = connector.createCMISObject(child, filter, includeAllowableActions,
+ ObjectData object = connector.createCMISObject(ni, filter, includeAllowableActions,
includeRelationships, renditionFilter, false, false);
ObjectInFolderDataImpl childData = new ObjectInFolderDataImpl();
@@ -523,7 +573,7 @@ public class AlfrescoCmisService extends AbstractCmisService
result.setObjects(list);
// get the children references
- NodeRef folderNodeRef = connector.getFolderNodeRef("Folder", folderId);
+ NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
// convert orderBy to sortProps
List> sortProps = null;
@@ -604,7 +654,8 @@ public class AlfrescoCmisService extends AbstractCmisService
try
{
// create a child CMIS object
- ObjectData object = connector.createCMISObject(child, filter, includeAllowableActions,
+ CMISNodeInfo ni = createNodeInfo(child.getNodeRef());
+ ObjectData object = connector.createCMISObject(ni, child, filter, includeAllowableActions,
includeRelationships, renditionFilter, false, false);
if (context.isObjectInfoRequired())
@@ -662,8 +713,9 @@ public class AlfrescoCmisService extends AbstractCmisService
List result = new ArrayList();
- getDescendantsTree(repositoryId, connector.getFolderNodeRef("Folder", folderId), depth.intValue(), filter,
- includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, false, result);
+ getDescendantsTree(repositoryId, getOrCreateFolderInfo(folderId, "Folder").getNodeRef(), depth.intValue(),
+ filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, false,
+ result);
return result;
}
@@ -677,8 +729,9 @@ public class AlfrescoCmisService extends AbstractCmisService
List result = new ArrayList();
- getDescendantsTree(repositoryId, connector.getFolderNodeRef("Folder", folderId), depth.intValue(), filter,
- includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, true, result);
+ getDescendantsTree(repositoryId, getOrCreateFolderInfo(folderId, "Folder").getNodeRef(), depth.intValue(),
+ filter, includeAllowableActions, includeRelationships, renditionFilter, includePathSegment, true,
+ result);
return result;
}
@@ -708,8 +761,9 @@ public class AlfrescoCmisService extends AbstractCmisService
// create a child CMIS object
ObjectInFolderDataImpl object = new ObjectInFolderDataImpl();
- object.setObject(connector.createCMISObject(child.getChildRef(), filter, includeAllowableActions,
- includeRelationships, renditionFilter, false, false));
+ CMISNodeInfo ni = createNodeInfo(child.getChildRef());
+ object.setObject(connector.createCMISObject(ni, filter, includeAllowableActions, includeRelationships,
+ renditionFilter, false, false));
if (context.isObjectInfoRequired())
{
getObjectInfo(repositoryId, object.getObject().getId());
@@ -747,23 +801,24 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// get the node ref
- NodeRef nodeRef = connector.getFolderNodeRef("Folder", folderId);
+ CMISNodeInfo info = getOrCreateFolderInfo(folderId, "Folder");
// the root folder has no parent
- if (nodeRef.equals(connector.getRootNodeRef()))
+ if (info.isRootFolder())
{
throw new CmisInvalidArgumentException("Root folder has no parent!");
}
// get the parent
- ChildAssociationRef parent = connector.getNodeService().getPrimaryParent(nodeRef);
+ ChildAssociationRef parent = connector.getNodeService().getPrimaryParent(info.getNodeRef());
if (parent == null)
{
throw new CmisRuntimeException("Folder has no parent and is not the root folder?!");
}
// create parent object
- ObjectData result = connector.createCMISObject(parent.getParentRef(), filter, false, IncludeRelationships.NONE,
+ CMISNodeInfo ni = createNodeInfo(parent.getParentRef());
+ ObjectData result = connector.createCMISObject(ni, filter, false, IncludeRelationships.NONE,
CMISConnector.RENDITION_NONE, false, false);
if (context.isObjectInfoRequired())
{
@@ -783,71 +838,64 @@ public class AlfrescoCmisService extends AbstractCmisService
List result = new ArrayList();
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- if (variant != ObjectVariantEnum.ASSOC)
+ // relationships are not filed
+ if (info.isRelationship())
{
- // versions are filed in the same folder -> cut off version suffix
- String currentVersionId = connector.getCurrentVersionId(objectId);
- NodeRef nodeRef = connector.getNodeRef(currentVersionId);
+ throw new CmisConstraintException("Relationships are not fileable!");
+ }
- TypeDefinitionWrapper type = connector.getType(nodeRef);
-
- if (type instanceof FolderTypeDefintionWrapper)
+ if (info.isFolder() && !info.isRootFolder())
+ {
+ ChildAssociationRef parent = connector.getNodeService().getPrimaryParent(info.getNodeRef());
+ if (parent != null)
{
- NodeRef rootNodeRef = connector.getRootNodeRef();
-
- if (!nodeRef.equals(rootNodeRef))
+ CMISNodeInfo ni = createNodeInfo(parent.getParentRef());
+ ObjectData object = connector.createCMISObject(ni, filter, includeAllowableActions,
+ includeRelationships, renditionFilter, false, false);
+ if (context.isObjectInfoRequired())
{
- ChildAssociationRef parent = connector.getNodeService().getPrimaryParent(nodeRef);
- if (parent != null)
- {
- ObjectData object = connector.createCMISObject(parent.getParentRef(), filter,
- includeAllowableActions, includeRelationships, renditionFilter, false, false);
- if (context.isObjectInfoRequired())
- {
- getObjectInfo(repositoryId, object.getId());
- }
-
- ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
- objectParent.setObject(object);
-
- // include relative path segment
- if (includeRelativePathSegment)
- {
- objectParent.setRelativePathSegment(connector.getName(nodeRef));
- }
-
- result.add(objectParent);
- }
+ getObjectInfo(repositoryId, object.getId());
}
- } else
- {
- List parents = connector.getNodeService().getParentAssocs(nodeRef,
- ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
- if (parents != null)
+
+ ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
+ objectParent.setObject(object);
+
+ // include relative path segment
+ if (includeRelativePathSegment)
{
- for (ChildAssociationRef parent : parents)
+ objectParent.setRelativePathSegment(info.getName());
+ }
+
+ result.add(objectParent);
+ }
+ } else if (info.isCurrentVersion() || info.isPWC())
+ {
+ List parents = connector.getNodeService().getParentAssocs(info.getNodeRef(),
+ ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL);
+ if (parents != null)
+ {
+ for (ChildAssociationRef parent : parents)
+ {
+ CMISNodeInfo ni = createNodeInfo(parent.getParentRef());
+ ObjectData object = connector.createCMISObject(ni, filter, includeAllowableActions,
+ includeRelationships, renditionFilter, false, false);
+ if (context.isObjectInfoRequired())
{
- ObjectData object = connector.createCMISObject(parent.getParentRef(), filter,
- includeAllowableActions, includeRelationships, renditionFilter, false, false);
- if (context.isObjectInfoRequired())
- {
- getObjectInfo(repositoryId, object.getId());
- }
-
- ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
- objectParent.setObject(object);
-
- // include relative path segment
- if (includeRelativePathSegment)
- {
- objectParent.setRelativePathSegment(connector.getName(nodeRef));
- }
-
- result.add(objectParent);
+ getObjectInfo(repositoryId, object.getId());
}
+
+ ObjectParentDataImpl objectParent = new ObjectParentDataImpl();
+ objectParent.setObject(object);
+
+ // include relative path segment
+ if (includeRelativePathSegment)
+ {
+ objectParent.setRelativePathSegment(info.getName());
+ }
+
+ result.add(objectParent);
}
}
}
@@ -933,14 +981,14 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// get the parent folder node ref
- final NodeRef parentNodeRef = connector.getFolderNodeRef("Parent folder", folderId);
+ final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Folder");
// get name and type
final String name = connector.getNameProperty(properties);
final String objectTypeId = connector.getObjectTypeIdProperty(properties);
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_FOLDER);
- connector.checkChildObjectType(parentNodeRef, type.getTypeId());
+ connector.checkChildObjectType(parentInfo, type.getTypeId());
// run transaction
endReadOnlyTransaction();
@@ -952,7 +1000,7 @@ public class AlfrescoCmisService extends AbstractCmisService
try
{
NodeRef nodeRef = connector.getFileFolderService()
- .create(parentNodeRef, name, type.getAlfrescoClass()).getNodeRef();
+ .create(parentInfo.getNodeRef(), name, type.getAlfrescoClass()).getNodeRef();
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME,
PropertyIds.OBJECT_TYPE_ID });
@@ -985,14 +1033,14 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// get the parent folder node ref
- final NodeRef parentNodeRef = connector.getFolderNodeRef("Parent folder", folderId);
+ final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Parent folder");
// get name and type
final String name = connector.getNameProperty(properties);
final String objectTypeId = connector.getObjectTypeIdProperty(properties);
final TypeDefinitionWrapper type = connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_DOCUMENT);
- connector.checkChildObjectType(parentNodeRef, type.getTypeId());
+ connector.checkChildObjectType(parentInfo, type.getTypeId());
DocumentTypeDefinition docType = (DocumentTypeDefinition) type.getTypeDefinition(false);
@@ -1030,7 +1078,7 @@ public class AlfrescoCmisService extends AbstractCmisService
try
{
NodeRef nodeRef = connector.getFileFolderService()
- .create(parentNodeRef, name, type.getAlfrescoClass()).getNodeRef();
+ .create(parentInfo.getNodeRef(), name, type.getAlfrescoClass()).getNodeRef();
connector.setProperties(nodeRef, type, properties, new String[] { PropertyIds.NAME,
PropertyIds.OBJECT_TYPE_ID });
@@ -1080,30 +1128,28 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// get the parent folder node ref
- final NodeRef parentNodeRef = connector.getFolderNodeRef("Parent folder", folderId);
+ final CMISNodeInfo parentInfo = getOrCreateFolderInfo(folderId, "Parent folder");
// get name and type
final String name = connector.getNameProperty(properties);
// get source
- ObjectVariantEnum variant = connector.getObjectVariant(sourceId);
- connector.throwCommonExceptions(variant, "Source", sourceId);
+ CMISNodeInfo info = getOrCreateNodeInfo(sourceId, "Source");
// check source
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisConstraintException("Source object is not a document!");
}
- final NodeRef sourceNodeRef = connector.getNodeRef(sourceId);
- final TypeDefinitionWrapper type = connector.getAndCheckType(sourceNodeRef);
-
- if (!(type instanceof DocumentTypeDefinitionWrapper))
+ final NodeRef sourceNodeRef = info.getNodeRef();
+ if (!info.isDocument())
{
throw new CmisConstraintException("Source object is not a document!");
}
- connector.checkChildObjectType(parentNodeRef, type.getTypeId());
+ final TypeDefinitionWrapper type = info.getType();
+ connector.checkChildObjectType(parentInfo, type.getTypeId());
// run transaction
endReadOnlyTransaction();
@@ -1115,7 +1161,7 @@ public class AlfrescoCmisService extends AbstractCmisService
try
{
NodeRef newDocumentNodeRef = connector.getFileFolderService()
- .copy(sourceNodeRef, parentNodeRef, name).getNodeRef();
+ .copy(sourceNodeRef, parentInfo.getNodeRef(), name).getNodeRef();
connector.setProperties(newDocumentNodeRef, type, properties, new String[] {
PropertyIds.NAME, PropertyIds.OBJECT_TYPE_ID });
@@ -1147,8 +1193,8 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- // get the parent folder node ref
- connector.getFolderNodeRef("Parent folder", folderId);
+ // get the parent folder
+ getOrCreateFolderInfo(folderId, "Parent Folder");
String objectTypeId = connector.getObjectTypeIdProperty(properties);
connector.getTypeForCreate(objectTypeId, BaseTypeId.CMIS_POLICY);
@@ -1169,27 +1215,26 @@ public class AlfrescoCmisService extends AbstractCmisService
// get source object
String sourceId = connector.getSourceIdProperty(properties);
- ObjectVariantEnum sourceVariant = connector.getObjectVariant(sourceId);
- connector.throwCommonExceptions(sourceVariant, "Source", sourceId);
+ CMISNodeInfo sourceInfo = getOrCreateNodeInfo(sourceId, "Source");
- if (sourceVariant != ObjectVariantEnum.NODE)
+ if (!sourceInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !sourceInfo.isVariant(CMISObjectVariant.FOLDER))
{
- throw new CmisInvalidArgumentException("Source is not a document or folder object!");
+ throw new CmisInvalidArgumentException("Source is not the latest version of a document or a folder object!");
}
- final NodeRef sourceNodeRef = connector.getNodeRefIfCurrent("Source", sourceId);
+ final NodeRef sourceNodeRef = sourceInfo.getNodeRef();
// get target object
String targetId = connector.getTargetIdProperty(properties);
- ObjectVariantEnum targetVariant = connector.getObjectVariant(targetId);
- connector.throwCommonExceptions(targetVariant, "Target", sourceId);
+ CMISNodeInfo targetInfo = getOrCreateNodeInfo(targetId, "Target");
- if (targetVariant != ObjectVariantEnum.NODE)
+ if (!targetInfo.isVariant(CMISObjectVariant.CURRENT_VERSION) && !targetInfo.isVariant(CMISObjectVariant.FOLDER))
{
- throw new CmisInvalidArgumentException("Target is not a document or folder object!");
+ throw new CmisInvalidArgumentException(
+ "Target is not the latest version of a document or a folder object!!");
}
- final NodeRef targetNodeRef = connector.getNodeRefIfCurrent("Target", targetId);
+ final NodeRef targetNodeRef = targetInfo.getNodeRef();
// check policies and ACLs
if ((policies != null) && (!policies.isEmpty()))
@@ -1238,23 +1283,16 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- ObjectVariantEnum variant = connector.getObjectVariant(objectId.getValue());
- connector.throwCommonExceptions(variant, "Object", objectId.getValue());
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
- if (variant == ObjectVariantEnum.ASSOC)
+ if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
{
- throw new CmisStreamNotSupportedException("Relationships don't support content!");
+ throw new CmisStreamNotSupportedException("Content can only be set ondocuments!");
}
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId.getValue());
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ final NodeRef nodeRef = info.getNodeRef();
- if (!(type instanceof DocumentTypeDefinitionWrapper))
- {
- throw new CmisStreamNotSupportedException("Object type doesn't support content!");
- }
-
- if (((DocumentTypeDefinition) type.getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
+ if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.NOTALLOWED)
{
throw new CmisStreamNotSupportedException("Document type doesn't allow content!");
}
@@ -1312,23 +1350,16 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- ObjectVariantEnum variant = connector.getObjectVariant(objectId.getValue());
- connector.throwCommonExceptions(variant, "Object", objectId.getValue());
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
- if (variant == ObjectVariantEnum.ASSOC)
+ if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION) && !info.isVariant(CMISObjectVariant.PWC))
{
- throw new CmisStreamNotSupportedException("Relationships don't support content!");
+ throw new CmisStreamNotSupportedException("Content can only be deleted from ondocuments!");
}
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId.getValue());
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ final NodeRef nodeRef = info.getNodeRef();
- if (!(type instanceof DocumentTypeDefinitionWrapper))
- {
- throw new CmisStreamNotSupportedException("Object type doesn't support content!");
- }
-
- if (((DocumentTypeDefinition) type.getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.REQUIRED)
+ if (((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).getContentStreamAllowed() == ContentStreamAllowed.REQUIRED)
{
throw new CmisInvalidArgumentException("Document type requires content!");
}
@@ -1364,15 +1395,13 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// get object and source and target parent
- ObjectVariantEnum variant = connector.getObjectVariant(objectId.getValue());
- connector.throwCommonExceptions(variant, "Object", objectId.getValue());
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId.getValue());
- final NodeRef sourceNodeRef = connector.getFolderNodeRef("Source folder", sourceFolderId);
- final NodeRef targetNodeRef = connector.getFolderNodeRef("Target folder", targetFolderId);
+ final NodeRef nodeRef = info.getCurrentNodeNodeRef();
+ final CMISNodeInfo sourceInfo = getOrCreateFolderInfo(sourceFolderId, "Source Folder");
+ final CMISNodeInfo targetInfo = getOrCreateFolderInfo(targetFolderId, "Target Folder");
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
- connector.checkChildObjectType(targetNodeRef, type.getTypeId());
+ connector.checkChildObjectType(targetInfo, info.getType().getTypeId());
endReadOnlyTransaction();
connector.getTransactionService().getRetryingTransactionHelper()
@@ -1384,9 +1413,9 @@ public class AlfrescoCmisService extends AbstractCmisService
{
ChildAssociationRef primaryParentRef = connector.getNodeService().getPrimaryParent(nodeRef);
// if this is a primary child node, move it
- if (primaryParentRef.getParentRef().equals(sourceNodeRef))
+ if (primaryParentRef.getParentRef().equals(sourceInfo.getNodeRef()))
{
- connector.getNodeService().moveNode(nodeRef, targetNodeRef,
+ connector.getNodeService().moveNode(nodeRef, targetInfo.getNodeRef(),
primaryParentRef.getTypeQName(), primaryParentRef.getQName());
} else
{
@@ -1394,10 +1423,10 @@ public class AlfrescoCmisService extends AbstractCmisService
for (ChildAssociationRef parent : connector.getNodeService().getParentAssocs(nodeRef,
ContentModel.ASSOC_CONTAINS, RegexQNamePattern.MATCH_ALL))
{
- if (parent.getParentRef().equals(sourceNodeRef))
+ if (parent.getParentRef().equals(sourceInfo.getNodeRef()))
{
connector.getNodeService().removeChildAssociation(parent);
- connector.getNodeService().addChild(targetNodeRef, nodeRef,
+ connector.getNodeService().addChild(targetInfo.getNodeRef(), nodeRef,
ContentModel.ASSOC_CONTAINS, parent.getQName());
return null;
}
@@ -1425,16 +1454,19 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- final ObjectVariantEnum variant = connector.getObjectVariant(objectId.getValue());
- connector.throwCommonExceptions(variant, "Object", objectId.getValue());
+ final CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisInvalidArgumentException("Relationship properties cannot be updated!");
} else
{
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId.getValue());
- final TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ if (info.isVariant(CMISObjectVariant.VERSION))
+ {
+ throw new CmisInvalidArgumentException("Document is not the latest version!");
+ }
+
+ final NodeRef nodeRef = info.getNodeRef();
// run transaction
endReadOnlyTransaction();
@@ -1445,7 +1477,7 @@ public class AlfrescoCmisService extends AbstractCmisService
{
try
{
- connector.setProperties(nodeRef, type, properties, new String[0]);
+ connector.setProperties(nodeRef, info.getType(), properties, new String[0]);
return null;
} catch (IntegrityException ie)
{
@@ -1475,8 +1507,7 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- final ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ final CMISNodeInfoImpl info = getOrCreateNodeInfo(objectId, "Object");
// run transaction
endReadOnlyTransaction();
@@ -1488,27 +1519,25 @@ public class AlfrescoCmisService extends AbstractCmisService
try
{
// handle relationships
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
- AssociationRef assocRef = connector.getAssociationRef(objectId);
+ AssociationRef assocRef = info.getAssociationRef();
connector.getNodeService().removeAssociation(assocRef.getSourceRef(),
assocRef.getTargetRef(), assocRef.getTypeQName());
return true;
}
- NodeRef nodeRef = connector.getNodeRef(objectId);
+ NodeRef nodeRef = info.getNodeRef();
// handle PWC
- if (variant == ObjectVariantEnum.PWC)
+ if (info.isVariant(CMISObjectVariant.PWC))
{
connector.getCheckOutCheckInService().cancelCheckout(nodeRef);
return true;
}
- TypeDefinitionWrapper type = connector.getType(nodeRef);
-
// handle folders
- if (type instanceof FolderTypeDefintionWrapper)
+ if (info.isFolder())
{
if (connector.getNodeService().getChildAssocs(nodeRef).size() > 0)
{
@@ -1528,16 +1557,16 @@ public class AlfrescoCmisService extends AbstractCmisService
{
connector.getCheckOutCheckInService().cancelCheckout(workingCopy);
}
- } else if (variant == ObjectVariantEnum.VERSION)
+ } else if (info.isVariant(CMISObjectVariant.VERSION))
{
- Version version = connector.getVersion(objectId);
+ Version version = info.getVersion();
connector.getVersionService().deleteVersion(nodeRef, version);
return true;
}
- if (variant == ObjectVariantEnum.VERSION)
+ if (info.isVariant(CMISObjectVariant.VERSION))
{
- nodeRef = connector.getNodeRef(connector.getCurrentVersionId(objectId));
+ nodeRef = info.getCurrentNodeNodeRef();
}
// remove not primary parent associations
@@ -1582,7 +1611,7 @@ public class AlfrescoCmisService extends AbstractCmisService
throw new CmisInvalidArgumentException("Unfiling not supported!");
}
- final NodeRef folderNodeRef = connector.getFolderNodeRef("Folder", folderId);
+ final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
final FailedToDeleteDataImpl result = new FailedToDeleteDataImpl();
// run transaction
@@ -1655,21 +1684,11 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// create a CMIS object
- if (variant == ObjectVariantEnum.ASSOC)
- {
- AssociationRef assocRef = connector.getAssociationRef(objectId);
- return connector.createCMISObject(assocRef, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeAcl);
- } else
- {
- NodeRef nodeRef = connector.getNodeRef(objectId);
- return connector.createCMISObject(nodeRef, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeAcl);
- }
+ return connector.createCMISObject(info, filter, includeAllowableActions, includeRelationships, renditionFilter,
+ includePolicyIds, includeAcl);
}
@Override
@@ -1681,28 +1700,26 @@ public class AlfrescoCmisService extends AbstractCmisService
// start at the root node
NodeRef rootNodeRef = connector.getRootNodeRef();
- NodeRef nodeRef = null;
if (path.equals("/"))
{
- nodeRef = rootNodeRef;
+ return connector.createCMISObject(createNodeInfo(rootNodeRef), filter, includeAllowableActions,
+ includeRelationships, renditionFilter, includePolicyIds, includeAcl);
} else
{
try
{
// resolve path and get the node ref
- FileInfo info = connector.getFileFolderService().resolveNamePath(rootNodeRef,
+ FileInfo fileInfo = connector.getFileFolderService().resolveNamePath(rootNodeRef,
Arrays.asList(path.substring(1).split("/")));
- nodeRef = info.getNodeRef();
+
+ return connector.createCMISObject(createNodeInfo(fileInfo.getNodeRef()), fileInfo, filter,
+ includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl);
} catch (FileNotFoundException e)
{
throw new CmisObjectNotFoundException("Object not found: " + path);
}
}
-
- // create the CMIS object
- return connector.createCMISObject(nodeRef, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeAcl);
}
@Override
@@ -1711,25 +1728,14 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
- AssociationRef assocRef = connector.getAssociationRef(objectId);
- TypeDefinitionWrapper type = connector.getType(assocRef);
- if (type == null)
- {
- throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
- }
-
- return connector.getAssocProperties(assocRef, filter, type);
+ return connector.getAssocProperties(info, filter);
} else
{
- NodeRef nodeRef = connector.getNodeRef(objectId);
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
-
- return connector.getNodeProperties(nodeRef, filter, type);
+ return connector.getNodeProperties(info, filter);
}
}
@@ -1739,30 +1745,9 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- TypeDefinitionWrapper type = null;
- EntityRef ref = null;
-
- if (variant == ObjectVariantEnum.ASSOC)
- {
- AssociationRef assocRef = connector.getAssociationRef(objectId);
- type = connector.getType(assocRef);
- ref = assocRef;
- } else
- {
- NodeRef nodeRef = connector.getNodeRef(objectId);
- type = connector.getType(nodeRef);
- ref = nodeRef;
- }
-
- if (type == null)
- {
- throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
- }
-
- return connector.getAllowableActions(type, ref);
+ return connector.getAllowableActions(info);
}
@Override
@@ -1772,18 +1757,16 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfoImpl info = getOrCreateNodeInfo(objectId, "Object");
// relationships cannot have content
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisInvalidArgumentException("Object is a relationship and cannot have content!");
}
// now get it
- NodeRef nodeRef = connector.getNodeRef(objectId);
- return connector.getContentStream(nodeRef, streamId, offset, length);
+ return connector.getContentStream(info, streamId, offset, length);
}
@Override
@@ -1793,16 +1776,14 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
return Collections.emptyList();
} else
{
- NodeRef nodeRef = connector.getNodeRef(objectId);
- return connector.getRendtions(nodeRef, renditionFilter, maxItems, skipCount);
+ return connector.getRendtions(info.getNodeRef(), renditionFilter, maxItems, skipCount);
}
}
@@ -1814,24 +1795,18 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- ObjectVariantEnum variant = connector.getObjectVariant(objectId.getValue());
- connector.throwCommonExceptions(variant, "Object", objectId.getValue());
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
- // relationships cannot be checked out
- if (variant == ObjectVariantEnum.ASSOC)
+ // check for current version
+ if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION))
{
- throw new CmisInvalidArgumentException("Unable to check-out a relationship!");
+ throw new CmisInvalidArgumentException("Only documents can be checked out!");
}
// get object
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Document", objectId.getValue());
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
- if (!(type instanceof DocumentTypeDefinitionWrapper))
- {
- throw new CmisInvalidArgumentException("Object is not a document!");
- }
+ final NodeRef nodeRef = info.getNodeRef();
- if (!((DocumentTypeDefinition) type.getTypeDefinition(false)).isVersionable())
+ if (!((DocumentTypeDefinition) info.getType().getTypeDefinition(false)).isVersionable())
{
throw new CmisConstraintException("Document is not versionable!");
}
@@ -1870,17 +1845,16 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// only accept a PWC
- if (variant != ObjectVariantEnum.PWC)
+ if (info.isVariant(CMISObjectVariant.PWC))
{
throw new CmisVersioningException("Object is not a PWC!");
}
// get object
- final NodeRef nodeRef = connector.getNodeRef(objectId);
+ final NodeRef nodeRef = info.getNodeRef();
// cancel check out
endReadOnlyTransaction();
@@ -1913,18 +1887,17 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- ObjectVariantEnum variant = connector.getObjectVariant(objectId.getValue());
- connector.throwCommonExceptions(variant, "Object", objectId.getValue());
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId.getValue(), "Object");
// only accept a PWC
- if (variant != ObjectVariantEnum.PWC)
+ if (!info.isVariant(CMISObjectVariant.PWC))
{
throw new CmisVersioningException("Object is not a PWC!");
}
// get object
- final NodeRef nodeRef = connector.getNodeRef(objectId.getValue());
- final TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ final NodeRef nodeRef = info.getNodeRef();
+ final TypeDefinitionWrapper type = info.getType();
// copy stream to temp file
final File tempFile = copyToTempFile(contentStream);
@@ -2025,46 +1998,39 @@ public class AlfrescoCmisService extends AbstractCmisService
List result = new ArrayList();
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(versionSeriesId);
- connector.throwCommonExceptions(variant, "Version Series", versionSeriesId);
+ CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
- if (variant == ObjectVariantEnum.ASSOC)
- {
- // the relationship history is always empty
- return result;
- }
-
- if (variant != ObjectVariantEnum.NODE)
+ if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION))
{
// the version series id is the id of current version, which is a
- // node
+ // document
throw new CmisInvalidArgumentException("Version Series does not exist!");
}
// get current version and it's history
- NodeRef nodeRef = connector.getNodeRef(versionSeriesId);
+ NodeRef nodeRef = info.getNodeRef();
VersionHistory versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
if (versionHistory == null)
{
// add current version
- result.add(connector.createCMISObject(nodeRef, filter, includeAllowableActions, IncludeRelationships.NONE,
+ result.add(connector.createCMISObject(info, filter, includeAllowableActions, IncludeRelationships.NONE,
CMISConnector.RENDITION_NONE, false, false));
} else
{
NodeRef pwcNodeRef = connector.getCheckOutCheckInService().getWorkingCopy(nodeRef);
if (pwcNodeRef != null)
{
- result.add(connector.createCMISObject(pwcNodeRef, filter, includeAllowableActions,
+ result.add(connector.createCMISObject(createNodeInfo(pwcNodeRef), filter, includeAllowableActions,
IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false));
}
// convert the version history
for (Version version : versionHistory.getAllVersions())
{
- result.add(connector.createCMISObject(version.getFrozenStateNodeRef(), filter, includeAllowableActions,
- IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false));
+ result.add(connector.createCMISObject(createNodeInfo(version.getFrozenStateNodeRef()), filter,
+ includeAllowableActions, IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false));
}
}
@@ -2085,21 +2051,10 @@ public class AlfrescoCmisService extends AbstractCmisService
}
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(versionSeriesId);
- connector.throwCommonExceptions(variant, "Version series", versionSeriesId);
+ CMISNodeInfoImpl info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
- // create a CMIS object
- if (variant == ObjectVariantEnum.ASSOC)
- {
- AssociationRef assocRef = connector.getAssociationRef(versionSeriesId);
- return connector.createCMISObject(assocRef, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeAcl);
- } else
- {
- NodeRef nodeRef = connector.getLatestVersionNodeRef(versionSeriesId, major);
- return connector.createCMISObject(nodeRef, filter, includeAllowableActions, includeRelationships,
- renditionFilter, includePolicyIds, includeAcl);
- }
+ return connector.createCMISObject(createNodeInfo(info.getLatestVersionNodeRef(major)), filter,
+ includeAllowableActions, includeRelationships, renditionFilter, includePolicyIds, includeAcl);
}
@Override
@@ -2115,25 +2070,14 @@ public class AlfrescoCmisService extends AbstractCmisService
}
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(versionSeriesId);
- connector.throwCommonExceptions(variant, "Version series", versionSeriesId);
+ CMISNodeInfoImpl info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
- AssociationRef assocRef = connector.getAssociationRef(versionSeriesId);
- TypeDefinitionWrapper type = connector.getType(assocRef);
- if (type == null)
- {
- throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
- }
-
- return connector.getAssocProperties(assocRef, filter, type);
+ return connector.getAssocProperties(info, filter);
} else
{
- NodeRef nodeRef = connector.getLatestVersionNodeRef(versionSeriesId, major);
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
-
- return connector.getNodeProperties(nodeRef, filter, type);
+ return connector.getNodeProperties(createNodeInfo(info.getLatestVersionNodeRef(major)), filter);
}
}
@@ -2151,26 +2095,19 @@ public class AlfrescoCmisService extends AbstractCmisService
}
// get node ref
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- if (variant != ObjectVariantEnum.NODE)
- {
- throw new CmisInvalidArgumentException("Object is not a current version of a document!");
- }
-
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
-
- if (!(type instanceof DocumentTypeDefinitionWrapper))
+ if (!info.isDocument())
{
throw new CmisInvalidArgumentException("Object is not a document!");
}
- // get the folder node ref
- final NodeRef folderNodeRef = connector.getFolderNodeRef("Folder", folderId);
+ final NodeRef nodeRef = info.getNodeRef();
- connector.checkChildObjectType(folderNodeRef, type.getTypeId());
+ // get the folder node ref
+ final CMISNodeInfo folderInfo = getOrCreateFolderInfo(folderId, "Folder");
+
+ connector.checkChildObjectType(folderInfo, info.getType().getTypeId());
final QName name = QName.createQName(
NamespaceService.CONTENT_MODEL_1_0_URI,
@@ -2185,8 +2122,8 @@ public class AlfrescoCmisService extends AbstractCmisService
{
try
{
- connector.getNodeService().addChild(folderNodeRef, nodeRef, ContentModel.ASSOC_CONTAINS,
- name);
+ connector.getNodeService().addChild(folderInfo.getNodeRef(), nodeRef,
+ ContentModel.ASSOC_CONTAINS, name);
return null;
} catch (IntegrityException ie)
{
@@ -2206,24 +2143,17 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// get node ref
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- if (variant != ObjectVariantEnum.NODE)
- {
- throw new CmisInvalidArgumentException("Object is not a current version of a document!");
- }
-
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
-
- if (!(type instanceof DocumentTypeDefinitionWrapper))
+ if (!info.isDocument())
{
throw new CmisInvalidArgumentException("Object is not a document!");
}
+ final NodeRef nodeRef = info.getNodeRef();
+
// get the folder node ref
- final NodeRef folderNodeRef = connector.getFolderNodeRef("Folder", folderId);
+ final NodeRef folderNodeRef = getOrCreateFolderInfo(folderId, "Folder").getNodeRef();
// check primary parent
if (connector.getNodeService().getPrimaryParent(nodeRef).getParentRef().equals(folderNodeRef))
@@ -2291,15 +2221,18 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- // create a CMIS object
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisInvalidArgumentException("Object is a relationship!");
}
+ if (info.isVariant(CMISObjectVariant.VERSION))
+ {
+ throw new CmisInvalidArgumentException("Object is a document version!");
+ }
+
// check if the relationship base type is requested
if (BaseTypeId.CMIS_RELATIONSHIP.value().equals(typeId))
{
@@ -2321,8 +2254,7 @@ public class AlfrescoCmisService extends AbstractCmisService
}
}
- NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
- return connector.getObjectRelationships(nodeRef, relationshipDirection, typeId, filter,
+ return connector.getObjectRelationships(info.getNodeRef(), relationshipDirection, typeId, filter,
includeAllowableActions, maxItems, skipCount);
}
@@ -2334,13 +2266,15 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
- TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ TypeDefinitionWrapper type = info.getType();
+ if (type == null)
+ {
+ throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
+ }
- connector.applyPolicies(nodeRef, type, Collections.singletonList(policyId));
+ connector.applyPolicies(info.getNodeRef(), type, Collections.singletonList(policyId));
}
@Override
@@ -2349,11 +2283,13 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
- NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
- connector.getAndCheckType(nodeRef);
+ TypeDefinitionWrapper type = info.getType();
+ if (type == null)
+ {
+ throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
+ }
throw new CmisConstraintException("Object is not policy controllable!");
}
@@ -2365,11 +2301,7 @@ public class AlfrescoCmisService extends AbstractCmisService
checkRepositoryId(repositoryId);
// what kind of object is it?
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
-
- NodeRef nodeRef = connector.getNodeRef(objectId);
- connector.getAndCheckType(nodeRef);
+ getOrCreateNodeInfo(objectId, "Object");
// policies are not supported -> return empty list
return Collections.emptyList();
@@ -2388,17 +2320,16 @@ public class AlfrescoCmisService extends AbstractCmisService
throw new CmisInvalidArgumentException("ACL propagation 'objectonly' is not supported!");
}
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisConstraintException("Relationships are not ACL controllable!");
}
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object id", objectId);
- final TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ final NodeRef nodeRef = info.getCurrentNodeNodeRef();
+ final TypeDefinitionWrapper type = info.getType();
endReadOnlyTransaction();
connector.getTransactionService().getRetryingTransactionHelper()
@@ -2434,17 +2365,16 @@ public class AlfrescoCmisService extends AbstractCmisService
throw new CmisInvalidArgumentException("ACL propagation 'objectonly' is not supported!");
}
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
throw new CmisConstraintException("Relationships are not ACL controllable!");
}
- final NodeRef nodeRef = connector.getNodeRefIfCurrent("Object", objectId);
- final TypeDefinitionWrapper type = connector.getAndCheckType(nodeRef);
+ final NodeRef nodeRef = info.getCurrentNodeNodeRef();
+ final TypeDefinitionWrapper type = info.getType();
endReadOnlyTransaction();
connector.getTransactionService().getRetryingTransactionHelper()
@@ -2476,19 +2406,16 @@ public class AlfrescoCmisService extends AbstractCmisService
{
checkRepositoryId(repositoryId);
- ObjectVariantEnum variant = connector.getObjectVariant(objectId);
- connector.throwCommonExceptions(variant, "Object", objectId);
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId, "Object");
// relationships don't have ACLs
- if (variant == ObjectVariantEnum.ASSOC)
+ if (info.isVariant(CMISObjectVariant.ASSOC))
{
return new AccessControlListImpl(Collections.EMPTY_LIST);
}
// get the ACL
- String currentVersionId = connector.getCurrentVersionId(objectId);
- NodeRef nodeRef = connector.getNodeRef(currentVersionId);
- return connector.getACL(nodeRef, onlyBasicPermissions);
+ return connector.getACL(info.getCurrentNodeNodeRef(), onlyBasicPermissions);
}
// --------------------------------------------------------
@@ -2498,6 +2425,7 @@ public class AlfrescoCmisService extends AbstractCmisService
*
* (Provided by OpenCMIS, but optimized for Alfresco.)
*/
+ @Override
protected ObjectInfo getObjectInfoIntern(String repositoryId, ObjectData object)
{
// if the object has no properties, stop here
@@ -2506,6 +2434,8 @@ public class AlfrescoCmisService extends AbstractCmisService
throw new CmisRuntimeException("No properties!");
}
+ CMISNodeInfo ni = getOrCreateNodeInfo(object.getId());
+
ObjectInfoImpl info = new ObjectInfoImpl();
// general properties
@@ -2518,14 +2448,13 @@ public class AlfrescoCmisService extends AbstractCmisService
info.setTypeId(getIdProperty(object, PropertyIds.OBJECT_TYPE_ID));
info.setBaseType(object.getBaseTypeId());
- if (object.getBaseTypeId() == BaseTypeId.CMIS_RELATIONSHIP)
+ if (ni.isRelationship())
{
// versioning
- info.setIsCurrentVersion(false);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
- info.setVersionSeriesId(getIdProperty(object, PropertyIds.VERSION_SERIES_ID));
+ info.setVersionSeriesId(null);
info.setIsCurrentVersion(true);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
@@ -2553,83 +2482,24 @@ public class AlfrescoCmisService extends AbstractCmisService
info.setHasAcl(false);
info.setSupportsDescendants(false);
info.setSupportsFolderTree(false);
- } else
+ } else if (ni.isFolder())
{
// versioning
- info.setIsCurrentVersion(object.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT);
info.setWorkingCopyId(null);
info.setWorkingCopyOriginalId(null);
+
info.setVersionSeriesId(null);
-
- if (object.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT)
- {
- info.setVersionSeriesId(getIdProperty(object, PropertyIds.VERSION_SERIES_ID));
- if (info.getVersionSeriesId() != null)
- {
- String versionLabel = getStringProperty(object, PropertyIds.VERSION_LABEL);
- if (CMISConnector.PWC_VERSION_LABEL.equals(versionLabel))
- {
- info.setIsCurrentVersion(false);
- info.setWorkingCopyId(object.getId());
-
- // get latest version
- List versions = getAllVersions(repositoryId, null, info.getVersionSeriesId(), null,
- Boolean.FALSE, null);
- if (versions != null && versions.size() > 0)
- {
- info.setWorkingCopyOriginalId(versions.get(0).getId());
- }
- } else
- {
- Boolean isLatest = getBooleanProperty(object, PropertyIds.IS_LATEST_VERSION);
- info.setIsCurrentVersion(isLatest == null ? true : isLatest.booleanValue());
-
- Boolean isCheckedOut = getBooleanProperty(object, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
- if (isCheckedOut != null && isCheckedOut.booleanValue())
- {
- info.setWorkingCopyId(getIdProperty(object, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID));
-
- // get latest version
- List versions = getAllVersions(repositoryId, object.getId(),
- info.getVersionSeriesId(), null, Boolean.FALSE, null);
- if (versions != null && versions.size() > 0)
- {
- info.setWorkingCopyOriginalId(versions.get(0).getId());
- }
- }
- }
- }
- }
+ info.setIsCurrentVersion(true);
+ info.setWorkingCopyId(null);
+ info.setWorkingCopyOriginalId(null);
// content
info.setHasContent(false);
info.setContentType(null);
info.setFileName(null);
- if (object.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT)
- {
- String fileName = getStringProperty(object, PropertyIds.CONTENT_STREAM_FILE_NAME);
- String mimeType = getStringProperty(object, PropertyIds.CONTENT_STREAM_MIME_TYPE);
- String streamId = getIdProperty(object, PropertyIds.CONTENT_STREAM_ID);
- BigInteger length = getIntegerProperty(object, PropertyIds.CONTENT_STREAM_LENGTH);
- boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
- if (hasContent)
- {
- info.setHasContent(hasContent);
- info.setContentType(mimeType);
- info.setFileName(fileName);
- }
- }
-
// parent
- info.setHasParent(true);
-
- if (object.getBaseTypeId() == BaseTypeId.CMIS_FOLDER)
- {
- List parents = getObjectParents(repositoryId, object.getId(), null, Boolean.FALSE,
- IncludeRelationships.NONE, "cmis:none", Boolean.FALSE, null);
- info.setHasParent(parents.size() > 0);
- }
+ info.setHasParent(!connector.getRootNodeRef().equals(object.getId()));
// policies and relationships
info.setSupportsRelationships(true);
@@ -2638,57 +2508,89 @@ public class AlfrescoCmisService extends AbstractCmisService
// renditions
info.setRenditionInfos(null);
- if (object.getBaseTypeId() == BaseTypeId.CMIS_DOCUMENT)
+ // relationships
+ setRelaionshipsToObjectInfo(object, info);
+
+ // global settings
+ info.setHasAcl(true);
+ info.setSupportsDescendants(true);
+ info.setSupportsFolderTree(true);
+ } else if (ni.isDocument())
+ {
+ // versioning
+ info.setWorkingCopyId(null);
+ info.setWorkingCopyOriginalId(null);
+
+ info.setVersionSeriesId(getIdProperty(object, PropertyIds.VERSION_SERIES_ID));
+
+ if (ni.isVariant(CMISObjectVariant.PWC))
{
- List renditions = object.getRenditions();
- if (renditions != null && renditions.size() > 0)
+ info.setIsCurrentVersion(false);
+ info.setWorkingCopyId(object.getId());
+ info.setWorkingCopyOriginalId(ni.getCurrentObjectId());
+ } else
+ {
+ info.setIsCurrentVersion(ni.isCurrentVersion());
+
+ Boolean isCheckedOut = getBooleanProperty(object, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+ if (Boolean.TRUE.equals(isCheckedOut))
{
- List renditionInfos = new ArrayList();
- for (RenditionData rendition : renditions)
- {
- RenditionInfoImpl renditionInfo = new RenditionInfoImpl();
- renditionInfo.setId(rendition.getStreamId());
- renditionInfo.setKind(rendition.getKind());
- renditionInfo.setContentType(rendition.getMimeType());
- renditionInfo.setTitle(rendition.getTitle());
- renditionInfo.setLength(rendition.getBigLength());
- renditionInfos.add(renditionInfo);
- }
- info.setRenditionInfos(renditionInfos);
+ info.setWorkingCopyId(getIdProperty(object, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID));
+ info.setWorkingCopyOriginalId(ni.getCurrentObjectId());
+ } else
+ {
+ info.setWorkingCopyId(null);
+ info.setWorkingCopyOriginalId(null);
}
}
- // relationships
- info.setRelationshipSourceIds(null);
- info.setRelationshipTargetIds(null);
- List relationships = object.getRelationships();
- if (relationships != null && relationships.size() > 0)
+ // content
+ String fileName = getStringProperty(object, PropertyIds.CONTENT_STREAM_FILE_NAME);
+ String mimeType = getStringProperty(object, PropertyIds.CONTENT_STREAM_MIME_TYPE);
+ String streamId = getIdProperty(object, PropertyIds.CONTENT_STREAM_ID);
+ BigInteger length = getIntegerProperty(object, PropertyIds.CONTENT_STREAM_LENGTH);
+ boolean hasContent = fileName != null || mimeType != null || streamId != null || length != null;
+ if (hasContent)
{
- List sourceIds = new ArrayList();
- List targetIds = new ArrayList();
- for (ObjectData relationship : relationships)
- {
- String sourceId = getIdProperty(relationship, PropertyIds.SOURCE_ID);
- String targetId = getIdProperty(relationship, PropertyIds.TARGET_ID);
- if (object.getId().equals(sourceId))
- {
- sourceIds.add(relationship.getId());
- }
- if (object.getId().equals(targetId))
- {
- targetIds.add(relationship.getId());
- }
- }
- if (sourceIds.size() > 0)
- {
- info.setRelationshipSourceIds(sourceIds);
- }
- if (targetIds.size() > 0)
- {
- info.setRelationshipTargetIds(targetIds);
- }
+ info.setHasContent(hasContent);
+ info.setContentType(mimeType);
+ info.setFileName(fileName);
+ } else
+ {
+ info.setHasContent(false);
+ info.setContentType(null);
+ info.setFileName(null);
}
+ // parent
+ info.setHasParent(true);
+
+ // policies and relationships
+ info.setSupportsRelationships(true);
+ info.setSupportsPolicies(true);
+
+ // renditions
+ info.setRenditionInfos(null);
+ List renditions = object.getRenditions();
+ if (renditions != null && renditions.size() > 0)
+ {
+ List renditionInfos = new ArrayList();
+ for (RenditionData rendition : renditions)
+ {
+ RenditionInfoImpl renditionInfo = new RenditionInfoImpl();
+ renditionInfo.setId(rendition.getStreamId());
+ renditionInfo.setKind(rendition.getKind());
+ renditionInfo.setContentType(rendition.getMimeType());
+ renditionInfo.setTitle(rendition.getTitle());
+ renditionInfo.setLength(rendition.getBigLength());
+ renditionInfos.add(renditionInfo);
+ }
+ info.setRenditionInfos(renditionInfos);
+ }
+
+ // relationships
+ setRelaionshipsToObjectInfo(object, info);
+
// global settings
info.setHasAcl(true);
info.setSupportsDescendants(true);
@@ -2698,6 +2600,40 @@ public class AlfrescoCmisService extends AbstractCmisService
return info;
}
+ private void setRelaionshipsToObjectInfo(ObjectData object, ObjectInfoImpl info)
+ {
+ info.setRelationshipSourceIds(null);
+ info.setRelationshipTargetIds(null);
+
+ List relationships = object.getRelationships();
+ if (relationships != null && relationships.size() > 0)
+ {
+ List sourceIds = new ArrayList();
+ List targetIds = new ArrayList();
+ for (ObjectData relationship : relationships)
+ {
+ String sourceId = getIdProperty(relationship, PropertyIds.SOURCE_ID);
+ String targetId = getIdProperty(relationship, PropertyIds.TARGET_ID);
+ if (object.getId().equals(sourceId))
+ {
+ sourceIds.add(relationship.getId());
+ }
+ if (object.getId().equals(targetId))
+ {
+ targetIds.add(relationship.getId());
+ }
+ }
+ if (sourceIds.size() > 0)
+ {
+ info.setRelationshipSourceIds(sourceIds);
+ }
+ if (targetIds.size() > 0)
+ {
+ info.setRelationshipTargetIds(targetIds);
+ }
+ }
+ }
+
// --------------------------------------------------------
private void checkRepositoryId(String repositoryId)
diff --git a/source/java/org/alfresco/opencmis/CMISConnector.java b/source/java/org/alfresco/opencmis/CMISConnector.java
index b8505443f8..b19922cbd5 100644
--- a/source/java/org/alfresco/opencmis/CMISConnector.java
+++ b/source/java/org/alfresco/opencmis/CMISConnector.java
@@ -45,9 +45,10 @@ import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
import org.alfresco.opencmis.dictionary.CMISAllowedActionEnum;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
+import org.alfresco.opencmis.dictionary.CMISObjectVariant;
import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
import org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper;
-import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
import org.alfresco.opencmis.dictionary.PropertyDefintionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.opencmis.mapping.DirectProperty;
@@ -59,7 +60,6 @@ import org.alfresco.opencmis.search.CMISResultSetColumn;
import org.alfresco.opencmis.search.CMISResultSetRow;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
-import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.security.permissions.PermissionReference;
import org.alfresco.repo.security.permissions.impl.AccessPermissionImpl;
import org.alfresco.repo.security.permissions.impl.ModelDAO;
@@ -74,17 +74,16 @@ import org.alfresco.service.cmr.audit.AuditService.AuditQueryCallback;
import org.alfresco.service.cmr.coci.CheckOutCheckInService;
import org.alfresco.service.cmr.dictionary.DictionaryService;
import org.alfresco.service.cmr.dictionary.InvalidAspectException;
+import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.model.FileExistsException;
import org.alfresco.service.cmr.model.FileFolderService;
import org.alfresco.service.cmr.model.FileInfo;
import org.alfresco.service.cmr.model.FileNotFoundException;
import org.alfresco.service.cmr.rendition.RenditionService;
-import org.alfresco.service.cmr.repository.AspectMissingException;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentService;
-import org.alfresco.service.cmr.repository.EntityRef;
import org.alfresco.service.cmr.repository.InvalidNodeRefException;
import org.alfresco.service.cmr.repository.MimetypeService;
import org.alfresco.service.cmr.repository.NodeRef;
@@ -98,9 +97,6 @@ import org.alfresco.service.cmr.security.AccessPermission;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.AuthenticationService;
import org.alfresco.service.cmr.security.PermissionService;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionDoesNotExistException;
-import org.alfresco.service.cmr.version.VersionHistory;
import org.alfresco.service.cmr.version.VersionService;
import org.alfresco.service.cmr.version.VersionType;
import org.alfresco.service.descriptor.Descriptor;
@@ -151,7 +147,6 @@ import org.apache.chemistry.opencmis.commons.exceptions.CmisConstraintException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisContentAlreadyExistsException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
-import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisRuntimeException;
import org.apache.chemistry.opencmis.commons.exceptions.CmisStreamNotSupportedException;
import org.apache.chemistry.opencmis.commons.impl.dataobjects.AbstractPropertyData;
@@ -231,6 +226,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private NodeService nodeService;
private VersionService versionService;
private CheckOutCheckInService checkOutCheckInService;
+ private LockService lockService;
private ContentService contentService;
private RenditionService renditionService;
private FileFolderService fileFolderService;
@@ -389,6 +385,19 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return checkOutCheckInService;
}
+ /**
+ * Sets the lock service.
+ */
+ public LockService getLockService()
+ {
+ return lockService;
+ }
+
+ public void setLockService(LockService lockService)
+ {
+ this.lockService = lockService;
+ }
+
/**
* Sets the content service.
*/
@@ -478,6 +487,11 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.cmisDictionaryService = cmisDictionaryService;
}
+ public CMISDictionaryService getOpenCMISDictionaryService()
+ {
+ return cmisDictionaryService;
+ }
+
/**
* Sets the OpenCMIS query service.
*/
@@ -486,11 +500,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.cmisQueryService = cmisQueryService;
}
- public CMISDictionaryService getOpenCMISDictionaryService()
- {
- return cmisDictionaryService;
- }
-
/**
* Sets the MIME type service.
*/
@@ -694,312 +703,27 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
/**
- * Returns the variant of the object.
+ * Creates an object info object.
*/
- public ObjectVariantEnum getObjectVariant(String objectId)
+ public CMISNodeInfoImpl createNodeInfo(String objectId)
{
- if (objectId == null)
- {
- return ObjectVariantEnum.INVALID_ID;
- }
-
- try
- {
- String nodeRefString = objectId;
- String versionString = null;
-
- // is it a version?
- int sepIndex = objectId.lastIndexOf(ID_SEPERATOR);
- if (sepIndex > -1)
- {
- nodeRefString = objectId.substring(0, sepIndex);
- versionString = objectId.substring(sepIndex + 1);
- }
-
- if (NodeRef.isNodeRef(nodeRefString))
- {
- NodeRef nodeRef = new NodeRef(nodeRefString);
-
- // check for existence
- if (!nodeService.exists(nodeRef))
- {
- return ObjectVariantEnum.NOT_EXISTING;
- }
-
- // check PWC
- if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
- {
- return ObjectVariantEnum.PWC;
- }
-
- if (versionString == null)
- {
- return ObjectVariantEnum.NODE;
- }
-
- // check version
- VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
- if (versionHistory == null)
- {
- if (versionString.equals(UNVERSIONED_VERSION_LABEL))
- {
- return ObjectVariantEnum.NODE;
- }
- return ObjectVariantEnum.NOT_EXISTING;
- }
-
- try
- {
- versionHistory.getVersion(versionString);
-
- if (versionString.equals(versionHistory.getHeadVersion().getVersionLabel()))
- {
- return ObjectVariantEnum.NODE;
- }
-
- return ObjectVariantEnum.VERSION;
- } catch (VersionDoesNotExistException e)
- {
- return ObjectVariantEnum.NOT_EXISTING;
- }
- } else if (objectId.startsWith(ASSOC_ID_PREFIX))
- {
- // check the association id
- Long assocId = null;
- try
- {
- assocId = new Long(objectId.substring(ASSOC_ID_PREFIX.length()));
- } catch (NumberFormatException nfe)
- {
- return ObjectVariantEnum.INVALID_ID;
- }
-
- // check the association
- AssociationRef associationRef = nodeService.getAssoc(assocId);
- if (associationRef == null)
- {
- return ObjectVariantEnum.NOT_EXISTING;
- }
-
- return ObjectVariantEnum.ASSOC;
- } else
- {
- return ObjectVariantEnum.INVALID_ID;
- }
- } catch (AccessDeniedException e)
- {
- return ObjectVariantEnum.PERMISSION_DENIED;
- }
- }
-
- public void throwCommonExceptions(ObjectVariantEnum variant, String what, String objectId)
- {
- switch (variant)
- {
- case INVALID_ID:
- throw new CmisInvalidArgumentException(what + " id is invalid: " + objectId);
- case NOT_EXISTING:
- throw new CmisObjectNotFoundException(what + " not found: " + objectId);
- case PERMISSION_DENIED:
- throw new CmisPermissionDeniedException("Permission denied!");
- }
+ return new CMISNodeInfoImpl(this, objectId);
}
/**
- * Returns a node ref from an object id.
+ * Creates an object info object.
*/
- public NodeRef getNodeRef(String objectId)
+ public CMISNodeInfoImpl createNodeInfo(NodeRef nodeRef)
{
- String nodeRefString = objectId;
- String versionString = null;
-
- // is it a version?
- int sepIndex = objectId.lastIndexOf(ID_SEPERATOR);
- if (sepIndex > -1)
- {
- nodeRefString = objectId.substring(0, sepIndex);
- versionString = objectId.substring(sepIndex + 1);
- }
-
- NodeRef nodeRef = new NodeRef(nodeRefString);
- if (versionString != null)
- {
- Version version = versionService.getCurrentVersion(nodeRef);
- if (version == null)
- {
- if (versionString.equals(UNVERSIONED_VERSION_LABEL))
- {
- return nodeRef;
- } else
- {
- throw new CmisInvalidArgumentException("Invalid version: " + objectId);
- }
- } else
- {
- if (!versionString.equals(version.getVersionLabel()))
- {
- VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
- version = versionHistory.getVersion(versionString);
-
- nodeRef = version.getFrozenStateNodeRef();
- }
- }
- }
-
- return nodeRef;
+ return new CMISNodeInfoImpl(this, nodeRef);
}
/**
- * Returns a node ref from a document id if its the current version.
+ * Creates an object info object.
*/
- public NodeRef getNodeRefIfCurrent(String what, String objectId)
+ public CMISNodeInfoImpl createNodeInfo(AssociationRef assocRef)
{
- String nodeRefString = objectId;
- String versionString = null;
-
- // is it a version?
- int sepIndex = objectId.lastIndexOf(ID_SEPERATOR);
- if (sepIndex > -1)
- {
- nodeRefString = objectId.substring(0, sepIndex);
- versionString = objectId.substring(sepIndex + 1);
- }
-
- NodeRef nodeRef = new NodeRef(nodeRefString);
- if (versionString != null)
- {
- Version version = versionService.getCurrentVersion(nodeRef);
- if (version == null)
- {
- if (versionString.equals(UNVERSIONED_VERSION_LABEL))
- {
- return nodeRef;
- } else
- {
- throw new CmisInvalidArgumentException(what + " id has an invalid version label: " + objectId);
- }
- }
-
- if (!version.getVersionLabel().equals(versionString))
- {
- throw new CmisInvalidArgumentException(what + " id does not refer to the current version: " + objectId);
- }
- }
-
- return nodeRef;
- }
-
- /**
- * Returns an association ref from an object id.
- */
- public AssociationRef getAssociationRef(String objectId)
- {
- Long assocId = new Long(objectId.substring(ASSOC_ID_PREFIX.length()));
- return nodeService.getAssoc(assocId);
- }
-
- /**
- * Returns the node ref of the latest version.
- */
- public NodeRef getLatestVersionNodeRef(String versionSeriesId, boolean major)
- {
- if (!major)
- {
- return getNodeRef(getCurrentVersionId(versionSeriesId));
- }
-
- NodeRef nodeRef = getNodeRef(versionSeriesId);
- VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
-
- // if there is no history, return the current version
- if (versionHistory == null)
- {
- // there are no versions
- return getNodeRef(getCurrentVersionId(versionSeriesId));
- }
-
- // find the latest major version
- for (Version version : versionHistory.getAllVersions())
- {
- if (version.getVersionType() == VersionType.MAJOR)
- {
- return version.getFrozenStateNodeRef();
- }
- }
-
- throw new CmisObjectNotFoundException("There is no major version!");
- }
-
- /**
- * Returns the version to a given object id or null
if it isn't
- * a version.
- */
- public Version getVersion(String objectId)
- {
- String nodeRefString = objectId;
- String versionString = null;
-
- // is it a version?
- int sepIndex = objectId.lastIndexOf(ID_SEPERATOR);
- if (sepIndex > -1)
- {
- nodeRefString = objectId.substring(0, sepIndex);
- versionString = objectId.substring(sepIndex + 1);
- } else
- {
- return null;
- }
-
- try
- {
- NodeRef nodeRef = new NodeRef(nodeRefString);
- VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
- return versionHistory.getVersion(versionString);
- } catch (Exception e)
- {
- return null;
- }
- }
-
- /**
- * Returns a folder node ref. If the given id is invalid or does no belong
- * to a folder, an exception will be thrown.
- */
- public NodeRef getFolderNodeRef(String what, String folderId)
- {
- if ((folderId == null) || (folderId.lastIndexOf(ID_SEPERATOR) > -1) || !NodeRef.isNodeRef(folderId))
- {
- throwCommonExceptions(ObjectVariantEnum.INVALID_ID, what, folderId);
- }
-
- NodeRef nodeRef = null;
- try
- {
- nodeRef = new NodeRef(folderId);
-
- // check for existence
- if (!nodeService.exists(nodeRef))
- {
- throwCommonExceptions(ObjectVariantEnum.NOT_EXISTING, what, folderId);
- }
-
- // check type
- TypeDefinitionWrapper type = getType(nodeRef);
- if (type == null)
- {
- throwCommonExceptions(ObjectVariantEnum.NOT_EXISTING, what, folderId);
- }
-
- if (!(type instanceof FolderTypeDefintionWrapper))
- {
- throw new CmisInvalidArgumentException(what + " is not a folder!");
- }
- } catch (AccessDeniedException e)
- {
- throwCommonExceptions(ObjectVariantEnum.PERMISSION_DENIED, what, folderId);
- }
-
- return nodeRef;
+ return new CMISNodeInfoImpl(this, assocRef);
}
/**
@@ -1032,21 +756,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return cmisDictionaryService.findNodeType(typeQName);
}
- /**
- * Returns the type definition of a node or throws a
- * CmisObjectNotFoundException if no type definition could be found.
- */
- public TypeDefinitionWrapper getAndCheckType(NodeRef nodeRef)
- {
- TypeDefinitionWrapper type = getType(nodeRef);
- if (type == null)
- {
- throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
- }
-
- return type;
- }
-
/**
* Returns the type definition of an association or null
if no
* type definition could be found.
@@ -1134,13 +843,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
* Checks if a child of a given type can be added to a given folder.
*/
@SuppressWarnings("unchecked")
- public void checkChildObjectType(NodeRef folderNodeRef, String childType)
+ public void checkChildObjectType(CMISNodeInfo folderInfo, String childType)
{
- TypeDefinitionWrapper targetType = getType(folderNodeRef);
+ TypeDefinitionWrapper targetType = folderInfo.getType();
PropertyDefintionWrapper allowableChildObjectTypeProperty = targetType
.getPropertyById(PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
List childTypes = (List) allowableChildObjectTypeProperty.getPropertyAccessor().getValue(
- folderNodeRef);
+ folderInfo);
if ((childTypes == null) || childTypes.isEmpty())
{
@@ -1156,141 +865,48 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
/**
* Creates the CMIS object for a node.
*/
- public ObjectData createCMISObject(FileInfo node, String filter, boolean includeAllowableActions,
- IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds,
- boolean includeAcl)
+ public ObjectData createCMISObject(CMISNodeInfo info, FileInfo node, String filter,
+ boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+ boolean includePolicyIds, boolean includeAcl)
{
- NodeRef nodeRef = node.getNodeRef();
- TypeDefinitionWrapper type = getType(node.getType());
- if (type == null)
+ if (info.getType() == null)
{
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
- Properties nodeProps = getNodeProperties(node, filter, type);
+ Properties nodeProps = getNodeProperties(info, node, filter, info.getType());
- return createCMISObjectImpl(nodeRef, type, nodeProps, filter, includeAllowableActions, includeRelationships,
+ return createCMISObjectImpl(info, nodeProps, filter, includeAllowableActions, includeRelationships,
renditionFilter, includePolicyIds, includeAcl);
}
- public ObjectData createCMISObject(NodeRef nodeRef, String filter, boolean includeAllowableActions,
+ public ObjectData createCMISObject(CMISNodeInfo info, String filter, boolean includeAllowableActions,
IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds,
boolean includeAcl)
{
- TypeDefinitionWrapper type = getType(nodeRef);
- if (type == null)
+ if (info.getType() == null)
{
throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
}
- Properties nodeProps = getNodeProperties(nodeRef, filter, type);
+ Properties nodeProps = (info.isRelationship() ? getAssocProperties(info, filter) : getNodeProperties(info,
+ filter));
- return createCMISObjectImpl(nodeRef, type, nodeProps, filter, includeAllowableActions, includeRelationships,
+ return createCMISObjectImpl(info, nodeProps, filter, includeAllowableActions, includeRelationships,
renditionFilter, includePolicyIds, includeAcl);
}
- private ObjectData createCMISObjectImpl(NodeRef nodeRef, TypeDefinitionWrapper type, Properties nodeProps,
- String filter, boolean includeAllowableActions, IncludeRelationships includeRelationships,
- String renditionFilter, boolean includePolicyIds, boolean includeAcl)
- {
- // get the current version
- NodeRef currentVersionNodeRef = nodeRef;
- if (type instanceof DocumentTypeDefinitionWrapper)
- {
- try
- {
- VersionHistory versionHistory = versionService.getVersionHistory(nodeRef);
- if (versionHistory != null)
- {
- Version currentVersion = versionHistory.getHeadVersion();
- currentVersionNodeRef = currentVersion.getVersionedNodeRef();
-
- Serializable versionLabel = getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
- if (currentVersion.getVersionLabel().equals(versionLabel))
- {
- nodeRef = currentVersionNodeRef;
- }
- }
- } catch (AspectMissingException e)
- {
- }
- }
-
- ObjectDataImpl result = new ObjectDataImpl();
-
- // set properties
- result.setProperties(nodeProps);
-
- // set allowable actions
- if (includeAllowableActions)
- {
- result.setAllowableActions(getAllowableActions(type, nodeRef));
- }
-
- // set relationships
- if (includeRelationships != IncludeRelationships.NONE)
- {
- result.setRelationships(getRelationships(nodeRef, includeRelationships));
- }
-
- // set renditions
- if (!RENDITION_NONE.equals(renditionFilter))
- {
- List renditions = getRendtions(nodeRef, renditionFilter, null, null);
- if ((renditions != null) && (!renditions.isEmpty()))
- {
- result.setRenditions(renditions);
- }
- }
-
- // set policy ids
- if (includePolicyIds)
- {
- result.setPolicyIds(new PolicyIdListImpl());
- }
-
- // set ACL
- if (includeAcl)
- {
- result.setAcl(getACL(currentVersionNodeRef, false));
- }
-
- // add aspects
- List extensions = getAspectExtensions(nodeRef, filter, result.getProperties()
- .getProperties().keySet());
- if (!extensions.isEmpty())
- {
- result.getProperties().setExtensions(
- Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl(
- ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions)));
- }
-
- return result;
- }
-
- /**
- * Creates the CMIS object for an association.
- */
@SuppressWarnings("unchecked")
- public ObjectData createCMISObject(AssociationRef assocRef, String filter, boolean includeAllowableActions,
- IncludeRelationships includeRelationships, String renditionFilter, boolean includePolicyIds,
- boolean includeAcl)
+ private ObjectData createCMISObjectImpl(CMISNodeInfo info, Properties nodeProps, String filter,
+ boolean includeAllowableActions, IncludeRelationships includeRelationships, String renditionFilter,
+ boolean includePolicyIds, boolean includeAcl)
{
- TypeDefinitionWrapper type = getType(assocRef);
- if (type == null)
- {
- throw new CmisObjectNotFoundException("No corresponding type found! Not a CMIS object?");
- }
-
ObjectDataImpl result = new ObjectDataImpl();
- // set properties
- result.setProperties(getAssocProperties(assocRef, filter, type));
-
// set allowable actions
if (includeAllowableActions)
{
- result.setAllowableActions(getAllowableActions(type, assocRef));
+ result.setAllowableActions(getAllowableActions(info));
}
// set policy ids
@@ -1299,13 +915,54 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
result.setPolicyIds(new PolicyIdListImpl());
}
- // set ACL
- if (includeAcl)
+ if (info.isRelationship())
{
- // association have no ACL - return an empty list of ACEs
- result.setAcl(new AccessControlListImpl((List) Collections.EMPTY_LIST));
- }
+ // set properties
+ result.setProperties(getAssocProperties(info, filter));
+ // set ACL
+ if (includeAcl)
+ {
+ // association have no ACL - return an empty list of ACEs
+ result.setAcl(new AccessControlListImpl((List) Collections.EMPTY_LIST));
+ }
+ } else
+ {
+ // set properties
+ result.setProperties(nodeProps);
+
+ // set relationships
+ if (includeRelationships != IncludeRelationships.NONE)
+ {
+ result.setRelationships(getRelationships(info.getNodeRef(), includeRelationships));
+ }
+
+ // set renditions
+ if (!RENDITION_NONE.equals(renditionFilter))
+ {
+ List renditions = getRendtions(info.getNodeRef(), renditionFilter, null, null);
+ if ((renditions != null) && (!renditions.isEmpty()))
+ {
+ result.setRenditions(renditions);
+ }
+ }
+
+ // set ACL
+ if (includeAcl)
+ {
+ result.setAcl(getACL(info.getCurrentNodeNodeRef(), false));
+ }
+
+ // add aspects
+ List extensions = getAspectExtensions(info, filter, result.getProperties()
+ .getProperties().keySet());
+ if (!extensions.isEmpty())
+ {
+ result.getProperties().setExtensions(
+ Collections.singletonList((CmisExtensionElement) new CmisExtensionElementImpl(
+ ALFRESCO_EXTENSION_NAMESPACE, ASPECTS, null, extensions)));
+ }
+ }
return result;
}
@@ -1361,29 +1018,28 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
/**
* Gets the content from the repository.
*/
- public ContentStream getContentStream(NodeRef nodeRef, String streamId, BigInteger offset, BigInteger length)
+ public ContentStream getContentStream(CMISNodeInfoImpl info, String streamId, BigInteger offset, BigInteger length)
{
// get the type and check if the object can have content
- TypeDefinitionWrapper type = getType(nodeRef);
+ TypeDefinitionWrapper type = info.getType();
checkDocumentTypeForContent(type);
// looks like a document, now get the content
ContentStreamImpl result = new ContentStreamImpl();
- result.setFileName(getName(nodeRef));
+ result.setFileName(info.getName());
// if streamId is set, fetch other content
- NodeRef streamNodeRef = nodeRef;
+ NodeRef streamNodeRef = info.getNodeRef();
if ((streamId != null) && (streamId.length() > 0))
{
- ObjectVariantEnum variant = getObjectVariant(streamId);
- throwCommonExceptions(variant, "Stream", streamId);
- if (variant != ObjectVariantEnum.NODE)
+ CMISNodeInfo streamInfo = createNodeInfo(streamId);
+ if (!streamInfo.isVariant(CMISObjectVariant.CURRENT_VERSION))
{
throw new CmisInvalidArgumentException("Stream id is invalid: " + streamId);
}
- streamNodeRef = getNodeRef(streamId);
- type = getType(streamNodeRef);
+ streamNodeRef = streamInfo.getNodeRef();
+ type = streamInfo.getType();
checkDocumentTypeForContent(type);
}
@@ -1444,13 +1100,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
- public Properties getNodeProperties(NodeRef nodeRef, String filter, TypeDefinitionWrapper type)
+ public Properties getNodeProperties(CMISNodeInfo info, String filter)
{
PropertiesImpl result = new PropertiesImpl();
Set filterSet = splitFilter(filter);
- for (PropertyDefintionWrapper propDef : type.getProperties())
+ for (PropertyDefintionWrapper propDef : info.getType().getProperties())
{
if (!propDef.getPropertyId().equals(PropertyIds.OBJECT_ID))
{
@@ -1462,14 +1118,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
}
- Serializable value = propDef.getPropertyAccessor().getValue(nodeRef);
+ Serializable value = propDef.getPropertyAccessor().getValue(info);
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
}
return result;
}
- public Properties getNodeProperties(FileInfo node, String filter, TypeDefinitionWrapper type)
+ public Properties getNodeProperties(CMISNodeInfo info, FileInfo node, String filter, TypeDefinitionWrapper type)
{
PropertiesImpl result = new PropertiesImpl();
@@ -1497,7 +1153,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
value = nodeProps.get(accessor.getMappedProperty());
} else
{
- value = propDef.getPropertyAccessor().getValue(node.getNodeRef());
+ value = propDef.getPropertyAccessor().getValue(info);
}
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
@@ -1506,13 +1162,13 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return result;
}
- public Properties getAssocProperties(AssociationRef assocRef, String filter, TypeDefinitionWrapper type)
+ public Properties getAssocProperties(CMISNodeInfo info, String filter)
{
PropertiesImpl result = new PropertiesImpl();
Set filterSet = splitFilter(filter);
- for (PropertyDefintionWrapper propDef : type.getProperties())
+ for (PropertyDefintionWrapper propDef : info.getType().getProperties())
{
if ((filterSet != null) && (!filterSet.contains(propDef.getPropertyDefinition().getQueryName())))
{
@@ -1520,7 +1176,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
continue;
}
- Serializable value = propDef.getPropertyAccessor().getValue(assocRef);
+ Serializable value = propDef.getPropertyAccessor().getValue(info);
result.addProperty(getProperty(propDef.getPropertyDefinition().getPropertyType(), propDef, value));
}
@@ -1530,14 +1186,14 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
/**
* Builds aspect extension.
*/
- public List getAspectExtensions(NodeRef nodeRef, String filter,
+ public List getAspectExtensions(CMISNodeInfo info, String filter,
Set alreadySetProperties)
{
List extensions = new ArrayList();
Set propertyIds = new HashSet(alreadySetProperties);
Set filterSet = splitFilter(filter);
- Set aspects = nodeService.getAspects(nodeRef);
+ Set aspects = nodeService.getAspects(info.getNodeRef());
for (QName aspect : aspects)
{
TypeDefinitionWrapper aspectType = cmisDictionaryService.findNodeType(aspect);
@@ -1564,7 +1220,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
continue;
}
- Serializable value = propDef.getPropertyAccessor().getValue(nodeRef);
+ Serializable value = propDef.getPropertyAccessor().getValue(info);
propertyExtensionList.add(createAspectPropertyExtension(propDef.getPropertyDefinition(), value));
// mark property as 'added'
@@ -1803,17 +1459,15 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return result;
}
- @SuppressWarnings("unchecked")
- public AllowableActions getAllowableActions(TypeDefinitionWrapper type, EntityRef ref)
+ public AllowableActions getAllowableActions(CMISNodeInfo info)
{
AllowableActionsImpl result = new AllowableActionsImpl();
Set allowableActions = new HashSet();
result.setAllowableActions(allowableActions);
- for (@SuppressWarnings("rawtypes")
- CMISActionEvaluator evaluator : type.getActionEvaluators().values())
+ for (CMISActionEvaluator evaluator : info.getType().getActionEvaluators().values())
{
- if (evaluator.isAllowed(ref))
+ if (evaluator.isAllowed(info))
{
allowableActions.add(evaluator.getAction());
}
@@ -1853,7 +1507,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
continue;
}
- result.add(createCMISObject(assocRef, null, false, IncludeRelationships.NONE, RENDITION_NONE, false, false));
+ result.add(createCMISObject(createNodeInfo(assocRef), null, false, IncludeRelationships.NONE,
+ RENDITION_NONE, false, false));
}
return result;
@@ -1920,8 +1575,8 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
if (max > 0)
{
result.getObjects().add(
- createCMISObject(assocRef, filter, includeAllowableActions, IncludeRelationships.NONE,
- RENDITION_NONE, false, false));
+ createCMISObject(createNodeInfo(assocRef), filter, includeAllowableActions,
+ IncludeRelationships.NONE, RENDITION_NONE, false, false));
} else
{
hasMore = true;
@@ -2327,7 +1982,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
// set allowable actions
if (includeAllowableActions)
{
- hit.setAllowableActions(getAllowableActions(type, nodeRef));
+ hit.setAllowableActions(getAllowableActions(createNodeInfo(nodeRef)));
}
// set relationships
@@ -2553,8 +2208,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
Updatability updatability = propDef.getPropertyDefinition().getUpdatability();
if ((updatability == Updatability.READONLY)
- || (updatability == Updatability.WHENCHECKEDOUT && !nodeService.hasAspect(nodeRef,
- ContentModel.ASPECT_WORKING_COPY)))
+ || (updatability == Updatability.WHENCHECKEDOUT && !checkOutCheckInService.isWorkingCopy(nodeRef)))
{
throw new CmisInvalidArgumentException("Property " + property.getId() + " is read-only!");
}
@@ -2906,16 +2560,6 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
latestChangeLogToken = auditQueryCallback.getEntryId();
}
- if (repositoryPermissions == null)
- {
- repositoryPermissions = getRepositoryPermissions();
- }
-
- if (permissionMappings == null)
- {
-
- }
-
// compile repository info
RepositoryInfoImpl ri = new RepositoryInfoImpl();
diff --git a/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java b/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
new file mode 100644
index 0000000000..3e82a9983e
--- /dev/null
+++ b/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
@@ -0,0 +1,769 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.opencmis;
+
+import java.io.Serializable;
+import java.util.GregorianCalendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
+import org.alfresco.opencmis.dictionary.CMISObjectVariant;
+import org.alfresco.opencmis.dictionary.DocumentTypeDefinitionWrapper;
+import org.alfresco.opencmis.dictionary.FolderTypeDefintionWrapper;
+import org.alfresco.opencmis.dictionary.RelationshipTypeDefintionWrapper;
+import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
+import org.alfresco.repo.security.permissions.AccessDeniedException;
+import org.alfresco.repo.version.VersionBaseModel;
+import org.alfresco.service.cmr.lock.LockType;
+import org.alfresco.service.cmr.repository.AssociationRef;
+import org.alfresco.service.cmr.repository.ChildAssociationRef;
+import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.Path;
+import org.alfresco.service.cmr.repository.Path.ChildAssocElement;
+import org.alfresco.service.cmr.version.Version;
+import org.alfresco.service.cmr.version.VersionDoesNotExistException;
+import org.alfresco.service.cmr.version.VersionHistory;
+import org.alfresco.service.cmr.version.VersionType;
+import org.alfresco.service.namespace.QName;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
+import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
+
+public class CMISNodeInfoImpl implements CMISNodeInfo
+{
+ private static final GregorianCalendar DUMMY_DATE = new GregorianCalendar(2010, 4, 1);
+
+ private CMISConnector connector;
+ private String objectId; // CMIS object id
+ private String currentObjectId; // CMIS object id of the latest version
+ private String currentNodeId; // node ref id of the latest version
+ private CMISObjectVariant objecVariant; // object variant
+ private NodeRef nodeRef; // object node ref
+ private String versionLabel; // version label
+ private AssociationRef associationRef; // association ref
+ private TypeDefinitionWrapper type; // CMIS type
+ private String name;
+ private boolean hasPWC;
+ private Boolean isRootFolder;
+ private String cmisPath;
+ private VersionHistory versionHistory;
+ private Version version;
+ private Boolean isLatestMajorVersion;
+ private Map properties;
+
+ public CMISNodeInfoImpl(CMISConnector connector, String objectId)
+ {
+ this.connector = connector;
+ this.objectId = objectId;
+
+ analyseObjectId();
+ }
+
+ public CMISNodeInfoImpl(CMISConnector connector, NodeRef nodeRef)
+ {
+ this.connector = connector;
+ this.nodeRef = nodeRef;
+
+ analyseNodeRef();
+ }
+
+ public CMISNodeInfoImpl(CMISConnector connector, AssociationRef associationRef)
+ {
+ this.connector = connector;
+ this.associationRef = associationRef;
+
+ analyseAssociationRef();
+ }
+
+ protected void analyseObjectId()
+ {
+ currentNodeId = objectId;
+ currentObjectId = objectId;
+ versionLabel = null;
+ nodeRef = null;
+ hasPWC = false;
+
+ if (objectId == null)
+ {
+ objecVariant = CMISObjectVariant.INVALID_ID;
+ return;
+ }
+
+ try
+ {
+ // is it a version?
+ int sepIndex = objectId.lastIndexOf(CMISConnector.ID_SEPERATOR);
+ if (sepIndex > -1)
+ {
+ currentNodeId = objectId.substring(0, sepIndex);
+ versionLabel = objectId.substring(sepIndex + 1);
+ }
+
+ if (NodeRef.isNodeRef(currentNodeId))
+ {
+ nodeRef = new NodeRef(currentNodeId);
+
+ // check for existence
+ if (!connector.getNodeService().exists(nodeRef))
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ return;
+ }
+
+ // check PWC
+ if (connector.getCheckOutCheckInService().isWorkingCopy(nodeRef))
+ {
+ NodeRef checkedOut = connector.getCheckOutCheckInService().getCheckedOut(nodeRef);
+ objecVariant = CMISObjectVariant.PWC;
+ currentObjectId = connector.createObjectId(checkedOut);
+ currentNodeId = checkedOut.toString();
+ versionLabel = CMISConnector.PWC_VERSION_LABEL;
+ hasPWC = true;
+ return;
+ }
+
+ if (versionLabel == null)
+ {
+ if (isFolder())
+ {
+ objecVariant = CMISObjectVariant.FOLDER;
+ } else if (isDocument())
+ {
+ objecVariant = CMISObjectVariant.CURRENT_VERSION;
+ hasPWC = (connector.getLockService().getLockType(nodeRef) == LockType.READ_ONLY_LOCK);
+ } else
+ {
+ objecVariant = CMISObjectVariant.NOT_A_CMIS_OBJECT;
+ }
+ return;
+ }
+
+ // check if it has PWC label
+ if (versionLabel.equals(CMISConnector.PWC_VERSION_LABEL))
+ {
+ NodeRef pwcNodeRef = connector.getCheckOutCheckInService().getWorkingCopy(nodeRef);
+ if (pwcNodeRef == null)
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ return;
+ }
+
+ objecVariant = CMISObjectVariant.PWC;
+ currentObjectId = connector.createObjectId(nodeRef);
+ currentNodeId = nodeRef.toString();
+ hasPWC = true;
+ nodeRef = pwcNodeRef;
+ return;
+ }
+
+ // check version
+ versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
+ if (versionHistory == null)
+ {
+ if (versionLabel.equals(CMISConnector.UNVERSIONED_VERSION_LABEL))
+ {
+ objecVariant = CMISObjectVariant.CURRENT_VERSION;
+
+ } else
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ }
+
+ return;
+ }
+
+ try
+ {
+ currentObjectId = currentNodeId + CMISConnector.ID_SEPERATOR
+ + versionHistory.getHeadVersion().getVersionLabel();
+
+ version = versionHistory.getVersion(versionLabel);
+
+ if (versionLabel.equals(versionHistory.getHeadVersion().getVersionLabel()))
+ {
+ objecVariant = CMISObjectVariant.CURRENT_VERSION;
+ } else
+ {
+ nodeRef = version.getFrozenStateNodeRef();
+ objecVariant = CMISObjectVariant.VERSION;
+ }
+ } catch (VersionDoesNotExistException e)
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ }
+
+ // check if checked out
+ hasPWC = connector.getCheckOutCheckInService().isCheckedOut(getCurrentNodeNodeRef());
+ } else if (objectId.startsWith(CMISConnector.ASSOC_ID_PREFIX))
+ {
+ // check the association id
+ Long assocId = null;
+ try
+ {
+ assocId = new Long(objectId.substring(CMISConnector.ASSOC_ID_PREFIX.length()));
+ } catch (NumberFormatException nfe)
+ {
+ objecVariant = CMISObjectVariant.INVALID_ID;
+ return;
+ }
+
+ // check the association
+ associationRef = connector.getNodeService().getAssoc(assocId);
+ if (associationRef == null)
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ } else
+ {
+ objecVariant = CMISObjectVariant.ASSOC;
+ }
+ } else
+ {
+ objecVariant = CMISObjectVariant.INVALID_ID;
+ }
+ } catch (AccessDeniedException e)
+ {
+ objecVariant = CMISObjectVariant.PERMISSION_DENIED;
+ }
+ }
+
+ protected void analyseNodeRef()
+ {
+ objectId = null;
+ currentNodeId = nodeRef.toString();
+ currentObjectId = null;
+ versionLabel = null;
+ hasPWC = false;
+
+ // check for existence
+ if (!connector.getNodeService().exists(nodeRef))
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ return;
+ }
+
+ if (isFolder())
+ {
+ objecVariant = CMISObjectVariant.FOLDER;
+ objectId = nodeRef.toString();
+ currentObjectId = objectId;
+ return;
+ } else if (getType() == null)
+ {
+ objecVariant = CMISObjectVariant.NOT_A_CMIS_OBJECT;
+ return;
+ }
+
+ // check PWC
+ if (connector.getCheckOutCheckInService().isWorkingCopy(nodeRef))
+ {
+ NodeRef checkedOut = connector.getCheckOutCheckInService().getCheckedOut(nodeRef);
+ objecVariant = CMISObjectVariant.PWC;
+ objectId = checkedOut.toString() + CMISConnector.ID_SEPERATOR + CMISConnector.PWC_VERSION_LABEL;
+ versionLabel = CMISConnector.PWC_VERSION_LABEL;
+ currentObjectId = connector.createObjectId(checkedOut);
+ currentNodeId = checkedOut.toString();
+ hasPWC = true;
+ return;
+ }
+
+ // check version
+ versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
+ if (versionHistory == null)
+ {
+ objecVariant = CMISObjectVariant.CURRENT_VERSION;
+ objectId = nodeRef.toString() + CMISConnector.ID_SEPERATOR + CMISConnector.UNVERSIONED_VERSION_LABEL;
+ versionLabel = CMISConnector.UNVERSIONED_VERSION_LABEL;
+ currentObjectId = objectId;
+ } else
+ {
+ Version headVersion = versionHistory.getHeadVersion();
+
+ versionLabel = (String) connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
+ objectId = headVersion.getVersionedNodeRef().toString() + CMISConnector.ID_SEPERATOR + versionLabel;
+ currentObjectId = headVersion.getVersionedNodeRef().toString() + CMISConnector.ID_SEPERATOR
+ + headVersion.getVersionLabel();
+ currentNodeId = headVersion.getVersionedNodeRef().toString();
+
+ objecVariant = (headVersion.getVersionLabel().equals(versionLabel) ? CMISObjectVariant.CURRENT_VERSION
+ : CMISObjectVariant.VERSION);
+ }
+
+ hasPWC = connector.getCheckOutCheckInService().isCheckedOut(getCurrentNodeNodeRef());
+ }
+
+ protected void analyseAssociationRef()
+ {
+ objectId = null;
+ currentNodeId = null;
+ currentObjectId = null;
+ versionLabel = null;
+ hasPWC = false;
+
+ if (associationRef == null)
+ {
+ objecVariant = CMISObjectVariant.NOT_EXISTING;
+ return;
+ }
+
+ objecVariant = CMISObjectVariant.ASSOC;
+ objectId = CMISConnector.ASSOC_ID_PREFIX + associationRef.getId();
+ }
+
+ private void determineType()
+ {
+ type = null;
+
+ if (nodeRef != null)
+ {
+ QName typeQName = connector.getNodeService().getType(nodeRef);
+ type = connector.getOpenCMISDictionaryService().findNodeType(typeQName);
+ } else if (associationRef != null)
+ {
+ QName typeQName = associationRef.getTypeQName();
+ type = connector.getOpenCMISDictionaryService().findAssocType(typeQName);
+ }
+ }
+
+ public String getObjectId()
+ {
+ return objectId;
+ }
+
+ public CMISObjectVariant getObjectVariant()
+ {
+ return objecVariant;
+ }
+
+ public boolean isVariant(CMISObjectVariant var)
+ {
+ return objecVariant == var;
+ }
+
+ public NodeRef getNodeRef()
+ {
+ return nodeRef;
+ }
+
+ public String getCurrentNodeId()
+ {
+ return currentNodeId;
+ }
+
+ public NodeRef getCurrentNodeNodeRef()
+ {
+ return new NodeRef(currentNodeId);
+ }
+
+ public String getCurrentObjectId()
+ {
+ return currentObjectId;
+ }
+
+ public boolean isCurrentVersion()
+ {
+ return objecVariant == CMISObjectVariant.CURRENT_VERSION;
+ }
+
+ public boolean isPWC()
+ {
+ return objecVariant == CMISObjectVariant.PWC;
+ }
+
+ public boolean hasPWC()
+ {
+ return hasPWC;
+ }
+
+ public boolean isVersion()
+ {
+ return objecVariant == CMISObjectVariant.VERSION;
+ }
+
+ public boolean isLatestVersion()
+ {
+ return isPWC() || (isCurrentVersion() && !hasPWC());
+ }
+
+ public boolean isLatestMajorVersion()
+ {
+ if (isLatestMajorVersion == null)
+ {
+ isLatestMajorVersion = Boolean.FALSE;
+ if (!isPWC())
+ {
+ VersionHistory versionHistory = getVersionHistory();
+ if (versionHistory == null)
+ {
+ isLatestMajorVersion = Boolean.TRUE;
+ } else
+ {
+ Version currentVersion = versionHistory.getHeadVersion();
+ while (currentVersion != null)
+ {
+ if (currentVersion.getVersionType() == VersionType.MAJOR)
+ {
+ isLatestMajorVersion = currentVersion.getFrozenStateNodeRef().equals(nodeRef);
+ break;
+ }
+ currentVersion = versionHistory.getPredecessor(currentVersion);
+ }
+ }
+ }
+ }
+
+ return isLatestMajorVersion.booleanValue();
+ }
+
+ public boolean isMajorVersion()
+ {
+ if (isPWC())
+ {
+ return false;
+ }
+ if (CMISConnector.UNVERSIONED_VERSION_LABEL.equals(versionLabel))
+ {
+ return true;
+ }
+
+ Version version = getVersion();
+ if (version == null)
+ {
+ return true;
+ }
+
+ return version.getVersionType() == VersionType.MAJOR;
+ }
+
+ public String getVersionLabel()
+ {
+ return versionLabel;
+ }
+
+ public String getCheckinComment()
+ {
+ if (!isDocument() || isPWC())
+ {
+ return null;
+ }
+
+ Version version = getVersion();
+ if (version != null)
+ {
+ return getVersion().getDescription();
+ }
+
+ return null;
+ }
+
+ public AssociationRef getAssociationRef()
+ {
+ return associationRef;
+ }
+
+ public TypeDefinitionWrapper getType()
+ {
+ if (type == null)
+ {
+ determineType();
+ }
+
+ return type;
+ }
+
+ public boolean isFolder()
+ {
+ return getType() instanceof FolderTypeDefintionWrapper;
+ }
+
+ public boolean isRootFolder()
+ {
+ if (isRootFolder == null)
+ {
+ isRootFolder = isFolder() && connector.getRootNodeRef().equals(nodeRef);
+ }
+
+ return isRootFolder.booleanValue();
+ }
+
+ public boolean isDocument()
+ {
+ return getType() instanceof DocumentTypeDefinitionWrapper;
+ }
+
+ public boolean isRelationship()
+ {
+ return getType() instanceof RelationshipTypeDefintionWrapper;
+ }
+
+ public String getName()
+ {
+ if (name == null)
+ {
+ if (isRelationship())
+ {
+ name = associationRef.toString();
+ } else
+ {
+ Object nameObj = connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_NAME);
+ name = (nameObj instanceof String ? (String) nameObj : "");
+ }
+ }
+
+ return name;
+ }
+
+ public String getPath()
+ {
+ if (cmisPath == null)
+ {
+ StringBuilder displayPath = new StringBuilder(64);
+
+ Path path = connector.getNodeService().getPath(nodeRef);
+ NodeRef rootNode = connector.getRootNodeRef();
+ int i = 0;
+ while (i < path.size())
+ {
+ Path.Element element = path.get(i);
+ if (element instanceof ChildAssocElement)
+ {
+ ChildAssociationRef assocRef = ((ChildAssocElement) element).getRef();
+ NodeRef node = assocRef.getChildRef();
+ if (node.equals(rootNode))
+ {
+ break;
+ }
+ }
+ i++;
+ }
+
+ if (i == path.size())
+ {
+ // TODO:
+ // throw new AlfrescoRuntimeException("Path " + path +
+ // " not in CMIS root node scope");
+ }
+
+ if (path.size() - i == 1)
+ {
+ // render root path
+ displayPath.append("/");
+ } else
+ {
+ // render CMIS scoped path
+ i++;
+ while (i < path.size() - 1)
+ {
+ Path.Element element = path.get(i);
+ if (element instanceof ChildAssocElement)
+ {
+ ChildAssociationRef assocRef = ((ChildAssocElement) element).getRef();
+ NodeRef node = assocRef.getChildRef();
+ displayPath.append("/");
+ displayPath.append(connector.getNodeService().getProperty(node, ContentModel.PROP_NAME));
+ }
+ i++;
+ }
+ displayPath.append("/");
+ displayPath.append(getName());
+ }
+
+ cmisPath = displayPath.toString();
+ }
+
+ return cmisPath;
+ }
+
+ public Serializable getCreationDate()
+ {
+ if (isDocument())
+ {
+ if (isCurrentVersion() || isPWC())
+ {
+ return connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_CREATED);
+ } else
+ {
+ return getVersion().getVersionProperty(VersionBaseModel.PROP_CREATED_DATE);
+ }
+ } else if (isFolder())
+ {
+ return connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_CREATED);
+ } else
+ {
+ return DUMMY_DATE;
+ }
+ }
+
+ public Serializable getModificationDate()
+ {
+ if (isDocument())
+ {
+ if (isCurrentVersion() || isPWC())
+ {
+ return connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_MODIFIED);
+ } else
+ {
+ return getVersion().getVersionProperty(ContentModel.PROP_MODIFIED.getLocalName());
+ }
+ } else if (isFolder())
+ {
+ return connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_MODIFIED);
+ } else
+ {
+ return DUMMY_DATE;
+ }
+ }
+
+ public NodeRef getLatestVersionNodeRef(boolean major)
+ {
+ if (!major)
+ {
+ return getLatestNonMajorVersionNodeRef();
+ }
+
+ VersionHistory versionHistory = getVersionHistory();
+
+ // if there is no history, return the current version
+ if (versionHistory == null)
+ {
+ // there are no versions
+ return getLatestNonMajorVersionNodeRef();
+ }
+
+ // find the latest major version
+ for (Version version : versionHistory.getAllVersions())
+ {
+ if (version.getVersionType() == VersionType.MAJOR)
+ {
+ return version.getFrozenStateNodeRef();
+ }
+ }
+
+ throw new CmisObjectNotFoundException("There is no major version!");
+ }
+
+ private NodeRef getLatestNonMajorVersionNodeRef()
+ {
+ if (isPWC())
+ {
+ return nodeRef;
+ } else if (hasPWC())
+ {
+ return connector.getCheckOutCheckInService().getWorkingCopy(getCurrentNodeNodeRef());
+ } else
+ {
+ return getCurrentNodeNodeRef();
+ }
+ }
+
+ public VersionHistory getVersionHistory()
+ {
+ if (versionHistory == null && isDocument())
+ {
+ try
+ {
+ versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
+ } catch (Exception e)
+ {
+ }
+ }
+
+ return versionHistory;
+ }
+
+ public Version getVersion()
+ {
+ if (version == null && isDocument())
+ {
+ try
+ {
+ VersionHistory versionHistory = getVersionHistory();
+ version = versionHistory.getVersion(versionLabel);
+ } catch (Exception e)
+ {
+ }
+ }
+
+ return version;
+ }
+
+ public void checkIfUseful(String what)
+ {
+ switch (objecVariant)
+ {
+ case INVALID_ID:
+ throw new CmisInvalidArgumentException(what + " id is invalid: " + objectId);
+ case NOT_EXISTING:
+ throw new CmisObjectNotFoundException(what + " not found: " + objectId);
+ case NOT_A_CMIS_OBJECT:
+ throw new CmisObjectNotFoundException(what + " is not a CMIS object: " + objectId);
+ case PERMISSION_DENIED:
+ throw new CmisPermissionDeniedException("Permission denied!");
+ }
+ }
+
+ public void checkIfFolder(String what)
+ {
+ checkIfUseful(what);
+ if (objecVariant != CMISObjectVariant.FOLDER)
+ {
+ throw new CmisInvalidArgumentException(what + " is not a folder!");
+ }
+ }
+
+ @Override
+ public Serializable getPropertyValue(String id)
+ {
+ if (properties == null)
+ {
+ return null;
+ }
+
+ return properties.get(id);
+ }
+
+ @Override
+ public boolean containsPropertyValue(String id)
+ {
+ if (properties == null)
+ {
+ return false;
+ }
+
+ return properties.containsKey(id);
+ }
+
+ @Override
+ public void putPropertyValue(String id, Serializable value)
+ {
+ if (properties == null)
+ {
+ properties = new HashMap();
+ }
+
+ properties.put(id, value);
+ }
+
+ @Override
+ public String toString()
+ {
+ return getObjectId() + " (" + getNodeRef() + ")";
+ }
+}
diff --git a/source/java/org/alfresco/opencmis/ObjectVariantEnum.java b/source/java/org/alfresco/opencmis/ObjectVariantEnum.java
deleted file mode 100644
index cbc7230160..0000000000
--- a/source/java/org/alfresco/opencmis/ObjectVariantEnum.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.opencmis;
-
-public enum ObjectVariantEnum
-{
- INVALID_ID, // not a valid object id
- NOT_EXISTING, // valid id but object doesn't exist
- NODE, // object is a node
- VERSION, // object is a version (not updatable)
- PWC, // object is a PWC
- ASSOC, // object is a relationship
- PERMISSION_DENIED
- // user has no permissions
-}
diff --git a/source/java/org/alfresco/opencmis/mapping/AbstractActionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/AbstractActionEvaluator.java
index b2d7f98914..3ead69ffe4 100644
--- a/source/java/org/alfresco/opencmis/mapping/AbstractActionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/AbstractActionEvaluator.java
@@ -28,7 +28,7 @@ import org.apache.chemistry.opencmis.commons.enums.Action;
* @author davidc
*
*/
-public abstract class AbstractActionEvaluator implements CMISActionEvaluator
+public abstract class AbstractActionEvaluator implements CMISActionEvaluator
{
private ServiceRegistry serviceRegistry;
private Action action;
diff --git a/source/java/org/alfresco/opencmis/mapping/AbstractProperty.java b/source/java/org/alfresco/opencmis/mapping/AbstractProperty.java
index 21aa5cdb49..89a3f6b89e 100644
--- a/source/java/org/alfresco/opencmis/mapping/AbstractProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/AbstractProperty.java
@@ -20,21 +20,28 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
+import org.alfresco.service.cmr.repository.ContentData;
import org.alfresco.service.cmr.repository.NodeRef;
+import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.namespace.QName;
/**
* Base class for all property accessors
*
* @author andyh
- *
+ *
*/
public abstract class AbstractProperty implements CMISPropertyAccessor
{
+ private static final String CONTENT_PROPERTY = "::content";
+
private ServiceRegistry serviceRegistry;
+ private CMISConnector connector;
private String propertyName;
/**
@@ -43,53 +50,85 @@ public abstract class AbstractProperty implements CMISPropertyAccessor
* @param serviceRegistry
* @param propertyName
*/
- protected AbstractProperty(ServiceRegistry serviceRegistry, String propertyName)
+ protected AbstractProperty(ServiceRegistry serviceRegistry, CMISConnector connector, String propertyName)
{
this.serviceRegistry = serviceRegistry;
+ this.connector = connector;
this.propertyName = propertyName;
}
/**
- * @return service registry
+ * @return service registry
*/
protected ServiceRegistry getServiceRegistry()
{
return serviceRegistry;
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.property.PropertyAccessor#getName()
- */
public String getName()
{
return propertyName;
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.property.PropertyAccessor#getMappedProperty()
- */
public QName getMappedProperty()
{
return null;
}
- @Override
- public Serializable getValue(NodeRef nodeRef)
- {
- throw new UnsupportedOperationException();
- }
-
@Override
public void setValue(NodeRef nodeRef, Serializable value)
{
throw new UnsupportedOperationException();
}
-
- @Override
- public Serializable getValue(AssociationRef assocRef)
+
+ public Serializable getValue(NodeRef nodeRef)
{
- throw new UnsupportedOperationException();
+ return getValue(createNodeInfo(nodeRef));
+ }
+
+ public Serializable getValue(CMISNodeInfo nodeInfo)
+ {
+ if (nodeInfo.containsPropertyValue(propertyName))
+ {
+ return nodeInfo.getPropertyValue(propertyName);
+ } else
+ {
+ Serializable value = getValueInternal(nodeInfo);
+ nodeInfo.putPropertyValue(propertyName, value);
+ return value;
+ }
+ }
+
+ protected abstract Serializable getValueInternal(CMISNodeInfo nodeInfo);
+
+ protected CMISNodeInfo createNodeInfo(NodeRef nodeRef)
+ {
+ return connector.createNodeInfo(nodeRef);
+ }
+
+ protected ContentData getContentData(CMISNodeInfo nodeInfo)
+ {
+ if (!nodeInfo.isDocument())
+ {
+ return null;
+ }
+
+ if (nodeInfo.containsPropertyValue(CONTENT_PROPERTY))
+ {
+ return (ContentData) nodeInfo.getPropertyValue(CONTENT_PROPERTY);
+ } else
+ {
+ ContentData contentData = null;
+
+ Serializable value = getServiceRegistry().getNodeService().getProperty(nodeInfo.getNodeRef(),
+ ContentModel.PROP_CONTENT);
+ if (value != null)
+ {
+ contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
+ }
+
+ nodeInfo.putPropertyValue(CONTENT_PROPERTY, contentData);
+ return contentData;
+ }
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/AbstractVersioningProperty.java b/source/java/org/alfresco/opencmis/mapping/AbstractVersioningProperty.java
deleted file mode 100644
index b8fe2e8d91..0000000000
--- a/source/java/org/alfresco/opencmis/mapping/AbstractVersioningProperty.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Copyright (C) 2005-2010 Alfresco Software Limited.
- *
- * This file is part of Alfresco
- *
- * Alfresco is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * Alfresco is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with Alfresco. If not, see .
- */
-package org.alfresco.opencmis.mapping;
-
-import java.io.Serializable;
-import java.util.Map;
-
-import org.alfresco.model.ContentModel;
-import org.alfresco.repo.version.VersionBaseModel;
-import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.lock.LockType;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionHistory;
-import org.alfresco.service.namespace.QName;
-
-/**
- * Base class for versioning property accessors.
- *
- * @author dward
- *
- */
-public abstract class AbstractVersioningProperty extends AbstractProperty
-{
-
- /**
- * Construct
- */
- protected AbstractVersioningProperty(ServiceRegistry serviceRegistry, String propertyName)
- {
- super(serviceRegistry, propertyName);
- }
-
- public NodeRef getVersionSeries(NodeRef nodeRef)
- {
- if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL))
- {
- // Due to the remapping done for us by the versioned node services,
- // we can simply look up the properties
- // containing the component parts of the node ref to map back to the
- // original node
- Map properties = getServiceRegistry().getNodeService().getProperties(nodeRef);
- nodeRef = new NodeRef((String) properties.get(ContentModel.PROP_STORE_PROTOCOL),
- (String) properties.get(ContentModel.PROP_STORE_IDENTIFIER),
- (String) properties.get(ContentModel.PROP_NODE_UUID));
- }
- else if (isWorkingCopy(nodeRef))
- {
- NodeRef originalNodeRef = getServiceRegistry().getCheckOutCheckInService().getCheckedOut(nodeRef);
- nodeRef = originalNodeRef == null ? nodeRef : originalNodeRef;
- }
- return nodeRef;
- }
-
- public boolean isWorkingCopy(NodeRef nodeRef)
- {
- return getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY);
- }
-
- public boolean hasWorkingCopy(NodeRef nodeRef)
- {
- return getServiceRegistry().getLockService().getLockType(nodeRef) == LockType.READ_ONLY_LOCK;
- }
-
- public NodeRef getLiveNodeRef(NodeRef nodeRef)
- {
- if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL))
- {
- VersionHistory versionHistory = getServiceRegistry().getVersionService().getVersionHistory(nodeRef);
- if (versionHistory == null)
- {
- return nodeRef;
- }
-
- Version currentVersion = versionHistory.getHeadVersion();
- Serializable versionLabel = getServiceRegistry().getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
-
- if (currentVersion.getVersionLabel().equals(versionLabel))
- {
- return currentVersion.getVersionedNodeRef();
- }
- }
-
- return nodeRef;
- }
-
- public boolean isCurrentVersion(NodeRef nodeRef)
- {
- if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL))
- {
- VersionHistory versionHistory = getServiceRegistry().getVersionService().getVersionHistory(nodeRef);
- if (versionHistory == null)
- {
- return true;
- }
-
- Version currentVersion = versionHistory.getHeadVersion();
- Serializable versionLabel = getServiceRegistry().getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
-
- return currentVersion.getVersionLabel().equals(versionLabel);
- }
-
- return true;
- }
-}
diff --git a/source/java/org/alfresco/opencmis/mapping/AllowedChildObjectTypeIdsProperty.java b/source/java/org/alfresco/opencmis/mapping/AllowedChildObjectTypeIdsProperty.java
index eca86a4c7c..61d759155a 100644
--- a/source/java/org/alfresco/opencmis/mapping/AllowedChildObjectTypeIdsProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/AllowedChildObjectTypeIdsProperty.java
@@ -22,11 +22,11 @@ import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.ChildAssociationDefinition;
import org.alfresco.service.cmr.dictionary.TypeDefinition;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
@@ -43,17 +43,18 @@ public class AllowedChildObjectTypeIdsProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public AllowedChildObjectTypeIdsProperty(ServiceRegistry serviceRegistry, CMISMapping cmisMapping)
+ public AllowedChildObjectTypeIdsProperty(ServiceRegistry serviceRegistry, CMISConnector connector,
+ CMISMapping cmisMapping)
{
- super(serviceRegistry, PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
+ super(serviceRegistry, connector, PropertyIds.ALLOWED_CHILD_OBJECT_TYPE_IDS);
this.cmisMapping = cmisMapping;
}
@Override
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- QName typeQName = getServiceRegistry().getNodeService().getType(nodeRef);
- TypeDefinition type = getServiceRegistry().getDictionaryService().getType(typeQName);
+ TypeDefinition type = getServiceRegistry().getDictionaryService()
+ .getType(nodeInfo.getType().getAlfrescoClass());
if ((type != null) && (type.getChildAssociations() != null) && (!type.getChildAssociations().isEmpty()))
{
ArrayList result = new ArrayList();
diff --git a/source/java/org/alfresco/opencmis/mapping/BaseTypeIdProperty.java b/source/java/org/alfresco/opencmis/mapping/BaseTypeIdProperty.java
index d532993f28..46f7f064ca 100644
--- a/source/java/org/alfresco/opencmis/mapping/BaseTypeIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/BaseTypeIdProperty.java
@@ -20,50 +20,39 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.opencmis.dictionary.CMISDictionaryService;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
/**
* Get the CMIS object type id property
*
- * @author andyh
+ * @author florian.mueller
*/
public class BaseTypeIdProperty extends AbstractProperty
{
- private CMISDictionaryService dictionaryService;
-
/**
* Construct
*
* @param serviceRegistry
*/
- public BaseTypeIdProperty(ServiceRegistry serviceRegistry, CMISDictionaryService dictionaryService)
+ public BaseTypeIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.BASE_TYPE_ID);
- this.dictionaryService = dictionaryService;
+ super(serviceRegistry, connector, PropertyIds.BASE_TYPE_ID);
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- QName type = getServiceRegistry().getNodeService().getType(nodeRef);
- return dictionaryService.findTypeForClass(type).getBaseTypeId().value();
- }
+ if (nodeInfo.isFolder())
+ {
+ return BaseTypeId.CMIS_FOLDER.value();
+ } else if (nodeInfo.isRelationship())
+ {
+ return BaseTypeId.CMIS_RELATIONSHIP.value();
+ }
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
- {
- return BaseTypeId.CMIS_RELATIONSHIP.value();
+ return BaseTypeId.CMIS_DOCUMENT.value();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/CanCancelCheckOutActionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/CanCancelCheckOutActionEvaluator.java
index 936387e54a..23fc161a0d 100644
--- a/source/java/org/alfresco/opencmis/mapping/CanCancelCheckOutActionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/CanCancelCheckOutActionEvaluator.java
@@ -18,22 +18,19 @@
*/
package org.alfresco.opencmis.mapping;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.chemistry.opencmis.commons.enums.Action;
/**
* Alfresco Permission based Action Evaluator
*
- * @author davidc
+ * @author florian.mueller
*/
-public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator
+public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator
{
private PermissionActionEvaluator permissionEvaluator;
- private NodeService nodeService;
/**
* Construct
@@ -46,15 +43,15 @@ public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator
+public class CanCheckInActionEvaluator extends AbstractActionEvaluator
{
private PermissionActionEvaluator permissionEvaluator;
- private NodeService nodeService;
/**
* Construct
@@ -46,15 +43,15 @@ public class CanCheckInActionEvaluator extends AbstractActionEvaluator
super(serviceRegistry, Action.CAN_CHECK_IN);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CHECK_IN,
PermissionService.CHECK_IN);
- nodeService = serviceRegistry.getNodeService();
}
- public boolean isAllowed(NodeRef nodeRef)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
- if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
+ if (nodeInfo.isPWC())
{
- return permissionEvaluator.isAllowed(nodeRef);
+ return permissionEvaluator.isAllowed(nodeInfo);
}
+
return false;
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/CanCheckOutActionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/CanCheckOutActionEvaluator.java
index 935b27e5af..c5ee0c8d33 100644
--- a/source/java/org/alfresco/opencmis/mapping/CanCheckOutActionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/CanCheckOutActionEvaluator.java
@@ -18,24 +18,21 @@
*/
package org.alfresco.opencmis.mapping;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockService;
import org.alfresco.service.cmr.lock.LockType;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.chemistry.opencmis.commons.enums.Action;
/**
* Alfresco Permission based Action Evaluator
*
- * @author davidc
+ * @author florian.mueller
*/
-public class CanCheckOutActionEvaluator extends AbstractActionEvaluator
+public class CanCheckOutActionEvaluator extends AbstractActionEvaluator
{
private PermissionActionEvaluator permissionEvaluator;
- private NodeService nodeService;
private LockService lockService;
/**
@@ -49,18 +46,17 @@ public class CanCheckOutActionEvaluator extends AbstractActionEvaluator
super(serviceRegistry, Action.CAN_CHECK_OUT);
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CHECK_OUT,
PermissionService.CHECK_OUT);
- nodeService = serviceRegistry.getNodeService();
lockService = serviceRegistry.getLockService();
}
- public boolean isAllowed(NodeRef nodeRef)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
- if (nodeService.hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY)
- || lockService.getLockType(nodeRef) == LockType.READ_ONLY_LOCK)
+ if (!nodeInfo.isPWC() || lockService.getLockType(nodeInfo.getNodeRef()) == LockType.READ_ONLY_LOCK)
{
return false;
}
- return permissionEvaluator.isAllowed(nodeRef);
+
+ return permissionEvaluator.isAllowed(nodeInfo);
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java b/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java
index 95b08a41a7..4e586dd415 100644
--- a/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/CheckinCommentProperty.java
@@ -21,56 +21,29 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionHistory;
/**
* Accessor for the CMIS Checkin Comment
*
- * @author dward
+ * @author florian.mueller
*/
-public class CheckinCommentProperty extends AbstractVersioningProperty
+public class CheckinCommentProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public CheckinCommentProperty(ServiceRegistry serviceRegistry)
+ public CheckinCommentProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, CMISDictionaryModel.PROP_CHECKIN_COMMENT);
+ super(serviceRegistry, connector, CMISDictionaryModel.PROP_CHECKIN_COMMENT);
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (isWorkingCopy(nodeRef))
- {
- return null;
- }
- ServiceRegistry serviceRegistry = getServiceRegistry();
- String versionLabel = (String)serviceRegistry.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
- if (versionLabel == null)
- {
- return null;
- }
- NodeRef versionSeries = getVersionSeries(nodeRef);
- VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries);
- if (versionHistory == null)
- {
- return null;
- }
- Version version = versionHistory.getVersion(versionLabel);
- if (version == null)
- {
- return null;
- }
- return version.getDescription();
+ return nodeInfo.getCheckinComment();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/ContentStreamIdProperty.java b/source/java/org/alfresco/opencmis/mapping/ContentStreamIdProperty.java
index d98411907c..a3ee778371 100644
--- a/source/java/org/alfresco/opencmis/mapping/ContentStreamIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/ContentStreamIdProperty.java
@@ -20,17 +20,16 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for CMIS content stream property id
*
- * @author andyh
+ * @author florian.mueller
*/
public class ContentStreamIdProperty extends AbstractProperty
{
@@ -39,27 +38,19 @@ public class ContentStreamIdProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public ContentStreamIdProperty(ServiceRegistry serviceRegistry)
+ public ContentStreamIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.CONTENT_STREAM_ID);
+ super(serviceRegistry, connector, PropertyIds.CONTENT_STREAM_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- Serializable sValue = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT);
- if (sValue != null)
+ ContentData contentData = getContentData(nodeInfo);
+
+ if (contentData != null)
{
- ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, sValue);
return contentData.getContentUrl();
}
return null;
}
-
}
diff --git a/source/java/org/alfresco/opencmis/mapping/ContentStreamLengthProperty.java b/source/java/org/alfresco/opencmis/mapping/ContentStreamLengthProperty.java
index 50d3f66647..1fe3257dc7 100644
--- a/source/java/org/alfresco/opencmis/mapping/ContentStreamLengthProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/ContentStreamLengthProperty.java
@@ -20,19 +20,18 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for CMIS content stream length property
*
- * @author andyh
+ * @author florian.mueller
*/
public class ContentStreamLengthProperty extends AbstractProperty
{
@@ -41,31 +40,22 @@ public class ContentStreamLengthProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public ContentStreamLengthProperty(ServiceRegistry serviceRegistry)
+ public ContentStreamLengthProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.CONTENT_STREAM_LENGTH);
+ super(serviceRegistry, connector, PropertyIds.CONTENT_STREAM_LENGTH);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT);
- if (value != null)
+ ContentData contentData = getContentData(nodeInfo);
+
+ if (contentData != null)
{
- ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
return contentData.getSize();
- } else
- {
- return 0L;
}
+ return 0L;
}
-
+
public QName getMappedProperty()
{
// spoof
diff --git a/source/java/org/alfresco/opencmis/mapping/ContentStreamMimetypeProperty.java b/source/java/org/alfresco/opencmis/mapping/ContentStreamMimetypeProperty.java
index 62c008b170..efee98e777 100644
--- a/source/java/org/alfresco/opencmis/mapping/ContentStreamMimetypeProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/ContentStreamMimetypeProperty.java
@@ -21,11 +21,12 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.repo.node.getchildren.GetChildrenCannedQuery;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
import org.alfresco.service.cmr.repository.ContentData;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
@@ -33,7 +34,7 @@ import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for CMIS content stream mimetype property
*
- * @author andyh
+ * @author florian.mueller
*/
public class ContentStreamMimetypeProperty extends AbstractProperty
{
@@ -42,29 +43,20 @@ public class ContentStreamMimetypeProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public ContentStreamMimetypeProperty(ServiceRegistry serviceRegistry)
+ public ContentStreamMimetypeProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.CONTENT_STREAM_MIME_TYPE);
+ super(serviceRegistry, connector, PropertyIds.CONTENT_STREAM_MIME_TYPE);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_CONTENT);
- if (value != null)
+ ContentData contentData = getContentData(nodeInfo);
+
+ if (contentData != null)
{
- ContentData contentData = DefaultTypeConverter.INSTANCE.convert(ContentData.class, value);
return contentData.getMimetype();
- } else
- {
- return "";
}
+ return "";
}
public String getLuceneFieldName()
@@ -75,7 +67,7 @@ public class ContentStreamMimetypeProperty extends AbstractProperty
field.append(".mimetype");
return field.toString();
}
-
+
public QName getMappedProperty()
{
// spoof
diff --git a/source/java/org/alfresco/opencmis/mapping/CreationDateProperty.java b/source/java/org/alfresco/opencmis/mapping/CreationDateProperty.java
new file mode 100644
index 0000000000..79bf1a2e9f
--- /dev/null
+++ b/source/java/org/alfresco/opencmis/mapping/CreationDateProperty.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.opencmis.mapping;
+
+import java.io.Serializable;
+
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
+import org.alfresco.service.ServiceRegistry;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+
+/**
+ * Get the CMIS object creation date property.
+ *
+ * @author florian.mueller
+ */
+public class CreationDateProperty extends AbstractProperty
+{
+ /**
+ * Construct
+ *
+ * @param serviceRegistry
+ */
+ public CreationDateProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
+ {
+ super(serviceRegistry, connector, PropertyIds.CREATION_DATE);
+ }
+
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
+ {
+ return nodeInfo.getCreationDate();
+ }
+}
diff --git a/source/java/org/alfresco/opencmis/mapping/CurrentVersionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/CurrentVersionEvaluator.java
index ccb5f35e68..852cdd6fd8 100644
--- a/source/java/org/alfresco/opencmis/mapping/CurrentVersionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/CurrentVersionEvaluator.java
@@ -18,20 +18,14 @@
*/
package org.alfresco.opencmis.mapping;
-import java.io.Serializable;
-
-import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
-import org.alfresco.repo.version.VersionBaseModel;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionHistory;
import org.apache.chemistry.opencmis.commons.enums.Action;
-public class CurrentVersionEvaluator extends AbstractActionEvaluator
+public class CurrentVersionEvaluator extends AbstractActionEvaluator
{
- private CMISActionEvaluator currentVersionEvaluator;
+ private CMISActionEvaluator currentVersionEvaluator;
private boolean currentVersionValue;
private boolean nonCurrentVersionValue;
@@ -53,32 +47,21 @@ public class CurrentVersionEvaluator extends AbstractActionEvaluator
*
* @param serviceRegistry
*/
- protected CurrentVersionEvaluator(ServiceRegistry serviceRegistry,
- CMISActionEvaluator currentVersionEvaluator, boolean nonCurrentVersionValue)
+ protected CurrentVersionEvaluator(ServiceRegistry serviceRegistry, CMISActionEvaluator currentVersionEvaluator,
+ boolean nonCurrentVersionValue)
{
super(serviceRegistry, currentVersionEvaluator.getAction());
this.currentVersionEvaluator = currentVersionEvaluator;
this.nonCurrentVersionValue = nonCurrentVersionValue;
}
- public boolean isAllowed(NodeRef nodeRef)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
- if (nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL))
+ if (!nodeInfo.isCurrentVersion())
{
- VersionHistory versionHistory = getServiceRegistry().getVersionService().getVersionHistory(nodeRef);
- if (versionHistory != null)
- {
- Version currentVersion = versionHistory.getHeadVersion();
- Serializable versionLabel = getServiceRegistry().getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
-
- if (!currentVersion.getVersionLabel().equals(versionLabel))
- {
- return nonCurrentVersionValue;
- }
- }
+ return nonCurrentVersionValue;
}
- return currentVersionEvaluator == null ? currentVersionValue : currentVersionEvaluator.isAllowed(nodeRef);
+ return currentVersionEvaluator == null ? currentVersionValue : currentVersionEvaluator.isAllowed(nodeInfo);
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/DirectProperty.java b/source/java/org/alfresco/opencmis/mapping/DirectProperty.java
index 062e13706e..2509fede58 100644
--- a/source/java/org/alfresco/opencmis/mapping/DirectProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/DirectProperty.java
@@ -20,15 +20,16 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
- * A simple 1-1 property mapping from a CMIS property name to an alfresco property
+ * A simple 1-1 property mapping from a CMIS property name to an alfresco
+ * property
*
- * @author andyh
+ * @author florian.mueller
*/
public class DirectProperty extends AbstractProperty
{
@@ -41,37 +42,29 @@ public class DirectProperty extends AbstractProperty
* @param propertyName
* @param alfrescoName
*/
- public DirectProperty(ServiceRegistry serviceRegistry, String propertyName, QName alfrescoName)
+ public DirectProperty(ServiceRegistry serviceRegistry, CMISConnector connector, String propertyName,
+ QName alfrescoName)
{
- super(serviceRegistry, propertyName);
+ super(serviceRegistry, connector, propertyName);
this.alfrescoName = alfrescoName;
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.property.AbstractPropertyAccessor#getMappedProperty()
- */
public QName getMappedProperty()
{
return alfrescoName;
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- return getServiceRegistry().getNodeService().getProperty(nodeRef, alfrescoName);
- }
+ if (nodeInfo.getNodeRef() != null)
+ {
+ return getServiceRegistry().getNodeService().getProperty(nodeInfo.getNodeRef(), alfrescoName);
+ } else if (nodeInfo.getAssociationRef() != null)
+ {
+ return getServiceRegistry().getNodeService().getProperty(nodeInfo.getAssociationRef().getSourceRef(),
+ alfrescoName);
+ }
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
- {
return null;
}
-
}
diff --git a/source/java/org/alfresco/opencmis/mapping/FixedValueActionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/FixedValueActionEvaluator.java
index 180e92c56a..b2338d4d3e 100644
--- a/source/java/org/alfresco/opencmis/mapping/FixedValueActionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/FixedValueActionEvaluator.java
@@ -18,16 +18,17 @@
*/
package org.alfresco.opencmis.mapping;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
import org.apache.chemistry.opencmis.commons.enums.Action;
/**
* Action Evaluator whose evaluation is fixed
*
- * @author davidc
+ * @author florian.mueller
*
*/
-public class FixedValueActionEvaluator extends AbstractActionEvaluator
+public class FixedValueActionEvaluator extends AbstractActionEvaluator
{
private boolean allowed;
@@ -43,7 +44,7 @@ public class FixedValueActionEvaluator extends AbstractActionEvaluator
this.allowed = allowed;
}
- public boolean isAllowed(T object)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
return allowed;
}
diff --git a/source/java/org/alfresco/opencmis/mapping/FixedValueProperty.java b/source/java/org/alfresco/opencmis/mapping/FixedValueProperty.java
index 4e78fe081f..cb43a2f4c7 100644
--- a/source/java/org/alfresco/opencmis/mapping/FixedValueProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/FixedValueProperty.java
@@ -20,19 +20,19 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
/**
* Property accessor for fixed value mapping (eg to null, true, etc)
*
- * @author andyh
+ * @author florian.mueller
*/
public class FixedValueProperty extends AbstractProperty
{
private Serializable value;
-
+
/**
* Construct
*
@@ -40,26 +40,14 @@ public class FixedValueProperty extends AbstractProperty
* @param propertyName
* @param value
*/
- public FixedValueProperty(ServiceRegistry serviceRegistry, String propertyName, Serializable value)
+ public FixedValueProperty(ServiceRegistry serviceRegistry, CMISConnector connector, String propertyName,
+ Serializable value)
{
- super(serviceRegistry, propertyName);
+ super(serviceRegistry, connector, propertyName);
this.value = value;
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
- {
- return value;
- }
-
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service.cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
return value;
}
diff --git a/source/java/org/alfresco/opencmis/mapping/IsImmutableProperty.java b/source/java/org/alfresco/opencmis/mapping/IsImmutableProperty.java
index af4f5276b6..46cbaaa3f5 100644
--- a/source/java/org/alfresco/opencmis/mapping/IsImmutableProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/IsImmutableProperty.java
@@ -20,40 +20,34 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Property accessor for CMIS is immutable property
*
- * @author dward
+ * @author florian.mueller
*/
-public class IsImmutableProperty extends AbstractVersioningProperty
+public class IsImmutableProperty extends AbstractProperty
{
/**
* Construct
*/
- public IsImmutableProperty(ServiceRegistry serviceRegistry)
+ public IsImmutableProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.IS_IMMUTABLE);
+ super(serviceRegistry, connector, PropertyIds.IS_IMMUTABLE);
}
@Override
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (!isCurrentVersion(nodeRef))
+ if (nodeInfo.isVersion())
{
return true;
}
- if (isWorkingCopy(nodeRef))
- {
- return false;
- }
- if (getVersionSeries(nodeRef).equals(nodeRef))
- {
- return hasWorkingCopy(nodeRef);
- }
- return true;
+
+ return false;
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/IsLatestMajorVersionProperty.java b/source/java/org/alfresco/opencmis/mapping/IsLatestMajorVersionProperty.java
index 0f3bd47534..80c303ceb1 100644
--- a/source/java/org/alfresco/opencmis/mapping/IsLatestMajorVersionProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/IsLatestMajorVersionProperty.java
@@ -20,87 +20,30 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
-import org.alfresco.repo.version.VersionBaseModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionHistory;
-import org.alfresco.service.cmr.version.VersionService;
-import org.alfresco.service.cmr.version.VersionType;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for CMIS is latest major version property
*
- * @author dward
+ * @author florian.mueller
*/
-public class IsLatestMajorVersionProperty extends AbstractVersioningProperty
+public class IsLatestMajorVersionProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public IsLatestMajorVersionProperty(ServiceRegistry serviceRegistry)
+ public IsLatestMajorVersionProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.IS_LATEST_MAJOR_VERSION);
+ super(serviceRegistry, connector, PropertyIds.IS_LATEST_MAJOR_VERSION);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (isWorkingCopy(nodeRef))
- {
- return false;
- }
- NodeRef versionSeries = getVersionSeries(nodeRef);
- ServiceRegistry serviceRegistry = getServiceRegistry();
- VersionService versionService = serviceRegistry.getVersionService();
- VersionHistory versionHistory = versionService.getVersionHistory(versionSeries);
- if (versionHistory == null)
- {
- return false;
- }
-
- NodeRef versionNodeRef = nodeRef;
- if (!nodeRef.getStoreRef().getProtocol().equals(VersionBaseModel.STORE_PROTOCOL))
- {
- String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
- if (versionLabel == null)
- {
- return false;
- }
- Version version = versionHistory.getVersion(versionLabel);
- if (version == null)
- {
- return false;
- }
- versionNodeRef = version.getFrozenStateNodeRef();
- }
-
- // Go back in time to the last major version
- Version currentVersion = versionService.getCurrentVersion(versionSeries);
- while (currentVersion != null)
- {
- if (currentVersion.getVersionType() == VersionType.MAJOR)
- {
- return currentVersion.getFrozenStateNodeRef().equals(versionNodeRef);
- }
- // We got to the current node and its not major. We failed!
- else if (currentVersion.getFrozenStateNodeRef().equals(versionNodeRef))
- {
- return false;
- }
- currentVersion = versionHistory.getPredecessor(currentVersion);
- }
- return false;
+ return nodeInfo.isLatestMajorVersion();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/IsLatestVersionProperty.java b/source/java/org/alfresco/opencmis/mapping/IsLatestVersionProperty.java
index 81118b1a80..b6a52654d4 100644
--- a/source/java/org/alfresco/opencmis/mapping/IsLatestVersionProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/IsLatestVersionProperty.java
@@ -20,58 +20,29 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.version.Version;
-import org.alfresco.service.cmr.version.VersionHistory;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accesser for CMIS is latest version property
*
- * @author dward
+ * @author florian.mueller
*/
-public class IsLatestVersionProperty extends AbstractVersioningProperty
+public class IsLatestVersionProperty extends AbstractProperty
{
/**
* Construct
*/
- public IsLatestVersionProperty(ServiceRegistry serviceRegistry)
+ public IsLatestVersionProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.IS_LATEST_VERSION);
+ super(serviceRegistry, connector, PropertyIds.IS_LATEST_VERSION);
}
@Override
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (isWorkingCopy(nodeRef) || getVersionSeries(nodeRef).equals(nodeRef) && !hasWorkingCopy(nodeRef))
- {
- return true;
- }
- NodeRef versionSeries = getVersionSeries(nodeRef);
- if (hasWorkingCopy(versionSeries))
- {
- return false;
- }
-
- ServiceRegistry serviceRegistry = getServiceRegistry();
- String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
- if (versionLabel == null)
- {
- return false;
- }
- VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries);
- if (versionHistory == null)
- {
- return false;
- }
- Version version = versionHistory.getVersion(versionLabel);
- if (version == null)
- {
- return false;
- }
- return versionHistory.getHeadVersion().getFrozenStateNodeRef().equals(version.getFrozenStateNodeRef());
+ return nodeInfo.isLatestVersion();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/IsMajorVersionProperty.java b/source/java/org/alfresco/opencmis/mapping/IsMajorVersionProperty.java
index df9fbddae9..9521bb264f 100644
--- a/source/java/org/alfresco/opencmis/mapping/IsMajorVersionProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/IsMajorVersionProperty.java
@@ -20,56 +20,30 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.version.VersionHistory;
-import org.alfresco.service.cmr.version.VersionType;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for CMIS is major version property
*
- * @author dward
+ * @author florian.mueller
*/
-public class IsMajorVersionProperty extends AbstractVersioningProperty
+public class IsMajorVersionProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public IsMajorVersionProperty(ServiceRegistry serviceRegistry)
+ public IsMajorVersionProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.IS_MAJOR_VERSION);
+ super(serviceRegistry, connector, PropertyIds.IS_MAJOR_VERSION);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (isWorkingCopy(nodeRef))
- {
- return false;
- }
- ServiceRegistry serviceRegistry = getServiceRegistry();
- String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
- if (versionLabel == null)
- {
- return false;
- }
- NodeRef versionSeries = getVersionSeries(nodeRef);
- VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries);
- if (versionHistory == null)
- {
- return false;
- }
- return versionHistory.getVersion(versionLabel).getVersionType() == VersionType.MAJOR;
+ return nodeInfo.isMajorVersion();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/IsVersionSeriesCheckedOutProperty.java b/source/java/org/alfresco/opencmis/mapping/IsVersionSeriesCheckedOutProperty.java
index 581db1a810..8033a12c4a 100644
--- a/source/java/org/alfresco/opencmis/mapping/IsVersionSeriesCheckedOutProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/IsVersionSeriesCheckedOutProperty.java
@@ -20,28 +20,29 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Get the CMIS version series checked out property
*
- * @author dward
+ * @author florian.mueller
*/
-public class IsVersionSeriesCheckedOutProperty extends AbstractVersioningProperty
+public class IsVersionSeriesCheckedOutProperty extends AbstractProperty
{
/**
* Construct
*/
- public IsVersionSeriesCheckedOutProperty(ServiceRegistry serviceRegistry)
+ public IsVersionSeriesCheckedOutProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
+ super(serviceRegistry, connector, PropertyIds.IS_VERSION_SERIES_CHECKED_OUT);
}
@Override
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- return isWorkingCopy(nodeRef) || hasWorkingCopy(getVersionSeries(nodeRef));
+ return nodeInfo.hasPWC();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/ModificationDateProperty.java b/source/java/org/alfresco/opencmis/mapping/ModificationDateProperty.java
new file mode 100644
index 0000000000..3df8cb00a8
--- /dev/null
+++ b/source/java/org/alfresco/opencmis/mapping/ModificationDateProperty.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.opencmis.mapping;
+
+import java.io.Serializable;
+
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
+import org.alfresco.service.ServiceRegistry;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+
+/**
+ * Get the CMIS object modification date property.
+ *
+ * @author florian.mueller
+ */
+public class ModificationDateProperty extends AbstractProperty
+{
+ /**
+ * Construct
+ *
+ * @param serviceRegistry
+ */
+ public ModificationDateProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
+ {
+ super(serviceRegistry, connector, PropertyIds.LAST_MODIFICATION_DATE);
+ }
+
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
+ {
+ return nodeInfo.getModificationDate();
+ }
+}
diff --git a/source/java/org/alfresco/opencmis/mapping/NameProperty.java b/source/java/org/alfresco/opencmis/mapping/NameProperty.java
new file mode 100644
index 0000000000..696ad573cd
--- /dev/null
+++ b/source/java/org/alfresco/opencmis/mapping/NameProperty.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2005-2010 Alfresco Software Limited.
+ *
+ * This file is part of Alfresco
+ *
+ * Alfresco is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * Alfresco is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Alfresco. If not, see .
+ */
+package org.alfresco.opencmis.mapping;
+
+import java.io.Serializable;
+
+import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
+import org.alfresco.service.ServiceRegistry;
+import org.alfresco.service.namespace.QName;
+import org.apache.chemistry.opencmis.commons.PropertyIds;
+
+/**
+ * Get the CMIS object name property.
+ *
+ * @author florian.mueller
+ */
+public class NameProperty extends AbstractProperty
+{
+ /**
+ * Construct
+ *
+ * @param serviceRegistry
+ */
+ public NameProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
+ {
+ super(serviceRegistry, connector, PropertyIds.NAME);
+ }
+
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
+ {
+ return nodeInfo.getName();
+ }
+
+ public QName getMappedProperty()
+ {
+ return ContentModel.PROP_NAME;
+ }
+}
diff --git a/source/java/org/alfresco/opencmis/mapping/NodeRefProperty.java b/source/java/org/alfresco/opencmis/mapping/NodeRefProperty.java
index ee456cb6f7..219b5d555f 100644
--- a/source/java/org/alfresco/opencmis/mapping/NodeRefProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/NodeRefProperty.java
@@ -20,14 +20,14 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
/**
* Get the CMIS object id property.
*/
-public class NodeRefProperty extends AbstractVersioningProperty
+public class NodeRefProperty extends AbstractProperty
{
public static final String NodeRefPropertyId = "alfcmis:nodeRef";
@@ -36,20 +36,28 @@ public class NodeRefProperty extends AbstractVersioningProperty
*
* @param serviceRegistry
*/
- public NodeRefProperty(ServiceRegistry serviceRegistry)
+ public NodeRefProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, NodeRefPropertyId);
+ super(serviceRegistry, connector, NodeRefPropertyId);
}
@Override
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- return getLiveNodeRef(nodeRef);
- }
+ if (nodeInfo.getNodeRef() != null)
+ {
+ if (nodeInfo.isCurrentVersion())
+ {
+ return nodeInfo.getCurrentNodeNodeRef().toString();
+ } else
+ {
+ return nodeInfo.getNodeRef().toString();
+ }
+ } else if (nodeInfo.getAssociationRef() != null)
+ {
+ return nodeInfo.getAssociationRef().toString();
+ }
- @Override
- public Serializable getValue(AssociationRef assocRef)
- {
- return "" + assocRef.getId();
+ return null;
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/ObjectIdProperty.java b/source/java/org/alfresco/opencmis/mapping/ObjectIdProperty.java
index 4b876dd138..4e91808c5d 100644
--- a/source/java/org/alfresco/opencmis/mapping/ObjectIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/ObjectIdProperty.java
@@ -20,75 +20,30 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Get the CMIS object id property.
*
- * @author andyh
- * @author dward
+ * @author florian.mueller
*/
-public class ObjectIdProperty extends AbstractVersioningProperty
+public class ObjectIdProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public ObjectIdProperty(ServiceRegistry serviceRegistry)
+ public ObjectIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.OBJECT_ID);
+ super(serviceRegistry, connector, PropertyIds.OBJECT_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (isWorkingCopy(nodeRef))
- {
- return nodeRef.toString();
- }
-
- QName typeQName = getServiceRegistry().getNodeService().getType(nodeRef);
- if (typeQName.equals(CMISMapping.DOCUMENT_QNAME)
- || getServiceRegistry().getDictionaryService().isSubClass(typeQName, ContentModel.TYPE_CONTENT))
- {
- Serializable versionLabel = getServiceRegistry().getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
- if (versionLabel == null)
- {
- versionLabel = CMISConnector.UNVERSIONED_VERSION_LABEL;
- }
-
- NodeRef versionSeries = getVersionSeries(nodeRef);
- return new StringBuilder(1024).append(versionSeries.toString()).append(CMISConnector.ID_SEPERATOR)
- .append(versionLabel).toString();
- }
-
- return nodeRef.toString();
+ return nodeInfo.getObjectId();
}
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
- {
- return CMISConnector.ASSOC_ID_PREFIX + assocRef.getId();
- }
-
}
diff --git a/source/java/org/alfresco/opencmis/mapping/ObjectTypeIdProperty.java b/source/java/org/alfresco/opencmis/mapping/ObjectTypeIdProperty.java
index bc5fcea0a1..20dc5878b6 100644
--- a/source/java/org/alfresco/opencmis/mapping/ObjectTypeIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/ObjectTypeIdProperty.java
@@ -20,57 +20,32 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
import org.alfresco.opencmis.dictionary.CMISDictionaryService;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
-import org.apache.chemistry.opencmis.commons.enums.BaseTypeId;
/**
* Get the CMIS object type id property
*
- * @author andyh
+ * @author florian.mueller
*/
public class ObjectTypeIdProperty extends AbstractProperty
{
- private CMISDictionaryService dictionaryService;
-
/**
* Construct
*
* @param serviceRegistry
*/
- public ObjectTypeIdProperty(ServiceRegistry serviceRegistry, CMISDictionaryService dictionaryService)
+ public ObjectTypeIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector,
+ CMISDictionaryService dictionaryService)
{
- super(serviceRegistry, PropertyIds.OBJECT_TYPE_ID);
- this.dictionaryService = dictionaryService;
+ super(serviceRegistry, connector, PropertyIds.OBJECT_TYPE_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- QName type = getServiceRegistry().getNodeService().getType(nodeRef);
- return dictionaryService.findTypeForClass(type).getTypeId();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
- {
- QName type = assocRef.getTypeQName();
- return dictionaryService.findTypeForClass(type, BaseTypeId.CMIS_RELATIONSHIP).getTypeId();
+ return nodeInfo.getType().getTypeId();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/ParentActionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/ParentActionEvaluator.java
index f3ddd520ec..29753aa5cf 100644
--- a/source/java/org/alfresco/opencmis/mapping/ParentActionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/ParentActionEvaluator.java
@@ -18,17 +18,19 @@
*/
package org.alfresco.opencmis.mapping;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
/**
* Action Evaluator whose evaluation takes place on parent
*
- * @author davidc
+ * @author florian.mueller
*/
-public class ParentActionEvaluator extends AbstractActionEvaluator
+public class ParentActionEvaluator extends AbstractActionEvaluator
{
- private AbstractActionEvaluator evaluator;
+ private AbstractActionEvaluator evaluator;
+ private CMISConnector cmisConnector;
/**
* Construct
@@ -36,36 +38,29 @@ public class ParentActionEvaluator extends AbstractActionEvaluator
* @param serviceRegistry
* @param action
*/
- protected ParentActionEvaluator(AbstractActionEvaluator evaluator)
+ protected ParentActionEvaluator(CMISConnector cmisConnector, AbstractActionEvaluator evaluator)
{
super(evaluator.getServiceRegistry(), evaluator.getAction());
this.evaluator = evaluator;
+ this.cmisConnector = cmisConnector;
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef)
- */
- public boolean isAllowed(NodeRef nodeRef)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
- if (nodeRef.equals(getServiceRegistry().getCMISService().getDefaultRootNodeRef()))
+ if (nodeInfo.isRootFolder())
{
return false;
}
- ChildAssociationRef car = getServiceRegistry().getNodeService().getPrimaryParent(nodeRef);
+ ChildAssociationRef car = getServiceRegistry().getNodeService().getPrimaryParent(nodeInfo.getNodeRef());
if ((car != null) && (car.getParentRef() != null))
{
- return evaluator.isAllowed(car.getParentRef());
+ return evaluator.isAllowed(cmisConnector.createNodeInfo(car.getParentRef()));
}
-
+
return false;
}
- /*
- * (non-Javadoc)
- * @see java.lang.Object#toString()
- */
@Override
public String toString()
{
@@ -74,4 +69,3 @@ public class ParentActionEvaluator extends AbstractActionEvaluator
return builder.toString();
}
}
-
diff --git a/source/java/org/alfresco/opencmis/mapping/ParentProperty.java b/source/java/org/alfresco/opencmis/mapping/ParentProperty.java
index c257ed275f..29279c1ce3 100644
--- a/source/java/org/alfresco/opencmis/mapping/ParentProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/ParentProperty.java
@@ -20,15 +20,16 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Get the CMIS parent property
*
- * @author andyh
+ * @author florian.mueller
*
*/
public class ParentProperty extends AbstractProperty
@@ -38,32 +39,24 @@ public class ParentProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public ParentProperty(ServiceRegistry serviceRegistry)
+ public ParentProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.PARENT_ID);
+ super(serviceRegistry, connector, PropertyIds.PARENT_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (nodeRef.equals(getServiceRegistry().getCMISService().getDefaultRootNodeRef()))
+ if (nodeInfo.isRootFolder())
{
return null;
}
- ChildAssociationRef car = getServiceRegistry().getNodeService().getPrimaryParent(nodeRef);
+ ChildAssociationRef car = getServiceRegistry().getNodeService().getPrimaryParent(nodeInfo.getNodeRef());
if ((car != null) && (car.getParentRef() != null))
{
return car.getParentRef().toString();
- } else
- {
- return null;
}
+
+ return null;
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/PathProperty.java b/source/java/org/alfresco/opencmis/mapping/PathProperty.java
index 4da72c767d..87261627f7 100644
--- a/source/java/org/alfresco/opencmis/mapping/PathProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/PathProperty.java
@@ -20,100 +20,30 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.ChildAssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
-import org.alfresco.service.cmr.repository.Path;
-import org.alfresco.service.cmr.repository.Path.ChildAssocElement;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Get the CMIS path property.
*
- * @author davidc
+ * @author florian.mueller
*/
public class PathProperty extends AbstractProperty
{
- private CMISConnector cmisConnector;
-
/**
* Construct
*
* @param serviceRegistry
*/
- public PathProperty(ServiceRegistry serviceRegistry, CMISConnector cmisConnector)
+ public PathProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.PATH);
- this.cmisConnector = cmisConnector;
+ super(serviceRegistry, connector, PropertyIds.PATH);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- Path path = getServiceRegistry().getNodeService().getPath(nodeRef);
- return toDisplayPath(path);
+ return nodeInfo.getPath();
}
-
- private String toDisplayPath(Path path)
- {
- StringBuilder displayPath = new StringBuilder(64);
-
- // skip to CMIS root path
- NodeRef rootNode = cmisConnector.getRootNodeRef();
- int i = 0;
- while (i < path.size())
- {
- Path.Element element = path.get(i);
- if (element instanceof ChildAssocElement)
- {
- ChildAssociationRef assocRef = ((ChildAssocElement) element).getRef();
- NodeRef node = assocRef.getChildRef();
- if (node.equals(rootNode))
- {
- break;
- }
- }
- i++;
- }
-
- if (i == path.size())
- {
- // TODO:
- // throw new AlfrescoRuntimeException("Path " + path +
- // " not in CMIS root node scope");
- }
-
- if (path.size() - i == 1)
- {
- // render root path
- displayPath.append("/");
- } else
- {
- // render CMIS scoped path
- i++;
- while (i < path.size())
- {
- Path.Element element = path.get(i);
- if (element instanceof ChildAssocElement)
- {
- ChildAssociationRef assocRef = ((ChildAssocElement) element).getRef();
- NodeRef node = assocRef.getChildRef();
- displayPath.append("/");
- displayPath.append(getServiceRegistry().getNodeService().getProperty(node, ContentModel.PROP_NAME));
- }
- i++;
- }
- }
-
- return displayPath.toString();
- }
-
}
diff --git a/source/java/org/alfresco/opencmis/mapping/PermissionActionEvaluator.java b/source/java/org/alfresco/opencmis/mapping/PermissionActionEvaluator.java
index 4e08183da6..a0cde4ff46 100644
--- a/source/java/org/alfresco/opencmis/mapping/PermissionActionEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/PermissionActionEvaluator.java
@@ -18,9 +18,8 @@
*/
package org.alfresco.opencmis.mapping;
-
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.AccessStatus;
import org.alfresco.service.cmr.security.PermissionService;
import org.apache.chemistry.opencmis.commons.enums.Action;
@@ -30,7 +29,7 @@ import org.apache.chemistry.opencmis.commons.enums.Action;
*
* @author davidc
*/
-public class PermissionActionEvaluator extends AbstractActionEvaluator
+public class PermissionActionEvaluator extends AbstractActionEvaluator
{
private String[] permissions;
private PermissionService permissionService;
@@ -48,22 +47,18 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator
this.permissionService = serviceRegistry.getPermissionService();
}
- /*
- * (non-Javadoc)
- * @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef)
- */
- public boolean isAllowed(NodeRef nodeRef)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
for (String permission : permissions)
{
- if (permissionService.hasPermission(nodeRef, permission) == AccessStatus.DENIED)
+ if (permissionService.hasPermission(nodeInfo.getNodeRef(), permission) == AccessStatus.DENIED)
{
return false;
}
}
return true;
}
-
+
@Override
public String toString()
{
@@ -77,5 +72,5 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator
builder.append("]");
return builder.toString();
}
-
+
}
diff --git a/source/java/org/alfresco/opencmis/mapping/RootFolderEvaluator.java b/source/java/org/alfresco/opencmis/mapping/RootFolderEvaluator.java
index dde89126b4..db514dfb4c 100644
--- a/source/java/org/alfresco/opencmis/mapping/RootFolderEvaluator.java
+++ b/source/java/org/alfresco/opencmis/mapping/RootFolderEvaluator.java
@@ -18,33 +18,30 @@
*/
package org.alfresco.opencmis.mapping;
-import org.alfresco.opencmis.CMISConnector;
import org.alfresco.opencmis.dictionary.CMISActionEvaluator;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
-public class RootFolderEvaluator extends AbstractActionEvaluator
+public class RootFolderEvaluator extends AbstractActionEvaluator
{
- private CMISConnector cmisConnector;
- private CMISActionEvaluator folderEvaluator;
+ private CMISActionEvaluator folderEvaluator;
private boolean rootFolderValue;
- protected RootFolderEvaluator(ServiceRegistry serviceRegistry, CMISConnector cmisConnector,
- CMISActionEvaluator folderEvaluator, boolean rootFolderValue)
+ protected RootFolderEvaluator(ServiceRegistry serviceRegistry, CMISActionEvaluator folderEvaluator,
+ boolean rootFolderValue)
{
super(serviceRegistry, folderEvaluator.getAction());
- this.cmisConnector = cmisConnector;
this.folderEvaluator = folderEvaluator;
this.rootFolderValue = rootFolderValue;
}
- public boolean isAllowed(NodeRef nodeRef)
+ public boolean isAllowed(CMISNodeInfo nodeInfo)
{
- if (cmisConnector.getRootNodeRef().equals(nodeRef))
+ if (nodeInfo.isRootFolder())
{
return rootFolderValue;
}
- return folderEvaluator.isAllowed(nodeRef);
+ return folderEvaluator.isAllowed(nodeInfo);
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/RuntimePropertyAccessorMapping.java b/source/java/org/alfresco/opencmis/mapping/RuntimePropertyAccessorMapping.java
index 14cb90761a..2b45f23cb7 100644
--- a/source/java/org/alfresco/opencmis/mapping/RuntimePropertyAccessorMapping.java
+++ b/source/java/org/alfresco/opencmis/mapping/RuntimePropertyAccessorMapping.java
@@ -18,7 +18,6 @@
*/
package org.alfresco.opencmis.mapping;
-import java.io.Serializable;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedHashMap;
@@ -32,8 +31,6 @@ import org.alfresco.opencmis.dictionary.CMISDictionaryService;
import org.alfresco.opencmis.dictionary.CMISPropertyAccessor;
import org.alfresco.opencmis.dictionary.PropertyAccessorMapping;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.security.PermissionService;
import org.alfresco.service.namespace.QName;
import org.apache.chemistry.opencmis.commons.PropertyIds;
@@ -61,7 +58,7 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
private CMISDictionaryService cmisDictionaryService;
private Map propertyAccessors = new HashMap();
- private Map>> actionEvaluators = new HashMap>>();
+ private Map> actionEvaluators = new HashMap>();
/**
* @param service
@@ -111,47 +108,38 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
// Property Mappings
//
- registerPropertyAccessor(new ObjectIdProperty(serviceRegistry));
- registerPropertyAccessor(new NodeRefProperty(serviceRegistry));
- registerPropertyAccessor(new ObjectTypeIdProperty(serviceRegistry, cmisDictionaryService));
- registerPropertyAccessor(new BaseTypeIdProperty(serviceRegistry, cmisDictionaryService));
- registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CREATED_BY, ContentModel.PROP_CREATOR));
- registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CREATION_DATE,
- ContentModel.PROP_CREATED));
- registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.LAST_MODIFIED_BY,
+ registerPropertyAccessor(new ObjectIdProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new NodeRefProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new ObjectTypeIdProperty(serviceRegistry, cmisConnector, cmisDictionaryService));
+ registerPropertyAccessor(new BaseTypeIdProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new DirectProperty(serviceRegistry, cmisConnector, PropertyIds.CREATED_BY,
+ ContentModel.PROP_CREATOR));
+ registerPropertyAccessor(new CreationDateProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new DirectProperty(serviceRegistry, cmisConnector, PropertyIds.LAST_MODIFIED_BY,
ContentModel.PROP_MODIFIER));
- registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.LAST_MODIFICATION_DATE,
- ContentModel.PROP_MODIFIED));
- registerPropertyAccessor(new FixedValueProperty(serviceRegistry, PropertyIds.CHANGE_TOKEN, null));
- registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.NAME, ContentModel.PROP_NAME)
- {
- @Override
- public Serializable getValue(AssociationRef assocRef)
- {
- // Let's use the association ref as the name
- return assocRef.toString();
- }
- });
- registerPropertyAccessor(new IsImmutableProperty(serviceRegistry));
- registerPropertyAccessor(new IsLatestVersionProperty(serviceRegistry));
- registerPropertyAccessor(new IsMajorVersionProperty(serviceRegistry));
- registerPropertyAccessor(new IsLatestMajorVersionProperty(serviceRegistry));
- registerPropertyAccessor(new VersionLabelProperty(serviceRegistry));
- registerPropertyAccessor(new VersionSeriesIdProperty(serviceRegistry));
- registerPropertyAccessor(new IsVersionSeriesCheckedOutProperty(serviceRegistry));
- registerPropertyAccessor(new VersionSeriesCheckedOutByProperty(serviceRegistry));
- registerPropertyAccessor(new VersionSeriesCheckedOutIdProperty(serviceRegistry));
- registerPropertyAccessor(new CheckinCommentProperty(serviceRegistry));
- registerPropertyAccessor(new ContentStreamLengthProperty(serviceRegistry));
- registerPropertyAccessor(new ContentStreamMimetypeProperty(serviceRegistry));
- registerPropertyAccessor(new ContentStreamIdProperty(serviceRegistry));
- registerPropertyAccessor(new DirectProperty(serviceRegistry, PropertyIds.CONTENT_STREAM_FILE_NAME,
- ContentModel.PROP_NAME));
- registerPropertyAccessor(new ParentProperty(serviceRegistry));
+ registerPropertyAccessor(new ModificationDateProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new FixedValueProperty(serviceRegistry, cmisConnector, PropertyIds.CHANGE_TOKEN, null));
+ registerPropertyAccessor(new NameProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new IsImmutableProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new IsLatestVersionProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new IsMajorVersionProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new IsLatestMajorVersionProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new VersionLabelProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new VersionSeriesIdProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new IsVersionSeriesCheckedOutProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new VersionSeriesCheckedOutByProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new VersionSeriesCheckedOutIdProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new CheckinCommentProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new ContentStreamLengthProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new ContentStreamMimetypeProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new ContentStreamIdProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new DirectProperty(serviceRegistry, cmisConnector,
+ PropertyIds.CONTENT_STREAM_FILE_NAME, ContentModel.PROP_NAME));
+ registerPropertyAccessor(new ParentProperty(serviceRegistry, cmisConnector));
registerPropertyAccessor(new PathProperty(serviceRegistry, cmisConnector));
- registerPropertyAccessor(new AllowedChildObjectTypeIdsProperty(serviceRegistry, cmisMapping));
- registerPropertyAccessor(new SourceIdProperty(serviceRegistry));
- registerPropertyAccessor(new TargetIdProperty(serviceRegistry));
+ registerPropertyAccessor(new AllowedChildObjectTypeIdsProperty(serviceRegistry, cmisConnector, cmisMapping));
+ registerPropertyAccessor(new SourceIdProperty(serviceRegistry, cmisConnector));
+ registerPropertyAccessor(new TargetIdProperty(serviceRegistry, cmisConnector));
//
// Action Evaluator Mappings
@@ -169,10 +157,11 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
PermissionService.WRITE_PROPERTIES), false));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_OBJECT_RELATIONSHIPS, true));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new ParentActionEvaluator(new PermissionActionEvaluator(
- serviceRegistry, Action.CAN_GET_OBJECT_PARENTS, PermissionService.READ_PERMISSIONS)));
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new ParentActionEvaluator(cmisConnector,
+ new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_OBJECT_PARENTS,
+ PermissionService.READ_PERMISSIONS)));
// Is CAN_MOVE correct mapping?
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
new PermissionActionEvaluator(serviceRegistry, Action.CAN_MOVE_OBJECT, PermissionService.DELETE_NODE),
@@ -187,26 +176,25 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
new PermissionActionEvaluator(serviceRegistry, Action.CAN_SET_CONTENT_STREAM,
PermissionService.WRITE_CONTENT), false));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_ALL_VERSIONS, true));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
- new ParentActionEvaluator(new PermissionActionEvaluator(serviceRegistry,
- Action.CAN_ADD_OBJECT_TO_FOLDER, PermissionService.LINK_CHILDREN)), false));
+ new FixedValueActionEvaluator(serviceRegistry, Action.CAN_ADD_OBJECT_TO_FOLDER, true), false));
// Is CAN_REMOVE_FROM_FOLDER correct mapping?
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
- new ParentActionEvaluator(new FixedValueActionEvaluator(serviceRegistry,
- Action.CAN_REMOVE_OBJECT_FROM_FOLDER, true)), false));
+ new PermissionActionEvaluator(serviceRegistry, Action.CAN_REMOVE_OBJECT_FROM_FOLDER,
+ PermissionService.DELETE_NODE), false));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_GET_CONTENT_STREAM, PermissionService.READ_CONTENT));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_APPLY_POLICY, false));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_APPLIED_POLICIES, true));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_REMOVE_POLICY, false));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
- new FixedValueActionEvaluator(serviceRegistry, Action.CAN_CREATE_RELATIONSHIP, true), false));
- registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
+ new FixedValueActionEvaluator(serviceRegistry, Action.CAN_CREATE_RELATIONSHIP, true), false));
+ registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_RENDITIONS, true));
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_ACL,
PermissionService.READ_PERMISSIONS));
@@ -215,7 +203,7 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
PermissionService.CHANGE_PERMISSIONS), false));
registerEvaluator(BaseTypeId.CMIS_FOLDER,
- new RootFolderEvaluator(serviceRegistry, cmisConnector, new PermissionActionEvaluator(serviceRegistry,
+ new RootFolderEvaluator(serviceRegistry, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_DELETE_OBJECT, PermissionService.DELETE_NODE), false));
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_UPDATE_PROPERTIES, PermissionService.WRITE_PROPERTIES));
@@ -223,24 +211,25 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
Action.CAN_GET_FOLDER_TREE, PermissionService.READ_CHILDREN));
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_OBJECT_RELATIONSHIPS, true));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new ParentActionEvaluator(new PermissionActionEvaluator(
- serviceRegistry, Action.CAN_GET_OBJECT_PARENTS, PermissionService.READ_PERMISSIONS)));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new RootFolderEvaluator(serviceRegistry, cmisConnector,
- new ParentActionEvaluator(new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_FOLDER_PARENT,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new ParentActionEvaluator(cmisConnector,
+ new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_OBJECT_PARENTS,
+ PermissionService.READ_PERMISSIONS)));
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new RootFolderEvaluator(serviceRegistry, new ParentActionEvaluator(
+ cmisConnector, new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_FOLDER_PARENT,
PermissionService.READ_PERMISSIONS)), false));
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_GET_DESCENDANTS, PermissionService.READ_CHILDREN));
// Is CAN_MOVE_OBJECT correct mapping?
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new RootFolderEvaluator(serviceRegistry, cmisConnector,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new RootFolderEvaluator(serviceRegistry,
new PermissionActionEvaluator(serviceRegistry, Action.CAN_MOVE_OBJECT, PermissionService.DELETE_NODE),
false));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_APPLY_POLICY, false));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_APPLIED_POLICIES, true));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_REMOVE_POLICY, false));
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_GET_CHILDREN, PermissionService.READ_CHILDREN));
@@ -250,7 +239,7 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
Action.CAN_CREATE_FOLDER, PermissionService.CREATE_CHILDREN));
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry,
Action.CAN_CREATE_RELATIONSHIP, PermissionService.CREATE_ASSOCIATIONS));
- registerEvaluator(BaseTypeId.CMIS_FOLDER, new RootFolderEvaluator(serviceRegistry, cmisConnector,
+ registerEvaluator(BaseTypeId.CMIS_FOLDER, new RootFolderEvaluator(serviceRegistry,
new PermissionActionEvaluator(serviceRegistry, Action.CAN_DELETE_TREE, PermissionService.DELETE_NODE),
false));
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry, Action.CAN_GET_ACL,
@@ -258,37 +247,37 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
registerEvaluator(BaseTypeId.CMIS_FOLDER, new PermissionActionEvaluator(serviceRegistry, Action.CAN_APPLY_ACL,
PermissionService.CHANGE_PERMISSIONS));
- registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_DELETE_OBJECT, true));
- registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_UPDATE_PROPERTIES, false));
- registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_PROPERTIES, true));
- registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_ACL, false));
- registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_APPLY_ACL, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_DELETE_OBJECT, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_UPDATE_PROPERTIES, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_PROPERTIES, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_OBJECT_PARENTS, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_MOVE_OBJECT, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_ADD_OBJECT_TO_FOLDER, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_REMOVE_OBJECT_FROM_FOLDER, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
Action.CAN_GET_OBJECT_RELATIONSHIPS, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
- Action.CAN_GET_ACL, false));
- registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
- Action.CAN_APPLY_ACL, false));
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry, Action.CAN_GET_ACL,
+ false));
+ registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry, Action.CAN_APPLY_ACL,
+ false));
}
/**
@@ -314,7 +303,7 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
*/
public CMISPropertyAccessor createDirectPropertyAccessor(String propertyId, QName propertyName)
{
- return new DirectProperty(serviceRegistry, propertyId, propertyName);
+ return new DirectProperty(serviceRegistry, cmisConnector, propertyId, propertyName);
}
/**
@@ -332,9 +321,9 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
*
* @param scope
*/
- public Map> getActionEvaluators(BaseTypeId scope)
+ public Map getActionEvaluators(BaseTypeId scope)
{
- Map> evaluators = actionEvaluators.get(scope);
+ Map evaluators = actionEvaluators.get(scope);
if (evaluators == null)
{
evaluators = Collections.emptyMap();
@@ -348,12 +337,12 @@ public class RuntimePropertyAccessorMapping implements PropertyAccessorMapping,
* @param scope
* @param evaluator
*/
- private void registerEvaluator(BaseTypeId scope, CMISActionEvaluator extends Object> evaluator)
+ private void registerEvaluator(BaseTypeId scope, CMISActionEvaluator evaluator)
{
- Map> evaluators = actionEvaluators.get(scope);
+ Map evaluators = actionEvaluators.get(scope);
if (evaluators == null)
{
- evaluators = new LinkedHashMap>();
+ evaluators = new LinkedHashMap();
actionEvaluators.put(scope, evaluators);
}
if (evaluators.get(evaluator.getAction()) != null)
diff --git a/source/java/org/alfresco/opencmis/mapping/SourceIdProperty.java b/source/java/org/alfresco/opencmis/mapping/SourceIdProperty.java
index 46445fc203..77fccd453a 100644
--- a/source/java/org/alfresco/opencmis/mapping/SourceIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/SourceIdProperty.java
@@ -20,14 +20,15 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for the Source Id (relationship)
*
- * @author davidc
+ * @author florian.mueller
*/
public class SourceIdProperty extends AbstractProperty
{
@@ -36,20 +37,13 @@ public class SourceIdProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public SourceIdProperty(ServiceRegistry serviceRegistry)
+ public SourceIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.SOURCE_ID);
+ super(serviceRegistry, connector, PropertyIds.SOURCE_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- return assocRef.getSourceRef().toString();
+ return createNodeInfo(nodeInfo.getAssociationRef().getSourceRef()).getObjectId();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/TargetIdProperty.java b/source/java/org/alfresco/opencmis/mapping/TargetIdProperty.java
index 9b901e27c1..60a013bf03 100644
--- a/source/java/org/alfresco/opencmis/mapping/TargetIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/TargetIdProperty.java
@@ -20,14 +20,15 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.AssociationRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Accessor for the Target Id (relationship)
*
- * @author davidc
+ * @author florian.mueller
*/
public class TargetIdProperty extends AbstractProperty
{
@@ -36,20 +37,13 @@ public class TargetIdProperty extends AbstractProperty
*
* @param serviceRegistry
*/
- public TargetIdProperty(ServiceRegistry serviceRegistry)
+ public TargetIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.TARGET_ID);
+ super(serviceRegistry, connector, PropertyIds.TARGET_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
- * .cmr.repository.AssociationRef)
- */
- public Serializable getValue(AssociationRef assocRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- return assocRef.getTargetRef().toString();
+ return createNodeInfo(nodeInfo.getAssociationRef().getTargetRef()).getObjectId();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/VersionLabelProperty.java b/source/java/org/alfresco/opencmis/mapping/VersionLabelProperty.java
index 75f35e95fd..7f79cc0e14 100644
--- a/source/java/org/alfresco/opencmis/mapping/VersionLabelProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/VersionLabelProperty.java
@@ -20,46 +20,28 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
-import org.alfresco.model.ContentModel;
import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
- * @author dward
+ * @author florian.mueller
*/
-public class VersionLabelProperty extends AbstractVersioningProperty
+public class VersionLabelProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public VersionLabelProperty(ServiceRegistry serviceRegistry)
+ public VersionLabelProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.VERSION_LABEL);
+ super(serviceRegistry, connector, PropertyIds.VERSION_LABEL);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- if (isWorkingCopy(nodeRef))
- {
- return CMISConnector.PWC_VERSION_LABEL;
- }
- Serializable versionLabel = getServiceRegistry().getNodeService().getProperty(nodeRef,
- ContentModel.PROP_VERSION_LABEL);
- if (versionLabel == null)
- {
- return CMISConnector.UNVERSIONED_VERSION_LABEL;
- }
- return versionLabel;
+ return nodeInfo.getVersionLabel();
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutByProperty.java b/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutByProperty.java
index 25ca5aa7a2..2025016e58 100644
--- a/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutByProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutByProperty.java
@@ -21,44 +21,43 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
import org.alfresco.model.ContentModel;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Get the CMIS version series checked out by property
*
- * @author dward
+ * @author florian.mueller
*/
-public class VersionSeriesCheckedOutByProperty extends AbstractVersioningProperty
+public class VersionSeriesCheckedOutByProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public VersionSeriesCheckedOutByProperty(ServiceRegistry serviceRegistry)
+ public VersionSeriesCheckedOutByProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
+ super(serviceRegistry, connector, PropertyIds.VERSION_SERIES_CHECKED_OUT_BY);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- NodeRef versionSeries;
- if (isWorkingCopy(nodeRef))
+ if (!nodeInfo.hasPWC())
{
- return getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_OWNER);
- } else if (hasWorkingCopy((versionSeries = getVersionSeries(nodeRef))))
- {
- return getServiceRegistry().getNodeService().getProperty(versionSeries, ContentModel.PROP_LOCK_OWNER);
+ return null;
+ }
+
+ if (nodeInfo.isPWC())
+ {
+ return getServiceRegistry().getNodeService().getProperty(nodeInfo.getNodeRef(),
+ ContentModel.PROP_WORKING_COPY_OWNER);
+ } else
+ {
+ return getServiceRegistry().getNodeService().getProperty(nodeInfo.getCurrentNodeNodeRef(),
+ ContentModel.PROP_LOCK_OWNER);
}
- return null;
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutIdProperty.java b/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutIdProperty.java
index 4e8a08c05f..5c13d39030 100644
--- a/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/VersionSeriesCheckedOutIdProperty.java
@@ -20,48 +20,35 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
* Get the CMIS version series checked out id property
*
- * @author dward
+ * @author florian.mueller
*/
-public class VersionSeriesCheckedOutIdProperty extends AbstractVersioningProperty
+public class VersionSeriesCheckedOutIdProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
- public VersionSeriesCheckedOutIdProperty(ServiceRegistry serviceRegistry)
+ public VersionSeriesCheckedOutIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
+ super(serviceRegistry, connector, PropertyIds.VERSION_SERIES_CHECKED_OUT_ID);
}
- /*
- * (non-Javadoc)
- *
- * @see
- * org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service
- * .cmr.repository.NodeRef)
- */
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- NodeRef versionSeries;
- if (isWorkingCopy(nodeRef))
+ if (!nodeInfo.hasPWC())
{
- return nodeRef.toString();
- } else if (hasWorkingCopy((versionSeries = getVersionSeries(nodeRef))))
- {
- NodeRef pwc = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(versionSeries);
- if (pwc != null)
- {
- return pwc.toString();
- }
+ return null;
}
- return null;
+
+ return nodeInfo.getCurrentNodeId() + CMISConnector.ID_SEPERATOR + CMISConnector.PWC_VERSION_LABEL;
}
}
diff --git a/source/java/org/alfresco/opencmis/mapping/VersionSeriesIdProperty.java b/source/java/org/alfresco/opencmis/mapping/VersionSeriesIdProperty.java
index 394e0f72f4..a97dfa2855 100644
--- a/source/java/org/alfresco/opencmis/mapping/VersionSeriesIdProperty.java
+++ b/source/java/org/alfresco/opencmis/mapping/VersionSeriesIdProperty.java
@@ -20,41 +20,27 @@ package org.alfresco.opencmis.mapping;
import java.io.Serializable;
+import org.alfresco.opencmis.CMISConnector;
+import org.alfresco.opencmis.dictionary.CMISNodeInfo;
import org.alfresco.service.ServiceRegistry;
-import org.alfresco.service.cmr.coci.CheckOutCheckInService;
-import org.alfresco.service.cmr.repository.NodeRef;
import org.apache.chemistry.opencmis.commons.PropertyIds;
/**
- * @author dward
+ * @author florian.mueller
*/
-public class VersionSeriesIdProperty extends AbstractVersioningProperty
+public class VersionSeriesIdProperty extends AbstractProperty
{
/**
* Construct
*/
- public VersionSeriesIdProperty(ServiceRegistry serviceRegistry)
+ public VersionSeriesIdProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
{
- super(serviceRegistry, PropertyIds.VERSION_SERIES_ID);
+ super(serviceRegistry, connector, PropertyIds.VERSION_SERIES_ID);
}
@Override
- public Serializable getValue(NodeRef nodeRef)
+ public Serializable getValueInternal(CMISNodeInfo nodeInfo)
{
- CheckOutCheckInService checkOutCheckInService = getServiceRegistry().getCheckOutCheckInService();
- NodeRef result = null;
- if (checkOutCheckInService.isWorkingCopy(nodeRef))
- {
- result = checkOutCheckInService.getCheckedOut(nodeRef);
- if (result == null)
- {
- result = nodeRef;
- }
- }
- else
- {
- result = getVersionSeries(nodeRef);
- }
- return result.toString();
+ return nodeInfo.getCurrentNodeId();
}
}