Package org.modeshape.web.jcr.rest.model

Examples of org.modeshape.web.jcr.rest.model.RestNode


        String parentUrl = isRoot ? RestHelper.urlFrom(baseUrl, ITEMS_METHOD_NAME, "..", "..") : RestHelper.urlFrom(baseUrl,
                                                                                                                    ITEMS_METHOD_NAME,
                                                                                                                    encodedPath(
                                                                                                                            node.getParent()
                                                                                                                                    .getPath()));
        RestNode restNode = new RestNode(nodeName(node), node.getIdentifier(), nodeUrl, parentUrl);

        // add the properties
        for (PropertyIterator propertyIterator = node.getProperties(); propertyIterator.hasNext();) {
            Property property = propertyIterator.nextProperty();
            restNode.addJcrProperty(createRestProperty(session, property, baseUrl));
        }

        // add the children
        for (NodeIterator nodeIterator = node.getNodes(); nodeIterator.hasNext();) {
            Node childNode = nodeIterator.nextNode();
            RestNode restChild = null;
            if (depth > 0) {
                restChild = createRestNode(session, childNode, baseUrl, depth - 1);
            } else if (depth < 0) {
                restChild = createRestNode(session, childNode, baseUrl, -1);
            } else {
                String childUrl = RestHelper.urlFrom(baseUrl, ITEMS_METHOD_NAME, encodedPath(childNode.getPath()));
                restChild = new RestNode(nodeName(childNode), childNode.getIdentifier(), childUrl, nodeUrl);
            }
            restNode.addChild(restChild);
        }
        return restNode;
    }
View Full Code Here

TOP

Related Classes of org.modeshape.web.jcr.rest.model.RestNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.