use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse in project carbon-apimgt by wso2.
the class ApplicationCreationApprovalWorkflowExecutor method execute.
/**
* Execute the Application Creation workflow approval process.
*
* @param workflowDTO
*/
@Override
public WorkflowResponse execute(WorkflowDTO workflowDTO) throws WorkflowException {
if (log.isDebugEnabled()) {
log.debug("Executing Application creation Workflow.");
}
ApplicationWorkflowDTO appWorkFlowDTO = (ApplicationWorkflowDTO) workflowDTO;
Application application = appWorkFlowDTO.getApplication();
String message = "Approve application " + application.getName() + " creation request from application creator -" + appWorkFlowDTO.getUserName() + " with throttling tier - " + application.getTier();
workflowDTO.setWorkflowDescription(message);
workflowDTO.setProperties("applicationName", application.getName());
workflowDTO.setProperties("userName", appWorkFlowDTO.getUserName());
workflowDTO.setProperties("applicationTier", application.getTier());
super.execute(workflowDTO);
return new GeneralWorkflowResponse();
}
use of org.wso2.carbon.apimgt.impl.workflow.GeneralWorkflowResponse 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