use of org.apache.syncope.core.persistence.api.dao.NotFoundException 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.dao.NotFoundException 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.dao.NotFoundException 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);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class ResourceLogic method connObjectInit.
private Triple<ExternalResource, AnyType, Provision> connObjectInit(final String resourceKey, final String anyTypeKey) {
ExternalResource resource = resourceDAO.authFind(resourceKey);
if (resource == null) {
throw new NotFoundException("Resource '" + resourceKey + "'");
}
AnyType anyType = anyTypeDAO.find(anyTypeKey);
if (anyType == null) {
throw new NotFoundException("AnyType '" + anyTypeKey + "'");
}
Optional<? extends Provision> provision = resource.getProvision(anyType);
if (!provision.isPresent()) {
throw new NotFoundException("Provision on resource '" + resourceKey + "' for type '" + anyTypeKey + "'");
}
return ImmutableTriple.of(resource, anyType, provision.get());
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class SecurityQuestionLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.SECURITY_QUESTION_DELETE + "')")
public SecurityQuestionTO delete(final String key) {
SecurityQuestion securityQuestion = securityQuestionDAO.find(key);
if (securityQuestion == null) {
LOG.error("Could not find security question '" + key + "'");
throw new NotFoundException(String.valueOf(key));
}
SecurityQuestionTO deleted = binder.getSecurityQuestionTO(securityQuestion);
securityQuestionDAO.delete(key);
return deleted;
}
Aggregations