Search in sources :

Example 11 with WorkflowException

use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.

the class APIPublisherImpl method cleanupPendingTaskForAPIStateChange.

private void cleanupPendingTaskForAPIStateChange(String apiId) throws APIManagementException {
    Optional<String> workflowExtRef = getWorkflowDAO().getExternalWorkflowReferenceForPendingTask(apiId, WorkflowConstants.WF_TYPE_AM_API_STATE);
    if (workflowExtRef.isPresent()) {
        WorkflowExecutor executor = WorkflowExecutorFactory.getInstance().getWorkflowExecutor(WorkflowConstants.WF_TYPE_AM_API_STATE);
        try {
            executor.cleanUpPendingTask(workflowExtRef.get());
        } catch (WorkflowException e) {
            String warn = "Failed to clean pending api state change task for " + apiId;
            // failed cleanup processes are ignored to prevent failing the deletion process
            log.warn(warn, e.getLocalizedMessage());
        }
        getWorkflowDAO().deleteWorkflowEntryforExternalReference(workflowExtRef.get());
    }
}
Also used : WorkflowException(org.wso2.carbon.apimgt.core.exception.WorkflowException) WorkflowExecutor(org.wso2.carbon.apimgt.core.api.WorkflowExecutor)

Aggregations

WorkflowResponse (org.wso2.carbon.apimgt.core.api.WorkflowResponse)7 WorkflowExecutor (org.wso2.carbon.apimgt.core.api.WorkflowExecutor)5 WorkflowException (org.wso2.carbon.apimgt.core.exception.WorkflowException)3 Test (org.testng.annotations.Test)2 APIGateway (org.wso2.carbon.apimgt.core.api.APIGateway)2 APISubscriptionDAO (org.wso2.carbon.apimgt.core.dao.APISubscriptionDAO)2 WorkflowDAO (org.wso2.carbon.apimgt.core.dao.WorkflowDAO)2 WorkflowConfigProperties (org.wso2.carbon.apimgt.core.models.WorkflowConfigProperties)2 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 ParseException (org.json.simple.parser.ParseException)1 APIManagementException (org.wso2.carbon.apimgt.core.exception.APIManagementException)1 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)1 APIMgtResourceAlreadyExistsException (org.wso2.carbon.apimgt.core.exception.APIMgtResourceAlreadyExistsException)1 WorkflowConfig (org.wso2.carbon.apimgt.core.models.WorkflowConfig)1 Policy (org.wso2.carbon.apimgt.core.models.policy.Policy)1 ApplicationCreationResponse (org.wso2.carbon.apimgt.core.workflow.ApplicationCreationResponse)1 ApplicationCreationWorkflow (org.wso2.carbon.apimgt.core.workflow.ApplicationCreationWorkflow)1