Search in sources :

Example 1 with DavResourceIteratorImpl

use of org.apache.jackrabbit.webdav.DavResourceIteratorImpl in project jackrabbit by apache.

the class VersionHistoryResourceImpl method getMembers.

//--------------------------------------------------------< DavResource >---
/**
     * Show all versions of this history as members.
     *
     * @return
     * @see DavResource#getMembers()
     */
@Override
public DavResourceIterator getMembers() {
    ArrayList<DavResource> list = new ArrayList<DavResource>();
    if (exists() && isCollection()) {
        try {
            // only display versions as members of the vh. the jcr:versionLabels
            // node is an internal structure.
            VersionIterator it = ((VersionHistory) getNode()).getAllVersions();
            while (it.hasNext()) {
                // omit item filter here. if the version history is visible
                // its versions should be visible as well.
                Version v = it.nextVersion();
                DavResourceLocator vhLocator = getLocator();
                DavResourceLocator resourceLocator = vhLocator.getFactory().createResourceLocator(vhLocator.getPrefix(), vhLocator.getWorkspacePath(), v.getPath(), false);
                DavResource childRes = getFactory().createResource(resourceLocator, getSession());
                list.add(childRes);
            }
        } catch (RepositoryException e) {
            // should not occur
            log.error("Unexpected error", e);
        } catch (DavException e) {
            // should not occur
            log.error("Unexpected error", e);
        }
    }
    return new DavResourceIteratorImpl(list);
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) Version(javax.jcr.version.Version) DavException(org.apache.jackrabbit.webdav.DavException) JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) DavResourceIteratorImpl(org.apache.jackrabbit.webdav.DavResourceIteratorImpl) ArrayList(java.util.ArrayList) VersionIterator(javax.jcr.version.VersionIterator) RepositoryException(javax.jcr.RepositoryException) VersionHistory(javax.jcr.version.VersionHistory) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 2 with DavResourceIteratorImpl

use of org.apache.jackrabbit.webdav.DavResourceIteratorImpl in project jackrabbit by apache.

the class DefaultItemCollection method getMembers.

/**
     * @see org.apache.jackrabbit.webdav.DavResource#getMembers()
     */
@Override
public DavResourceIterator getMembers() {
    ArrayList<DavResource> memberList = new ArrayList<DavResource>();
    if (exists()) {
        try {
            Node n = (Node) item;
            // add all node members
            NodeIterator it = n.getNodes();
            while (it.hasNext()) {
                Node node = it.nextNode();
                DavResourceLocator loc = getLocatorFromItem(node);
                memberList.add(createResourceFromLocator(loc));
            }
            // add all property members
            PropertyIterator propIt = n.getProperties();
            while (propIt.hasNext()) {
                Property prop = propIt.nextProperty();
                DavResourceLocator loc = getLocatorFromItem(prop);
                memberList.add(createResourceFromLocator(loc));
            }
        } catch (RepositoryException e) {
            // ignore
            log.error(e.getMessage());
        } catch (DavException e) {
            // should never occur.
            log.error(e.getMessage());
        }
    }
    return new DavResourceIteratorImpl(memberList);
}
Also used : NodeIterator(javax.jcr.NodeIterator) DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) DavResourceIteratorImpl(org.apache.jackrabbit.webdav.DavResourceIteratorImpl) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) PropertyIterator(javax.jcr.PropertyIterator) RepositoryException(javax.jcr.RepositoryException) Property(javax.jcr.Property) HrefProperty(org.apache.jackrabbit.webdav.property.HrefProperty) JcrUserPrivilegesProperty(org.apache.jackrabbit.webdav.jcr.security.JcrUserPrivilegesProperty) DefaultDavProperty(org.apache.jackrabbit.webdav.property.DefaultDavProperty) JcrSupportedPrivilegesProperty(org.apache.jackrabbit.webdav.jcr.security.JcrSupportedPrivilegesProperty) NodeTypeProperty(org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeProperty) DavProperty(org.apache.jackrabbit.webdav.property.DavProperty) ValuesProperty(org.apache.jackrabbit.webdav.jcr.property.ValuesProperty) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 3 with DavResourceIteratorImpl

use of org.apache.jackrabbit.webdav.DavResourceIteratorImpl in project jackrabbit by apache.

the class RootCollection method getMembers.

/**
     * Returns an iterator over the member resources, which are all
     * workspace resources available.
     *
     * @return members of this collection
     * @see org.apache.jackrabbit.webdav.DavResource#getMembers()
     */
