diff --git a/config/alfresco/opencmis-context.xml b/config/alfresco/opencmis-context.xml
index 5e18dcc8b4..0a5f5319c7 100644
--- a/config/alfresco/opencmis-context.xml
+++ b/config/alfresco/opencmis-context.xml
@@ -149,7 +149,11 @@
-
+
+
+ cm:checkedOut
+
+
@@ -185,6 +189,7 @@
+
diff --git a/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java b/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java
index 346e110c63..f1e40ca1bc 100644
--- a/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java
+++ b/source/java/org/alfresco/opencmis/AlfrescoCmisServiceImpl.java
@@ -30,6 +30,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
@@ -2215,9 +2216,9 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
List result = new ArrayList();
// what kind of object is it?
- CMISNodeInfo info = getOrCreateNodeInfo(versionSeriesId, "Version Series");
+ CMISNodeInfo info = getOrCreateNodeInfo(objectId);
- if (!info.isVariant(CMISObjectVariant.CURRENT_VERSION))
+ if (!EnumSet.of(CMISObjectVariant.CURRENT_VERSION, CMISObjectVariant.PWC, CMISObjectVariant.VERSION).contains(info.getObjectVariant()))
{
// the version series id is the id of current version, which is a
// document
@@ -2228,7 +2229,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
NodeRef nodeRef = info.getNodeRef();
VersionHistory versionHistory = ((CMISNodeInfoImpl) info).getVersionHistory();
- if (versionHistory == null)
+ if (versionHistory == null || info.isPWC())
{
// add current version
result.add(connector.createCMISObject(info, filter, includeAllowableActions, IncludeRelationships.NONE,
@@ -2251,7 +2252,7 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
pwcInfo, filter, includeAllowableActions,
IncludeRelationships.NONE, CMISConnector.RENDITION_NONE, false, false));
- boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
+ boolean isObjectInfoRequired = getContext().isObjectInfoRequired();
if (isObjectInfoRequired)
{
getObjectInfo(repositoryId, pwcInfo.getObjectId(), IncludeRelationships.NONE);
diff --git a/source/java/org/alfresco/opencmis/CMISConnector.java b/source/java/org/alfresco/opencmis/CMISConnector.java
index 7a881d40f1..397efbda1f 100644
--- a/source/java/org/alfresco/opencmis/CMISConnector.java
+++ b/source/java/org/alfresco/opencmis/CMISConnector.java
@@ -72,10 +72,14 @@ import org.alfresco.opencmis.search.CMISQueryService;
import org.alfresco.opencmis.search.CMISResultSet;
import org.alfresco.opencmis.search.CMISResultSetColumn;
import org.alfresco.opencmis.search.CMISResultSetRow;
+import org.alfresco.query.PagingRequest;
+import org.alfresco.query.PagingResults;
import org.alfresco.repo.Client;
import org.alfresco.repo.Client.ClientType;
import org.alfresco.repo.action.executer.ContentMetadataExtracter;
import org.alfresco.repo.cache.SimpleCache;
+import org.alfresco.repo.dictionary.DictionaryDAO;
+import org.alfresco.repo.dictionary.DictionaryListener;
import org.alfresco.repo.events.EventPreparator;
import org.alfresco.repo.events.EventPublisher;
import org.alfresco.repo.model.filefolder.GetChildrenCannedQuery;
@@ -242,7 +246,7 @@ import org.springframework.util.StringUtils;
* @author Derek Hulley
* @author steveglover
*/
-public class CMISConnector implements ApplicationContextAware, ApplicationListener, TenantDeployer
+public class CMISConnector implements ApplicationContextAware, ApplicationListener, TenantDeployer, DictionaryListener
{
private static Log logger = LogFactory.getLog(CMISConnector.class);
@@ -324,12 +328,15 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
private CmisActivityPoster activityPoster;
private BehaviourFilter behaviourFilter;
+ private DictionaryDAO dictionaryDAO;
private HiddenAspect hiddenAspect;
private StoreRef storeRef;
private String rootPath;
private Map> kindToRenditionNames;
+ private Set ignoreChildren = Collections.emptySet();
+ private Set ignoreChildrenQNames = Collections.emptySet();
// note: cache is tenant-aware (if using TransctionalCache impl)
@@ -461,6 +468,11 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.kindToRenditionNames = renditionKinds;
}
+ public void setIgnoreChildren(Set ignoreChildren)
+ {
+ this.ignoreChildren = ignoreChildren;
+ }
+
public void setOpenHttpSession(boolean openHttpSession)
{
this.openHttpSession = openHttpSession;
@@ -499,6 +511,11 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
this.behaviourFilter = behaviourFilter;
}
+ public void setDictionaryDAO(DictionaryDAO dictionaryDAO)
+ {
+ this.dictionaryDAO = dictionaryDAO;
+ }
+
/**
* Sets the node service.
*/
@@ -816,6 +833,7 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
{
throw new AlfrescoRuntimeException("Failed to create CMIS temporary directory");
}
+ dictionaryDAO.register(this);
}
public void init()
@@ -3902,6 +3920,11 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
return descriptorService.getCurrentRepositoryDescriptor().getId();
}
+ public PagingResults getChildren(NodeRef folderNodeRef, List> sortProps, PagingRequest pageRequest)
+ {
+ return fileFolderService.list(folderNodeRef, true, true, ignoreChildrenQNames, sortProps, pageRequest);
+ }
+
/**
* Creates the repository info object.
*/
@@ -4049,4 +4072,41 @@ public class CMISConnector implements ApplicationContextAware, ApplicationListen
}
return renditionMapping;
}
+
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.repo.dictionary.DictionaryListener#onDictionaryInit()
+ */
+ @Override
+ public void onDictionaryInit()
+ {
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.repo.dictionary.DictionaryListener#afterDictionaryInit()
+ */
+ @Override
+ public void afterDictionaryInit()
+ {
+ this.ignoreChildrenQNames = new HashSet(this.ignoreChildren.size(), 1);
+ for (String prefixString : this.ignoreChildren)
+ {
+ try
+ {
+ this.ignoreChildrenQNames.add(QName.createQName(prefixString, this.namespaceService));
+ }
+ catch (Exception e)
+ {
+ logger.warn("Couldn't create QName from " + prefixString, e);
+ }
+ }
+ }
+ /*
+ * (non-Javadoc)
+ * @see org.alfresco.repo.dictionary.DictionaryListener#afterDictionaryDestroy()
+ */
+ @Override
+ public void afterDictionaryDestroy()
+ {
+ }
}
diff --git a/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java b/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
index 4e49f0a6d2..7a019e175c 100644
--- a/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
+++ b/source/java/org/alfresco/opencmis/CMISNodeInfoImpl.java
@@ -36,7 +36,6 @@ import org.alfresco.opencmis.dictionary.RelationshipTypeDefintionWrapper;
import org.alfresco.opencmis.dictionary.TypeDefinitionWrapper;
import org.alfresco.repo.security.permissions.AccessDeniedException;
import org.alfresco.repo.version.Version2Model;
-import org.alfresco.repo.version.VersionBaseModel;
import org.alfresco.repo.version.VersionModel;
import org.alfresco.service.cmr.repository.AssociationRef;
import org.alfresco.service.cmr.repository.ChildAssociationRef;
@@ -598,7 +597,7 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
public boolean isLatestVersion()
{
- return isCurrentVersion();
+ return (isCurrentVersion() && !hasPWC()) || isPWC();
}
public boolean isLatestMajorVersion()
@@ -899,16 +898,18 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
private NodeRef getLatestNonMajorVersionNodeRef()
{
-// if (isPWC())
-// {
-// return nodeRef;
-// } else if (hasPWC())
-// {
-// return connector.getCheckOutCheckInService().getWorkingCopy(getCurrentNodeNodeRef());
-// } else
-// {
+ if (isPWC())
+ {
+ return nodeRef;
+ }
+ else if (hasPWC())
+ {
+ return connector.getCheckOutCheckInService().getWorkingCopy(getCurrentNodeNodeRef());
+ }
+ else
+ {
return getCurrentNodeNodeRef();
-// }
+ }
}
// TODO lock here??