use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class AbstractApplicationRegistrationWorkflowExecutor method execute.
public WorkflowResponse execute(WorkflowDTO workFlowDTO) throws WorkflowException {
if (log.isDebugEnabled()) {
log.debug("Executing AbstractApplicationRegistrationWorkflowExecutor...");
}
ApiMgtDAO dao = ApiMgtDAO.getInstance();
try {
// dao.createApplicationRegistrationEntry((ApplicationRegistrationWorkflowDTO) workFlowDTO, false);
ApplicationRegistrationWorkflowDTO appRegDTO;
if (workFlowDTO instanceof ApplicationRegistrationWorkflowDTO) {
appRegDTO = (ApplicationRegistrationWorkflowDTO) workFlowDTO;
} else {
String message = "Invalid workflow type found";
log.error(message);
throw new WorkflowException(message);
}
dao.createApplicationRegistrationEntry(appRegDTO, false);
// appRegDTO.getAppInfoDTO().saveDTO();
super.execute(workFlowDTO);
} catch (APIManagementException e) {
log.error("Error while creating Application Registration entry.", e);
throw new WorkflowException("Error while creating Application Registration entry.", e);
}
return new GeneralWorkflowResponse();
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class ApplicationDeletionSimpleWorkflowExecutor method complete.
@Override
public WorkflowResponse complete(WorkflowDTO workflowDTO) throws WorkflowException {
ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
ApplicationWorkflowDTO applicationWorkflowDTO = (ApplicationWorkflowDTO) workflowDTO;
Application application = applicationWorkflowDTO.getApplication();
String errorMsg = null;
try {
apiMgtDAO.deleteApplication(application);
} catch (APIManagementException e) {
if (e.getMessage() == null) {
errorMsg = "Couldn't complete simple application deletion workflow for application: " + application.getName();
} else {
errorMsg = e.getMessage();
}
throw new WorkflowException(errorMsg, e);
}
return new GeneralWorkflowResponse();
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class SubscriptionCreationApprovalWorkflowExecutor 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 Subscription Creation Webservice Workflow.. ");
}
SubscriptionWorkflowDTO subsWorkflowDTO = (SubscriptionWorkflowDTO) workflowDTO;
String message = "Approve API " + subsWorkflowDTO.getApiName() + " - " + subsWorkflowDTO.getApiVersion() + " subscription creation request from subscriber - " + subsWorkflowDTO.getSubscriber() + " for the application - " + subsWorkflowDTO.getApplicationName();
workflowDTO.setWorkflowDescription(message);
workflowDTO.setProperties("apiName", subsWorkflowDTO.getApiName());
workflowDTO.setProperties("apiVersion", subsWorkflowDTO.getApiVersion());
workflowDTO.setProperties("subscriber", subsWorkflowDTO.getSubscriber());
workflowDTO.setProperties("applicationName", subsWorkflowDTO.getApplicationName());
super.execute(workflowDTO);
return new GeneralWorkflowResponse();
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class SubscriptionCreationApprovalWorkflowExecutor method cleanUpPendingTask.
/**
* Handle cleanup task for subscription creation Approval workflow executor.
* Use workflow external reference to delete the pending workflow request
*
* @param workflowExtRef Workflow external reference of pending workflow request
*/
@Override
public void cleanUpPendingTask(String workflowExtRef) throws WorkflowException {
String errorMsg = null;
super.cleanUpPendingTask(workflowExtRef);
if (log.isDebugEnabled()) {
log.debug("Starting cleanup task for SubscriptionCreationApprovalWorkflowExecutor for :" + workflowExtRef);
}
try {
ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
apiMgtDAO.deleteWorkflowRequest(workflowExtRef);
} catch (APIManagementException axisFault) {
errorMsg = "Error sending out cancel pending subscription approval process message. cause: " + axisFault.getMessage();
throw new WorkflowException(errorMsg, axisFault);
}
}
use of org.wso2.carbon.apimgt.api.model.Workflow in project carbon-apimgt by wso2.
the class SubscriptionCreationWSWorkflowExecutor method complete.
@Override
public WorkflowResponse complete(WorkflowDTO workflowDTO) throws WorkflowException {
workflowDTO.setUpdatedTime(System.currentTimeMillis());
super.complete(workflowDTO);
log.info("Subscription Creation [Complete] Workflow Invoked. Workflow ID : " + workflowDTO.getExternalWorkflowReference() + "Workflow State : " + workflowDTO.getStatus());
if (WorkflowStatus.APPROVED.equals(workflowDTO.getStatus())) {
ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
try {
apiMgtDAO.updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.UNBLOCKED);
} catch (APIManagementException e) {
log.error("Could not complete subscription creation workflow", e);
throw new WorkflowException("Could not complete subscription creation workflow", e);
}
} else if (WorkflowStatus.REJECTED.equals(workflowDTO.getStatus())) {
ApiMgtDAO apiMgtDAO = ApiMgtDAO.getInstance();
try {
apiMgtDAO.updateSubscriptionStatus(Integer.parseInt(workflowDTO.getWorkflowReference()), APIConstants.SubscriptionStatus.REJECTED);
} catch (APIManagementException e) {
log.error("Could not complete subscription creation workflow", e);
throw new WorkflowException("Could not complete subscription creation workflow", e);
}
}
return new GeneralWorkflowResponse();
}
Aggregations