use of org.eclipse.wst.server.core.model.PublishOperation in project sling by apache.
the class ServerBehaviourDelegateWithModulePublishSupport method publish.
// from WST's ServerBehavior
public IStatus publish(int kind, IProgressMonitor monitor) {
Activator.getDefault().getPluginLogger().trace("-->-- Publishing to server: " + getServer().toString() + " -->--");
if (getServer().getServerType().hasRuntime() && getServer().getRuntime() == null)
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "No runtime available", null);
//getAllModules();
final List<IModule[]> moduleList = modules3 == null ? getAllModules() : new LinkedList<>(modules3);
List<Integer> deltaKindList = computeDelta(moduleList);
PublishOperation[] tasks = getTasks(kind, moduleList, deltaKindList);
int size = 2000 + 3500 * moduleList.size() + 500 * tasks.length;
// monitor = ProgressUtil.getMonitorFor(monitor); //TODO
//NLS.bind(Messages.publishing, getServer().getName());
String mainTaskMsg = "Publishing to " + getServer().getName();
monitor.beginTask(mainTaskMsg, size);
MultiStatus tempMulti = new MultiStatus(Activator.PLUGIN_ID, 0, "", null);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
try {
Activator.getDefault().getPluginLogger().trace("Starting publish");
//ProgressUtil.getSubMonitorFor(monitor, 1000)); //TODO
publishStart(monitor);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// execute tasks
MultiStatus taskStatus = performTasks(tasks, monitor);
monitor.setTaskName(mainTaskMsg);
if (taskStatus != null && !taskStatus.isOK())
tempMulti.addAll(taskStatus);
// execute publishers
taskStatus = executePublishers(kind, moduleList, deltaKindList, monitor, info3);
monitor.setTaskName(mainTaskMsg);
if (taskStatus != null && !taskStatus.isOK())
tempMulti.addAll(taskStatus);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// publish the server
//ProgressUtil.getSubMonitorFor(monitor, 1000));//TODO
publishServer(kind, monitor);
monitor.setTaskName(mainTaskMsg);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
// publish modules
publishModules(kind, moduleList, deltaKindList, tempMulti, monitor);
if (monitor.isCanceled())
return Status.CANCEL_STATUS;
monitor.done();
} catch (CoreException ce) {
Activator.getDefault().getPluginLogger().error("CoreException publishing to " + toString(), ce);
return ce.getStatus();
} catch (Exception e) {
Activator.getDefault().getPluginLogger().error("Error publishing to " + toString(), e);
tempMulti.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Error publishing", e));
} finally {
// end the publishing
try {
//ProgressUtil.getSubMonitorFor(monitor, 500));
publishFinish(monitor);
} catch (CoreException ce) {
Activator.getDefault().getPluginLogger().error("CoreException publishing to " + toString(), ce);
tempMulti.add(ce.getStatus());
} catch (Exception e) {
Activator.getDefault().getPluginLogger().error("Error stopping publish to " + toString(), e);
tempMulti.add(new Status(IStatus.ERROR, Activator.PLUGIN_ID, 0, "Error publishing", e));
}
}
Activator.getDefault().getPluginLogger().trace("--<-- Done publishing --<--");
if (tempMulti.getChildren().length == 1)
return tempMulti.getChildren()[0];
MultiStatus multi = null;
if (tempMulti.getSeverity() == IStatus.OK)
return Status.OK_STATUS;
else if (tempMulti.getSeverity() == IStatus.INFO)
multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing completed with information", null);
else if (tempMulti.getSeverity() == IStatus.WARNING)
multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing completed with a warning", null);
else if (tempMulti.getSeverity() == IStatus.ERROR)
multi = new MultiStatus(Activator.PLUGIN_ID, 0, "Publishing failed", null);
if (multi != null)
multi.addAll(tempMulti);
return multi;
}
Aggregations