use of org.apache.sling.ide.serialization.SerializationException in project sling by apache.
the class ImportWizard method performFinish.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.wizard.Wizard#performFinish()
*/
public boolean performFinish() {
if (!mainPage.isPageComplete()) {
return false;
}
final IServer server = mainPage.getServer();
IResource resource = mainPage.getResource();
final IProject project = resource.getProject();
final IPath projectRelativePath = resource.getProjectRelativePath();
try {
getContainer().run(true, true, new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
// following this change ( see org.apache.sling.ide.core.ResourceUtil )
try {
ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
try {
new ImportRepositoryContentAction(server, projectRelativePath, project, serializationManager).run(monitor);
} catch (SerializationException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed", e));
} catch (InvocationTargetException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Import failed", e.getCause()));
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} finally {
serializationManager.destroy();
}
}
}, project, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
});
} catch (InvocationTargetException e) {
Throwable cause = e.getCause();
mainPage.setErrorMessage("Import error : " + cause.getMessage() + " . Please see the error log for details.");
Activator.getDefault().getPluginLogger().error("Repository import failed", cause);
return false;
} catch (OperationCanceledException | InterruptedException e) {
Thread.currentThread().interrupt();
return false;
}
return true;
}
use of org.apache.sling.ide.serialization.SerializationException in project sling by apache.
the class VltSerializationDataBuilder method buildSerializationData.
@Override
public SerializationData buildSerializationData(File contentSyncRoot, ResourceProxy resource) throws SerializationException {
try {
List<Aggregate> chain = findAggregateChain(resource);
if (chain == null) {
return null;
}
Aggregate aggregate = chain.get(chain.size() - 1);
String fileOrFolderPathHint = calculateFileOrFolderPathHint(chain);
String nameHint = PlatformNameFormat.getPlatformName(aggregate.getName());
SerializationKind serializationKind = getSerializationKind(aggregate);
if (resource.getPath().equals("/") || serializationKind == SerializationKind.METADATA_PARTIAL || serializationKind == SerializationKind.FILE || serializationKind == SerializationKind.FOLDER) {
nameHint = Constants.DOT_CONTENT_XML;
} else if (serializationKind == SerializationKind.METADATA_FULL) {
nameHint += ".xml";
}
Activator.getDefault().getPluginLogger().trace("Got location {0} for path {1}", fileOrFolderPathHint, resource.getPath());
if (!needsDir(aggregate)) {
return SerializationData.empty(fileOrFolderPathHint, serializationKind);
}
DocViewSerializer s = new DocViewSerializer(aggregate);
ByteArrayOutputStream out = new ByteArrayOutputStream();
s.writeContent(out);
byte[] result = out.toByteArray();
return new SerializationData(fileOrFolderPathHint, nameHint, result, serializationKind);
} catch (RepositoryException e) {
throw new SerializationException(e);
} catch (IOException e) {
throw new SerializationException(e);
}
}
use of org.apache.sling.ide.serialization.SerializationException in project sling by apache.
the class VltSerializationDataBuilder method init.
public void init(org.apache.sling.ide.transport.Repository repository, File contentSyncRoot) throws SerializationException {
this.repo = repository;
try {
this.skm = new SerializationKindManager();
this.skm.init(repository);
if (!contentSyncRoot.exists()) {
throw new IllegalArgumentException("contentSyncRoot does not exist: " + contentSyncRoot);
}
Repository jcrRepo = RepositoryUtils.getRepository(repo.getRepositoryInfo());
Credentials credentials = RepositoryUtils.getCredentials(repo.getRepositoryInfo());
session = jcrRepo.login(credentials);
RepositoryAddress address = RepositoryUtils.getRepositoryAddress(repo.getRepositoryInfo());
fs = fsLocator.getFileSystem(address, contentSyncRoot, session);
} catch (org.apache.sling.ide.transport.RepositoryException e) {
throw new SerializationException(e);
} catch (RepositoryException e) {
throw new SerializationException(e);
} catch (IOException e) {
throw new SerializationException(e);
} catch (ConfigurationException e) {
throw new SerializationException(e);
}
}
use of org.apache.sling.ide.serialization.SerializationException in project sling by apache.
the class SlingLaunchpadBehaviour method publishModule.
@Override
protected void publishModule(int kind, int deltaKind, IModule[] module, IProgressMonitor monitor) throws CoreException {
Logger logger = Activator.getDefault().getPluginLogger();
if (commandFactory == null) {
commandFactory = new ResourceChangeCommandFactory(Activator.getDefault().getSerializationManager(), Activator.getDefault().getPreferences().getIgnoredFileNamesForSync());
}
logger.trace(traceOperation(kind, deltaKind, module));
if (getServer().getServerState() == IServer.STATE_STOPPED) {
logger.trace("Ignoring request to publish module when the server is stopped");
setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
return;
}
if ((kind == IServer.PUBLISH_AUTO || kind == IServer.PUBLISH_INCREMENTAL) && deltaKind == ServerBehaviourDelegate.NO_CHANGE) {
logger.trace("Ignoring request to publish the module when no resources have changed; most likely another module has changed");
setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
return;
}
if (kind == IServer.PUBLISH_FULL && deltaKind == ServerBehaviourDelegate.REMOVED) {
logger.trace("Ignoring request to unpublish all of the module resources");
setModulePublishState(module, IServer.PUBLISH_STATE_NONE);
return;
}
try {
if (ProjectHelper.isBundleProject(module[0].getProject())) {
String serverMode = getServer().getMode();
if (!serverMode.equals(ILaunchManager.DEBUG_MODE) || kind == IServer.PUBLISH_CLEAN) {
// in debug mode, we rely on the hotcode replacement feature of eclipse/jvm
// otherwise, for run and profile modes we explicitly publish the bundle module
// TODO: make this configurable as part of the server config
// SLING-3655 : when doing PUBLISH_CLEAN, the bundle deployment mechanism should
// still be triggered
publishBundleModule(module, monitor);
}
} else if (ProjectHelper.isContentProject(module[0].getProject())) {
try {
publishContentModule(kind, deltaKind, module, monitor);
} catch (SerializationException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Serialization error for " + traceOperation(kind, deltaKind, module).toString(), e));
} catch (IOException e) {
throw new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "IO error for " + traceOperation(kind, deltaKind, module).toString(), e));
}
}
} catch (CoreException e) {
// in case of errors always require full redeployment of the whole module
setModulePublishState(module, IServer.PUBLISH_STATE_FULL);
throw e;
}
}
use of org.apache.sling.ide.serialization.SerializationException in project sling by apache.
the class ImportRepositoryContentAction method run.
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException, SerializationException, CoreException {
// TODO: We should try to make this give 'nice' progress feedback (aka here's what I'm processing)
monitor.beginTask("Repository import", IProgressMonitor.UNKNOWN);
this.monitor = monitor;
repository = ServerUtil.getConnectedRepository(server, monitor);
this.builder = serializationManager.newBuilder(repository, ProjectUtil.getSyncDirectoryFile(project));
SerializationKindManager skm;
try {
skm = new SerializationKindManager();
skm.init(repository);
} catch (RepositoryException e1) {
throw new InvocationTargetException(e1);
}
filter = ProjectUtil.loadFilter(project);
ProgressUtils.advance(monitor, 1);
try {
contentSyncRootDir = ProjectUtil.getSyncDirectory(project);
repositoryImportRoot = projectRelativePath.makeRelativeTo(contentSyncRootDir.getProjectRelativePath()).makeAbsolute();
contentSyncRoot = ProjectUtil.getSyncDirectoryFullPath(project).toFile();
readVltIgnoresNotUnderImportRoot(contentSyncRootDir, repositoryImportRoot);
ProgressUtils.advance(monitor, 1);
Activator.getDefault().getPluginLogger().trace("Starting import; repository start point is {0}, workspace start point is {1}", repositoryImportRoot, projectRelativePath);
recordNotIgnoredResources();
ProgressUtils.advance(monitor, 1);
crawlChildrenAndImport(repositoryImportRoot.toPortableString());
removeNotIgnoredAndNotUpdatedResources(new NullProgressMonitor());
ProgressUtils.advance(monitor, 1);
} catch (OperationCanceledException e) {
throw e;
} catch (Exception e) {
throw new InvocationTargetException(e);
} finally {
if (builder != null) {
builder.destroy();
builder = null;
}
monitor.done();
}
}
Aggregations