use of org.apache.syncope.core.persistence.api.entity.ReportTemplate in project syncope by apache.
the class ReportTemplateLogic method getFormat.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_TEMPLATE_READ + "')")
public String getFormat(final String key, final ReportTemplateFormat format) {
ReportTemplate reportTemplate = reportTemplateDAO.find(key);
if (reportTemplate == null) {
LOG.error("Could not find report template '" + key + "'");
throw new NotFoundException(key);
}
String template = format == ReportTemplateFormat.HTML ? reportTemplate.getHTMLTemplate() : format == ReportTemplateFormat.CSV ? reportTemplate.getCSVTemplate() : reportTemplate.getFOTemplate();
if (StringUtils.isBlank(template)) {
LOG.error("Could not find report template '" + key + "' in " + format + " format");
throw new NotFoundException(key + " in " + format);
}
return template;
}
use of org.apache.syncope.core.persistence.api.entity.ReportTemplate in project syncope by apache.
the class ReportTemplateLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_TEMPLATE_DELETE + "')")
public ReportTemplateTO delete(final String key) {
ReportTemplate reportTemplate = reportTemplateDAO.find(key);
if (reportTemplate == null) {
LOG.error("Could not find report template '" + key + "'");
throw new NotFoundException(key);
}
List<Report> reports = reportDAO.findByTemplate(reportTemplate);
if (!reports.isEmpty()) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InUse);
sce.getElements().addAll(reports.stream().map(Entity::getKey).collect(Collectors.toList()));
throw sce;
}
ReportTemplateTO deleted = getReportTemplateTO(key);
reportTemplateDAO.delete(key);
return deleted;
}
use of org.apache.syncope.core.persistence.api.entity.ReportTemplate in project syncope by apache.
the class ReportTemplateLogic method setFormat.
@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_TEMPLATE_UPDATE + "')")
public void setFormat(final String key, final ReportTemplateFormat format, final String template) {
ReportTemplate reportTemplate = reportTemplateDAO.find(key);
if (reportTemplate == null) {
LOG.error("Could not find report template '" + key + "'");
throw new NotFoundException(key);
}
switch(format) {
case CSV:
reportTemplate.setCSVTemplate(template);
break;
case FO:
reportTemplate.setFOTemplate(template);
break;
case HTML:
reportTemplate.setHTMLTemplate(template);
break;
default:
}
reportTemplateDAO.save(reportTemplate);
}
Aggregations