use of org.wso2.carbon.humantask.core.engine.commands.Complete in project carbon-apimgt by wso2.
the class APIStateChangeSimpleWorkflowExecutor method execute.
@Override
public WorkflowResponse execute(WorkflowDTO workflowDTO) throws WorkflowException {
workflowDTO.setStatus(WorkflowStatus.APPROVED);
WorkflowResponse workflowResponse = complete(workflowDTO);
return workflowResponse;
}
use of org.wso2.carbon.humantask.core.engine.commands.Complete in project carbon-apimgt by wso2.
the class UserSignUpApprovalWorkflowExecutor method complete.
/**
* Complete the Approval workflow executor for User self sign up.
*
* @param workflowDTO
*/
@Override
public WorkflowResponse complete(WorkflowDTO workflowDTO) throws WorkflowException {
workflowDTO.setUpdatedTime(System.currentTimeMillis());
if (log.isDebugEnabled()) {
log.debug("User Sign Up [Complete] Workflow Invoked. Workflow ID : " + workflowDTO.getExternalWorkflowReference() + " Workflow State : " + workflowDTO.getStatus());
}
super.complete(workflowDTO);
String tenantDomain = workflowDTO.getTenantDomain();
try {
UserRegistrationConfigDTO signupConfig = SelfSignUpUtil.getSignupConfiguration(tenantDomain);
String tenantAwareUserName = MultitenantUtils.getTenantAwareUsername(workflowDTO.getWorkflowReference());
if (WorkflowStatus.APPROVED.equals(workflowDTO.getStatus())) {
try {
updateRolesOfUser(tenantAwareUserName, SelfSignUpUtil.getRoleNames(signupConfig), tenantDomain);
} catch (Exception e) {
// updateRolesOfUser throws generic Exception. Therefore generic Exception is caught
throw new WorkflowException("Error while assigning role to user", e);
}
} else {
try {
/* Remove created user */
deleteUser(tenantDomain, tenantAwareUserName);
} catch (Exception e) {
throw new WorkflowException("Error while deleting the user", e);
}
}
} catch (APIManagementException e1) {
throw new WorkflowException("Error while accessing signup configuration", e1);
}
return new GeneralWorkflowResponse();
}
Aggregations