Search in sources :

Example 6 with FilterResult

use of org.apache.sling.ide.filter.FilterResult in project sling by apache.

the class ImportRepositoryContentAction method recordNotIgnoredResources.

private void recordNotIgnoredResources() throws CoreException {
    final ResourceChangeCommandFactory rccf = new ResourceChangeCommandFactory(serializationManager, Activator.getDefault().getPreferences().getIgnoredFileNamesForSync());
    IResource importStartingPoint = contentSyncRootDir.findMember(repositoryImportRoot);
    if (importStartingPoint == null) {
        return;
    }
    importStartingPoint.accept(new IResourceVisitor() {

        @Override
        public boolean visit(IResource resource) throws CoreException {
            try {
                ResourceAndInfo rai = rccf.buildResourceAndInfo(resource, repository);
                if (rai == null) {
                    // can be a prerequisite
                    return true;
                }
                String repositoryPath = rai.getResource().getPath();
                FilterResult filterResult = filter.filter(repositoryPath);
                if (ignoredResources.isIgnored(repositoryPath)) {
                    return false;
                }
                if (filterResult == FilterResult.ALLOW) {
                    currentResources.add(resource);
                    return true;
                }
                return false;
            } catch (IOException e) {
                throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Failed reading current project's resources", e));
            }
        }
    });
    logger.trace("Found {0} not ignored local resources", currentResources.size());
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IResourceVisitor(org.eclipse.core.resources.IResourceVisitor) CoreException(org.eclipse.core.runtime.CoreException) ResourceAndInfo(org.apache.sling.ide.eclipse.core.internal.ResourceAndInfo) ResourceChangeCommandFactory(org.apache.sling.ide.eclipse.core.internal.ResourceChangeCommandFactory) FilterResult(org.apache.sling.ide.filter.FilterResult) IOException(java.io.IOException) IResource(org.eclipse.core.resources.IResource)

Example 7 with FilterResult

use of org.apache.sling.ide.filter.FilterResult in project sling by apache.

the class ResourceChangeCommandFactory method getFilterResult.

/**
     * Gets the filter result for a resource/resource proxy combination
     * 
     * <p>
     * The resourceProxy may be null, typically when a resource is already deleted.
     * 
     * <p>
     * In case the filter is {@code null} no resource should be added, i.e. {@link FilterResult#DENY} is returned
     * 
     * @param resource the resource to filter for, must not be <code>null</code>
     * @param resourceProxy the resource proxy to filter for, possibly <code>null</code>
     * @param filter the filter to use, possibly <tt>null</tt>
     * @return the filtering result, never <code>null</code>
     */
private FilterResult getFilterResult(IResource resource, ResourceProxy resourceProxy, Filter filter) {
    if (filter == null) {
        return FilterResult.DENY;
    }
    File contentSyncRoot = ProjectUtil.getSyncDirectoryFile(resource.getProject());
    String repositoryPath = resourceProxy != null ? resourceProxy.getPath() : getRepositoryPathForDeletedResource(resource, contentSyncRoot);
    FilterResult filterResult = filter.filter(repositoryPath);
    Activator.getDefault().getPluginLogger().trace("Filter result for {0} for {1}", repositoryPath, filterResult);
    return filterResult;
}
Also used : FilterResult(org.apache.sling.ide.filter.FilterResult) IFile(org.eclipse.core.resources.IFile) File(java.io.File)

Aggregations

FilterResult (org.apache.sling.ide.filter.FilterResult)7 Filter (org.apache.sling.ide.filter.Filter)4 ResourceProxy (org.apache.sling.ide.transport.ResourceProxy)4 IOException (java.io.IOException)3 IFolder (org.eclipse.core.resources.IFolder)3 File (java.io.File)2 CommandContext (org.apache.sling.ide.transport.CommandContext)2 FileInfo (org.apache.sling.ide.transport.FileInfo)2 IFile (org.eclipse.core.resources.IFile)2 IResource (org.eclipse.core.resources.IResource)2 CoreException (org.eclipse.core.runtime.CoreException)2 IPath (org.eclipse.core.runtime.IPath)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 InputStream (java.io.InputStream)1 Iterator (java.util.Iterator)1 LinkedList (java.util.LinkedList)1 Node (javax.jcr.Node)1 RepositoryException (javax.jcr.RepositoryException)1 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1