本文整理汇总了Java中org.alfresco.service.cmr.repository.Path.size方法的典型用法代码示例。如果您正苦于以下问题:Java Path.size方法的具体用法?Java Path.size怎么用?Java Path.size使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.alfresco.service.cmr.repository.Path
的用法示例。
在下文中一共展示了Path.size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toDisplayPath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* @param path Path
* @return display path
*/
private String toDisplayPath(Path path)
{
StringBuffer displayPath = new StringBuffer();
if (path.size() == 1)
{
displayPath.append("/");
}
else
{
for (int i = 1; i < path.size(); i++)
{
Path.Element element = path.get(i);
if (element instanceof ChildAssocElement)
{
ChildAssociationRef assocRef = ((ChildAssocElement)element).getRef();
NodeRef node = assocRef.getChildRef();
displayPath.append("/");
displayPath.append(nodeService.getProperty(node, ContentModel.PROP_NAME));
}
}
}
return displayPath.toString();
}
示例2: startNode
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
public void startNode(NodeRef nodeRef)
{
try
{
AttributesImpl attrs = new AttributesImpl();
Path path = nodeService.getPath(nodeRef);
if (path.size() > 1)
{
// a child name does not exist for root
Path.ChildAssocElement pathElement = (Path.ChildAssocElement)path.last();
QName childQName = pathElement.getRef().getQName();
attrs.addAttribute(NamespaceService.REPOSITORY_VIEW_1_0_URI, CHILDNAME_LOCALNAME, CHILDNAME_QNAME.toPrefixString(), null, toPrefixString(childQName));
}
QName type = nodeService.getType(nodeRef);
contentHandler.startElement(type.getNamespaceURI(), type.getLocalName(), toPrefixString(type), attrs);
}
catch (SAXException e)
{
throw new ExporterException("Failed to process start node event - node ref " + nodeRef.toString(), e);
}
}
示例3: createIndexedPath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Helper to convert a path into an indexed path which uniquely identifies a node
*
* @param nodeRef NodeRef
* @param path Path
* @return Path
*/
private Path createIndexedPath(NodeRef nodeRef, Path path)
{
// Add indexes for same name siblings
// TODO: Look at more efficient approach
for (int i = path.size() - 1; i >= 0; i--)
{
Path.Element pathElement = path.get(i);
if (i > 0 && pathElement instanceof Path.ChildAssocElement)
{
int index = 1; // for xpath index compatibility
String searchPath = path.subPath(i).toPrefixString(namespaceService);
List<NodeRef> siblings = searchService.selectNodes(nodeRef, searchPath, null, namespaceService, false);
if (siblings.size() > 1)
{
ChildAssociationRef childAssoc = ((Path.ChildAssocElement)pathElement).getRef();
NodeRef childRef = childAssoc.getChildRef();
for (NodeRef sibling : siblings)
{
if (sibling.equals(childRef))
{
childAssoc.setNthSibling(index);
break;
}
index++;
}
}
}
}
return path;
}
示例4: resolveParentPath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
*
* @param store StoreRef
* @param parentPath Path
* @return NodeRef
*/
private NodeRef resolveParentPath(StoreRef store, Path parentPath)
{
if (log.isDebugEnabled())
{
log.debug("Trying to resolve parent path " + parentPath);
}
NodeRef node = nodeService.getRootNode(store);
int index = 1;
while (index < parentPath.size())
{
Element element = parentPath.get(index++);
QName name = QName.createQName(element.getElementString());
List<ChildAssociationRef> children = nodeService.getChildAssocs(node, RegexQNamePattern.MATCH_ALL, name);
if (children.isEmpty())
{
if (log.isDebugEnabled())
{
log.debug("Failed to resolve path element " + element.getElementString());
}
return null;
}
if (log.isDebugEnabled())
{
log.debug("Resolved path element " + element.getElementString());
}
node = children.get(0).getChildRef();
}
return node;
}
示例5: getSiteShortName
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Returns the short name of the site this node is located within. If the
* node is not located within a site null is returned.
*
* @return The short name of the site this node is located within, null
* if the node is not located within a site.
*/
public String getSiteShortName()
{
if (!this.siteNameResolved)
{
this.siteNameResolved = true;
Path path = this.services.getNodeService().getPath(getNodeRef());
if (logger.isDebugEnabled())
logger.debug("Determing if node is within a site using path: " + path);
for (int i = 0; i < path.size(); i++)
{
if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
{
// we now know the node is in a site, find the next element in the array (if there is one)
if ((i+1) < path.size())
{
// get the site name
Path.Element siteName = path.get(i+1);
// remove the "cm:" prefix and add to result object
this.siteName = ISO9075.decode(siteName.getPrefixedString(
this.services.getNamespaceService()).substring(3));
}
break;
}
}
}
if (logger.isDebugEnabled())
{
logger.debug(this.siteName != null ?
"Node is in the site named \"" + this.siteName + "\"" : "Node is not in a site");
}
return this.siteName;
}
示例6: getSiteShortName
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Returns the short name of the site this node is located within. If the
* node is not located within a site null is returned.
*
* @return The short name of the site this node is located within, null
* if the node is not located within a site.
*/
public String getSiteShortName()
{
if (!this.siteNameResolved)
{
this.siteNameResolved = true;
Path path = this.services.getNodeService().getPath(getNodeRef());
for (int i = 0; i < path.size(); i++)
{
if ("st:sites".equals(path.get(i).getPrefixedString(this.services.getNamespaceService())))
{
// we now know the node is in a site, find the next element in the array (if there is one)
if ((i+1) < path.size())
{
// get the site name
Path.Element siteName = path.get(i+1);
// remove the "cm:" prefix and add to result object
this.siteName = ISO9075.decode(siteName.getPrefixedString(
this.services.getNamespaceService()).substring(3));
}
break;
}
}
}
return this.siteName;
}
示例7: getDisplayPath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Return the human readable form of the specified node Path. Fast version
* of the method that simply converts QName localname components to Strings.
*
* @param path Path to extract readable form from
* @param showLeaf Whether to process the final leaf element of the path
*
* @return human readable form of the Path
*/
public static String getDisplayPath(Path path, boolean showLeaf)
{
// This method was moved here from org.alfresco.web.bean.repository.Repository
StringBuilder buf = new StringBuilder(64);
int count = path.size() - (showLeaf ? 0 : 1);
for (int i = 0; i < count; i++)
{
String elementString = null;
Path.Element element = path.get(i);
if (element instanceof Path.ChildAssocElement)
{
ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
if (elementRef.getParentRef() != null)
{
elementString = elementRef.getQName().getLocalName();
}
} else
{
elementString = element.getElementString();
}
if (elementString != null)
{
buf.append("/");
buf.append(elementString);
}
}
return buf.toString();
}
示例8: getMappedPath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Get mapped path
*/
public Path getMappedPath(Path from)
{
Path to = new Path();
/**
*
*/
Path source = new Path();
for (int i = 0; i < from.size(); i++)
{
// Source steps through each element of from.
source.append(from.get(i));
boolean replacePath = false;
for (Pair<Path, Path> xx : getPathMap())
{
// Can't use direct equals because of mismatched node refs (which we don't care about)
if (xx.getFirst().toString().equals(source.toString()))
{
to = xx.getSecond().subPath(xx.getSecond().size() - 1);
replacePath = true;
break;
}
}
if (!replacePath)
{
to.append(from.get(i));
}
}
return to;
}
示例9: getPathFromSpaceRef
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Generate a search XPATH pointing to the specified node, optionally return an XPATH
* that includes the child nodes.
*
* @param ref Of the node to generate path too
* @param children Whether to include children of the node
*
* @return the path
*/
public static String getPathFromSpaceRef(NodeRef ref, boolean children)
{
FacesContext context = FacesContext.getCurrentInstance();
Path path = Repository.getServiceRegistry(context).getNodeService().getPath(ref);
NamespaceService ns = Repository.getServiceRegistry(context).getNamespaceService();
StringBuilder buf = new StringBuilder(64);
for (int i=0; i<path.size(); i++)
{
String elementString = "";
Path.Element element = path.get(i);
if (element instanceof Path.ChildAssocElement)
{
ChildAssociationRef elementRef = ((Path.ChildAssocElement)element).getRef();
if (elementRef.getParentRef() != null)
{
Collection<String> prefixes = ns.getPrefixes(elementRef.getQName().getNamespaceURI());
if (prefixes.size() >0)
{
elementString = '/' + (String)prefixes.iterator().next() + ':' + ISO9075.encode(elementRef.getQName().getLocalName());
}
}
}
buf.append(elementString);
}
if (children == true)
{
// append syntax to get all children of the path
buf.append("//*");
}
else
{
// append syntax to just represent the path, not the children
buf.append("/*");
}
return buf.toString();
}
示例10: getSiteShortName
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Returns the short name of the site this node is located within. If the node is not located within a site null is
* returned.
*
* @return The short name of the site this node is located within, null if the node is not located within a site.
*/
public String getSiteShortName(NodeRef nodeRef)
{
String result = null;
Path path = nodeService.getPath(nodeRef);
if (logger.isDebugEnabled())
logger.debug("Determing if node is within a site using path: " + path);
for (int i = 0; i < path.size(); i++)
{
if ("st:sites".equals(path.get(i).getPrefixedString(namespaceService)))
{
// we now know the node is in a site, find the next element in the array (if there is one)
if ((i + 1) < path.size())
{
// get the site name
Path.Element siteName = path.get(i + 1);
// remove the "cm:" prefix and add to result object
result = ISO9075.decode(siteName.getPrefixedString(namespaceService).substring(3));
}
break;
}
}
if (logger.isDebugEnabled())
{
logger.debug(result != null ? "Node is in the site named \"" + result + "\"" : "Node is not in a site");
}
return result;
}
示例11: getRelativePath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* @return the relative 'path' (a list of folder names) of the {@code homeFolder}
* from the {@code root} or {@code null} if the homeFolder is not under the root
* or is the root. An empty list is returned if the homeFolder is the same as the
* root or the root is below the homeFolder.
*/
private List<String> getRelativePath(NodeRef root, NodeRef homeFolder)
{
if (root == null || homeFolder == null)
{
return null;
}
if (root.equals(homeFolder))
{
return Collections.emptyList();
}
Path rootPath = nodeService.getPath(root);
Path homeFolderPath = nodeService.getPath(homeFolder);
int rootSize = rootPath.size();
int homeFolderSize = homeFolderPath.size();
if (rootSize >= homeFolderSize)
{
return Collections.emptyList();
}
// Check homeFolder is under root
for (int i=0; i < rootSize; i++)
{
if (!rootPath.get(i).equals(homeFolderPath.get(i)))
{
return null;
}
}
// Build up path of sub folders
List<String> path = new ArrayList<String>();
for (int i = rootSize; i < homeFolderSize; i++)
{
Path.Element element = homeFolderPath.get(i);
if (!(element instanceof Path.ChildAssocElement))
{
return null;
}
QName folderQName = ((Path.ChildAssocElement) element).getRef().getQName();
path.add(folderQName.getLocalName());
}
return path;
}
示例12: isWithinExport
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
/**
* Determine if specified Node Reference is within the set of nodes to be exported
*
* @param nodeRef node reference to check
* @return true => node reference is within export set
*/
private boolean isWithinExport(NodeRef nodeRef, ExporterCrawlerParameters parameters)
{
boolean isWithin = false;
try
{
// Current strategy is to determine if node is a child of the root exported node
for (NodeRef exportRoot : context.getExportList())
{
if (nodeRef.equals(exportRoot) && parameters.isCrawlSelf() == true)
{
// node to export is the root export node (and root is to be exported)
isWithin = true;
}
else
{
// locate export root in primary parent path of node
Path nodePath = nodeService.getPath(nodeRef);
for (int i = nodePath.size() - 1; i >= 0; i--)
{
Path.ChildAssocElement pathElement = (Path.ChildAssocElement) nodePath.get(i);
if (pathElement.getRef().getChildRef().equals(exportRoot))
{
isWithin = true;
break;
}
}
}
}
}
catch (AccessDeniedException accessErr)
{
// use default if this occurs
}
catch (InvalidNodeRefException nodeErr)
{
// use default if this occurs
}
return isWithin;
}
示例13: generateContainersAndBelow
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
private void generateContainersAndBelow(List<Path> paths, List<Document> docs, boolean cascade,
Set<Pair<Boolean, Path>> pathsToRegenerate, Map<NodeRef, List<ChildAssociationRef>> childAssociationsSinceFlush)
{
if (paths.isEmpty())
{
return;
}
for (Path path: paths)
{
NodeRef nodeRef = tenantService.getName(((ChildAssocElement) path.last()).getRef().getChildRef());
// Categories have special powers - generate their container regardless of their actual children
boolean isCategory = isCategory(getDictionaryService().getType(nodeService.getType(nodeRef)));
// For other containers, we only add a doc if they actually have children
if (!isCategory)
{
// Only process 'containers' - not leaves
if (!mayHaveChildren(nodeRef))
{
continue;
}
// Only process 'containers' - not leaves
if (getCachedChildren(childAssociationsSinceFlush, nodeRef, cascade).isEmpty())
{
continue;
}
}
QName nodeType = nodeService.getType(nodeRef);
Set<QName> aspects = nodeService.getAspects(nodeRef);
boolean ignoreRegeneration = (typeIndexFilter.shouldBeIgnored(nodeType) || aspectIndexFilter.shouldBeIgnored(aspects));
if (ignoreRegeneration)
{
continue;
}
// Skip the root, which is a single document
if (path.size() > 1)
{
// Record this path for writing to the index
pathsToRegenerate.add(new Pair<Boolean, Path>(isCategory, path));
}
if (cascade)
{
List<Path> childPaths = new LinkedList<Path>();
for (ChildAssociationRef childRef : getCachedChildren(childAssociationsSinceFlush, nodeRef, cascade))
{
childPaths.add(new Path().append(path).append(new Path.ChildAssocElement(childRef)));
}
generateContainersAndBelow(childPaths, docs, true, pathsToRegenerate,
childAssociationsSinceFlush);
}
}
}
示例14: toPath
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
private String toPath(NodeRef root, NodeRef homeFolder)
{
if (root == null || homeFolder == null)
{
return null;
}
if (root.equals(homeFolder))
{
return ".";
}
Path rootPath = nodeService.getPath(root);
Path homeFolderPath = nodeService.getPath(homeFolder);
int rootSize = rootPath.size();
int homeFolderSize = homeFolderPath.size();
if (rootSize >= homeFolderSize)
{
return null;
}
StringBuilder sb = new StringBuilder("");
// Check homeFolder is under root
for (int i=0; i < rootSize; i++)
{
if (!rootPath.get(i).equals(homeFolderPath.get(i)))
{
return null;
}
}
// Build up path of sub folders
for (int i = rootSize; i < homeFolderSize; i++)
{
Path.Element element = homeFolderPath.get(i);
if (!(element instanceof Path.ChildAssocElement))
{
return null;
}
QName folderQName = ((Path.ChildAssocElement) element).getRef().getQName();
if (sb.length() > 0)
{
sb.append('/');
}
sb.append(folderQName.getLocalName());
}
return sb.toString();
}
示例15: lookupPathInfo
import org.alfresco.service.cmr.repository.Path; //导入方法依赖的package包/类
@Override
public PathInfo lookupPathInfo(NodeRef nodeRefIn, ChildAssociationRef archivedParentAssoc)
{
List<ElementInfo> pathElements = new ArrayList<>();
Boolean isComplete = Boolean.TRUE;
final Path nodePath;
final int pathIndex;
if (archivedParentAssoc != null)
{
if (permissionService.hasPermission(archivedParentAssoc.getParentRef(), PermissionService.READ).equals(AccessStatus.ALLOWED)
&& nodeService.exists(archivedParentAssoc.getParentRef()))
{
nodePath = nodeService.getPath(archivedParentAssoc.getParentRef());
pathIndex = 1;// 1 => we want to include the given node in the path as well.
}
else
{
//We can't return a valid path
return null;
}
}
else
{
nodePath = nodeService.getPath(nodeRefIn);
pathIndex = 2; // 2 => as we don't want to include the given node in the path as well.
}
for (int i = nodePath.size() - pathIndex; i >= 0; i--)
{
Element element = nodePath.get(i);
if (element instanceof Path.ChildAssocElement)
{
ChildAssociationRef elementRef = ((Path.ChildAssocElement) element).getRef();
if (elementRef.getParentRef() != null)
{
NodeRef childNodeRef = elementRef.getChildRef();
if (permissionService.hasPermission(childNodeRef, PermissionService.READ) == AccessStatus.ALLOWED)
{
Serializable nameProp = nodeService.getProperty(childNodeRef, ContentModel.PROP_NAME);
String type = getNodeType(childNodeRef).toPrefixString(namespaceService);
Set<QName> aspects = nodeService.getAspects(childNodeRef);
List<String> aspectNames = mapFromNodeAspects(aspects, EXCLUDED_NS, EXCLUDED_ASPECTS);
pathElements.add(0, new ElementInfo(childNodeRef.getId(), nameProp.toString(), type, aspectNames));
}
else
{
// Just return the pathInfo up to the location where the user has access
isComplete = Boolean.FALSE;
break;
}
}
}
}
String pathStr = null;
if (pathElements.size() > 0)
{
StringBuilder sb = new StringBuilder(120);
for (PathInfo.ElementInfo e : pathElements)
{
sb.append("/").append(e.getName());
}
pathStr = sb.toString();
}
else
{
// There is no path element, so set it to null in order to be
// ignored by Jackson during serialisation
isComplete = null;
}
return new PathInfo(pathStr, isComplete, pathElements);
}