@Override
public DavResourceIterator getMembers() {
    List<DavResource> memberList = new ArrayList();
    try {
        String[] wsNames = getRepositorySession().getWorkspace().getAccessibleWorkspaceNames();
        for (String wsName : wsNames) {
            String wspPath = "/" + wsName;
            DavResourceLocator childLoc = getLocator().getFactory().createResourceLocator(getLocator().getPrefix(), wspPath, wspPath);
            memberList.add(createResourceFromLocator(childLoc));
        }
    } catch (RepositoryException e) {
        log.error(e.getMessage());
    } catch (DavException e) {
        // should never occur
        log.error(e.getMessage());
    }
    return new DavResourceIteratorImpl(memberList);
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) DavResourceIteratorImpl(org.apache.jackrabbit.webdav.DavResourceIteratorImpl) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 4 with DavResourceIteratorImpl

use of org.apache.jackrabbit.webdav.DavResourceIteratorImpl in project jackrabbit by apache.

the class DavResourceImpl method getMembers.

/**
     * @see DavResource#getMembers()
     */
public DavResourceIterator getMembers() {
    ArrayList<DavResource> list = new ArrayList<DavResource>();
    if (exists() && isCollection()) {
        try {
            NodeIterator it = node.getNodes();
            while (it.hasNext()) {
                Node n = it.nextNode();
                if (!isFilteredItem(n)) {
                    DavResourceLocator resourceLocator = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), n.getPath(), false);
                    DavResource childRes = factory.createResource(resourceLocator, session);
                    list.add(childRes);
                } else {
                    log.debug("Filtered resource '" + n.getName() + "'.");
                }
            }
        } catch (RepositoryException e) {
        // should not occur
        } catch (DavException e) {
        // should not occur
        }
    }
    return new DavResourceIteratorImpl(list);
}
Also used : NodeIterator(javax.jcr.NodeIterator) DavResource(org.apache.jackrabbit.webdav.DavResource) JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) DavException(org.apache.jackrabbit.webdav.DavException) DavResourceIteratorImpl(org.apache.jackrabbit.webdav.DavResourceIteratorImpl) Node(javax.jcr.Node) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 5 with DavResourceIteratorImpl

use of org.apache.jackrabbit.webdav.DavResourceIteratorImpl in project jackrabbit by apache.

the class WorkspaceResourceImpl method getMembers.

/**
     * Returns the resource representing the JCR root node.
     *
     * @return
     */
@Override
public DavResourceIterator getMembers() {
    try {
        DavResourceLocator loc = getLocatorFromItem(getRepositorySession().getRootNode());
        List<DavResource> list = Collections.singletonList(createResourceFromLocator(loc));
        return new DavResourceIteratorImpl(list);
    } catch (DavException e) {
        log.error("Internal error while building resource for the root node.", e);
        return DavResourceIteratorImpl.EMPTY;
    } catch (RepositoryException e) {
        log.error("Internal error while building resource for the root node.", e);
        return DavResourceIteratorImpl.EMPTY;
    }
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) DavResourceIteratorImpl(org.apache.jackrabbit.webdav.DavResourceIteratorImpl) RepositoryException(javax.jcr.RepositoryException) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Aggregations

RepositoryException (javax.jcr.RepositoryException)5 DavException (org.apache.jackrabbit.webdav.DavException)5 DavResource (org.apache.jackrabbit.webdav.DavResource)5 DavResourceIteratorImpl (org.apache.jackrabbit.webdav.DavResourceIteratorImpl)5 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)5 ArrayList (java.util.ArrayList)4 Node (javax.jcr.Node)2 NodeIterator (javax.jcr.NodeIterator)2 JcrDavException (org.apache.jackrabbit.webdav.jcr.JcrDavException)2 Property (javax.jcr.Property)1 PropertyIterator (javax.jcr.PropertyIterator)1 Version (javax.jcr.version.Version)1 VersionHistory (javax.jcr.version.VersionHistory)1 VersionIterator (javax.jcr.version.VersionIterator)1 NodeTypeProperty (org.apache.jackrabbit.webdav.jcr.nodetype.NodeTypeProperty)1 ValuesProperty (org.apache.jackrabbit.webdav.jcr.property.ValuesProperty)1 JcrSupportedPrivilegesProperty (org.apache.jackrabbit.webdav.jcr.security.JcrSupportedPrivilegesProperty)1 JcrUserPrivilegesProperty (org.apache.jackrabbit.webdav.jcr.security.JcrUserPrivilegesProperty)1 DavProperty (org.apache.jackrabbit.webdav.property.DavProperty)1 DefaultDavProperty (org.apache.jackrabbit.webdav.property.DefaultDavProperty)1