// monitor = ProgressUtil.getMonitorFor(monitor); //TODO
String mainTaskMsg = "Publishing to "+getServer().getName();//NLS.bind(Messages.publishing, 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");
publishStart(monitor);//ProgressUtil.getSubMonitorFor(monitor, 1000)); //TODO
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
publishServer(kind, monitor);//ProgressUtil.getSubMonitorFor(monitor, 1000));//TODO
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 {
publishFinish(monitor);//ProgressUtil.getSubMonitorFor(monitor, 500));
} 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;
}