public synchronized void setState()

in taverna-workflowmodel-impl/src/main/java/org/apache/taverna/facade/impl/WorkflowInstanceFacadeImpl.java [514:570]


	public synchronized void setState(State newState) throws IllegalStateException {
		State oldState = state;
		if (newState.equals(state))
			return;
		switch (newState) {
		case running:
			switch (state) {
			case prepared:
			case paused:
				stateLastModified = new Date();
				state = newState;
				notifyFacadeListeners(oldState, newState);
				return;
			default:
				throw new IllegalStateException("Can't change state from "
						+ state + " to " + newState);
			}
		case paused:
			switch (state) {
			case running:
				stateLastModified = new Date();
				state = newState;
				notifyFacadeListeners(oldState, newState);
				return;
			default:
				throw new IllegalStateException("Can't change state from "
						+ state + " to " + newState);
			}
		case completed:
			switch (state) {
			case running:
				stateLastModified = new Date();
				state = newState;
				notifyFacadeListeners(oldState, newState);
				return;
			case cancelled:
				// Keep as cancelled
				return;
			default:
				throw new IllegalStateException("Can't change state from "
						+ state + " to " + newState);
			}
		case cancelled:
			switch (state) {
			case completed:
				throw new IllegalStateException("Can't change state from "
						+ state + " to " + newState);
			default:
				stateLastModified = new Date();
				state = newState;
				notifyFacadeListeners(oldState, newState);
				return;
			}
		default:
			throw new IllegalStateException("Can't change state from " + state  + " to " + newState);		
		}		
	}