}
if (cToCancel == null) throw new CommitmentNotFoundInInteractionStateException(c);
// check lifecyclestatus of commitment
if (c.getLifeCycleStatus() != LifeCycleState.CONDITIONAL && c.getLifeCycleStatus() != LifeCycleState.DETACHED) {
throw new CommitmentOperationNotPerformable(c, ProtocolArtifact.CANCEL_COMMITMENT);
}
// UPDATE STRUCTURE BY LIFECYCLE
logger.trace("Commitment to cancel found");
logger.debug("Updating roles-commitments support datastructures");
// UPDATE COMMITMENT LIFECYCLE STATUS
logger.trace("Updating commitments by LifeCycleStatus "+c.getLifeCycleStatus());
HashSet<Commitment> actualCommits = commitments.get(c.getLifeCycleStatus());
if (actualCommits != null) {
logger.trace("At least a commitment found with status "+c.getLifeCycleStatus()+".");
if (actualCommits.contains(c)) {
logger.trace("Commitment individuated");
logger.debug("Actual commitments with status "+c.getLifeCycleStatus());
logger.debug(printHashSet(actualCommits));
actualCommits.remove(c);
logger.debug("After removal: ");
logger.debug(printHashSet(actualCommits));
// now change commitment status
switch (c.getLifeCycleStatus()) {
case CONDITIONAL:
c.setStatus(LifeCycleState.TERMINATED);
break;
case DETACHED:
c.setStatus(LifeCycleState.VIOLATED);
break;
default:
throw new CommitmentOperationNotPerformable(c, ProtocolArtifact.CANCEL_COMMITMENT);
}
// UPDATE COMMITMENT LIST BY LIFECYCLE STATUS
logger.trace("Updating commitments by LifeCycleStatus "+c.getLifeCycleStatus());
actualCommits = commitments.get(c.getLifeCycleStatus());