use of org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method doUpdateApplicationTemplate.
/**
* Update SP template from database and cache.
*
* @param templateName template name
* @param spTemplate template info
* @param tenantDomain tenant domain
* @throws IdentityApplicationManagementException
*/
private void doUpdateApplicationTemplate(String templateName, SpTemplate spTemplate, String tenantDomain) throws IdentityApplicationManagementException {
// Update SP template in database
ApplicationTemplateDAO applicationTemplateDAO = ApplicationMgtSystemConfig.getInstance().getApplicationTemplateDAO();
applicationTemplateDAO.updateApplicationTemplate(templateName, spTemplate, tenantDomain);
// Update the template in cache
if (!templateName.equals(spTemplate.getName())) {
ServiceProviderTemplateCacheKey templateCacheKey = new ServiceProviderTemplateCacheKey(templateName);
ServiceProviderTemplateCache.getInstance().clearCacheEntry(templateCacheKey, tenantDomain);
}
ServiceProviderTemplateCacheKey templateCacheKey = new ServiceProviderTemplateCacheKey(spTemplate.getName());
ServiceProviderTemplateCache.getInstance().addToCache(templateCacheKey, spTemplate, tenantDomain);
}
use of org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method getSpTemplateFromDB.
private SpTemplate getSpTemplateFromDB(String templateName, String tenantDomain, ServiceProviderTemplateCacheKey templateCacheKey) throws IdentityApplicationManagementException {
ApplicationTemplateDAO applicationTemplateDAO = ApplicationMgtSystemConfig.getInstance().getApplicationTemplateDAO();
SpTemplate spTemplate = applicationTemplateDAO.getApplicationTemplate(templateName, tenantDomain);
if (spTemplate != null) {
if (log.isDebugEnabled()) {
log.debug(String.format("Template with name: %s is taken from database for tenant: %s ", templateName, tenantDomain));
}
ServiceProviderTemplateCache.getInstance().addToCache(templateCacheKey, spTemplate, tenantDomain);
return spTemplate;
}
return null;
}
use of org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method doGetApplicationTemplate.
/**
* Get SP template from cache or database.
*
* @param templateName template name
* @param tenantDomain tenant domain
* @return template info
* @throws IdentityApplicationManagementException
*/
private SpTemplate doGetApplicationTemplate(String templateName, String tenantDomain) throws IdentityApplicationManagementException {
// Get SP template from cache
ServiceProviderTemplateCacheKey templateCacheKey = new ServiceProviderTemplateCacheKey(templateName);
SpTemplate spTemplate = getSpTemplateFromCache(templateCacheKey, tenantDomain);
if (spTemplate == null) {
// Get SP template from database
spTemplate = getSpTemplateFromDB(templateName, tenantDomain, templateCacheKey);
}
return spTemplate;
}
use of org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method doCheckApplicationTemplateExistence.
/**
* Check existence of a SP template.
*
* @param templateName template name
* @param tenantDomain tenant domain
* @return true if SP template exists
* @throws IdentityApplicationManagementException
*/
private boolean doCheckApplicationTemplateExistence(String templateName, String tenantDomain) throws IdentityApplicationManagementException {
// Check existence in cache
ServiceProviderTemplateCacheKey templateCacheKey = new ServiceProviderTemplateCacheKey(templateName);
SpTemplate spTemplate = getSpTemplateFromCache(templateCacheKey, tenantDomain);
if (spTemplate == null) {
// Check existence in database
ApplicationTemplateDAO applicationTemplateDAO = ApplicationMgtSystemConfig.getInstance().getApplicationTemplateDAO();
return applicationTemplateDAO.isExistingTemplate(templateName, tenantDomain);
}
return true;
}
use of org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey in project carbon-identity-framework by wso2.
the class ApplicationManagementServiceImpl method doDeleteApplicationTemplate.
/**
* Delete SP template from database and cache.
*
* @param templateName template name
* @param tenantDomain tenant domain
* @throws IdentityApplicationManagementException
*/
private void doDeleteApplicationTemplate(String templateName, String tenantDomain) throws IdentityApplicationManagementException {
// Delete SP template from database
ApplicationTemplateDAO applicationTemplateDAO = ApplicationMgtSystemConfig.getInstance().getApplicationTemplateDAO();
applicationTemplateDAO.deleteApplicationTemplate(templateName, tenantDomain);
// Delete SP template from cache
ServiceProviderTemplateCacheKey templateCacheKey = new ServiceProviderTemplateCacheKey(templateName);
ServiceProviderTemplateCache.getInstance().clearCacheEntry(templateCacheKey, tenantDomain);
}
Aggregations