Skip to content
Snippets Groups Projects

Draft: F acm permissions2

Closed Timm Fitschen requested to merge f-acm-permissions2 into dev
3 files
+ 46
8
Compare changes
  • Side-by-side
  • Inline

Files

@@ -52,6 +52,12 @@ public class CheckStateTransition extends EntityStateJob {
}
}
/**
* Check if the state belongs to the state model.
*
* @param state
* @throws Message
*/
private void checkStateValid(State state) throws Message {
if (state.isFinal() || state.isInitial() || state.getStateModel().getStates().contains(state)) {
return;
@@ -59,7 +65,13 @@ public class CheckStateTransition extends EntityStateJob {
throw STATE_NOT_IN_STATE_MODEL;
}
/** Check if state is valid and transition is allowed */
/**
* Check if state is valid and transition is allowed.
*
* @param fromState
* @param toState
* @throws Message if not
*/
private void checkStateTransition(State fromState, State toState) throws Message {
if (fromState == null && toState == null) {
return;
@@ -88,6 +100,12 @@ public class CheckStateTransition extends EntityStateJob {
throw TRANSITION_NOT_ALLOWED;
}
/**
* @param fromState
* @param toState
* @return the state model which contains both of the states.
* @throws Message if the state model of one of the states cannot be constructed.
*/
private StateModel findMatchingStateModel(State fromState, State toState) throws Message {
if (fromState.getStateModel().equals(toState.getStateModel())) {
return fromState.getStateModel();
@@ -95,6 +113,12 @@ public class CheckStateTransition extends EntityStateJob {
return null;
}
/**
* Check if the old state is final or if the {@link FORCE_FINAL_STATE} flag is true.
*
* @param fromState
* @throws Message if the state is not final.
*/
private void checkFinalState(State fromState) throws Message {
if (!fromState.isFinal()) {
if ("true".equalsIgnoreCase(getTransaction().getContainer().getFlags().get(FORCE_FINAL_STATE))
@@ -107,6 +131,12 @@ public class CheckStateTransition extends EntityStateJob {
// TODO permissions
}
/**
* Check if the new state is an initial state.
*
* @param toState
* @throws Message if not
*/
private void checkInitialState(State toState) throws Message {
if (!toState.isInitial()) {
throw INITIAL_STATE_NOT_ALLOWED;
Loading