Search in sources :

Example 1 with LoggerTO

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()));
    }
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) Test(org.junit.jupiter.api.Test)

Example 2 with LoggerTO

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());
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) Test(org.junit.jupiter.api.Test)

Example 3 with LoggerTO

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;
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) ArrayList(java.util.ArrayList) AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName)

Example 4 with LoggerTO

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);
    }
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) WebServiceException(javax.xml.ws.WebServiceException) ArrayList(java.util.ArrayList) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException)

Example 5 with LoggerTO

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);
}
Also used : LoggerTO(org.apache.syncope.common.lib.log.LoggerTO) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) AuditLoggerName(org.apache.syncope.common.lib.types.AuditLoggerName) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

LoggerTO (org.apache.syncope.common.lib.log.LoggerTO)15 AuditLoggerName (org.apache.syncope.common.lib.types.AuditLoggerName)5 Test (org.junit.jupiter.api.Test)5 ArrayList (java.util.ArrayList)4 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)4 WebServiceException (javax.xml.ws.WebServiceException)3 LoggerContext (org.apache.logging.log4j.core.LoggerContext)2 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)2 Logger (org.apache.syncope.core.persistence.api.entity.Logger)2 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 LinkedHashMap (java.util.LinkedHashMap)1 Properties (java.util.Properties)1 Response (javax.ws.rs.core.Response)1 LoggerConfig (org.apache.logging.log4j.core.config.LoggerConfig)1 AuditReportletConf (org.apache.syncope.common.lib.report.AuditReportletConf)1 ConnInstanceTO (org.apache.syncope.common.lib.to.ConnInstanceTO)1 ConnPoolConfTO (org.apache.syncope.common.lib.to.ConnPoolConfTO)1