Java Code Examples for org.alfresco.service.cmr.repository.Path#iterator()

The following examples show how to use org.alfresco.service.cmr.repository.Path#iterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LuceneCategoryServiceImpl.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private String buildXPath(Path path)
{
    StringBuilder pathBuffer = new StringBuilder(64);
    for (Iterator<Path.Element> elit = path.iterator(); elit.hasNext(); /**/)
    {
        Path.Element element = elit.next();
        if (!(element instanceof Path.ChildAssocElement))
        {
            throw new IndexerException("Confused path: " + path);
        }
        Path.ChildAssocElement cae = (Path.ChildAssocElement) element;
        if (cae.getRef().getParentRef() != null)
        {
            pathBuffer.append("/");
            pathBuffer.append(getPrefix(cae.getRef().getQName().getNamespaceURI()));
            pathBuffer.append(ISO9075.encode(cae.getRef().getQName().getLocalName()));
        }
    }
    return pathBuffer.toString();
}
 
Example 2
Source File: FilenameFilteringInterceptor.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
private boolean isSystemPath(NodeRef parentNodeRef, String filename)
{
    boolean ret = false;
    Path path = nodeService.getPath(parentNodeRef);

    Iterator<Element> it = path.iterator();
    while(it.hasNext())
    {
        Path.ChildAssocElement elem = (Path.ChildAssocElement)it.next();
        QName qname = elem.getRef().getQName();
        if(qname != null && systemPaths.isFiltered(qname.getLocalName()))
        {
            ret = true;
            break;
        }
    }

    return ret;
}
 
Example 3
Source File: HiddenAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Checks whether the node is on a hidden path
 *
 * @param nodeRef NodeRef
 * @return the matching filter, or null if no match
 */
public HiddenFileInfo onHiddenPath(NodeRef nodeRef)
{
    HiddenFileInfo ret = null;
    // TODO would be nice to check each part of the path in turn, bailing out if a match is found
    Path path = nodeService.getPath(nodeRef);
    nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);

    Iterator<Element> it = path.iterator();
    while(it.hasNext())
    {
        Path.ChildAssocElement elem = (Path.ChildAssocElement)it.next();
        QName qname = elem.getRef().getQName();
        if(qname != null)
        {
            ret = isHidden(qname.getLocalName());
            if(ret != null)
            {
                break;
            }
        }
    }

    return ret;
}
 
Example 4
Source File: NodesMetaDataGet.java    From alfresco-remote-api with GNU Lesser General Public License v3.0 6 votes vote down vote up
private ArrayList<NodeRef> getAncestors(Path path)
{
    ArrayList<NodeRef> ancestors = new ArrayList<NodeRef>(8);
    for (Iterator<Path.Element> elit = path.iterator(); elit.hasNext(); /**/)
    {
        Path.Element element = elit.next();
        if (!(element instanceof Path.ChildAssocElement))
        {
            throw new IndexerException("Confused path: " + path);
        }
        Path.ChildAssocElement cae = (Path.ChildAssocElement) element;
        NodeRef parentRef = cae.getRef().getParentRef();
        if(parentRef != null)
        {
            ancestors.add(0, parentRef);
        }

    }
    return ancestors;
}
 
Example 5
Source File: HiddenAspect.java    From alfresco-repository with GNU Lesser General Public License v3.0 4 votes vote down vote up
private HiddenFileInfo findMatch(NodeRef nodeRef)
{
    HiddenFileInfo ret = null;
    Path path = null;
    String name = null;

    OUTER: for(HiddenFileInfo filter : filters)
    {
        if (Client.cmis.equals(FileFilterMode.getClient()) && filter instanceof ConfigurableHiddenFileInfo)
        {
            if (((ConfigurableHiddenFileInfo) filter).isCmisDisableHideConfig())
            {
                continue;
            }
        }
    	if(filter.cascadeHiddenAspect() || filter.cascadeIndexControlAspect())
    	{
    		if(path == null)
    		{
    			path = nodeService.getPath(nodeRef);
    		}

            // TODO would be nice to check each part of the path in turn, bailing out if a match is found
            Iterator<Element> it = path.iterator();
            while(it.hasNext())
            {
                Path.ChildAssocElement elem = (Path.ChildAssocElement)it.next();
                QName qname = elem.getRef().getQName();
                if(qname != null)
                {
        			if(filter.isHidden(qname.getLocalName()))
        			{
        				ret = filter;
                        break OUTER;
                    }
                }
    		}
    	}
    	else
    	{
    		if(name == null)
    		{
    			name = (String)nodeService.getProperty(nodeRef, ContentModel.PROP_NAME);
    		}

         if(filter.isHidden(name))
         {
         	ret = filter;
         	break;
         }
    	}
    }

    return ret;
}