use of org.wso2.carbon.apimgt.keymgt.model.entity.ApplicationKeyMappingCacheKey in project carbon-apimgt by wso2.
the class SubscriptionDataStoreImpl method getKeyMappingByKeyAndKeyManager.
@Override
public ApplicationKeyMapping getKeyMappingByKeyAndKeyManager(String key, String keyManager) {
ApplicationKeyMappingCacheKey applicationKeyMappingCacheKey = new ApplicationKeyMappingCacheKey(key, keyManager);
String synchronizeKey = "SubscriptionDataStoreImpl-KeyMapping-" + applicationKeyMappingCacheKey;
ApplicationKeyMapping applicationKeyMapping = applicationKeyMappingMap.get(applicationKeyMappingCacheKey);
if (applicationKeyMapping == null) {
synchronized (synchronizeKey.intern()) {
applicationKeyMapping = applicationKeyMappingMap.get(applicationKeyMappingCacheKey);
if (applicationKeyMapping != null) {
return applicationKeyMapping;
}
try {
applicationKeyMapping = new SubscriptionDataLoaderImpl().getKeyMapping(key, keyManager, tenantDomain);
} catch (DataLoadingException e) {
log.error("Error while Loading KeyMapping Information from Internal API.", e);
}
if (applicationKeyMapping != null && !StringUtils.isEmpty(applicationKeyMapping.getConsumerKey())) {
// load to the memory
log.debug("Loading Keymapping to the in-memory datastore.");
addOrUpdateApplicationKeyMapping(applicationKeyMapping);
}
}
}
if (log.isDebugEnabled()) {
log.debug("Retrieving Application information with Consumer Key : " + key + " and keymanager : " + keyManager);
if (applicationKeyMapping != null) {
log.debug("Retrieved Application information with Consumer Key : " + key + " and keymanager : " + keyManager + " is " + applicationKeyMapping.toString());
} else {
log.debug("Retrieving Application information with Consumer Key : " + key + " and keymanager : " + keyManager + " is empty");
}
}
return applicationKeyMapping;
}
Aggregations