use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class DefaultWorkflowExecutor method complete.
/**
* Complete the external process status
* Based on the workflow status we will update the status column of the
* Application table
*
* @param workFlow - Workflow
*/
public WorkflowResponse complete(Workflow workFlow) throws WorkflowException {
if (log.isDebugEnabled()) {
log.debug("Executing complete() in Workflow for " + workFlow.getWorkflowType());
}
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
workflowResponse.setWorkflowStatus(workFlow.getStatus());
return workflowResponse;
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class DefaultWorkflowExecutor method execute.
/**
* {@inheritDoc}
*/
@Override
public WorkflowResponse execute(Workflow workFlow) throws WorkflowException {
if (log.isDebugEnabled()) {
log.debug("Executing execute() in Workflow for " + workFlow.getWorkflowType());
}
WorkflowResponse workflowResponse = new GeneralWorkflowResponse();
// set the state to approved
workflowResponse.setWorkflowStatus(WorkflowStatus.APPROVED);
return workflowResponse;
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class WorkflowConfigHolder method loadWorkflowConfigurations.
private void loadWorkflowConfigurations(WorkflowExecutorInfo workflowConfig, String workflowExecutorType) throws ClassNotFoundException, IllegalAccessException, InstantiationException, WorkflowException {
String executorClass = workflowConfig.getExecutor();
Class clazz = WorkflowConfigHolder.class.getClassLoader().loadClass(executorClass);
WorkflowExecutor workFlowExecutor = (WorkflowExecutor) clazz.newInstance();
List<WorkflowConfigProperties> properties = workflowConfig.getProperty();
if (properties != null) {
loadProperties(properties, workFlowExecutor);
}
workflowExecutorMap.put(workflowExecutorType, workFlowExecutor);
}
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());
}
}
use of org.wso2.carbon.apimgt.core.exception.WorkflowException in project carbon-apimgt by wso2.
the class APIConsumerImplTest method testRemoveSubscription.
@Test
public void testRemoveSubscription() throws APIManagementException, WorkflowException, APIPersistenceException {
String uuid = UUID.randomUUID().toString();
String apiUUID = UUID.randomUUID().toString();
Subscriber subscriber = new Subscriber("sub1");
Application application = new Application("app1", subscriber);
application.setId(1);
APIIdentifier identifier = new APIIdentifier(API_PROVIDER, SAMPLE_API_NAME, SAMPLE_API_VERSION);
identifier.setUuid(apiUUID);
SubscribedAPI subscribedAPIOld = new SubscribedAPI(subscriber, identifier);
subscribedAPIOld.setApplication(application);
Mockito.when(apiMgtDAO.isAppAllowed(Mockito.anyInt(), Mockito.anyString(), Mockito.anyString())).thenReturn(true);
PowerMockito.mockStatic(ApiMgtDAO.class);
PowerMockito.when(ApiMgtDAO.getInstance()).thenReturn(apiMgtDAO);
Mockito.when(apiMgtDAO.checkAPIUUIDIsARevisionUUID(Mockito.anyString())).thenReturn(null);
DevPortalAPI devPortalAPI = Mockito.mock(DevPortalAPI.class);
Mockito.when(apiPersistenceInstance.getDevPortalAPI(any(Organization.class), any(String.class))).thenReturn(devPortalAPI);
SubscribedAPI subscribedAPINew = new SubscribedAPI(subscriber, identifier);
subscribedAPINew.setUUID(uuid);
subscribedAPINew.setApplication(application);
APIConsumerImpl apiConsumer = new APIConsumerImplWrapper(apiMgtDAO, apiPersistenceInstance);
apiConsumer.removeSubscription(subscribedAPINew, "org1");
Mockito.verify(apiMgtDAO, Mockito.times(1)).getApplicationNameFromId(Mockito.anyInt());
String workflowExtRef = "test_wf_ref";
String workflowExtRef1 = "complete_wf_ref";
Mockito.when(apiMgtDAO.getExternalWorkflowReferenceForSubscription((APIIdentifier) Mockito.any(), Mockito.anyInt(), Mockito.anyString())).thenReturn(workflowExtRef, workflowExtRef1);
SubscriptionWorkflowDTO subscriptionWorkflowDTO = new SubscriptionWorkflowDTO();
subscriptionWorkflowDTO.setWorkflowReference("1");
Mockito.when(apiMgtDAO.retrieveWorkflow(workflowExtRef)).thenReturn(subscriptionWorkflowDTO);
SubscribedAPI subscribedAPI = new SubscribedAPI("api1");
subscribedAPI.setTier(new Tier("Gold"));
Mockito.when(apiMgtDAO.getSubscriptionById(Mockito.anyInt())).thenReturn(subscribedAPI);
Mockito.when(apiMgtDAO.getSubscriptionStatus(uuid, 1)).thenReturn(APIConstants.SubscriptionStatus.ON_HOLD);
apiConsumer.removeSubscription(subscribedAPINew, "org1");
Mockito.when(apiMgtDAO.retrieveWorkflow(workflowExtRef1)).thenReturn(subscriptionWorkflowDTO);
PowerMockito.when(MultitenantUtils.getTenantDomain(Mockito.anyString())).thenReturn("abc.org");
apiConsumer.removeSubscription(subscribedAPINew, "org1");
Mockito.verify(apiMgtDAO, Mockito.times(2)).retrieveWorkflow(Mockito.anyString());
}
Aggregations