mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-21 18:09:20 +00:00
Merged HEAD (5.2) to 5.2.N (5.2.1)
126374 jkaabimofrad: Merged FILE-FOLDER-API (5.2.0) to HEAD (5.2) 119857 jvonka: FileFolder API - optimise check when getting 'type' of node (whether folder or file, or a link to thereof) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@126720 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -345,9 +345,20 @@ public class NodesImpl implements Nodes
|
|||||||
|
|
||||||
private Type getType(QName typeQName, NodeRef nodeRef)
|
private Type getType(QName typeQName, NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
|
// quick check for common types
|
||||||
|
if (typeQName.equals(ContentModel.TYPE_FOLDER) || typeQName.equals(ApplicationModel.TYPE_FOLDERLINK))
|
||||||
|
{
|
||||||
|
return Type.FOLDER;
|
||||||
|
}
|
||||||
|
else if (typeQName.equals(ContentModel.TYPE_CONTENT) || typeQName.equals(ApplicationModel.TYPE_FILELINK))
|
||||||
|
{
|
||||||
|
return Type.DOCUMENT;
|
||||||
|
}
|
||||||
|
|
||||||
|
// further checks
|
||||||
|
|
||||||
if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_LINK))
|
if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_LINK))
|
||||||
{
|
{
|
||||||
// handle file/folder link type (we do not explicitly validate that the destination type matches)
|
|
||||||
if (dictionaryService.isSubClass(typeQName, ApplicationModel.TYPE_FOLDERLINK))
|
if (dictionaryService.isSubClass(typeQName, ApplicationModel.TYPE_FOLDERLINK))
|
||||||
{
|
{
|
||||||
return Type.FOLDER;
|
return Type.FOLDER;
|
||||||
@@ -356,15 +367,15 @@ public class NodesImpl implements Nodes
|
|||||||
{
|
{
|
||||||
return Type.DOCUMENT;
|
return Type.DOCUMENT;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
// cm:link (or other subclass)
|
|
||||||
NodeRef linkNodeRef = (NodeRef)nodeService.getProperty(nodeRef, ContentModel.PROP_LINK_DESTINATION);
|
NodeRef linkNodeRef = (NodeRef)nodeService.getProperty(nodeRef, ContentModel.PROP_LINK_DESTINATION);
|
||||||
if (linkNodeRef != null)
|
if (linkNodeRef != null)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
typeQName = nodeService.getType(linkNodeRef);
|
typeQName = nodeService.getType(linkNodeRef);
|
||||||
|
// drop-through to check type of destination
|
||||||
|
// note: edge-case - if link points to another link then we will return null
|
||||||
}
|
}
|
||||||
catch (InvalidNodeRefException inre)
|
catch (InvalidNodeRefException inre)
|
||||||
{
|
{
|
||||||
@@ -372,11 +383,21 @@ public class NodesImpl implements Nodes
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_FOLDER))
|
||||||
|
{
|
||||||
|
if (! dictionaryService.isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER))
|
||||||
|
{
|
||||||
|
return Type.FOLDER;
|
||||||
|
}
|
||||||
|
return null; // unknown
|
||||||
|
}
|
||||||
|
else if (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_CONTENT))
|
||||||
|
{
|
||||||
|
return Type.DOCUMENT;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean isContainer = (dictionaryService.isSubClass(typeQName, ContentModel.TYPE_FOLDER) &&
|
return null; // unknown
|
||||||
(! dictionaryService.isSubClass(typeQName, ContentModel.TYPE_SYSTEM_FOLDER)));
|
|
||||||
return isContainer ? Type.FOLDER : Type.DOCUMENT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -385,7 +406,7 @@ public class NodesImpl implements Nodes
|
|||||||
public Document getDocument(NodeRef nodeRef)
|
public Document getDocument(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
Type type = getType(nodeRef);
|
Type type = getType(nodeRef);
|
||||||
if (type.equals(Type.DOCUMENT))
|
if ((type != null) && type.equals(Type.DOCUMENT))
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
@@ -423,7 +444,7 @@ public class NodesImpl implements Nodes
|
|||||||
public Folder getFolder(NodeRef nodeRef)
|
public Folder getFolder(NodeRef nodeRef)
|
||||||
{
|
{
|
||||||
Type type = getType(nodeRef);
|
Type type = getType(nodeRef);
|
||||||
if (type.equals(Type.FOLDER))
|
if ((type != null) && type.equals(Type.FOLDER))
|
||||||
{
|
{
|
||||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
@@ -572,6 +593,12 @@ public class NodesImpl implements Nodes
|
|||||||
Node node;
|
Node node;
|
||||||
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
Map<QName, Serializable> properties = nodeService.getProperties(nodeRef);
|
||||||
|
|
||||||
|
if (type == null)
|
||||||
|
{
|
||||||
|
// unknown type
|
||||||
|
node = new Document(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
||||||
|
node.setIsFolder(null);
|
||||||
|
}
|
||||||
if (type.equals(Type.DOCUMENT))
|
if (type.equals(Type.DOCUMENT))
|
||||||
{
|
{
|
||||||
node = new Document(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
node = new Document(nodeRef, parentNodeRef, properties, mapUserInfo, sr);
|
||||||
@@ -583,7 +610,7 @@ public class NodesImpl implements Nodes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
throw new InvalidArgumentException("Node is not a folder or file");
|
throw new RuntimeException("Unexpected - should not reach here");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selectParam.size() > 0)
|
if (selectParam.size() > 0)
|
||||||
|
Reference in New Issue
Block a user