Search in sources :

Example 1 with AsadminRecorderService

use of fish.payara.asadmin.recorder.AsadminRecorderService 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.getDefaultHabitat().getService(AsadminRecorderService.class);
    if (asadminRecorderService.isEnabled()) {
        asadminRecorderService.recordAsadminCommand(commandName, parameters);
    }
    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) 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 RestActionReporter (org.glassfish.admin.rest.utils.xml.RestActionReporter)1 CommandRunner (org.glassfish.api.admin.CommandRunner)1 CommandInvocation (org.glassfish.api.admin.CommandRunner.CommandInvocation)1