mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged V4.1-BUG-FIX to HEAD
42804: Merged BRANCHES/DEV/BELARUS/V4.1-BUG-FIX-2012_10_17 to BRANCHES/DEV/V4.1-BUG-FIX: 42748: ALF-14200: Adding Invalid Aspects Via CMIS ATOM API Results in NullPointerException 42810: Fix for ALF-15276 - sys:locale Attribute No Longer Available From jsnode 42814: ALF-15276 - small improvement to remove duplicated data from response 42824: ALF-15048: Merged PATCHES/V4.0.2 to V4.1-BUG-FIX 42724: ALF-16048: CLONE - Version history doesn't go beyond two versions (0.1 and 0.2) when dragged and dropped via CIFS from Mac Lion OSx 42739: ALF-16048: New files missing from previous check in 42742: ALF-16048: Another missing file. 42839: ALF-16417: Fix "Hybrid Sync - can retain invalid cloud tickets in a local cache" - retry once for invalid auth - also externalise the implicit/default cache config 42849: NodeDAO: Added new method to retrieve specific store ID - public Pair<Long, StoreRef> getStore(StoreRef storeRef); 42857: Merged DEV to V4.1-BUG-FIX 42821: ALF-13506 : WCMQS Example Application Caching Causes Changes to Inconsistently Appear on the Editorial Web Site Concurrency was improved for AssetImpl class. The returned values of the collections were made unmodifiable in the classes which implement Resource interface. 42872: ALF-15601: "Performance issue using CMIS method getChildren() - gets version history" - avoids getting the version history (an expensive operation) if possible i.e. in the case of current version (live) nodes like for getChildren 42900: Merged DEV to V4.1-BUG-FIX 42734: ALF-15335 : 'external' authentication subsystem debug information too scarce Extended debug information in the authentication subsystem. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@42904 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -685,6 +685,11 @@ public class AlfrescoCmisServiceImpl extends AbstractCmisService implements Alfr
|
||||
continue;
|
||||
}
|
||||
|
||||
if(isFolder && type.getAlfrescoClass().equals(ContentModel.TYPE_SYSTEM_FOLDER))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// create a child CMIS object
|
||||
ObjectInFolderDataImpl object = new ObjectInFolderDataImpl();
|
||||
CMISNodeInfo ni = createNodeInfo(child.getChildRef());
|
||||
|
@@ -53,6 +53,12 @@ import org.apache.chemistry.opencmis.commons.exceptions.CmisInvalidArgumentExcep
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisObjectNotFoundException;
|
||||
import org.apache.chemistry.opencmis.commons.exceptions.CmisPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* CMIS representation of a node.
|
||||
*
|
||||
* Tries to avoid getting the node's version history where possible (because it's not very performant).
|
||||
*
|
||||
*/
|
||||
public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
{
|
||||
private static final GregorianCalendar DUMMY_DATE = new GregorianCalendar(2010, 4, 1);
|
||||
@@ -76,6 +82,10 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
private Map<String, Serializable> properties;
|
||||
private List<CMISNodeInfo> parents;
|
||||
|
||||
public CMISNodeInfoImpl()
|
||||
{
|
||||
}
|
||||
|
||||
public CMISNodeInfoImpl(CMISConnector connector, String objectId)
|
||||
{
|
||||
this.connector = connector;
|
||||
@@ -100,6 +110,61 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
analyseAssociationRef();
|
||||
}
|
||||
|
||||
private boolean isCurrentNode()
|
||||
{
|
||||
return objecVariant != CMISObjectVariant.VERSION;
|
||||
}
|
||||
|
||||
protected void analyseVersionNode(NodeRef nodeRef)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
protected void analyseCurrentVersion(NodeRef nodeRef)
|
||||
{
|
||||
if(connector.getVersionService().isVersioned(nodeRef))
|
||||
{
|
||||
versionLabel = (String) connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
|
||||
objectId = nodeRef.toString() + CMISConnector.ID_SEPERATOR + versionLabel;
|
||||
currentObjectId = nodeRef.toString() + CMISConnector.ID_SEPERATOR + versionLabel;
|
||||
currentNodeId = nodeRef.toString();
|
||||
objecVariant = CMISObjectVariant.CURRENT_VERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
setUnversioned(nodeRef);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setUnversioned(NodeRef nodeRef)
|
||||
{
|
||||
objecVariant = CMISObjectVariant.CURRENT_VERSION;
|
||||
objectId = nodeRef.toString() + CMISConnector.ID_SEPERATOR + CMISConnector.UNVERSIONED_VERSION_LABEL;
|
||||
versionLabel = CMISConnector.UNVERSIONED_VERSION_LABEL;
|
||||
currentObjectId = objectId;
|
||||
}
|
||||
|
||||
protected void analyseObjectId()
|
||||
{
|
||||
currentNodeId = objectId;
|
||||
@@ -126,6 +191,7 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
|
||||
if (NodeRef.isNodeRef(currentNodeId))
|
||||
{
|
||||
// nodeRef is a "live" node, the version label identifies the specific version of the node
|
||||
nodeRef = new NodeRef(currentNodeId);
|
||||
|
||||
// check for existence
|
||||
@@ -200,10 +266,9 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
return;
|
||||
}
|
||||
|
||||
// check version
|
||||
versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
|
||||
if (versionHistory == null)
|
||||
{
|
||||
if(!connector.getVersionService().isVersioned(nodeRef))
|
||||
{
|
||||
// the node isn't versioned
|
||||
if (versionLabel.equals(CMISConnector.UNVERSIONED_VERSION_LABEL))
|
||||
{
|
||||
objecVariant = CMISObjectVariant.CURRENT_VERSION;
|
||||
@@ -212,29 +277,52 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// the node is versioned, determine whether the versionLabel refers to the head version or a
|
||||
// specific non-head version
|
||||
String headVersionLabel = (String)connector.getNodeService().getProperty(nodeRef, ContentModel.PROP_VERSION_LABEL);
|
||||
currentObjectId = currentNodeId + CMISConnector.ID_SEPERATOR + headVersionLabel;
|
||||
|
||||
if (versionLabel.equals(headVersionLabel))
|
||||
{
|
||||
// the version label refers to the current head version
|
||||
objecVariant = CMISObjectVariant.CURRENT_VERSION;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the version label refers to a specific non-head version, find the nodeRef
|
||||
// of the version node from the version history
|
||||
versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
|
||||
if (versionHistory == null)
|
||||
{
|
||||
// unexpected null versionHistory, assume not versioned
|
||||
if (versionLabel.equals(CMISConnector.UNVERSIONED_VERSION_LABEL))
|
||||
{
|
||||
objecVariant = CMISObjectVariant.CURRENT_VERSION;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
objecVariant = CMISObjectVariant.NOT_EXISTING;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
version = versionHistory.getVersion(versionLabel);
|
||||
nodeRef = version.getFrozenStateNodeRef();
|
||||
objecVariant = CMISObjectVariant.VERSION;
|
||||
}
|
||||
catch (VersionDoesNotExistException e)
|
||||
{
|
||||
objecVariant = CMISObjectVariant.NOT_EXISTING;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// check if checked out
|
||||
hasPWC = connector.getCheckOutCheckInService().isCheckedOut(getCurrentNodeNodeRef());
|
||||
@@ -323,26 +411,13 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
}
|
||||
|
||||
// check version
|
||||
versionHistory = connector.getVersionService().getVersionHistory(nodeRef);
|
||||
if (versionHistory == null)
|
||||
if(connector.getVersionService().isAVersion(nodeRef))
|
||||
{
|
||||
objecVariant = CMISObjectVariant.CURRENT_VERSION;
|
||||
objectId = nodeRef.toString() + CMISConnector.ID_SEPERATOR + CMISConnector.UNVERSIONED_VERSION_LABEL;
|
||||
versionLabel = CMISConnector.UNVERSIONED_VERSION_LABEL;
|
||||
currentObjectId = objectId;
|
||||
analyseVersionNode(nodeRef);
|
||||
}
|
||||
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);
|
||||
analyseCurrentVersion(nodeRef);
|
||||
}
|
||||
|
||||
hasPWC = connector.getCheckOutCheckInService().isCheckedOut(nodeRef);
|
||||
@@ -450,30 +525,37 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
{
|
||||
if (isLatestMajorVersion == null)
|
||||
{
|
||||
isLatestMajorVersion = Boolean.FALSE;
|
||||
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)
|
||||
{
|
||||
// ALF-11116: the current node (in the main store) and the frozen node (in the version store) are both represented as CMISNodeInfos
|
||||
// but are indistinguishable apart from their storeRef (their objectVariant can be the same).
|
||||
isLatestMajorVersion = (nodeRef.getStoreRef().getIdentifier().equals(Version2Model.STORE_ID) || nodeRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID)) ?
|
||||
currentVersion.getFrozenStateNodeRef().equals(nodeRef) : currentVersion.getVersionedNodeRef().equals(nodeRef);
|
||||
break;
|
||||
}
|
||||
currentVersion = versionHistory.getPredecessor(currentVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
if(isCurrentNode())
|
||||
{
|
||||
isLatestMajorVersion = Boolean.TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
VersionHistory versionHistory = getVersionHistory();
|
||||
if (versionHistory == null)
|
||||
{
|
||||
isLatestMajorVersion = Boolean.TRUE;
|
||||
} else
|
||||
{
|
||||
Version currentVersion = versionHistory.getHeadVersion();
|
||||
while (currentVersion != null)
|
||||
{
|
||||
if (currentVersion.getVersionType() == VersionType.MAJOR)
|
||||
{
|
||||
// ALF-11116: the current node (in the main store) and the frozen node (in the version store) are both represented as CMISNodeInfos
|
||||
// but are indistinguishable apart from their storeRef (their objectVariant can be the same).
|
||||
isLatestMajorVersion = (nodeRef.getStoreRef().getIdentifier().equals(Version2Model.STORE_ID) || nodeRef.getStoreRef().getIdentifier().equals(VersionModel.STORE_ID)) ?
|
||||
currentVersion.getFrozenStateNodeRef().equals(nodeRef) : currentVersion.getVersionedNodeRef().equals(nodeRef);
|
||||
break;
|
||||
}
|
||||
currentVersion = versionHistory.getPredecessor(currentVersion);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return isLatestMajorVersion.booleanValue();
|
||||
@@ -730,6 +812,7 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
}
|
||||
}
|
||||
|
||||
// TODO lock here??
|
||||
public VersionHistory getVersionHistory()
|
||||
{
|
||||
if (versionHistory == null && isDocument())
|
||||
@@ -744,8 +827,28 @@ public class CMISNodeInfoImpl implements CMISNodeInfo
|
||||
|
||||
return versionHistory;
|
||||
}
|
||||
|
||||
public void deleteNode()
|
||||
{
|
||||
Version version = getVersion();
|
||||
|
||||
public Version getVersion()
|
||||
if (getVersionHistory().getPredecessor(version) == null)
|
||||
{
|
||||
connector.getNodeService().deleteNode(nodeRef);
|
||||
}
|
||||
else
|
||||
{
|
||||
connector.getVersionService().deleteVersion(nodeRef, version);
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteVersion()
|
||||
{
|
||||
Version version = getVersion();
|
||||
connector.getVersionService().deleteVersion(nodeRef, version);
|
||||
}
|
||||
|
||||
protected Version getVersion()
|
||||
{
|
||||
if (version == null && isDocument())
|
||||
{
|
||||
|
@@ -70,6 +70,7 @@ public class OpenCmisLocalTest extends TestCase
|
||||
@Override
|
||||
public void init(Map<String, String> parameters)
|
||||
{
|
||||
serviceFactory.init(parameters);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Reference in New Issue
Block a user