use of org.apache.sling.ide.eclipse.core.internal.ResourceChangeCommandFactory in project sling by apache.
the class ExportWizard method performFinish.
@Override
public boolean performFinish() {
try {
getContainer().run(true, false, new IRunnableWithProgress() {
@Override
public void run(final IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
final ResourceChangeCommandFactory factory = new ResourceChangeCommandFactory(Activator.getDefault().getSerializationManager(), Activator.getDefault().getPreferences().getIgnoredFileNamesForSync());
final Repository[] selectedServer = new Repository[1];
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
try {
selectedServer[0] = ServerUtil.getConnectedRepository(exportPage.getServer(), monitor);
} catch (CoreException e) {
throw new RuntimeException(e);
}
}
});
try {
syncStartPoint.accept(new IResourceVisitor() {
@Override
public boolean visit(IResource resource) throws CoreException {
Command<?> command = factory.newCommandForAddedOrUpdated(selectedServer[0], resource);
if (command == null) {
return true;
}
Result<?> result = command.execute();
if (!result.isSuccess()) {
throw new CoreException(new Status(Status.ERROR, Activator.PLUGIN_ID, "Failed exporting: " + result.toString()));
}
return true;
}
});
} catch (CoreException e) {
throw new InvocationTargetException(e);
} catch (Throwable t) {
t.printStackTrace();
throw new InvocationTargetException(t);
}
}
});
return true;
} catch (RuntimeException | InterruptedException e) {
exportPage.setErrorMessage(e.getMessage());
return false;
} catch (InvocationTargetException e) {
exportPage.setErrorMessage(e.getCause().getMessage());
return false;
}
}
use of org.apache.sling.ide.eclipse.core.internal.ResourceChangeCommandFactory in project sling by apache.
the class ResourceChangeCommandFactoryTest method setUp.
@Before
public void setUp() throws Exception {
// create faceted project
contentProject = projectRule.getProject();
project = new ProjectAdapter(contentProject);
project.addNatures("org.eclipse.wst.common.project.facet.core.nature");
// install content facet
project.installFacet("sling.content", "1.0");
// create filter.xml
project.createVltFilterWithRoots("/content");
Set<String> ignoredFileNames = new HashSet<>();
ignoredFileNames.add(".gitignore");
factory = new ResourceChangeCommandFactory(Activator.getDefault().getSerializationManager(), ignoredFileNames);
spyRepo = new SpyRepository();
}
use of org.apache.sling.ide.eclipse.core.internal.ResourceChangeCommandFactory 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());
}
Aggregations