Search in sources :

Example 1 with DELETE_TEMPLATE

use of org.wso2.carbon.identity.template.mgt.TemplateMgtConstants.SqlQueries.DELETE_TEMPLATE in project carbon-identity-framework by wso2.

the class TemplateManagerDAOImpl method deleteTemplate.

/**
 * Delete {@link Template} for a given template name and a tenant Id.
 *
 * @param templateName name of the {@link Template} to be deleted.the tenant
 * @param tenantId     tenant Id of the tenant which the {@link Template} resides.
 * @return TemplateInfo of the deleted {@link Template}.
 * @throws TemplateManagementException If error occurs while deleting the {@link Template}
 */
public TemplateInfo deleteTemplate(String templateName, Integer tenantId) throws TemplateManagementException {
    JdbcTemplate jdbcTemplate = JdbcUtils.getNewTemplate();
    try {
        jdbcTemplate.executeUpdate(DELETE_TEMPLATE, preparedStatement -> {
            preparedStatement.setString(1, templateName);
            preparedStatement.setInt(2, tenantId);
        });
    } catch (DataAccessException e) {
        throw new TemplateManagementServerException(String.format(ERROR_CODE_DELETE_TEMPLATE.getMessage(), tenantId.toString(), templateName), ERROR_CODE_DELETE_TEMPLATE.getCode(), e);
    }
    return new TemplateInfo(tenantId, templateName);
}
Also used : TemplateInfo(org.wso2.carbon.identity.template.mgt.model.TemplateInfo) TemplateManagementServerException(org.wso2.carbon.identity.template.mgt.exception.TemplateManagementServerException) JdbcTemplate(org.wso2.carbon.database.utils.jdbc.JdbcTemplate) DataAccessException(org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)

Aggregations

JdbcTemplate (org.wso2.carbon.database.utils.jdbc.JdbcTemplate)1 DataAccessException (org.wso2.carbon.database.utils.jdbc.exceptions.DataAccessException)1 TemplateManagementServerException (org.wso2.carbon.identity.template.mgt.exception.TemplateManagementServerException)1 TemplateInfo (org.wso2.carbon.identity.template.mgt.model.TemplateInfo)1