Search in sources :

Example 1 with ApplicationTemplateDAO

use of org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO 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 ApplicationTemplateDAO

use of org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO 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 ApplicationTemplateDAO

use of org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO in project carbon-identity-framework by wso2.

the class ApplicationMgtSystemConfig method getApplicationTemplateDAO.

/**
 * Return an instance of the ApplicationDAO
 *
 * @return
 */
public ApplicationTemplateDAO getApplicationTemplateDAO() {
    ApplicationTemplateDAO applicationTemplateDAO = null;
    if (appTemplateDAOClassName != null) {
        try {
            // Bundle class loader will cache the loaded class and returned
            // the already loaded instance, hence calling this method
            // multiple times doesn't cost.
            Class clazz = Class.forName(appTemplateDAOClassName);
            applicationTemplateDAO = (ApplicationTemplateDAO) clazz.newInstance();
        } catch (ClassNotFoundException e) {
            log.error("Error while instantiating the ApplicationTemplateDAO ", e);
        } catch (InstantiationException e) {
            log.error("Error while instantiating the ApplicationTemplateDAO ", e);
        } catch (IllegalAccessException e) {
            log.error("Error while instantiating the ApplicationTemplateDAO ", e);
        }
    } else {
        applicationTemplateDAO = new ApplicationTemplateDAOImpl();
    }
    return applicationTemplateDAO;
}
Also used : ApplicationTemplateDAOImpl(org.wso2.carbon.identity.application.mgt.dao.impl.ApplicationTemplateDAOImpl) ApplicationTemplateDAO(org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)

Example 4 with ApplicationTemplateDAO

use of org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO 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 ApplicationTemplateDAO

use of org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO 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

ApplicationTemplateDAO (org.wso2.carbon.identity.application.mgt.dao.ApplicationTemplateDAO)6 ServiceProviderTemplateCacheKey (org.wso2.carbon.identity.application.mgt.cache.ServiceProviderTemplateCacheKey)4 SpTemplate (org.wso2.carbon.identity.application.common.model.SpTemplate)2 ApplicationTemplateDAOImpl (org.wso2.carbon.identity.application.mgt.dao.impl.ApplicationTemplateDAOImpl)1