use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerITCase method listAudits.
@Test
public void listAudits() throws ParseException {
List<LoggerTO> audits = loggerService.list(LoggerType.AUDIT);
assertNotNull(audits);
assertFalse(audits.isEmpty());
for (LoggerTO audit : audits) {
assertNotNull(AuditLoggerName.fromLoggerName(audit.getKey()));
}
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerITCase method setLevel.
@Test
public void setLevel() {
List<LoggerTO> loggers = loggerService.list(LoggerType.LOG);
assertNotNull(loggers);
int startSize = loggers.size();
LoggerTO logger = new LoggerTO();
logger.setKey("TEST");
logger.setLevel(LoggerLevel.INFO);
loggerService.update(LoggerType.LOG, logger);
logger = loggerService.read(LoggerType.LOG, logger.getKey());
assertNotNull(logger);
assertEquals(LoggerLevel.INFO, logger.getLevel());
loggers = loggerService.list(LoggerType.LOG);
assertNotNull(loggers);
assertEquals(startSize + 1, loggers.size());
// TEST Delete
loggerService.delete(LoggerType.LOG, "TEST");
loggers = loggerService.list(LoggerType.LOG);
assertNotNull(loggers);
assertEquals(startSize, loggers.size());
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerWrapper method unwrap.
public static List<LoggerTO> unwrap(final Collection<AuditLoggerName> auditNames) {
List<LoggerTO> result = new ArrayList<>();
for (AuditLoggerName name : auditNames) {
LoggerTO loggerTO = new LoggerTO();
loggerTO.setKey(name.toLoggerName());
loggerTO.setLevel(LoggerLevel.DEBUG);
result.add(loggerTO);
}
return result;
}
use of org.apache.syncope.common.lib.log.LoggerTO in project syncope by apache.
the class LoggerCreate method create.
public void create() {
if (input.parameterNumber() >= 1) {
final List<LoggerTO> loggerTOs = new ArrayList<>();
boolean failed = false;
for (String parameter : input.getParameters()) {
LoggerTO loggerTO = new LoggerTO();
Pair<String, String> pairParameter = Input.toPairParameter(parameter);
try {
loggerTO.setKey(pairParameter.getKey());
loggerTO.setLevel(LoggerLevel.valueOf(pairParameter.getValue()));
loggerSyncopeOperations.update(loggerTO);
loggerTOs.add(loggerTO);
} catch (WebServiceException | SyncopeClientException | IllegalArgumentException ex) {
LOG.error("Error creating logger", ex);
loggerResultManager.typeNotValidError("logger level", input.firstParameter(), CommandUtils.fromEnumToArray(LoggerLevel.class));
failed = true;
break;
}
}
if (!failed) {
loggerResultManager.fromUpdate(loggerTOs);
}
} else {
loggerResultManager.commandOptionError(CREATE_HELP_MESSAGE);
}
}
use of org.apache.syncope.common.lib.log.LoggerTO 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);
}
Aggregations