use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class APIManagerFactory method newProvider.
private APIPublisher newProvider(String username) throws APIManagementException {
try {
APIPublisherImpl apiPublisher = new APIPublisherImpl(username, getIdentityProvider(), getKeyManager(), DAOFactory.getApiDAO(), DAOFactory.getApplicationDAO(), DAOFactory.getAPISubscriptionDAO(), DAOFactory.getPolicyDAO(), geApiLifecycleManager(), DAOFactory.getLabelDAO(), DAOFactory.getWorkflowDAO(), DAOFactory.getTagDAO(), DAOFactory.getThreatProtectionDAO(), new GatewaySourceGeneratorImpl(), new APIGatewayPublisherImpl());
// Register all the observers which need to observe 'Publisher' component
apiPublisher.registerObserver(new EventLogger());
apiPublisher.registerObserver(new FunctionTrigger(DAOFactory.getFunctionDAO(), new RestCallUtilImpl()));
return apiPublisher;
} catch (APIMgtDAOException e) {
log.error("Couldn't Create API Provider", e);
throw new APIMgtDAOException("Couldn't Create API Provider", ExceptionCodes.APIMGT_DAO_EXCEPTION);
}
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ServiceReferenceHolder method getAPIMConfiguration.
/**
* Gives the APIMConfigurations explicitly set in the deployment yaml or the default configurations
*
* @return APIMConfigurations
*/
public APIMConfigurations getAPIMConfiguration() {
try {
if (configProvider != null) {
apimConfigurations = configProvider.getConfigurationObject(APIMConfigurations.class);
} else {
log.error("Configuration provider is null");
}
} catch (ConfigurationException e) {
log.error("error getting config : org.wso2.carbon.apimgt.core.internal.APIMConfiguration", e);
}
if (apimConfigurations == null) {
apimConfigurations = new APIMConfigurations();
log.info("APIMConfiguration: Setting default configurations...");
}
return apimConfigurations;
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ServiceReferenceHolder method getEnvironmentConfigurations.
/**
* Gives the EnvironmentConfigurations explicitly set in the deployment yaml or the default configurations
*
* @return EnvironmentConfigurations
*/
public EnvironmentConfigurations getEnvironmentConfigurations() {
try {
if (configProvider != null) {
environmentConfigurations = configProvider.getConfigurationObject(EnvironmentConfigurations.class);
} else {
log.error("Configuration provider is null");
}
} catch (ConfigurationException e) {
log.error("error getting config : org.wso2.carbon.apimgt.core.internal.EnvironmentConfigurations", e);
}
if (environmentConfigurations == null) {
environmentConfigurations = new EnvironmentConfigurations();
log.info("EnvironmentConfigurations: Setting default configurations...");
}
return environmentConfigurations;
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class SampleTestObjectCreator method createUniqueCompositeAPI.
public static CompositeAPI.Builder createUniqueCompositeAPI() {
Set<String> transport = new HashSet<>();
transport.add(HTTP);
HashMap permissionMap = new HashMap();
permissionMap.put(DEVELOPER_ROLE_ID, 6);
permissionMap.put(ADMIN_ROLE_ID, 15);
permissionMap.put(ADMIN_ROLE_ID, 7);
Application app = createDefaultApplication();
// generate random name for each time when generating unique composite API
app.setName(UUID.randomUUID().toString());
try {
DAOFactory.getApplicationDAO().addApplication(app);
} catch (APIMgtDAOException e) {
log.error("Error adding application", e);
}
CompositeAPI.Builder apiBuilder = new CompositeAPI.Builder().id(UUID.randomUUID().toString()).name(UUID.randomUUID().toString()).provider(UUID.randomUUID().toString()).version(API_VERSION).context(UUID.randomUUID().toString()).description("Get Food & Beverage Info").transport(transport).permissionMap(permissionMap).applicationId(app.getId()).createdTime(LocalDateTime.now()).createdBy(API_CREATOR).uriTemplates(Collections.emptyMap()).apiDefinition(apiDefinition).lastUpdatedTime(LocalDateTime.now()).threatProtectionPolicies(threatProtectionPolicies);
return apiBuilder;
}
use of org.wso2.carbon.apimgt.api.model.Provider in project carbon-apimgt by wso2.
the class ApiDAOImplIT method testGetAPIsWhenUserRolesInAPIPermissionsWithoutREAD.
@Test(description = "Tests getting the APIs when the user roles are contained in the API permission list " + "but without READ permissions")
public void testGetAPIsWhenUserRolesInAPIPermissionsWithoutREAD() throws Exception {
ApiDAO apiDAO = DAOFactory.getApiDAO();
Set<String> rolesOfUser = new HashSet<>();
rolesOfUser.add(SampleTestObjectCreator.DEVELOPER_ROLE_ID);
// This user is not the provider of the API
List<API> apiList = apiDAO.getAPIs(rolesOfUser, ALTERNATIVE_USER);
Assert.assertTrue(apiList.isEmpty());
Map map = new HashMap();
map.put(SampleTestObjectCreator.DEVELOPER_ROLE_ID, 0);
API.APIBuilder builder = SampleTestObjectCreator.createDefaultAPI().permissionMap(map);
API api1 = builder.build();
testAddGetEndpoint();
apiDAO.addAPI(api1);
apiList = apiDAO.getAPIs(rolesOfUser, ALTERNATIVE_USER);
// Since the API has the role ID of the user but without READ permissions, it is not visible to this user
Assert.assertTrue(apiList.size() == 0);
}
Aggregations