mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -20,100 +20,30 @@ package org.alfresco.opencmis.mapping;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.opencmis.CMISConnector;
|
||||
import org.alfresco.opencmis.dictionary.CMISNodeInfo;
|
||||
import org.alfresco.service.ServiceRegistry;
|
||||
import org.alfresco.service.cmr.repository.ChildAssociationRef;
|
||||
import org.alfresco.service.cmr.repository.NodeRef;
|
||||
import org.alfresco.service.cmr.repository.Path;
|
||||
import org.alfresco.service.cmr.repository.Path.ChildAssocElement;
|
||||
import org.apache.chemistry.opencmis.commons.PropertyIds;
|
||||
|
||||
/**
|
||||
* Get the CMIS path property.
|
||||
*
|
||||
* @author davidc
|
||||
* @author florian.mueller
|
||||
*/
|
||||
public class PathProperty extends AbstractProperty
|
||||
{
|
||||
private CMISConnector cmisConnector;
|
||||
|
||||
/**
|
||||
* Construct
|
||||
*
|
||||
* @param serviceRegistry
|
||||
*/
|
||||
public PathProperty(ServiceRegistry serviceRegistry, CMISConnector cmisConnector)
|
||||
public PathProperty(ServiceRegistry serviceRegistry, CMISConnector connector)
|
||||
{
|
||||
super(serviceRegistry, PropertyIds.PATH);
|
||||
this.cmisConnector = cmisConnector;
|
||||
super(serviceRegistry, connector, PropertyIds.PATH);
|
||||
}
|
||||
|
||||
/*
|
||||
* (non-Javadoc)
|
||||
*
|
||||
* @see
|
||||
* org.alfresco.cmis.mapping.AbstractProperty#getValue(org.alfresco.service
|
||||
* .cmr.repository.NodeRef)
|
||||
*/
|
||||
public Serializable getValue(NodeRef nodeRef)
|
||||
public Serializable getValueInternal(CMISNodeInfo nodeInfo)
|
||||
{
|
||||
Path path = getServiceRegistry().getNodeService().getPath(nodeRef);
|
||||
return toDisplayPath(path);
|
||||
return nodeInfo.getPath();
|
||||
}
|
||||
|
||||
private String toDisplayPath(Path path)
|
||||
{
|
||||
StringBuilder displayPath = new StringBuilder(64);
|
||||
|
||||
// skip to CMIS root path
|
||||
NodeRef rootNode = cmisConnector.getRootNodeRef();
|
||||
int i = 0;
|
||||
while (i < path.size())
|
||||
{
|
||||
Path.Element element = path.get(i);
|
||||
if (element instanceof ChildAssocElement)
|
||||
{
|
||||
ChildAssociationRef assocRef = ((ChildAssocElement) element).getRef();
|
||||
NodeRef node = assocRef.getChildRef();
|
||||
if (node.equals(rootNode))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
if (i == path.size())
|
||||
{
|
||||
// TODO:
|
||||
// throw new AlfrescoRuntimeException("Path " + path +
|
||||
// " not in CMIS root node scope");
|
||||
}
|
||||
|
||||
if (path.size() - i == 1)
|
||||
{
|
||||
// render root path
|
||||
displayPath.append("/");
|
||||
} else
|
||||
{
|
||||
// render CMIS scoped path
|
||||
i++;
|
||||
while (i < path.size())
|
||||
{
|
||||
Path.Element element = path.get(i);
|
||||
if (element instanceof ChildAssocElement)
|
||||
{
|
||||
ChildAssociationRef assocRef = ((ChildAssocElement) element).getRef();
|
||||
NodeRef node = assocRef.getChildRef();
|
||||
displayPath.append("/");
|
||||
displayPath.append(getServiceRegistry().getNodeService().getProperty(node, ContentModel.PROP_NAME));
|
||||
}
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
return displayPath.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user