use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class GatewayUtils method convertToApplicationDto.
private static ApplicationInfoDTO convertToApplicationDto(int applicationId, SubscriptionDataStore subscriptionDataStore) {
ApplicationInfoDTO applicationInfoDTO = new ApplicationInfoDTO();
Application application = subscriptionDataStore.getApplicationById(applicationId);
if (application != null) {
applicationInfoDTO.setId(application.getId());
applicationInfoDTO.setName(application.getName());
applicationInfoDTO.setPolicy(application.getPolicy());
applicationInfoDTO.setAttributes(application.getAttributes());
applicationInfoDTO.setSubName(application.getSubName());
applicationInfoDTO.setUuid(application.getUUID());
applicationInfoDTO.setTokenType(application.getTokenType());
applicationInfoDTO.setKeys(convertToApplicationKeyMapping(applicationId, subscriptionDataStore));
}
return applicationInfoDTO;
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class KeyManagerDataServiceImpl method removeApplication.
@Override
public void removeApplication(ApplicationEvent event) {
if (log.isDebugEnabled()) {
log.debug("Remove Application 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.removeApplication(getApplicationFromApplicationEvent(event));
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class KeyManagerDataServiceImpl method removeApplicationKeyMapping.
@Override
public void removeApplicationKeyMapping(ApplicationRegistrationEvent event) {
if (log.isDebugEnabled()) {
log.debug("Remove ApplicationKey Mapping 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.removeApplicationKeyMapping(getApplicationKeyMappingFromApplicationRegistrationEvent(event));
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class KeyManagerDataServiceImpl method addOrUpdateSubscription.
@Override
public void addOrUpdateSubscription(SubscriptionEvent event) {
if (log.isDebugEnabled()) {
log.debug("Add or Update Subscription 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.addOrUpdateSubscription(getSubscriptionFromSubscriptionEvent(event));
}
use of org.wso2.carbon.apimgt.keymgt.model.SubscriptionDataStore in project carbon-apimgt by wso2.
the class GatewayUtilsTestCase method testGetAPIasNull.
@Test
public void testGetAPIasNull() {
MessageContext messageContext = Mockito.mock(MessageContext.class);
SubscriptionDataHolder subscriptionDataHolder = Mockito.mock(SubscriptionDataHolder.class);
Mockito.when(SubscriptionDataHolder.getInstance()).thenReturn(subscriptionDataHolder);
SubscriptionDataStore subscriptionDataStore = Mockito.mock(SubscriptionDataStore.class);
Mockito.when(subscriptionDataHolder.getTenantSubscriptionStore("carbon.super")).thenReturn(subscriptionDataStore);
Mockito.when(messageContext.getProperty(RESTConstants.REST_API_CONTEXT)).thenReturn("/abc1");
Mockito.when(messageContext.getProperty(RESTConstants.SYNAPSE_REST_API_VERSION)).thenReturn("1.0.0");
Assert.assertNull(GatewayUtils.getAPI(messageContext));
Assert.assertNull(GatewayUtils.getAPINameFromContextAndVersion(messageContext));
Assert.assertNull(GatewayUtils.getApiProviderFromContextAndVersion(messageContext));
Mockito.verify(messageContext, Mockito.times(0)).setProperty(Mockito.anyString(), Mockito.any());
Mockito.verify(messageContext, Mockito.times(6)).getProperty(APIMgtGatewayConstants.API_OBJECT);
Mockito.verify(messageContext, Mockito.times(3)).getProperty(RESTConstants.REST_API_CONTEXT);
Mockito.verify(messageContext, Mockito.times(3)).getProperty(RESTConstants.SYNAPSE_REST_API_VERSION);
Mockito.verify(subscriptionDataStore, Mockito.times(3)).getApiByContextAndVersion("/abc1", "1.0.0");
}
Aggregations