Merging BRANCHES/DEV/CMIS_10 to HEAD (phase 2 - currently up-to-date with branch):

18717: SAIL-166: Refactor CMIS to use shared services and resolve objectIds and error codes consistently
   18731: SAIL-169: CMIS REST versioning compliance
   18732: Fix failing change log test.
   18768: Add displayName and queryName attributes to rendered properties (in CMIS AtomPub binding).
   18775: Fix exception reporting when retrieving items that do not exist (in CMIS AtomPub binding).
   18784: Fix CMIS REST change logging
   18785: SAIL-174: CMIS Relationship lookup by association ID
   18812: SAIL-183: Support orderBy argument for getChildren and getCheckedOutDocs in CMIS REST and Web Service bindings
   18823: CMIS WS Bindings were moved to 1.0 cd07 schema.
   18838: Update to latest Chemistry TCK.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18847 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
David Caruana
2010-02-25 15:02:44 +00:00
parent cfc0643817
commit fbd7aab3b1
71 changed files with 2811 additions and 1624 deletions

View File

@@ -34,7 +34,7 @@ import org.alfresco.service.ServiceRegistry;
* @author davidc
*
*/
public abstract class AbstractActionEvaluator implements CMISActionEvaluator
public abstract class AbstractActionEvaluator <T> implements CMISActionEvaluator <T>
{
private ServiceRegistry serviceRegistry;
private CMISAllowedActionEnum action;

View File

@@ -0,0 +1,85 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.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.namespace.QName;
/**
* Base class for versioning property accessors.
*
* @author dward
*
*/
public abstract class AbstractVersioningProperty extends AbstractProperty
{
/**
* Construct
*
* @param serviceRegistry
* @param propertyName
*/
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);
return 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))
{
return (NodeRef) getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_COPY_REFERENCE);
}
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;
}
}

View File

