|
|
|
@ -3,12 +3,10 @@ package net.pingex.dcf.commands.audit;
|
|
|
|
|
import net.pingex.dcf.commands.Context;
|
|
|
|
|
import net.pingex.dcf.commands.audit.basic.EnabledCheck;
|
|
|
|
|
import net.pingex.dcf.commands.audit.basic.ScopeCheck;
|
|
|
|
|
import net.pingex.dcf.permissions.PermissionCheck;
|
|
|
|
|
import org.apache.logging.log4j.LogManager;
|
|
|
|
|
import org.apache.logging.log4j.Logger;
|
|
|
|
|
import java.util.Collection;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
import java.util.TreeSet;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The Audit Manager stores all components and executes an audit when told to, usually from CommandHandler.
|
|
|
|
@ -26,8 +24,7 @@ public class AuditManager
|
|
|
|
|
|
|
|
|
|
static
|
|
|
|
|
{
|
|
|
|
|
add(new EnabledCheck());
|
|
|
|
|
add(new ScopeCheck());
|
|
|
|
|
addAll(Arrays.asList(new EnabledCheck(), new ScopeCheck(), new PermissionCheck()));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -46,6 +43,10 @@ public class AuditManager
|
|
|
|
|
AuditResult result = component.doAudit(context);
|
|
|
|
|
resultBuilder.appendAuditResult(component, result);
|
|
|
|
|
LOGGER.trace("Auditing component {} [{}].", component.name(), result.getOpcode());
|
|
|
|
|
|
|
|
|
|
if(result.hasSubAudits())
|
|
|
|
|
for(Map.Entry<IAuditComponentProvider, AuditResult> i : result.getSubAuditsResults())
|
|
|
|
|
LOGGER.trace("=> Subaudit {} [{}]", i.getKey().name(), i.getValue().getOpcode());
|
|
|
|
|
}
|
|
|
|
|
resultBuilder.setOpcode(resultBuilder.getSubAuditsResults().stream().min(Comparator.comparing(entry -> entry.getValue().getOpcode())).get().getValue().getOpcode());
|
|
|
|
|
resultBuilder.setMessage(resultBuilder.getSubAuditsResults().stream().min(Comparator.comparing(entry -> entry.getValue().getOpcode())).get().getValue().getMessage());
|
|
|
|
|