Search in sources :

Example 1 with ResourceAndInfo

use of org.apache.sling.ide.eclipse.core.internal.ResourceAndInfo 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)

Aggregations

IOException (java.io.IOException)1 ResourceAndInfo (org.apache.sling.ide.eclipse.core.internal.ResourceAndInfo)1 ResourceChangeCommandFactory (org.apache.sling.ide.eclipse.core.internal.ResourceChangeCommandFactory)1 FilterResult (org.apache.sling.ide.filter.FilterResult)1 IResource (org.eclipse.core.resources.IResource)1 IResourceVisitor (org.eclipse.core.resources.IResourceVisitor)1 CoreException (org.eclipse.core.runtime.CoreException)1 IStatus (org.eclipse.core.runtime.IStatus)1 Status (org.eclipse.core.runtime.Status)1