use of org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployArchiveCommand 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);
}
use of org.jboss.as.cli.impl.aesh.cmd.deployment.UndeployArchiveCommand 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());
}
}
Aggregations