Search in sources :

Example 1 with DisableCommand

use of org.jboss.as.cli.impl.aesh.cmd.deployment.DisableCommand in project wildfly-core by wildfly.

the class UndeployHandler method buildRequestWithoutHeaders.

@Override
public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException {
    final ParsedCommandLine args = ctx.getParsedCommandLine();
    String p = this.path.getValue(args);
    if (p != null) {
        File f = new File(p);
        if (DeployArchiveCommand.isCliArchive(f)) {
            UndeployArchiveCommand command = new UndeployArchiveCommand(ctx);
            command.file = f;
            command.script = script.getValue(args);
            return command.buildRequest(ctx);
        }
    }
    if (name == null) {
        throw new CommandFormatException("Deployment name is missing.");
    }
    UndeployCommand command = null;
    boolean keepContent = this.keepContent.isPresent(args);
    if (keepContent) {
        command = new DisableCommand(ctx);
    } else {
        command = new UndeployCommand(ctx);
    }
    final String name = this.name.getValue(ctx.getParsedCommandLine());
    command.allRelevantServerGroups = allRelevantServerGroups.isPresent(args);
    if (name != null) {
        command.name = name;
    }
    command.serverGroups = serverGroups.getValue(args);
    return command.buildRequest(ctx);
}
Also used : UndeployCommand(org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployCommand) CommandFormatException(org.jboss.as.cli.CommandFormatException) ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) File(java.io.File) DisableCommand(org.jboss.as.cli.impl.aesh.cmd.deployment.DisableCommand) UndeployArchiveCommand(org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployArchiveCommand)

Example 2 with DisableCommand

use of org.jboss.as.cli.impl.aesh.cmd.deployment.DisableCommand in project wildfly-core by wildfly.

the class UndeployHandler method doHandle.

@Override
protected void doHandle(CommandContext ctx) throws CommandLineException {
    final ParsedCommandLine args = ctx.getParsedCommandLine();
    final boolean l = this.l.isPresent(args);
    if (!args.hasProperties() || l) {
        try {
            ListCommand.listDeployments(ctx, l);
        } catch (CommandException ex) {
            throw new CommandLineException(ex.getLocalizedMessage());
        }
        return;
    }
    final String path = this.path.getValue(args);
    final File f;
    if (path != null) {
        f = new File(path);
        if (DeployArchiveCommand.isCliArchive(f)) {
            UndeployArchiveCommand command = new UndeployArchiveCommand(ctx);
            command.file = f;
            command.script = script.getValue(args);
            try {
                command.execute(ctx);
            } catch (CommandException ex) {
                throw new CommandLineException(ex.getLocalizedMessage());
            }
            return;
        }
    }
    final String name = this.name.getValue(ctx.getParsedCommandLine());
    if (name == null) {
        try {
            ListCommand.listDeployments(ctx, l);
        } catch (CommandException ex) {
            throw new CommandLineException(ex.getLocalizedMessage());
        }
        return;
    }
    UndeployCommand command = null;
    boolean keepContent = this.keepContent.isPresent(args);
    if (keepContent) {
        command = new DisableCommand(ctx);
    } else {
        command = new UndeployCommand(ctx);
    }
    command.allRelevantServerGroups = allRelevantServerGroups.isPresent(args);
    final ModelNode headersNode = headers.toModelNode(ctx);
    if (headersNode != null && headersNode.getType() != ModelType.OBJECT) {
        throw new CommandFormatException("--headers option has wrong value '" + headersNode + "'");
    }
    command.headers = headersNode;
    if (name != null) {
        command.name = name;
    }
    command.serverGroups = serverGroups.getValue(args);
    try {
        command.execute(ctx);
    } catch (CommandException ex) {
        throw new CommandLineException(ex.getLocalizedMessage());
    }
}
Also used : UndeployCommand(org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployCommand) CommandFormatException(org.jboss.as.cli.CommandFormatException) ParsedCommandLine(org.jboss.as.cli.operation.ParsedCommandLine) CommandException(org.aesh.command.CommandException) ModelNode(org.jboss.dmr.ModelNode) File(java.io.File) CommandLineException(org.jboss.as.cli.CommandLineException) DisableCommand(org.jboss.as.cli.impl.aesh.cmd.deployment.DisableCommand) UndeployArchiveCommand(org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployArchiveCommand)

Aggregations

File (java.io.File)2 CommandFormatException (org.jboss.as.cli.CommandFormatException)2 DisableCommand (org.jboss.as.cli.impl.aesh.cmd.deployment.DisableCommand)2 UndeployArchiveCommand (org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployArchiveCommand)2 UndeployCommand (org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployCommand)2 ParsedCommandLine (org.jboss.as.cli.operation.ParsedCommandLine)2 CommandException (org.aesh.command.CommandException)1 CommandLineException (org.jboss.as.cli.CommandLineException)1 ModelNode (org.jboss.dmr.ModelNode)1