Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove disable action from Approval profiles #967

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,21 @@ public void processMessage(final ActionMessage actionMessage) throws MessageHand
final Optional<List<ApprovalProfileRelation>> approvalProfileRelationOptional = approvalProfileRelationRepository.findByResourceUuidAndResource(actionMessage.getApprovalProfileResourceUuid(), actionMessage.getApprovalProfileResource());
if (approvalProfileRelationOptional.isPresent() && !approvalProfileRelationOptional.get().isEmpty()) {
try {
final ApprovalProfileRelation approvalProfileRelation = approvalProfileRelationOptional.get().get(0);
final ApprovalProfileVersion approvalProfileVersion = approvalProfileRelation.getApprovalProfile().getTheLatestApprovalProfileVersion();
final Approval approval = approvalService.createApproval(approvalProfileVersion, actionMessage.getResource(), actionMessage.getResourceAction(), actionMessage.getResourceUuid(), actionMessage.getUserUuid(), actionMessage.getData());
logger.info("Created new Approval {} for object {}", approval.getUuid(), actionMessage.getResourceUuid());
processApprovalCreated(actionMessage);
final ApprovalProfileRelation approvalProfileRelation = approvalProfileRelationOptional.get().getFirst();
if (approvalProfileRelation.getApprovalProfile().isEnabled()) {
final ApprovalProfileVersion approvalProfileVersion = approvalProfileRelation.getApprovalProfile().getTheLatestApprovalProfileVersion();
final Approval approval = approvalService.createApproval(approvalProfileVersion, actionMessage.getResource(), actionMessage.getResourceAction(), actionMessage.getResourceUuid(), actionMessage.getUserUuid(), actionMessage.getData());
logger.info("Created new Approval {} for object {}", approval.getUuid(), actionMessage.getResourceUuid());
processApprovalCreated(actionMessage);
return;
}
} catch (Exception e) {
String errorMessage = String.format("Cannot create new approval to approve %s %s action!", actionMessage.getResource().getLabel(), actionMessage.getResourceAction().getCode());
logger.error("{}: {}", errorMessage, e.getMessage());
notificationProducer.produceNotificationText(actionMessage.getResource(), actionMessage.getResourceUuid(),
NotificationRecipient.buildUserNotificationRecipient(actionMessage.getUserUuid()), errorMessage, e.getMessage());
throw new MessageHandlingException(RabbitMQConstants.QUEUE_ACTIONS_NAME, actionMessage, "Handling of action approval creation failed: " + e.getMessage());
}
return;
}
}

Expand Down