Package org.apache.sling.ide.transport

Examples of org.apache.sling.ide.transport.ResourceProxy


        assertThat(serializationData, is(nullValue()));
    }

    private ResourceProxy newResourceWithProperties(Map<String, Object> properties) {
        ResourceProxy resource = new ResourceProxy("/");
        for (Map.Entry<String, Object> entry : properties.entrySet()) {
            resource.addProperty(entry.getKey(), entry.getValue());
        }
        return resource;
    }
View Full Code Here


            path = parent.getPath() + name;
        } else {
            path = parent.getPath() + "/" + name;
        }

        ResourceProxy resourceProxy = new ResourceProxy(path);
        // set defaults
        resourceProxy.addProperty("jcr:nodeTypeName", name);
        resourceProxy.addProperty("jcr:primaryType", "nt:nodeType");
        resourceProxy.addProperty("jcr:isMixin", false);
        resourceProxy.addProperty("jcr:mixinTypes", new String[] {});
        return new NodeTypeResourceBuilder(resourceProxy);
    }
View Full Code Here

    @Override
    protected ResourceProxy execute0(Session session) throws RepositoryException {

        Node node = session.getNode(getPath());

        ResourceProxy parent = nodeToResource(node);

        addChildren(parent, node, levels-1);
       
        return parent;
    }
View Full Code Here

            // TODO - this should not be needed if we obey the vlt filters
            if (childNode.getPath().equals("/jcr:system")) {
                continue;
            }

            final ResourceProxy childResourceProxy = nodeToResource(childNode);
            parent.addChild(childResourceProxy);
           
            if (remainingLevels>0) {
                addChildren(childResourceProxy, childNode, remainingLevels-1);
            }
View Full Code Here

        //TODO change responseAsString with something like
        //return EncodingUtil.getString(rawdata, m.getResponseCharSet());
            if (!isSuccessStatus(responseStatus))
                return failureResultForStatusCode(responseStatus);

            ResourceProxy resource = new ResourceProxy(path);

            JSONObject json = new JSONObject(get.getResponseBodyAsString());
            String primaryType = json.optString(Repository.JCR_PRIMARY_TYPE);
            if (primaryType != null) { // TODO - needed?
                resource.addProperty(Repository.JCR_PRIMARY_TYPE, primaryType);
            }

            // TODO - populate all properties

            for (Iterator<?> keyIterator = json.keys(); keyIterator.hasNext();) {

                String key = (String) keyIterator.next();
                JSONObject value = json.optJSONObject(key);
                if (value != null) {
                    ResourceProxy child = new ResourceProxy(PathUtil.join(path, key));
                    child.addProperty(Repository.JCR_PRIMARY_TYPE, value.optString(Repository.JCR_PRIMARY_TYPE));
                    resource.addChild(child);
                }
            }
       
            return AbstractResult.success(resource);
View Full Code Here

            SerializationDataHandler h = new SerializationDataHandler();

            saxParser.parse(new InputSource(source), h);

            return new ResourceProxy(filePath, h.getResult());
        } catch (ParserConfigurationException e) {
            // TODO proper exception handling
            throw new RuntimeException(e);
        } catch (SAXException e) {
            // TODO proper exception handling
View Full Code Here

            return;
        }

        while (childrenIterator.hasNext() || nodeChildrenListIt.hasNext()) {

            ResourceProxy childResource = childrenIterator.next();
            Node childNode = nodeChildrenListIt.next();

            // order is as expected, skip reordering
            if (Text.getName(childResource.getPath()).equals(childNode.getName())) {
                // descend into covered child resources once they are properly arranged and perform reordering
                if (resourceToReorder.covers(childResource.getPath())) {
                    reorderChildNodes(childNode, childResource);
                }
                continue;
            }

            // don't perform any reordering if this particular node does not have reorderable children
            if (!nodeToReorder.getPrimaryNodeType().hasOrderableChildNodes()) {
                getLogger().trace("Node at {0} does not have orderable child nodes, skipping reordering of {1}",
                        nodeToReorder.getPath(), childResource.getPath());
                continue;
            }

            String expectedParentName;
            if (childrenIterator.hasNext()) {
                expectedParentName = Text.getName(childrenIterator.next().getPath());
                childrenIterator.previous(); // move back
            } else {
                expectedParentName = null;
            }

            getLogger().trace("For node at {0} ordering {1} before {2}", nodeToReorder.getPath(),
                    Text.getName(childResource.getPath()), expectedParentName);

            nodeToReorder.orderBefore(Text.getName(childResource.getPath()), expectedParentName);
        }
    }
View Full Code Here

            if (!isSuccessStatus(responseStatus))
                return failureResultForStatusCode(responseStatus);

            JSONObject result = new JSONObject(get.getResponseBodyAsString());

            ResourceProxy resource = new ResourceProxy(path);
            JSONArray names = result.names();
            for (int i = 0; i < names.length(); i++) {
                String name = names.getString(i);
                Object object = result.get(name);
                if (object instanceof String) {
                    resource.addProperty(name, object);
                } else {
                    System.out.println("Property '" + name + "' of type '" + object.getClass().getName()
                            + " is not handled");
                }
            }
View Full Code Here

        return logger;
    }

    protected ResourceProxy nodeToResource(Node node) throws RepositoryException {
   
        ResourceProxy resource = new ResourceProxy(node.getPath());
        resource.addAdapted(Node.class, node);

        PropertyIterator properties = node.getProperties();
        while (properties.hasNext()) {
            Property property = properties.nextProperty();
            String propertyName = property.getName();
            Object propertyValue = ConversionUtils.getPropertyValue(property);
   
            if (propertyValue != null) {
                resource.addProperty(propertyName, propertyValue);
            }
        }
   
        return resource;
   
View Full Code Here

        }

        // phase 3: init property definitions
        for (Iterator<VltNodeType> it = nodeTypes.values().iterator(); it.hasNext();) {
            VltNodeType nt = it.next();
            final ResourceProxy child = nt.getResourceProxy();
            initPropertyDefinitions(nt);
            initProperties(nt, child);
        }
       
        // phase 4: initialize the allowed primary childnodetypes
View Full Code Here

TOP

Related Classes of org.apache.sling.ide.transport.ResourceProxy

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.