Search in sources :

Example 6 with SerializationKind

use of org.apache.sling.ide.serialization.SerializationKind in project sling by apache.

the class ResourceChangeCommandFactory method buildResourceProxyForPlainFileOrFolder.

private ResourceProxy buildResourceProxyForPlainFileOrFolder(IResource changedResource, IFolder syncDirectory, Repository repository) throws CoreException, IOException {
    SerializationKind serializationKind;
    String fallbackNodeType;
    if (changedResource.getType() == IResource.FILE) {
        serializationKind = SerializationKind.FILE;
        fallbackNodeType = Repository.NT_FILE;
    } else {
        // i.e. IResource.FOLDER
        serializationKind = SerializationKind.FOLDER;
        fallbackNodeType = Repository.NT_FOLDER;
    }
    String resourceLocation = '/' + changedResource.getFullPath().makeRelativeTo(syncDirectory.getFullPath()).toPortableString();
    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;
        }
    }
    return buildResourceProxy(resourceLocation, serializationResource, syncDirectory, fallbackNodeType, repository);
}
Also used : IPath(org.eclipse.core.runtime.IPath) SerializationKind(org.apache.sling.ide.serialization.SerializationKind) IResource(org.eclipse.core.resources.IResource) ResourceProxy(org.apache.sling.ide.transport.ResourceProxy)

Aggregations

SerializationKind (org.apache.sling.ide.serialization.SerializationKind)6 CoreException (org.eclipse.core.runtime.CoreException)3 Aggregate (org.apache.jackrabbit.vault.fs.api.Aggregate)2 RepositoryException (org.apache.sling.ide.transport.RepositoryException)2 ResourceProxy (org.apache.sling.ide.transport.ResourceProxy)2 IFolder (org.eclipse.core.resources.IFolder)2 IResource (org.eclipse.core.resources.IResource)2 IPath (org.eclipse.core.runtime.IPath)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Attribute (de.pdark.decentxml.Attribute)1 Element (de.pdark.decentxml.Element)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 RepositoryException (javax.jcr.RepositoryException)1 DocViewSerializer (org.apache.jackrabbit.vault.fs.impl.io.DocViewSerializer)1