use of org.wso2.carbon.apimgt.core.models.API in project carbon-apimgt by wso2.
the class WorkflowConfigHolder method load.
public void load() throws WorkflowException {
workflowExecutorMap = new ConcurrentHashMap<>();
try {
WorkflowConfig config = WorkflowExtensionsConfigBuilder.getWorkflowConfig();
// Load application creation workflow configurations
loadWorkflowConfigurations(config.getApplicationCreation(), WorkflowConstants.WF_TYPE_AM_APPLICATION_CREATION);
// Load application deletion workflow configurations
loadWorkflowConfigurations(config.getApplicationDeletion(), WorkflowConstants.WF_TYPE_AM_APPLICATION_DELETION);
// Load subscription creation workflow configurations
loadWorkflowConfigurations(config.getSubscriptionCreation(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_CREATION);
// Load subscription deletion workflow configurations
loadWorkflowConfigurations(config.getSubscriptionDeletion(), WorkflowConstants.WF_TYPE_AM_SUBSCRIPTION_DELETION);
// Load api state change workflow configurations
loadWorkflowConfigurations(config.getApiStateChange(), WorkflowConstants.WF_TYPE_AM_API_STATE);
// Load application update workflow configurations
loadWorkflowConfigurations(config.getApplicationUpdate(), WorkflowConstants.WF_TYPE_AM_APPLICATION_UPDATE);
} catch (ClassNotFoundException e) {
handleException("Unable to find class", e);
} catch (InstantiationException e) {
handleException("Unable to instantiate class", e);
} catch (IllegalAccessException e) {
handleException("Illegal attempt to invoke class methods", e);
} catch (WorkflowException e) {
handleException("Unable to load workflow executor class", e);
}
}
use of org.wso2.carbon.apimgt.core.models.API in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createDefaultBlockCondition.
public static BlockConditions createDefaultBlockCondition(String conditionType) {
BlockConditions blockConditions = new BlockConditions();
blockConditions.setConditionType(conditionType);
blockConditions.setEnabled(true);
if (conditionType.equals(APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITIONS_IP)) {
blockConditions.setConditionValue(SAMPLE_IP_1);
} else if (conditionType.equals(APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITION_IP_RANGE)) {
blockConditions.setStartingIP(SAMPLE_IP_1);
blockConditions.setEndingIP(SAMPLE_IP_2);
} else if (conditionType.equals(APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITIONS_API)) {
try {
API.APIBuilder apiBuilder = SampleTestObjectCreator.createDefaultAPI();
API api = apiBuilder.build();
DAOFactory.getApiDAO().addAPI(api);
blockConditions.setConditionValue(api.getContext());
} catch (APIMgtDAOException e) {
log.error("Error while adding default api in default block condition", e);
}
} else if (conditionType.equals(APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITIONS_APPLICATION)) {
try {
Application app = createDefaultApplication();
DAOFactory.getApplicationDAO().addApplication(app);
blockConditions.setConditionValue(app.getId() + ":" + app.getName());
} catch (APIMgtDAOException e) {
log.error("Error while adding default app in default block condition", e);
}
} else if (conditionType.equals(APIMgtConstants.ThrottlePolicyConstants.BLOCKING_CONDITIONS_USER)) {
blockConditions.setConditionValue(ADMIN);
}
return blockConditions;
}
use of org.wso2.carbon.apimgt.core.models.API in project carbon-apimgt by wso2.
the class TestUtil method addAlternativeAPI.
public static API addAlternativeAPI() throws APIManagementException {
ApiDAO apiDAO = DAOFactory.getApiDAO();
apiDAO.addEndpoint(SampleTestObjectCreator.createAlternativeEndpoint());
API api = SampleTestObjectCreator.createAlternativeAPI().build();
apiDAO.addAPI(api);
return api;
}
use of org.wso2.carbon.apimgt.core.models.API in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testAddGetRating.
@Test
public void testAddGetRating() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
API.APIBuilder builder = SampleTestObjectCreator.createDefaultAPI().apiDefinition(SampleTestObjectCreator.apiDefinition);
API api = builder.build();
testAddGetEndpoint();
apiDAO.addAPI(api);
Rating rating = SampleTestObjectCreator.createDefaultRating(api.getId());
apiDAO.addRating(api.getId(), rating);
Rating ratingFromDB = apiDAO.getRatingByUUID(api.getId(), rating.getUuid());
Assert.assertNotNull(ratingFromDB);
}
use of org.wso2.carbon.apimgt.core.models.API in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testAddEndPointsForApi.
@Test(description = "Test adding API with endpointMap")
public void testAddEndPointsForApi() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
Map<String, Endpoint> endpointMap = new HashMap<>();
endpointMap.put(APIMgtConstants.PRODUCTION_ENDPOINT, new Endpoint.Builder().id(SampleTestObjectCreator.endpointId).applicableLevel(APIMgtConstants.GLOBAL_ENDPOINT).build());
API api = SampleTestObjectCreator.createDefaultAPI().endpoint(endpointMap).build();
testAddGetEndpoint();
apiDAO.addAPI(api);
API apiFromDB = apiDAO.getAPI(api.getId());
Assert.assertNotNull(apiFromDB);
Assert.assertTrue(api.equals(apiFromDB), TestUtil.printDiff(api, apiFromDB));
}
Aggregations