Search in sources :

Example 1 with ServiceProviderTemplateCacheKey

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);
}
Also used : ServiceProviderTemplateCacheKey(org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey) ApplicationTemplateDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)

Example 2 with ServiceProviderTemplateCacheKey

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;
}
Also used : SpTemplate(org.wso2.carbon.identity.application.common.model.SpTemplate) ApplicationTemplateDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)

Example 3 with ServiceProviderTemplateCacheKey

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;
}
Also used : SpTemplate(org.wso2.carbon.identity.application.common.model.SpTemplate) ServiceProviderTemplateCacheKey(org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey)

Example 4 with ServiceProviderTemplateCacheKey

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;
}
Also used : SpTemplate(org.wso2.carbon.identity.application.common.model.SpTemplate) ServiceProviderTemplateCacheKey(org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey) ApplicationTemplateDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)

Example 5 with ServiceProviderTemplateCacheKey

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);
}
Also used : ServiceProviderTemplateCacheKey(org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey) ApplicationTemplateDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)

Aggregations

ServiceProviderTemplateCacheKey (org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey)5 ApplicationTemplateDAO (org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)5 SpTemplate (org.wso2.carbon.identity.application.common.model.SpTemplate)3