use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class LoggerLogic method readAudit.
@PreAuthorize("hasRole('" + StandardEntitlement.AUDIT_READ + "')")
@Transactional(readOnly = true)
public LoggerTO readAudit(final String name) {
for (final AuditLoggerName logger : listAudits()) {
if (logger.toLoggerName().equals(name)) {
final LoggerTO loggerTO = new LoggerTO();
loggerTO.setKey(logger.toLoggerName());
loggerTO.setLevel(LoggerLevel.DEBUG);
return loggerTO;
}
}
throw new NotFoundException("Logger " + name);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class LoggerLogic method delete.
private LoggerTO delete(final String name, final LoggerType expectedType) {
Logger syncopeLogger = loggerDAO.find(name);
if (syncopeLogger == null) {
throw new NotFoundException("Logger " + name);
}
if (expectedType != syncopeLogger.getType()) {
throwInvalidLogger(expectedType);
}
LoggerTO loggerToDelete = new LoggerTO();
BeanUtils.copyProperties(syncopeLogger, loggerToDelete);
// remove SyncopeLogger from local storage, so that LoggerLoader won't load this next time
loggerDAO.delete(syncopeLogger);
// set log level to OFF in order to disable configured logger until next reboot
LoggerContext ctx = (LoggerContext) LogManager.getContext(false);
String auditLoggerName = AuditLoggerName.getAuditEventLoggerName(AuthContextUtils.getDomain(), syncopeLogger.getKey());
org.apache.logging.log4j.core.Logger logger = SyncopeConstants.ROOT_LOGGER.equals(name) ? ctx.getLogger(LogManager.ROOT_LOGGER_NAME) : LoggerType.AUDIT.equals(syncopeLogger.getType()) ? ctx.getLogger(auditLoggerName) : ctx.getLogger(name);
logger.setLevel(Level.OFF);
ctx.updateLoggers();
return loggerToDelete;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class NotificationLogic method update.
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_UPDATE + "')")
public NotificationTO update(final NotificationTO notificationTO) {
Notification notification = notificationDAO.find(notificationTO.getKey());
if (notification == null) {
LOG.error("Could not find notification '" + notificationTO.getKey() + "'");
throw new NotFoundException(String.valueOf(notificationTO.getKey()));
}
binder.update(notification, notificationTO);
notification = notificationDAO.save(notification);
return binder.getNotificationTO(notification);
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class NotificationLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.NOTIFICATION_DELETE + "')")
public NotificationTO delete(final String key) {
Notification notification = notificationDAO.find(key);
if (notification == null) {
LOG.error("Could not find notification '" + key + "'");
throw new NotFoundException(String.valueOf(key));
}
NotificationTO deleted = binder.getNotificationTO(notification);
notificationDAO.delete(key);
return deleted;
}
use of org.apache.syncope.core.persistence.api.dao.NotFoundException in project syncope by apache.
the class PolicyLogic method delete.
@PreAuthorize("hasRole('" + StandardEntitlement.POLICY_DELETE + "')")
public <T extends PolicyTO> T delete(final PolicyType type, final String key) {
Policy policy = policyDAO.find(key);
if (policy == null) {
throw new NotFoundException("Policy " + key + " not found");
}
PolicyUtils policyUtils = policyUtilsFactory.getInstance(policy);
if (type != null && policyUtils.getType() != type) {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.InvalidRequest);
sce.getElements().add("Found " + type + ", expected " + policyUtils.getType());
throw sce;
}
T deleted = binder.getPolicyTO(policy);
policyDAO.delete(policy);
return deleted;
}
Aggregations