mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
OpenCMIS server refactoring
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@29544 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -68,6 +68,7 @@
|
||||
<property name="fileFolderService" ref="FileFolderService" />
|
||||
<property name="versionService" ref="VersionService" />
|
||||
<property name="checkOutCheckInService" ref="CheckoutCheckinService" />
|
||||
<property name="lockService" ref="LockService" />
|
||||
<property name="contentService" ref="ContentService" />
|
||||
<property name="renditionService" ref="RenditionService" />
|
||||
<property name="tenantAdminService" ref="tenantAdminService" />
|
||||
|
71
source/java/org/alfresco/cmis/CMISPropertyAccessor.java
Normal file
71
source/java/org/alfresco/cmis/CMISPropertyAccessor.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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);
|
||||
}
|
@@ -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,6 +45,7 @@ public interface CMISPropertyDefinition
|
||||
|
||||
/**
|
||||
* Get the query name
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getQueryName();
|
||||
@@ -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<CMISChoice> 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
|
||||
*/
|
||||
|
@@ -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;
|
||||
@@ -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,7 +282,9 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
|
||||
return maximumLength;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISPropertyDefinition#getMinValue()
|
||||
*/
|
||||
public Double getMinValue()
|
||||
@@ -290,7 +292,9 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
|
||||
return minValue;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see org.alfresco.cmis.CMISPropertyDefinition#getMaxValue()
|
||||
*/
|
||||
public Double getMaxValue()
|
||||
@@ -299,7 +303,8 @@ public class CMISBasePropertyDefinition implements CMISPropertyDefinition, Seria
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@@ -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;
|
||||
@@ -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<Serializable> values, Boolean not, PredicateMode mode) throws ParseException
|
||||
public Query buildLuceneIn(AbstractLuceneQueryParser lqp, Collection<Serializable> 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;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@@ -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 <code>null</code> 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 <code>null</code> 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<String> childTypes = (List<String>) 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<RenditionData> 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<CmisExtensionElement> 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<Ace>) 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<Ace>) 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<RenditionData> 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<CmisExtensionElement> 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<String> 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<String> 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<CmisExtensionElement> getAspectExtensions(NodeRef nodeRef, String filter,
|
||||
public List<CmisExtensionElement> getAspectExtensions(CMISNodeInfo info, String filter,
|
||||
Set<String> alreadySetProperties)
|
||||
{
|
||||
List<CmisExtensionElement> extensions = new ArrayList<CmisExtensionElement>();
|
||||
Set<String> propertyIds = new HashSet<String>(alreadySetProperties);
|
||||
Set<String> filterSet = splitFilter(filter);
|
||||
|
||||
Set<QName> aspects = nodeService.getAspects(nodeRef);
|
||||
Set<QName> 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<Action> allowableActions = new HashSet<Action>();
|
||||
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();
|
||||
|
||||
|
769
source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
Normal file
769
source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<String, Serializable> 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<String, Serializable>();
|
||||
}
|
||||
|
||||
properties.put(id, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return getObjectId() + " (" + getNodeRef() + ")";
|
||||
}
|
||||
}
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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
|
||||
}
|
@@ -28,7 +28,7 @@ import org.apache.chemistry.opencmis.commons.enums.Action;
|
||||
* @author davidc
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractActionEvaluator<T> implements CMISActionEvaluator<T>
|
||||
public abstract class AbstractActionEvaluator implements CMISActionEvaluator
|
||||
{
|
||||
private ServiceRegistry serviceRegistry;
|
||||
private Action action;
|
||||
|
@@ -20,10 +20,14 @@ 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;
|
||||
|
||||
/**
|
||||
@@ -34,7 +38,10 @@ import org.alfresco.service.namespace.QName;
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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<QName, Serializable> 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;
|
||||
}
|
||||
}
|
@@ -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<String> result = new ArrayList<String>();
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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<NodeRef>
|
||||
public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private PermissionActionEvaluator permissionEvaluator;
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
@@ -46,15 +43,15 @@ public class CanCancelCheckOutActionEvaluator extends AbstractActionEvaluator<No
|
||||
super(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT);
|
||||
permissionEvaluator = new PermissionActionEvaluator(serviceRegistry, Action.CAN_CANCEL_CHECK_OUT,
|
||||
PermissionService.CANCEL_CHECK_OUT);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -18,10 +18,8 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
@@ -30,10 +28,9 @@ import org.apache.chemistry.opencmis.commons.enums.Action;
|
||||
*
|
||||
* @author davidc
|
||||
*/
|
||||
public class CanCheckInActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
public class CanCheckInActionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private PermissionActionEvaluator permissionEvaluator;
|
||||
private NodeService nodeService;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
@@ -46,15 +43,15 @@ public class CanCheckInActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@@ -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<NodeRef>
|
||||
public class CanCheckOutActionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private PermissionActionEvaluator permissionEvaluator;
|
||||
private NodeService nodeService;
|
||||
private LockService lockService;
|
||||
|
||||
/**
|
||||
@@ -49,18 +46,17 @@ public class CanCheckOutActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
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);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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,29 +40,20 @@ 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()
|
||||
|
@@ -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()
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
@@ -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<NodeRef>
|
||||
public class CurrentVersionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private CMISActionEvaluator<NodeRef> currentVersionEvaluator;
|
||||
private CMISActionEvaluator currentVersionEvaluator;
|
||||
private boolean currentVersionValue;
|
||||
private boolean nonCurrentVersionValue;
|
||||
|
||||
@@ -53,32 +47,21 @@ public class CurrentVersionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
protected CurrentVersionEvaluator(ServiceRegistry serviceRegistry,
|
||||
CMISActionEvaluator<NodeRef> 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<T> extends AbstractActionEvaluator<T>
|
||||
public class FixedValueActionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private boolean allowed;
|
||||
|
||||
@@ -43,7 +44,7 @@ public class FixedValueActionEvaluator<T> extends AbstractActionEvaluator<T>
|
||||
this.allowed = allowed;
|
||||
}
|
||||
|
||||
public boolean isAllowed(T object)
|
||||
public boolean isAllowed(CMISNodeInfo nodeInfo)
|
||||
{
|
||||
return allowed;
|
||||
}
|
||||
|
@@ -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;
|
||||
|
||||
/**
|
||||
* Property accessor for fixed value mapping (eg to null, true, etc)
|
||||
*
|
||||
* @author andyh
|
||||
* @author florian.mueller
|
||||
*/
|
||||
public class FixedValueProperty extends AbstractProperty
|
||||
{
|
||||
@@ -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;
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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();
|
||||
}
|
||||
}
|
56
source/java/org/alfresco/opencmis/mapping/NameProperty.java
Normal file
56
source/java/org/alfresco/opencmis/mapping/NameProperty.java
Normal file
@@ -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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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<NodeRef>
|
||||
public class ParentActionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private AbstractActionEvaluator<NodeRef> evaluator;
|
||||
private AbstractActionEvaluator evaluator;
|
||||
private CMISConnector cmisConnector;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
@@ -36,36 +38,29 @@ public class ParentActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
* @param serviceRegistry
|
||||
* @param action
|
||||
*/
|
||||
protected ParentActionEvaluator(AbstractActionEvaluator<NodeRef> 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<NodeRef>
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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<NodeRef>
|
||||
public class PermissionActionEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private String[] permissions;
|
||||
private PermissionService permissionService;
|
||||
@@ -48,15 +47,11 @@ public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
|
||||
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;
|
||||
}
|
||||
|
@@ -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<NodeRef>
|
||||
public class RootFolderEvaluator extends AbstractActionEvaluator
|
||||
{
|
||||
private CMISConnector cmisConnector;
|
||||
private CMISActionEvaluator<NodeRef> folderEvaluator;
|
||||
private CMISActionEvaluator folderEvaluator;
|
||||
private boolean rootFolderValue;
|
||||
|
||||
protected RootFolderEvaluator(ServiceRegistry serviceRegistry, CMISConnector cmisConnector,
|
||||
CMISActionEvaluator<NodeRef> 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);
|
||||
}
|
||||
}
|
||||
|
@@ -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<String, AbstractProperty> propertyAccessors = new HashMap<String, AbstractProperty>();
|
||||
private Map<BaseTypeId, Map<Action, CMISActionEvaluator<? extends Object>>> actionEvaluators = new HashMap<BaseTypeId, Map<Action, CMISActionEvaluator<? extends Object>>>();
|
||||
private Map<BaseTypeId, Map<Action, CMISActionEvaluator>> actionEvaluators = new HashMap<BaseTypeId, Map<Action, CMISActionEvaluator>>();
|
||||
|
||||
/**
|
||||
* @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<NodeRef>(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<NodeRef>(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<NodeRef>(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<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_APPLY_POLICY, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_APPLIED_POLICIES, true));
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_REMOVE_POLICY, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new CurrentVersionEvaluator(serviceRegistry,
|
||||
new FixedValueActionEvaluator<NodeRef>(serviceRegistry, Action.CAN_CREATE_RELATIONSHIP, true), false));
|
||||
registerEvaluator(BaseTypeId.CMIS_DOCUMENT, new FixedValueActionEvaluator<NodeRef>(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<NodeRef>(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<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_APPLY_POLICY, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_APPLIED_POLICIES, true));
|
||||
registerEvaluator(BaseTypeId.CMIS_FOLDER, new FixedValueActionEvaluator<NodeRef>(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<AssociationRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_DELETE_OBJECT, true));
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_UPDATE_PROPERTIES, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_PROPERTIES, true));
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_ACL, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_APPLY_ACL, false));
|
||||
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_DELETE_OBJECT, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_UPDATE_PROPERTIES, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_PROPERTIES, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_OBJECT_PARENTS, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_MOVE_OBJECT, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_ADD_OBJECT_TO_FOLDER, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_REMOVE_OBJECT_FROM_FOLDER, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator(serviceRegistry,
|
||||
Action.CAN_GET_OBJECT_RELATIONSHIPS, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry,
|
||||
Action.CAN_GET_ACL, false));
|
||||
registerEvaluator(BaseTypeId.CMIS_POLICY, new FixedValueActionEvaluator<NodeRef>(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<Action, CMISActionEvaluator<? extends Object>> getActionEvaluators(BaseTypeId scope)
|
||||
public Map<Action, CMISActionEvaluator> getActionEvaluators(BaseTypeId scope)
|
||||
{
|
||||
Map<Action, CMISActionEvaluator<? extends Object>> evaluators = actionEvaluators.get(scope);
|
||||
Map<Action, CMISActionEvaluator> 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<Action, CMISActionEvaluator<? extends Object>> evaluators = actionEvaluators.get(scope);
|
||||
Map<Action, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
|
||||
if (evaluators == null)
|
||||
{
|
||||
evaluators = new LinkedHashMap<Action, CMISActionEvaluator<? extends Object>>();
|
||||
evaluators = new LinkedHashMap<Action, CMISActionEvaluator>();
|
||||
actionEvaluators.put(scope, evaluators);
|
||||
}
|
||||
if (evaluators.get(evaluator.getAction()) != null)
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user