Search in sources :

Example 56 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project pinot by linkedin.

the class HierarchyNode method toString.

public String toString() {
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    //.append(data.baselineValue).append(data.currentValue)
    tsb.append(data.dimensionValues).append(baselineValue).append(currentValue).append("ratio", currentRatio());
    if (parent != null) {
        tsb.append("\t parent").append(parent.data.dimensionValues).append(parent.baselineValue).append(parent.currentValue).append("ratio", parent.currentRatio());
    }
    return tsb.toString();
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder)

Example 57 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project pinot by linkedin.

the class SummaryResponse method toString.

public String toString() {
    ToStringBuilder tsb = new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE);
    tsb.append('\n').append(this.dimensions);
    for (SummaryResponseRow row : getResponseRows()) {
        tsb.append('\n').append(row);
    }
    return tsb.toString();
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder)

Example 58 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project cas by apereo.

the class NullableReturnValueAuditResourceResolver method resolveFrom.

@Override
public String[] resolveFrom(final JoinPoint joinPoint, final Object o) {
    if (o == null) {
        return new String[0];
    }
    if (o instanceof Event) {
        final Event event = Event.class.cast(o);
        final String sourceName = event.getSource().getClass().getSimpleName();
        final String result = new ToStringBuilder(event, ToStringStyle.NO_CLASS_NAME_STYLE).append("event", event.getId()).append("timestamp", new Date(event.getTimestamp())).append("source", sourceName).toString();
        return new String[] { result };
    }
    return this.delegate.resolveFrom(joinPoint, o);
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) Event(org.springframework.webflow.execution.Event) Date(java.util.Date)

Example 59 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project cas by apereo.

the class ServiceAccessEnforcementAuditResourceResolver method resolveFrom.

@Override
public String[] resolveFrom(final JoinPoint auditableTarget, final Object returnValue) {
    Objects.requireNonNull(returnValue, "AuditableExecutionResult must not be null");
    final AuditableExecutionResult serviceAccessCheckResult = AuditableExecutionResult.class.cast(returnValue);
    final String accessCheckOutcome = "Service Access " + BooleanUtils.toString(serviceAccessCheckResult.isExecutionFailure(), "Denied", "Granted");
    final ToStringBuilder builder = new ToStringBuilder(this, NO_CLASS_NAME_STYLE).append("result", accessCheckOutcome);
    serviceAccessCheckResult.getService().ifPresent(service -> builder.append("service", service.getId()));
    serviceAccessCheckResult.getAuthentication().ifPresent(authn -> builder.append("principal", authn.getPrincipal()));
    serviceAccessCheckResult.getRegisteredService().ifPresent(regSvc -> builder.append("requiredAttributes", regSvc.getAccessStrategy().getRequiredAttributes()));
    return new String[] { builder.toString() };
}
Also used : ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) AuditableExecutionResult(org.apereo.cas.audit.AuditableExecutionResult)

Example 60 with ToStringBuilder

use of org.apache.commons.lang3.builder.ToStringBuilder in project cas by apereo.

the class LoggingConfigController method getConfiguration.

/**
 * Gets configuration as JSON.
 * Depends on the log4j core API.
 *
 * @param request  the request
 * @param response the response
 * @return the configuration
 * @throws Exception the exception
 */