@@ -47,6 +47,8 @@ import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.dictionary.AspectDefinition;
import org.alfresco.service.cmr.dictionary.AssociationDefinition;
import org.alfresco.service.cmr.dictionary.DataTypeDefinition;
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.NamespaceService;
import org.alfresco.service.namespace.QName;
@@ -109,7 +111,7 @@ public class CMISMapping implements InitializingBean
private Map<QName, QName> mapAlfrescoQNameToCmisQName = new HashMap<QName, QName>();
private Map<QName, CMISDataTypeEnum> mapAlfrescoToCmisDataType = new HashMap<QName, CMISDataTypeEnum>();
private Map<String, AbstractProperty> propertyAccessors = new HashMap<String, AbstractProperty>();
private Map<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator>> actionEvaluators = new HashMap<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator>>();
private Map<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>>> actionEvaluators = new HashMap<CMISScope, Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>>>();
private Set<String> cmisRead = new HashSet<String>();
@@ -185,7 +187,7 @@ public class CMISMapping implements InitializingBean
registerPropertyAccessor(new IsLatestVersionProperty(serviceRegistry));
registerPropertyAccessor(new IsMajorVersionProperty(serviceRegistry));
registerPropertyAccessor(new IsLatestMajorVersionProperty(serviceRegistry));
registerPropertyAccessor(new DirectProperty(serviceRegistry, CMISDictionaryModel.PROP_VERSION_LABEL, ContentModel.PROP_VERSION_LABEL));
registerPropertyAccessor(new VersionLabelProperty(serviceRegistry));
registerPropertyAccessor(new VersionSeriesIdProperty(serviceRegistry));
registerPropertyAccessor(new IsVersionSeriesCheckedOutProperty(serviceRegistry));
registerPropertyAccessor(new VersionSeriesCheckedOutByProperty(serviceRegistry));
@@ -211,8 +213,8 @@ public class CMISMapping implements InitializingBean
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, PermissionService.DELETE_NODE));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, PermissionService.WRITE_PROPERTIES));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, true));
// Is CAN_MOVE correct mapping?
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, PermissionService.DELETE_NODE));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_CONTENT_STREAM, PermissionService.WRITE_PROPERTIES, PermissionService.WRITE_CONTENT));
@@ -220,16 +222,16 @@ public class CMISMapping implements InitializingBean
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CANCEL_CHECKOUT, PermissionService.CANCEL_CHECK_OUT));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CHECKIN, PermissionService.CHECK_IN));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_SET_CONTENT_STREAM, PermissionService.WRITE_CONTENT));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ALL_VERSIONS, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ALL_VERSIONS, true));
registerEvaluator(CMISScope.DOCUMENT, new ParentActionEvaluator(new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_ADD_OBJECT_TO_FOLDER, PermissionService.LINK_CHILDREN)));
// Is CAN_REMOVE_FROM_FOLDER correct mapping?
registerEvaluator(CMISScope.DOCUMENT, new ParentActionEvaluator(new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER, true)));
registerEvaluator(CMISScope.DOCUMENT, new ParentActionEvaluator(new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER, true)));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_CONTENT_STREAM, PermissionService.READ_CONTENT));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, false));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_RELATIONSHIP, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RENDITIONS, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, false));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_RELATIONSHIP, true));
registerEvaluator(CMISScope.DOCUMENT, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_RENDITIONS, true));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, PermissionService.READ_PERMISSIONS));
registerEvaluator(CMISScope.DOCUMENT, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, PermissionService.CHANGE_PERMISSIONS));
@@ -237,15 +239,15 @@ public class CMISMapping implements InitializingBean
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, PermissionService.WRITE_PROPERTIES));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_TREE, PermissionService.READ_CHILDREN));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, PermissionService.READ_PROPERTIES));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, true));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, true));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_PARENT, true));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, true));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, true));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_FOLDER_PARENT, true));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_DESCENDANTS, PermissionService.READ_CHILDREN));
// Is CAN_MOVE_OBJECT correct mapping?
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, PermissionService.DELETE_NODE));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, false));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_POLICY, false));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_APPLIED_POLICIES, false));
registerEvaluator(CMISScope.FOLDER, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_POLICY, false));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_CHILDREN, PermissionService.READ_CHILDREN));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_DOCUMENT, PermissionService.CREATE_CHILDREN));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_CREATE_FOLDER, PermissionService.CREATE_CHILDREN));
@@ -254,22 +256,22 @@ public class CMISMapping implements InitializingBean
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, PermissionService.READ_PERMISSIONS));
registerEvaluator(CMISScope.FOLDER, new PermissionActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, PermissionService.CHANGE_PERMISSIONS));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, true));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, true));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, true));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, true));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false));
registerEvaluator(CMISScope.RELATIONSHIP, new FixedValueActionEvaluator<AssociationRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_ADD_OBJECT_TO_FOLDER, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_DELETE_OBJECT, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_UPDATE_PROPERTIES, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_PROPERTIES, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_PARENTS, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_MOVE_OBJECT, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_ADD_OBJECT_TO_FOLDER, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_REMOVE_OBJECT_FROM_FOLDER, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_OBJECT_RELATIONSHIPS, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_GET_ACL, false));
registerEvaluator(CMISScope.POLICY, new FixedValueActionEvaluator<NodeRef>(serviceRegistry, CMISAllowedActionEnum.CAN_APPLY_ACL, false));
cmisRead.add(PermissionService.READ_PROPERTIES);
cmisRead.add(PermissionService.READ_CONTENT);
@@ -756,9 +758,9 @@ public class CMISMapping implements InitializingBean
* @param cmisScope
* @return
*/
public Map<CMISAllowedActionEnum, CMISActionEvaluator> getActionEvaluators(CMISScope scope)
public Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> getActionEvaluators(CMISScope scope)
{
Map<CMISAllowedActionEnum, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> evaluators = actionEvaluators.get(scope);
if (evaluators == null)
{
evaluators = Collections.emptyMap();
@@ -772,12 +774,12 @@ public class CMISMapping implements InitializingBean
* @param scope
* @param evaluator
*/
private void registerEvaluator(CMISScope scope, CMISActionEvaluator evaluator)
private void registerEvaluator(CMISScope scope, CMISActionEvaluator<? extends Object> evaluator)
{
Map<CMISAllowedActionEnum, CMISActionEvaluator> evaluators = actionEvaluators.get(scope);
Map<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>> evaluators = actionEvaluators.get(scope);
if (evaluators == null)
{
evaluators = new LinkedHashMap<CMISAllowedActionEnum, CMISActionEvaluator>();
evaluators = new LinkedHashMap<CMISAllowedActionEnum, CMISActionEvaluator<? extends Object>>();
actionEvaluators.put(scope, evaluators);
}
if (evaluators.get(evaluator.getAction()) != null)

View File

@@ -42,7 +42,7 @@ import org.alfresco.service.cmr.version.VersionType;
public class CMISPropertyServiceTest extends BaseCMISTest
{
public void testBasicFolder()
public void testBasicFolder() throws Exception
{
NodeRef folder = fileFolderService.create(cmisService.getDefaultRootNodeRef(), "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef();
Map<String, Serializable> properties = cmisService.getProperties(folder);
@@ -76,7 +76,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
}
public void testBasicDocument()
public void testBasicDocument() throws Exception
{
NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef();
@@ -109,7 +109,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
}
public void testContentProperties()
public void testContentProperties() throws Exception
{
NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef();
@@ -160,7 +160,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNotNull(properties.get(CMISDictionaryModel.PROP_CONTENT_STREAM_ID));
}
public void testLock()
public void testLock() throws Exception
{
NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef();
@@ -239,7 +239,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
}
public void testCheckOut()
public void testCheckOut() throws Exception
{
NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef();
@@ -423,7 +423,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
}
public void testVersioning()
public void testVersioning() throws Exception
{
NodeRef content = fileFolderService.create(rootNodeRef, "BaseContent", ContentModel.TYPE_CONTENT).getNodeRef();
@@ -719,7 +719,7 @@ public class CMISPropertyServiceTest extends BaseCMISTest
assertNull(properties.get(CMISDictionaryModel.PROP_ALLOWED_CHILD_OBJECT_TYPE_IDS));
}
public void testSinglePropertyFolderAccess()
public void testSinglePropertyFolderAccess() throws Exception
{
NodeRef folder = fileFolderService.create(rootNodeRef, "BaseFolder", ContentModel.TYPE_FOLDER).getNodeRef();
assertEquals(cmisService.getProperty(folder, CMISDictionaryModel.PROP_OBJECT_ID), folder.toString());

File diff suppressed because it is too large Load Diff

View File

@@ -27,16 +27,18 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
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 andyh
* @author dward
*/
public class CheckinCommentProperty extends AbstractProperty
public class CheckinCommentProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -54,14 +56,27 @@ public class CheckinCommentProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
Version version = getServiceRegistry().getVersionService().getCurrentVersion(nodeRef);
if (version != null)
{
return version.getDescription();
}
else
NodeRef versionSeries;
if (isWorkingCopy(nodeRef) || (versionSeries = getVersionSeries(nodeRef)).equals(nodeRef))
{
return null;
}
ServiceRegistry serviceRegistry = getServiceRegistry();
String versionLabel = (String)serviceRegistry.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
if (versionLabel == null)
{
return null;
}
VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries);
if (versionHistory == null)
{
return null;
}
Version version = versionHistory.getVersion(versionLabel);
if (version == null)
{
return null;
}
return version.getDescription();
}
}

View File

@@ -26,7 +26,6 @@ package org.alfresco.cmis.mapping;
import org.alfresco.cmis.CMISAllowedActionEnum;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Action Evaluator whose evaluation is fixed
@@ -34,7 +33,7 @@ import org.alfresco.service.cmr.repository.NodeRef;
* @author davidc
*
*/
public class FixedValueActionEvaluator extends AbstractActionEvaluator
public class FixedValueActionEvaluator <T> extends AbstractActionEvaluator <T>
{
private boolean allowed;
@@ -54,7 +53,7 @@ public class FixedValueActionEvaluator extends AbstractActionEvaluator
* (non-Javadoc)
* @see org.alfresco.cmis.CMISActionEvaluator#isAllowed(org.alfresco.service.cmr.repository.NodeRef)
*/
public boolean isAllowed(NodeRef nodeRef)
public boolean isAllowed(T object)
{
return allowed;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -27,18 +27,15 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.datatype.DefaultTypeConverter;
/**
* Property accessor for CMIS is immutable property
*
* @author andyh
* @author dward
*/
public class IsImmutableProperty extends AbstractProperty
public class IsImmutableProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -56,20 +53,14 @@ public class IsImmutableProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
LockType type = getServiceRegistry().getLockService().getLockType(nodeRef);
if (type == LockType.READ_ONLY_LOCK)
if (isWorkingCopy(nodeRef))
{
return Boolean.valueOf(true);
return false;
}
Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_AUTO_VERSION);
if (value != null)
if (getVersionSeries(nodeRef).equals(nodeRef))
{
Boolean autoVersion = DefaultTypeConverter.INSTANCE.convert(Boolean.class, value);
if (false == autoVersion.booleanValue())
{
return Boolean.valueOf(true);
}
return hasWorkingCopy(nodeRef);
}
return Boolean.valueOf(false);
return true;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -27,18 +27,19 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
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;
/**
* Accessor for CMIS is latest major version property
*
* @author andyh
* @author dward
*/
public class IsLatestMajorVersionProperty extends AbstractProperty
public class IsLatestMajorVersionProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -57,21 +58,33 @@ public class IsLatestMajorVersionProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
NodeRef versionSeries;
if (isWorkingCopy(nodeRef) || (versionSeries = getVersionSeries(nodeRef)).equals(nodeRef))
{
return false;
}
else
ServiceRegistry serviceRegistry = getServiceRegistry();
VersionService versionService = serviceRegistry.getVersionService();
VersionHistory versionHistory = versionService.getVersionHistory(versionSeries);
if (versionHistory == null)
{
Version version = getServiceRegistry().getVersionService().getCurrentVersion(nodeRef);
if (version != null)
return false;
}
// Go back in time to the last major version
Version currentVersion = versionService.getCurrentVersion(versionSeries);
while (currentVersion != null)
{
if (currentVersion.getVersionType() == VersionType.MAJOR)
{
return (version.getVersionType() == VersionType.MAJOR);
return currentVersion.getFrozenStateNodeRef().equals(nodeRef);
}
else
// We got to the current node and its not major. We failed!
else if (currentVersion.getFrozenStateNodeRef().equals(nodeRef))
{
return false;
}
currentVersion = versionHistory.getPredecessor(currentVersion);
}
return false;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -27,16 +27,15 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Accesser for CMIS is latest version property
*
* @author andyh
* @author dward
*/
public class IsLatestVersionProperty extends AbstractProperty
public class IsLatestVersionProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -54,6 +53,6 @@ public class IsLatestVersionProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
return !getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY);
return isWorkingCopy(nodeRef) || getVersionSeries(nodeRef).equals(nodeRef) && !hasWorkingCopy(nodeRef);
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -30,15 +30,15 @@ import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
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.VersionType;
/**
* Accessor for CMIS is major version property
*
* @author andyh
* @author dward
*/
public class IsMajorVersionProperty extends AbstractProperty
public class IsMajorVersionProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -56,21 +56,23 @@ public class IsMajorVersionProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
NodeRef versionSeries;
if (isWorkingCopy(nodeRef) || (versionSeries = getVersionSeries(nodeRef)).equals(nodeRef))
{
return false;
}
else
ServiceRegistry serviceRegistry = getServiceRegistry();
String versionLabel = (String) serviceRegistry.getNodeService().getProperty(nodeRef,
ContentModel.PROP_VERSION_LABEL);
if (versionLabel == null)
{
Version version = getServiceRegistry().getVersionService().getCurrentVersion(nodeRef);
if (version != null)
{
return (version.getVersionType() == VersionType.MAJOR);
}
else
{
return false;
}
return false;
}
VersionHistory versionHistory = serviceRegistry.getVersionService().getVersionHistory(versionSeries);
if (versionHistory == null)
{
return false;
}
return versionHistory.getVersion(versionLabel).getVersionType() == VersionType.MAJOR;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -27,17 +27,15 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Get the CMIS version series checked out property
*
* @author andyh
* @author dward
*/
public class IsVersionSeriesCheckedOutProperty extends AbstractProperty
public class IsVersionSeriesCheckedOutProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -55,22 +53,6 @@ public class IsVersionSeriesCheckedOutProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
{
return true;
}
else
{
LockType type = getServiceRegistry().getLockService().getLockType(nodeRef);
if (type == LockType.READ_ONLY_LOCK)
{
NodeRef wc = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(nodeRef);
return (wc != null);
}
else
{
return false;
}
}
return isWorkingCopy(nodeRef) || hasWorkingCopy(getVersionSeries(nodeRef));
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -29,6 +29,7 @@ import java.util.Collection;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.cmis.CMISQueryException;
import org.alfresco.cmis.CMISServices;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.search.impl.lucene.AnalysisMode;
import org.alfresco.repo.search.impl.lucene.LuceneFunction;
@@ -51,8 +52,9 @@ import org.apache.lucene.search.BooleanClause.Occur;
* Get the CMIS object id property.
*
* @author andyh
* @author dward
*/
public class ObjectIdProperty extends AbstractProperty
public class ObjectIdProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -70,24 +72,17 @@ public class ObjectIdProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (!getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
NodeRef versionSeries;
if (isWorkingCopy(nodeRef) || (versionSeries = getVersionSeries(nodeRef)).equals(nodeRef))
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_VERSIONABLE))
{
Serializable value = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
if (value != null)
{
String versionLabel = DefaultTypeConverter.INSTANCE.convert(String.class, value);
StringBuilder builder = new StringBuilder(128);
builder.append(nodeRef.toString());
builder.append(";");
builder.append(versionLabel);
return builder.toString();
}
}
return nodeRef.toString();
}
else
{
return new StringBuilder(1024).append(versionSeries.toString()).append(';').append(
getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL))
.toString();
}
return nodeRef.toString();
}
/*
@@ -96,8 +91,7 @@ public class ObjectIdProperty extends AbstractProperty
*/
public Serializable getValue(AssociationRef assocRef)
{
// TODO: determine appropriate id for associations
return assocRef.getSourceRef().toString();
return CMISServices.ASSOC_ID_PREFIX + assocRef.getId();
}
public String getLuceneFieldName()

