Search in sources :

Example 1 with AdminAuditService

use of fish.payara.audit.AdminAuditService in project Payara by payara.

the class ResourceUtil method runCommand.

/**
 * Executes the specified __asadmin command.
 * @param commandName
 * @param parameters
 * @param subject
 * @param managedJob
 * @return
 */
public static RestActionReporter runCommand(String commandName, ParameterMap parameters, Subject subject, boolean managedJob) {
    AsadminRecorderService asadminRecorderService = Globals.get(AsadminRecorderService.class);
    if (asadminRecorderService != null && asadminRecorderService.isEnabled()) {
        asadminRecorderService.recordAsadminCommand(commandName, parameters);
    }
    AdminAuditService auditService = Globals.getDefaultHabitat().getService(AdminAuditService.class);
    if (auditService != null && auditService.isEnabled()) {
        auditService.recordAsadminCommand(commandName, parameters, subject);
    }
    CommandRunner cr = Globals.getDefaultHabitat().getService(CommandRunner.class);
    RestActionReporter ar = new RestActionReporter();
    final CommandInvocation commandInvocation = cr.getCommandInvocation(commandName, ar, subject);
    if (managedJob) {
        commandInvocation.managedJob();
    }
    commandInvocation.parameters(parameters).execute();
    addCommandLog(ar, commandName, parameters);
    return ar;
}
Also used : RestActionReporter(org.glassfish.admin.rest.utils.xml.RestActionReporter) AdminAuditService(fish.payara.audit.AdminAuditService) AsadminRecorderService(fish.payara.asadmin.recorder.AsadminRecorderService) CommandRunner(org.glassfish.api.admin.CommandRunner) CommandInvocation(org.glassfish.api.admin.CommandRunner.CommandInvocation)

Aggregations

AsadminRecorderService (fish.payara.asadmin.recorder.AsadminRecorderService)1 AdminAuditService (fish.payara.audit.AdminAuditService)1 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 CommandInvocation (org.glassfish.api.admin.CommandRunner.CommandInvocation)1