Created
July 16, 2016 17:16
-
-
Save jottley/925b44a86f0275178738c134e47b828a to your computer and use it in GitHub Desktop.
Returns display path with the final content/folder node
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Copyright (C) 2005-2015 Alfresco Software Limited. | |
* | |
* This file is part of Alfresco | |
* | |
* Alfresco is free software: you can redistribute it and/or modify it under the | |
* terms of the GNU Lesser General Public License as published by the Free | |
* Software Foundation, either version 3 of the License, or (at your option) any | |
* later version. | |
* | |
* Alfresco is distributed in the hope that it will be useful, but WITHOUT ANY | |
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more | |
* details. | |
* | |
* You should have received a copy of the GNU Lesser General Public License | |
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>. | |
*/ | |
/** | |
* @author Jared Ottley <jared.ottley@alfresco.com> | |
*/ | |
//Returns display path with the final content/folder node | |
private String toDisplayPath(Path path) | |
{ | |
StringBuilder buf = new StringBuilder(64); | |
for (int i = 1; i < path.size(); i++) | |
{ | |
String elementString = null; | |
Element element = path.get(i); | |
if (element instanceof ChildAssocElement) | |
{ | |
ChildAssociationRef elementRef = ((ChildAssocElement)element).getRef(); | |
if (elementRef.getParentRef() != null) | |
{ | |
Serializable nameProp = null; | |
if (permissionService.hasPermission(elementRef.getChildRef(), PermissionService.READ) == AccessStatus.ALLOWED) | |
{ | |
nameProp = nodeService.getProperty(elementRef.getChildRef(), ContentModel.PROP_NAME); | |
// use the name property if we are allowed access to it | |
elementString = nameProp.toString(); | |
} | |
else | |
{ | |
// revert to using QName if not | |
elementString = elementRef.getQName().getLocalName(); | |
} | |
} | |
} | |
else | |
{ | |
elementString = element.getElementString(); | |
} | |
if (elementString != null) | |
{ | |
buf.append(“/”); | |
buf.append(elementString); | |
} | |
} | |
return buf.toString(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment