next = STATE_PROPAGATING_TO_PAUSE;
}
final String errMsg = "propagate functionality " +
"needed but it has been disabled";
final ManageException wexc = new ManageException(errMsg);
final int stateToSet;
if (next == STATE_INVALID) {
stateToSet = STATE_CORRUPTED_GENERIC;
} else {
stateToSet = STATE_CORRUPTED + next;
}
resource.setStateUnderLock(stateToSet, wexc);
throw wexc;
}
WorkspaceRequest req;
boolean fallback = false;
final boolean propstartOK = resource.isPropagateStartOK();
if (target == STATE_STARTED) {
if (propstartOK) {
req = this.reqFactory.propagateAndStart();
if (req == null) {
if (this.trace) {
logger.trace("\n\n ***** ST--propagate " + idStr +
": could use propagateToStart, " +
"but not implemented\n");
}
fallback = true;
}
} else {
req = reqFactory.propagate();
if (req == null) {
final String errMsg = "propagate functionality " +
"needed but it is not implemented";
final ManageException wexc =
new ManageException(errMsg);
resource.setStateUnderLock(
STATE_CORRUPTED + STATE_PROPAGATING, wexc);
throw wexc;
}
// just change local var, not real resource target
target = STATE_PROPAGATED;
if (this.trace) {
logger.trace("\n\n ***** ST--propagate " + idStr +
": propagateToStart not OK for this resource, doing" +
" propagate-only\n");
}
}
} else if (target == STATE_PAUSED) {
if (propstartOK) {
req = this.reqFactory.propagateAndPause();
if (req == null) {
if (this.trace) {
logger.trace("\n\n ***** ST--propagate " + idStr +
": could use propagateToPause, but not implemented\n");
}
fallback = true;
}
} else {
req = reqFactory.propagate();
if (req == null) {
final String errMsg = "propagate functionality " +
"needed but it is not implemented";
final ManageException wexc =
new ManageException(errMsg);
resource.setStateUnderLock(
STATE_CORRUPTED + STATE_PROPAGATING, wexc);
throw wexc;
}
// just change local var, not real resource target
// todo: comment why
target = STATE_PROPAGATED;
if (this.trace) {
logger.trace("\n\n ***** ST--propagate " + idStr +
": propagateToPause not OK for this resource, doing" +
" propagate-only\n");
}
}
} else if (target == STATE_PROPAGATED) {
req = this.reqFactory.propagate();
if (req == null) {
final String errMsg = "propagate functionality " +
"needed but it is not implemented";
final ManageException wexc =
new ManageException(errMsg);
resource.setStateUnderLock(
STATE_CORRUPTED + STATE_PROPAGATING, wexc);
throw wexc;
}
} else {
// handlers before propagate handler should not
// let this happen
throw new ManageException("Current state is " +
this.dataConvert.stateName(current) + ", " +
"propagate is needed but not" +
" achieved, but target state is not " +
this.dataConvert.stateName(STATE_STARTED) + ", " +
this.dataConvert.stateName(STATE_PAUSED) + ", or" +
this.dataConvert.stateName(STATE_PROPAGATED) + ", it is " +
this.dataConvert.stateName(target));
}
if (fallback) {
if (this.trace) {
logger.trace("\n\n ***** ST--propagate " + idStr +
": falling back to propagate-only\n");
}
req = reqFactory.propagate();
if (req == null) {
final String errMsg = "propagate functionality " +
"needed but it is not implemented";
final ManageException wexc =
new ManageException(errMsg);
resource.setStateUnderLock(
STATE_CORRUPTED + STATE_PROPAGATING, wexc);
throw wexc;