Search in sources :

Example 16 with DavResource

use of org.apache.jackrabbit.webdav.DavResource 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 17 with DavResource

use of org.apache.jackrabbit.webdav.DavResource 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 18 with DavResource

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

the class DavResourceImpl method getCollection.

/**
     * @see DavResource#getCollection()
     */
public DavResource getCollection() {
    DavResource parent = null;
    if (getResourcePath() != null && !getResourcePath().equals("/")) {
        String parentPath = Text.getRelativeParent(getResourcePath(), 1);
        if (parentPath.equals("")) {
            parentPath = "/";
        }
        DavResourceLocator parentloc = locator.getFactory().createResourceLocator(locator.getPrefix(), locator.getWorkspacePath(), parentPath);
        try {
            parent = factory.createResource(parentloc, session);
        } catch (DavException e) {
        // should not occur
        }
    }
    return parent;
}
Also used : DavResource(org.apache.jackrabbit.webdav.DavResource) JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) DavException(org.apache.jackrabbit.webdav.DavException) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 19 with DavResource

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

the class VersionControlledResourceImpl method getVersionHistory.

/**
     * Returns the {@link javax.jcr.version.VersionHistory} associated with the repository node.
     * If the node is not versionable an exception is thrown.
     *
     * @return the {@link VersionHistoryResource} associated with this resource.
     * @throws org.apache.jackrabbit.webdav.DavException
     * @see org.apache.jackrabbit.webdav.version.VersionControlledResource#getVersionHistory()
     * @see javax.jcr.Node#getVersionHistory()
     */
public VersionHistoryResource getVersionHistory() throws DavException {
    if (!exists()) {
        throw new DavException(DavServletResponse.SC_NOT_FOUND);
    }
    if (!isVersionControlled()) {
        throw new DavException(DavServletResponse.SC_FORBIDDEN);
    }
    try {
        VersionHistory vh = getNode().getVersionHistory();
        DavResourceLocator loc = getLocatorFromNode(vh);
        DavResource vhr = createResourceFromLocator(loc);
        if (vhr instanceof VersionHistoryResource) {
            return (VersionHistoryResource) vhr;
        } else {
            // severe error since resource factory doesn't behave correctly.
            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    } catch (RepositoryException e) {
        throw new JcrDavException(e);
    }
}
Also used : JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) VersionHistoryResource(org.apache.jackrabbit.webdav.version.VersionHistoryResource) RepositoryException(javax.jcr.RepositoryException) VersionHistory(javax.jcr.version.VersionHistory) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Example 20 with DavResource

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

the class VersionResourceImpl method getVersionHistory.

/**
     * Returns the {@link VersionHistory} associated with the repository version.
     * Note: in contrast to a versionable node, the version history of a version
     * item is always represented by its nearest ancestor.
     *
     * @return the {@link org.apache.jackrabbit.webdav.version.VersionHistoryResource} associated with this resource.
     * @throws org.apache.jackrabbit.webdav.DavException
     * @see org.apache.jackrabbit.webdav.version.VersionResource#getVersionHistory()
     * @see javax.jcr.Item#getParent()
     */
public VersionHistoryResource getVersionHistory() throws DavException {
    if (!exists()) {
        throw new DavException(DavServletResponse.SC_NOT_FOUND);
    }
    try {
        VersionHistory vh = getVersionHistoryItem();
        DavResourceLocator loc = getLocatorFromNode(vh);
        DavResource vhr = createResourceFromLocator(loc);
        if (vhr instanceof VersionHistoryResource) {
            return (VersionHistoryResource) vhr;
        } else {
            // severe error since resource factory doesn't behave correctly.
            throw new DavException(DavServletResponse.SC_INTERNAL_SERVER_ERROR);
        }
    } catch (RepositoryException e) {
        throw new JcrDavException(e);
    }
}
Also used : JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) DavResource(org.apache.jackrabbit.webdav.DavResource) DavException(org.apache.jackrabbit.webdav.DavException) JcrDavException(org.apache.jackrabbit.webdav.jcr.JcrDavException) VersionHistoryResource(org.apache.jackrabbit.webdav.version.VersionHistoryResource) RepositoryException(javax.jcr.RepositoryException) VersionHistory(javax.jcr.version.VersionHistory) DavResourceLocator(org.apache.jackrabbit.webdav.DavResourceLocator)

Aggregations

DavResource (org.apache.jackrabbit.webdav.DavResource)40 DavException (org.apache.jackrabbit.webdav.DavException)21 DavResourceLocator (org.apache.jackrabbit.webdav.DavResourceLocator)19 RepositoryException (javax.jcr.RepositoryException)16 JcrDavException (org.apache.jackrabbit.webdav.jcr.JcrDavException)7 ArrayList (java.util.ArrayList)6 Node (javax.jcr.Node)6 VersionHistory (javax.jcr.version.VersionHistory)6 DavResourceIteratorImpl (org.apache.jackrabbit.webdav.DavResourceIteratorImpl)5 Version (javax.jcr.version.Version)4 DavResourceIterator (org.apache.jackrabbit.webdav.DavResourceIterator)4 OutputStreamWriter (java.io.OutputStreamWriter)3 PrintWriter (java.io.PrintWriter)3 Item (javax.jcr.Item)3 NodeIterator (javax.jcr.NodeIterator)3 Repository (javax.jcr.Repository)3 HrefProperty (org.apache.jackrabbit.webdav.property.HrefProperty)3 Session (javax.jcr.Session)2 VersionIterator (javax.jcr.version.VersionIterator)2 MultiStatus (org.apache.jackrabbit.webdav.MultiStatus)2