Permalink
Browse files

[263890] [regression] Run on Server does not run publish first, if se…

…rver is not yet started
  • Loading branch information...
1 parent 07527aa commit c907f2c7c5a4b3ddc2359b2e345617bd1ed955ad avera committed Feb 9, 2009
@@ -1644,12 +1644,11 @@ protected IStatus publishBeforeStart(IProgressMonitor monitor, boolean synchrono
byte pub = StartJob.PUBLISH_NONE;
if (ServerCore.isAutoPublishing() && shouldPublish()) {
if (((ServerType)getServerType()).startBeforePublish())
- pub = StartJob.PUBLISH_AFTER;
- else
return Status.OK_STATUS;
+ pub = StartJob.PUBLISH_BEFORE;
}
- final IStatus [] pubStatus = new IStatus[1];
+ final IStatus [] pubStatus = new IStatus[]{Status.OK_STATUS};
// publish before start
byte publish = pub;
@@ -1675,21 +1674,21 @@ public void done(IJobChangeEvent event) {
return Status.CANCEL_STATUS;
}
}
- return Status.OK_STATUS;
+ return pubStatus[0];
}
- protected IStatus publishAfterStart(IProgressMonitor monitor, boolean synchronous){
+ protected IStatus publishAfterStart(IProgressMonitor monitor, boolean synchronous, final IOperationListener op){
// check if we need to publish
byte pub = StartJob.PUBLISH_NONE;
if (ServerCore.isAutoPublishing() && shouldPublish()) {
if (((ServerType)getServerType()).startBeforePublish())
+ pub = StartJob.PUBLISH_AFTER;
+ else
return Status.OK_STATUS;
-
- pub = StartJob.PUBLISH_AFTER;
}
- final IStatus [] pubStatus = new IStatus[1];
+ final IStatus [] pubStatus = new IStatus[]{Status.OK_STATUS};
// publish after start
byte publish = pub;
@@ -1700,6 +1699,9 @@ public void done(IJobChangeEvent event) {
IStatus status = event.getResult();
if (status != null && status.getSeverity() == IStatus.ERROR)
pubStatus[0] = status;
+ if (op != null){
+ op.done(status);
+ }
}
});
@@ -1714,7 +1716,7 @@ public void done(IJobChangeEvent event) {
return Status.CANCEL_STATUS;
}
}
- return Status.OK_STATUS;
+ return pubStatus[0];
}
/**
@@ -1739,7 +1741,7 @@ public void start(String mode2, IProgressMonitor monitor) throws CoreException {
StartJob startJob = new StartJob(mode2);
startJob.schedule();
- publishAfterStart(monitor,false);
+ publishAfterStart(monitor,false,null);
}
@@ -1763,19 +1765,27 @@ public void start(String mode2, final IOperationListener opListener) {
Trace.trace(Trace.FINEST,"Failed publish job during start routine");
return;
}
-
+
+ // check the publish flag (again) to determine when to call opListener.done
+ byte pub = StartJob.PUBLISH_NONE;
+ if (ServerCore.isAutoPublishing() && shouldPublish()) {
+ if (((ServerType)getServerType()).startBeforePublish())
+ pub = StartJob.PUBLISH_AFTER;
+ else
+ pub = StartJob.PUBLISH_BEFORE;
+ }
+
StartJob startJob = new StartJob(mode2);
- if (opListener != null) {
+ if (opListener != null && pub == StartJob.PUBLISH_BEFORE) {
startJob.addJobChangeListener(new JobChangeAdapter() {
public void done(IJobChangeEvent event) {
- publishAfterStart(null,false);
opListener.done(event.getResult());
}
});
}
startJob.schedule();
- publishAfterStart(null,false);
+ publishAfterStart(null,false, opListener);
}
public void synchronousStart(String mode2, IProgressMonitor monitor) throws CoreException {
@@ -1802,7 +1812,7 @@ public void synchronousStart(String mode2, IProgressMonitor monitor) throws Core
Trace.trace(Trace.WARNING, "Error waiting for job", e);
}
- publishAfterStart(monitor,true);
+ publishAfterStart(monitor,true,null);
}
/*
@@ -2701,12 +2711,10 @@ public void run() {
if (timer.timeout) {
stop(false);
- // TODO this message should be changed to restart time out
return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorRestartFailed, new String[] { getName(), (restartTimeout / 1000) + "" }), null);
}
if (getServerState() == IServer.STATE_STOPPED)
- // TODO this message should be changed to restart time out
return new Status(IStatus.ERROR, ServerPlugin.PLUGIN_ID, 0, NLS.bind(Messages.errorRestartFailed, getName()), null);
Trace.trace(Trace.FINEST, "synchronousRestart 4");

0 comments on commit c907f2c

Please sign in to comment.