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());
}
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;
}
Aggregations