View File

@@ -32,9 +32,9 @@ import org.alfresco.service.cmr.repository.NodeRef;
*
* @author davidc
*/
public class ParentActionEvaluator extends AbstractActionEvaluator
public class ParentActionEvaluator extends AbstractActionEvaluator<NodeRef>
{
private AbstractActionEvaluator evaluator;
private AbstractActionEvaluator<NodeRef> evaluator;
/**
* Construct
@@ -42,7 +42,7 @@ public class ParentActionEvaluator extends AbstractActionEvaluator
* @param serviceRegistry
* @param action
*/
protected ParentActionEvaluator(AbstractActionEvaluator evaluator)
protected ParentActionEvaluator(AbstractActionEvaluator<NodeRef> evaluator)
{
super(evaluator.getServiceRegistry(), evaluator.getAction());
this.evaluator = evaluator;

View File

@@ -35,7 +35,7 @@ import org.alfresco.service.cmr.security.PermissionService;
*
* @author davidc
*/
public class PermissionActionEvaluator extends AbstractActionEvaluator
public class PermissionActionEvaluator extends AbstractActionEvaluator<NodeRef>
{
private String[] permissions;
private PermissionService permissionService;

View File

@@ -0,0 +1,68 @@
/*
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* This program 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 General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* @author dward
*/
public class VersionLabelProperty extends AbstractVersioningProperty
{
/**
* Construct
*
* @param serviceRegistry
*/
public VersionLabelProperty(ServiceRegistry serviceRegistry)
{
super(serviceRegistry, CMISDictionaryModel.PROP_VERSION_LABEL);
}
/*
* (non-Javadoc)
* @see org.alfresco.cmis.property.PropertyAccessor#getValue(org.alfresco.service.cmr.repository.NodeRef)
*/
public Serializable getValue(NodeRef nodeRef)
{
if (isWorkingCopy(nodeRef))
{
return "pwc";
}
if (getVersionSeries(nodeRef).equals(nodeRef))
{
return "current";
}
else
{
return getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -29,15 +29,14 @@ import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Get the CMIS version series checked out by property
*
* @author andyh
* @author dward
*/
public class VersionSeriesCheckedOutByProperty extends AbstractProperty
public class VersionSeriesCheckedOutByProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -55,29 +54,15 @@ public class VersionSeriesCheckedOutByProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
NodeRef versionSeries;
if (isWorkingCopy(nodeRef))
{
return getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_WORKING_COPY_OWNER);
}
else
else if (hasWorkingCopy((versionSeries = getVersionSeries(nodeRef))))
{
LockType type = getServiceRegistry().getLockService().getLockType(nodeRef);
if (type == LockType.READ_ONLY_LOCK)
{
NodeRef wc = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(nodeRef);
if (wc != null)
{
return getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_LOCK_OWNER);
}
else
{
return null;
}
}
else
{
return null;
}
return getServiceRegistry().getNodeService().getProperty(versionSeries, ContentModel.PROP_LOCK_OWNER);
}
return null;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -27,17 +27,15 @@ package org.alfresco.cmis.mapping;
import java.io.Serializable;
import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.lock.LockType;
import org.alfresco.service.cmr.repository.NodeRef;
/**
* Get the CMIS version series checked out id property
*
* @author andyh
* @author dward
*/
public class VersionSeriesCheckedOutIdProperty extends AbstractProperty
public class VersionSeriesCheckedOutIdProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -55,22 +53,19 @@ public class VersionSeriesCheckedOutIdProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
NodeRef versionSeries;
if (isWorkingCopy(nodeRef))
{
return nodeRef.toString();
}
else
else if (hasWorkingCopy((versionSeries = getVersionSeries(nodeRef))))
{
LockType type = getServiceRegistry().getLockService().getLockType(nodeRef);
if (type == LockType.READ_ONLY_LOCK)
NodeRef pwc = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(versionSeries);
if (pwc != null)
{
NodeRef pwc = getServiceRegistry().getCheckOutCheckInService().getWorkingCopy(nodeRef);
return (pwc == null) ? null : pwc.toString();
}
else
{
return null;
return pwc.toString();
}
}
return null;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright (C) 2005-2007 Alfresco Software Limited.
* Copyright (C) 2005-2010 Alfresco Software Limited.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@@ -18,7 +18,7 @@
* As a special exception to the terms and conditions of version 2.0 of
* the GPL, you may redistribute this Program in connection with Free/Libre
* and Open Source Software ("FLOSS") applications as described in Alfresco's
* FLOSS exception. You should have recieved a copy of the text describing
* FLOSS exception. You should have received a copy of the text describing
* the FLOSS exception, and it is also available here:
* http://www.alfresco.com/legal/licensing"
*/
@@ -30,11 +30,12 @@ import org.alfresco.cmis.CMISDictionaryModel;
import org.alfresco.model.ContentModel;
import org.alfresco.service.ServiceRegistry;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
/**
* @author andyh
* @author dward
*/
public class VersionSeriesIdProperty extends AbstractProperty
public class VersionSeriesIdProperty extends AbstractVersioningProperty
{
/**
* Construct
@@ -52,11 +53,14 @@ public class VersionSeriesIdProperty extends AbstractProperty
*/
public Serializable getValue(NodeRef nodeRef)
{
if (getServiceRegistry().getNodeService().hasAspect(nodeRef, ContentModel.ASPECT_WORKING_COPY))
NodeService nodeService = getServiceRegistry().getNodeService();
if (isWorkingCopy(nodeRef))
{
Serializable seriesId = getServiceRegistry().getNodeService().getProperty(nodeRef, ContentModel.PROP_COPY_REFERENCE);
return (seriesId != null) ? seriesId.toString() : null;
return nodeService.getProperty(nodeRef, ContentModel.PROP_COPY_REFERENCE).toString();
}
else
{
return getVersionSeries(nodeRef).toString();
}
return nodeRef.toString();
}
}