@GetMapping(value = "/getConfiguration")
@ResponseBody
public Map<String, Object> getConfiguration(final HttpServletRequest request, final HttpServletResponse response) throws Exception {
    ensureEndpointAccessIsAuthorized(request, response);
    final Collection<Map<String, Object>> configuredLoggers = new HashSet<>();
    getLoggerConfigurations().forEach(config -> {
        final Map<String, Object> loggerMap = new HashMap<>();
        loggerMap.put("name", StringUtils.defaultIfBlank(config.getName(), LOGGER_NAME_ROOT));
        loggerMap.put("state", config.getState());
        if (config.getProperties() != null) {
            loggerMap.put("properties", config.getProperties());
        }
        loggerMap.put("additive", config.isAdditive());
        loggerMap.put("level", config.getLevel().name());
        final Collection<String> appenders = new HashSet<>();
        config.getAppenders().keySet().stream().map(key -> config.getAppenders().get(key)).forEach(appender -> {
            final ToStringBuilder builder = new ToStringBuilder(this, ToStringStyle.JSON_STYLE);
            builder.append("name", appender.getName());
            builder.append("state", appender.getState());
            builder.append("layoutFormat", appender.getLayout().getContentFormat());
            builder.append("layoutContentType", appender.getLayout().getContentType());
            if (appender instanceof FileAppender) {
                builder.append(FILE_PARAM, ((FileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, "(none)");
            }
            if (appender instanceof RandomAccessFileAppender) {
                builder.append(FILE_PARAM, ((RandomAccessFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, "(none)");
            }
            if (appender instanceof RollingFileAppender) {
                builder.append(FILE_PARAM, ((RollingFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, ((RollingFileAppender) appender).getFilePattern());
            }
            if (appender instanceof MemoryMappedFileAppender) {
                builder.append(FILE_PARAM, ((MemoryMappedFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, "(none)");
            }
            if (appender instanceof RollingRandomAccessFileAppender) {
                builder.append(FILE_PARAM, ((RollingRandomAccessFileAppender) appender).getFileName());
                builder.append(FILE_PATTERN_PARAM, ((RollingRandomAccessFileAppender) appender).getFilePattern());
            }
            appenders.add(builder.build());
        });
        loggerMap.put("appenders", appenders);
        configuredLoggers.add(loggerMap);
    });
    final Map<String, Object> responseMap = new HashMap<>();
    responseMap.put("loggers", configuredLoggers);
    return responseMap;
}
Also used : LoggerConfig(org.apache.logging.log4j.core.config.LoggerConfig) CasConfigurationProperties(org.apereo.cas.configuration.CasConfigurationProperties) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) RequestParam(org.springframework.web.bind.annotation.RequestParam) BaseCasMvcEndpoint(org.apereo.cas.web.BaseCasMvcEndpoint) LoggerContext(org.apache.logging.log4j.core.LoggerContext) LoggerFactory(org.slf4j.LoggerFactory) ToStringStyle(org.apache.commons.lang3.builder.ToStringStyle) Level(org.apache.logging.log4j.Level) Autowired(org.springframework.beans.factory.annotation.Autowired) HashMap(java.util.HashMap) AuditActionContext(org.apereo.inspektr.audit.AuditActionContext) StringUtils(org.apache.commons.lang3.StringUtils) Configuration(org.apache.logging.log4j.core.config.Configuration) HashSet(java.util.HashSet) HttpServletRequest(javax.servlet.http.HttpServletRequest) Pair(org.apache.commons.lang3.tuple.Pair) Map(java.util.Map) GetMapping(org.springframework.web.bind.annotation.GetMapping) Log4jLoggerFactory(org.apache.logging.slf4j.Log4jLoggerFactory) Resource(org.springframework.core.io.Resource) PostMapping(org.springframework.web.bind.annotation.PostMapping) Logger(org.slf4j.Logger) ResourceLoader(org.springframework.core.io.ResourceLoader) NonNull(lombok.NonNull) AuditTrailExecutionPlan(org.apereo.cas.audit.AuditTrailExecutionPlan) Collection(java.util.Collection) HttpServletResponse(javax.servlet.http.HttpServletResponse) Set(java.util.Set) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) ControllerUtils(org.apereo.cas.web.report.util.ControllerUtils) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) ModelAndView(org.springframework.web.servlet.ModelAndView) Slf4j(lombok.extern.slf4j.Slf4j) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) Environment(org.springframework.core.env.Environment) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) LocalDate(java.time.LocalDate) PostConstruct(javax.annotation.PostConstruct) Optional(java.util.Optional) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) ILoggerFactory(org.slf4j.ILoggerFactory) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) FileAppender(org.apache.logging.log4j.core.appender.FileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) RandomAccessFileAppender(org.apache.logging.log4j.core.appender.RandomAccessFileAppender) HashMap(java.util.HashMap) RollingFileAppender(org.apache.logging.log4j.core.appender.RollingFileAppender) MemoryMappedFileAppender(org.apache.logging.log4j.core.appender.MemoryMappedFileAppender) ToStringBuilder(org.apache.commons.lang3.builder.ToStringBuilder) HashMap(java.util.HashMap) Map(java.util.Map) RollingRandomAccessFileAppender(org.apache.logging.log4j.core.appender.RollingRandomAccessFileAppender) HashSet(java.util.HashSet) GetMapping(org.springframework.web.bind.annotation.GetMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Aggregations

ToStringBuilder (org.apache.commons.lang3.builder.ToStringBuilder)109 Person (org.apache.commons.lang3.builder.ToStringStyleTest.Person)10 Test (org.junit.Test)10 XWikiToStringBuilder (org.xwiki.text.XWikiToStringBuilder)7 Date (java.util.Date)3 Map (java.util.Map)3 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Optional (java.util.Optional)2 Set (java.util.Set)2 Slf4j (lombok.extern.slf4j.Slf4j)2 StringUtils (org.apache.commons.lang3.StringUtils)2 ToStringStyle (org.apache.commons.lang3.builder.ToStringStyle)2 Pair (org.apache.commons.lang3.tuple.Pair)2 Level (org.apache.logging.log4j.Level)2 LoggerContext (org.apache.logging.log4j.core.LoggerContext)2 FileAppender (org.apache.logging.log4j.core.appender.FileAppender)2 MemoryMappedFileAppender (org.apache.logging.log4j.core.appender.MemoryMappedFileAppender)2 RandomAccessFileAppender (org.apache.logging.log4j.core.appender.RandomAccessFileAppender)2 RollingFileAppender (org.apache.logging.log4j.core.appender.RollingFileAppender)2