Package org.apache.sling.ide.transport

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


    private void crawlChildrenAndImport(String path)
            throws RepositoryException, CoreException, IOException, SerializationException {

        logger.trace("crawlChildrenAndImport({0},  {1}, {2}, {3}", repository, path, project, projectRelativePath);

        ResourceProxy resource = executeCommand(repository.newListChildrenNodeCommand(path));
       
        SerializationData serializationData = builder.buildSerializationData(contentSyncRoot, resource);
        logger.trace("For resource at path {0} got serialization data {1}", resource.getPath(), serializationData);

        final List<ResourceProxy> resourceChildren = new LinkedList<ResourceProxy>(resource.getChildren());
    if (serializationData != null) {

            IPath serializationFolderPath = contentSyncRootDir.getProjectRelativePath().append(
                    serializationData.getFolderPath());
 
          switch (serializationData.getSerializationKind()) {
              case FILE: {
                  byte[] contents = executeCommand(repository.newGetNodeCommand(path));
                    createFile(project, getPathForPlainFileNode(resource, serializationFolderPath), contents);
 
                  if (serializationData.hasContents()) {
                        createFolder(project, serializationFolderPath);
                        createFile(project, serializationFolderPath.append(serializationData.getFileName()),
                              serializationData.getContents());
                     
                        // special processing for nt:resource nodes
                        for (Iterator<ResourceProxy> it = resourceChildren.iterator(); it.hasNext();) {
                        ResourceProxy child = it.next();
                          if (Repository.NT_RESOURCE.equals(child.getProperties().get(Repository.JCR_PRIMARY_TYPE))) {

                                ResourceProxy reloadedChildResource = executeCommand(repository
                                        .newListChildrenNodeCommand(child.getPath()));

                                logger.trace(
                                        "Skipping direct handling of {0} node at {1} ; will additionally handle {2} direct children",
                                        Repository.NT_RESOURCE, child.getPath(), reloadedChildResource.getChildren()
                                                .size());

                                if (reloadedChildResource.getChildren().size() != 0) {

                                    String pathName = Text.getName(reloadedChildResource.getPath());
                                    pathName = serializationManager.getOsPath(pathName);
                                    createFolder(project, serializationFolderPath.append(pathName));

                                    // 2. recursively handle all resources
                                    for (ResourceProxy grandChild : reloadedChildResource.getChildren()) {
                                        crawlChildrenAndImport(grandChild.getPath());
                                    }
                                }
                             
                            it.remove();
View Full Code Here


        File syncDirectoryAsFile = ProjectUtil.getSyncDirectoryFullPath(resource.getProject()).toFile();
        IFolder syncDirectory = ProjectUtil.getSyncDirectory(resource.getProject());

        Filter filter = ProjectUtil.loadFilter(resource.getProject());

        ResourceProxy resourceProxy = null;

        if (serializationManager.isSerializationFile(resource.getLocation().toOSString())) {
            InputStream contents = null;
            try {
                IFile file = (IFile) resource;
                contents = file.getContents();
                String resourceLocation = file.getFullPath().makeRelativeTo(syncDirectory.getFullPath())
                        .toPortableString();
                resourceProxy = serializationManager.readSerializationData(resourceLocation, contents);
                normaliseResourceChildren(file, resourceProxy, syncDirectory, repository);


                // TODO - not sure if this 100% correct, but we definitely should not refer to the FileInfo as the
                // .serialization file, since for nt:file/nt:resource nodes this will overwrite the file contents
                String primaryType = (String) resourceProxy.getProperties().get(Repository.JCR_PRIMARY_TYPE);
                if (Repository.NT_FILE.equals(primaryType)) {
                    // TODO move logic to serializationManager
                    File locationFile = new File(info.getLocation());
                    String locationFileParent = locationFile.getParent();
                    int endIndex = locationFileParent.length() - ".dir".length();
View Full Code Here

        IPath serializationFilePath = Path.fromOSString(serializationManager.getSerializationFilePath(
                resourceLocation, serializationKind));
        IResource serializationResource = syncDirectory.findMember(serializationFilePath);

        if (serializationResource == null && changedResource.getType() == IResource.FOLDER) {
            ResourceProxy dataFromCoveringParent = findSerializationDataFromCoveringParent(changedResource,
                    syncDirectory, resourceLocation, serializationFilePath);

            if (dataFromCoveringParent != null) {
                return dataFromCoveringParent;
            }
View Full Code Here

                            possibleSerializationFile.getFullPath());
                    continue;
                }

                InputStream contents = possibleSerializationFile.getContents();
                ResourceProxy serializationData;
                try {
                    serializationData = serializationManager.readSerializationData(
                            parentSerializationFilePath.toPortableString(), contents);
                } finally {
                    IOUtils.closeQuietly(contents);
                }

                String repositoryPath = serializationManager.getRepositoryPath(resourceLocation);
                String potentialPath = serializationData.getPath();
                boolean covered = serializationData.covers(repositoryPath);

                logger.trace(
                        "Found possible serialization data at {0}. Resource :{1} ; our resource: {2}. Covered: {3}",
                        parentSerializationFilePath, potentialPath, repositoryPath, covered);
                // note what we don't need to normalize the children here since this resource's data is covered by
                // another resource
                if (covered) {
                    return serializationData.getChild(repositoryPath);
                }

                break;
            }
        }
View Full Code Here

            InputStream contents = null;
            try {
                contents = serializationFile.getContents();
                String serializationFilePath = serializationResource.getFullPath()
                        .makeRelativeTo(syncDirectory.getFullPath()).toPortableString();
                ResourceProxy resourceProxy = serializationManager.readSerializationData(serializationFilePath, contents);
                normaliseResourceChildren(serializationFile, resourceProxy, syncDirectory, repository);

                return resourceProxy;
            } finally {
                IOUtils.closeQuietly(contents);
            }
        }

        return new ResourceProxy(serializationManager.getRepositoryPath(resourceLocation), Collections.singletonMap(
                Repository.JCR_PRIMARY_TYPE, (Object) fallbackPrimaryType));
    }
View Full Code Here

            }
            extraChildResources.put(member.getName(), member);
        }

        while (childIterator.hasNext()) {
            ResourceProxy child = childIterator.next();
            String childName = PathUtil.getName(child.getPath());
            String osPath = serializationManager.getOsPath(childName);

            // covered children might have a FS representation, depending on their child nodes, so
            // accept a directory which maps to their name
            extraChildResources.remove(osPath);

            // covered children do not need a filesystem representation
            if (resourceProxy.covers(child.getPath())) {
                continue;
            }

            IPath childPath = serializationDirectoryPath.append(osPath);

            IResource childResource = ResourcesPlugin.getWorkspace().getRoot().findMember(childPath);
            if (childResource == null) {

                Activator.getDefault().getPluginLogger()
                        .trace("For resource at with serialization data {0} the serialized child resource at {1} does not exist in the filesystem and will be ignored",
                                serializationFile, childPath);
                childIterator.remove();
            }
        }

        for ( IResource extraChildResource : extraChildResources.values()) {
            IPath extraChildResourcePath = extraChildResource.getFullPath()
                    .makeRelativeTo(syncDirectory.getFullPath()).makeAbsolute();
            resourceProxy.addChild(new ResourceProxy(serializationManager
                    .getRepositoryPath(extraChildResourcePath.toPortableString())));
           
            Activator.getDefault().getPluginLogger()
                .trace("For resource at with serialization data {0} the found a child resource at {1} which is not listed in the serialized child resources and will be added",
                            serializationFile, extraChildResource);
View Full Code Here

        // was rearranged under a covering parent aggregate
        if (resource.getType() == IResource.FOLDER) {
            IPath serializationFilePath = Path.fromOSString(serializationManager.getSerializationFilePath(
                    resourceLocation, SerializationKind.FOLDER));

            ResourceProxy coveringParentData = findSerializationDataFromCoveringParent(resource, syncDirectory,
                    resourceLocation, serializationFilePath);
            if (coveringParentData != null) {
                Activator
                        .getDefault()
                        .getPluginLogger()
View Full Code Here

        InputStream contents = null;
        try{
            contents = file.getContents();
            String resourceLocation = file.getFullPath().makeRelativeTo(contentSyncRoot.getFullPath())
                    .toPortableString();
            ResourceProxy resourceProxy = Activator.getDefault()
                    .getSerializationManager().readSerializationData(resourceLocation, contents);
           
            // resourceProxy could be containing a full tree
            // dive into the right position
            String rawValue = properties.getValue(propertyName);
View Full Code Here

            }
        } else {
            List<ResourceProxy> resourceProxyChildren = resourceProxy.getChildren();
            for (Iterator<ResourceProxy> it = resourceProxyChildren.iterator(); it
                    .hasNext();) {
                final ResourceProxy aChild = it.next();
                final Object p1 = doGetProperty(aChild, propertyName);
                if (p1!=null) {
                    return p1;
                }
            }
View Full Code Here

                content.addNode(nodeName);
            }

            session.save();

            ResourceProxy resource = newResource("/content", "nt:unstructured");

            for (String resourceName : resourceNames) {
                resource.addChild(newResource("/content/" + resourceName, "nt:unstructured"));
            }

            ReorderChildNodesCommand cmd = new ReorderChildNodesCommand(repo, credentials, resource, logger);
            cmd.execute().get();
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.