mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-10-08 14:51:49 +00:00
125603 rmunteanu: Merged 5.1.1 (5.1.1) to 5.1.N (5.1.2) 125484 slanglois: MNT-16155 Update source headers - remove old Copyrights from Java and JSP dource files git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/BRANCHES/DEV/5.2.N/root@125781 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
67 lines
1.9 KiB
Java
67 lines
1.9 KiB
Java
|
|
package org.alfresco.repo.virtual.ref;
|
|
|
|
/**
|
|
* Returns a virtual parent reference upon execution by subtracting the last
|
|
* template path element from of the given reference.<br>
|
|
* For root template path references a <code>null</code> will be returned upon
|
|
* execution.
|
|
*
|
|
* @see VirtualProtocol#replaceTemplatePath(Reference, String)
|
|
* @author Bogdan Horje
|
|
*/
|
|
public class GetParentReferenceMethod extends AbstractProtocolMethod<Reference>
|
|
{
|
|
@Override
|
|
public Reference execute(VirtualProtocol virtualProtocol, Reference reference) throws ProtocolMethodException
|
|
{
|
|
String path = virtualProtocol.getTemplatePath(reference);
|
|
if (path.trim().endsWith(PATH_SEPARATOR))
|
|
{
|
|
|
|
int trailingPathIndex = path.lastIndexOf(PATH_SEPARATOR);
|
|
if (trailingPathIndex == 0)
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
path = path.substring(0,
|
|
trailingPathIndex);
|
|
}
|
|
}
|
|
|
|
int index = path.lastIndexOf(PATH_SEPARATOR);
|
|
if (index < 0)
|
|
{
|
|
return null;
|
|
}
|
|
else
|
|
{
|
|
String parentPath = path.substring(0,
|
|
index);
|
|
|
|
if (parentPath.isEmpty())
|
|
{
|
|
if (path.length() > 1)
|
|
{
|
|
parentPath = PATH_SEPARATOR;
|
|
}
|
|
else
|
|
{
|
|
return null;
|
|
}
|
|
}
|
|
|
|
return virtualProtocol.replaceTemplatePath(reference,
|
|
parentPath);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Reference execute(NodeProtocol protocol, Reference reference) throws ProtocolMethodException
|
|
{
|
|
return ((ReferenceParameter) reference.getParameters().get(0)).getValue();
|
|
}
|
|
}
|