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:
Florian Mü
2011-08-04 08:50:53 +00:00
parent 7ceaf0a9b0
commit 4b507ee7d8
48 changed files with 2024 additions and 1996 deletions

View File

@@ -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);
}
}