use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class KeyManagerDataServiceImpl method removeAPIPolicy.
@Override
public void removeAPIPolicy(APIPolicyEvent event) {
if (log.isDebugEnabled()) {
log.debug("Remove API Policy in datastore in tenant " + event.getTenantDomain());
}
SubscriptionDataStore store = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(event.getTenantDomain());
if (store == null) {
if (log.isDebugEnabled()) {
log.debug("Ignoring the Event due to tenant " + event.getTenantDomain() + " not loaded");
}
return;
}
store.removeApiPolicy(getAPIPolicyFromAPIPolicyEvent(event));
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class KeyManagerDataServiceImpl method addOrUpdateApplicationKeyMapping.
@Override
public void addOrUpdateApplicationKeyMapping(ApplicationRegistrationEvent event) {
if (log.isDebugEnabled()) {
log.debug("Add or Update Application keymapping in datastore in tenant " + event.getTenantDomain());
}
SubscriptionDataStore store = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(event.getTenantDomain());
if (store == null) {
if (log.isDebugEnabled()) {
log.debug("Ignoring the Event due to tenant " + event.getTenantDomain() + " not loaded");
}
return;
}
store.addOrUpdateApplicationKeyMapping(getApplicationKeyMappingFromApplicationRegistrationEvent(event));
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class SynapseAnalyticsDataProvider method getApi.
@Override
public API getApi() throws DataNotFoundException {
String apiContext = (String) messageContext.getProperty(RESTConstants.REST_API_CONTEXT);
String apiVersion = (String) messageContext.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION);
String tenantDomain = MultitenantUtils.getTenantDomainFromRequestURL(apiContext);
if (tenantDomain == null) {
tenantDomain = MultitenantConstants.SUPER_TENANT_DOMAIN_NAME;
}
SubscriptionDataStore store = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain);
org.wso2.carbon.apimgt.keymgt.model.entity.API apiObj = store.getApiByContextAndVersion(apiContext, apiVersion);
API api = new API();
if (apiObj == null) {
try {
apiObj = new SubscriptionDataLoaderImpl().getApi(apiContext, apiVersion);
} catch (DataLoadingException e) {
log.error("Error occurred when getting api.", e);
throw new DataNotFoundException("Error occurred when getting API information", e);
}
}
if (apiObj != null) {
api.setApiId(apiObj.getUuid());
api.setApiType(apiObj.getApiType());
api.setApiName(apiObj.getApiName());
api.setApiVersion(apiObj.getApiVersion());
api.setApiCreator(apiObj.getApiProvider());
api.setApiCreatorTenantDomain(MultitenantUtils.getTenantDomain(api.getApiCreator()));
}
return api;
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class InMemoryAPIDeployer method reDeployAPI.
public void reDeployAPI(String apiName, String version, String tenantDomain) throws ArtifactSynchronizerException {
SubscriptionDataStore tenantSubscriptionStore = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain);
Set<String> gatewayLabels = gatewayArtifactSynchronizerProperties.getGatewayLabels();
if (tenantSubscriptionStore != null) {
org.wso2.carbon.apimgt.keymgt.model.entity.API retrievedAPI = tenantSubscriptionStore.getApiByNameAndVersion(apiName, version);
if (retrievedAPI != null) {
DeployAPIInGatewayEvent deployAPIInGatewayEvent = new DeployAPIInGatewayEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.REMOVE_API_FROM_GATEWAY.name(), tenantDomain, retrievedAPI.getApiId(), retrievedAPI.getUuid(), gatewayLabels, apiName, version, retrievedAPI.getApiProvider(), retrievedAPI.getApiType(), retrievedAPI.getContext());
deployAPI(deployAPIInGatewayEvent);
}
}
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class InMemoryAPIDeployer method unDeployAPI.
public void unDeployAPI(String apiName, String version, String tenantDomain) throws ArtifactSynchronizerException {
SubscriptionDataStore tenantSubscriptionStore = SubscriptionDataHolder.getInstance().getTenantSubscriptionStore(tenantDomain);
Set<String> gatewayLabels = gatewayArtifactSynchronizerProperties.getGatewayLabels();
if (tenantSubscriptionStore != null) {
org.wso2.carbon.apimgt.keymgt.model.entity.API retrievedAPI = tenantSubscriptionStore.getApiByNameAndVersion(apiName, version);
if (retrievedAPI != null) {
DeployAPIInGatewayEvent deployAPIInGatewayEvent = new DeployAPIInGatewayEvent(UUID.randomUUID().toString(), System.currentTimeMillis(), APIConstants.EventType.REMOVE_API_FROM_GATEWAY.name(), tenantDomain, retrievedAPI.getApiId(), retrievedAPI.getUuid(), gatewayLabels, apiName, version, retrievedAPI.getApiProvider(), retrievedAPI.getApiType(), retrievedAPI.getContext());
unDeployAPI(deployAPIInGatewayEvent);
}
}
}
Aggregations