use of org.jboss.as.cli.impl.aesh.cmd.deployment.EnableCommand in project wildfly-core by wildfly.
the class DeployHandler method buildRequestWithoutHeaders.
@Override
public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException {
ParsedCommandLine args = ctx.getParsedCommandLine();
boolean l = this.l.isPresent(args);
if (!args.hasProperties() || l) {
throw new CommandFormatException("No Option");
}
final boolean unmanaged = this.unmanaged.isPresent(args);
final String path = this.path.getValue(args);
final String name = this.name.getValue(args);
final String rtName = this.rtName.getValue(args);
final String url = this.url.getValue(args);
final boolean force = this.force.isPresent(args);
final boolean disabled = this.disabled.isPresent(args);
final boolean enabled = this.enabled.isPresent(args);
final String serverGroups = this.serverGroups.getValue(args);
final boolean allServerGroups = this.allServerGroups.isPresent(args);
final ModelNode headersNode = headers.toModelNode(ctx);
if (headersNode != null && headersNode.getType() != ModelType.OBJECT) {
throw new CommandFormatException("--headers option has wrong value '" + headersNode + "'");
}
if (path == null && url == null) {
if (name == null) {
throw new CommandFormatException("Filesystem path, --url or --name is " + " required.");
}
if (name.equals(ALL)) {
if (force || disabled) {
throw new CommandFormatException("force and disabled can't be used " + "when deploying all disabled deployments");
}
EnableAllCommand command = new EnableAllCommand(ctx);
command.allServerGroups = allServerGroups;
command.headers = headersNode;
command.serverGroups = serverGroups;
return command.buildRequest(ctx);
} else {
EnableCommand command = new EnableCommand(ctx);
command.allServerGroups = allServerGroups;
command.headers = headersNode;
command.serverGroups = serverGroups;
command.name = name;
return command.buildRequest(ctx);
}
}
if (path != null) {
if (url != null) {
throw new CommandFormatException("Filesystem path and --url can't be used together.");
}
File f = new File(path);
DMRCommand c;
if (DeployArchiveCommand.isCliArchive(f)) {
DeployArchiveCommand command = new DeployArchiveCommand(ctx);
command.file = f;
command.script = this.script.getValue(args);
c = command;
} else {
DeployFileCommand command = new DeployFileCommand(ctx, REPLACE_OPTION);
command.allServerGroups = allServerGroups;
command.disabled = disabled;
command.enabled = enabled;
command.file = f;
command.replace = force;
command.headers = headersNode;
command.name = name;
command.runtimeName = rtName;
command.serverGroups = serverGroups;
command.unmanaged = unmanaged;
c = command;
}
return c.buildRequest(ctx);
}
if (url != null) {
if (path != null) {
throw new CommandFormatException("Filesystem path and --url can't be " + "used together.");
}
DeployUrlCommand command = new DeployUrlCommand(ctx, REPLACE_OPTION);
command.allServerGroups = allServerGroups;
command.disabled = disabled;
command.enabled = enabled;
try {
command.deploymentUrl = new URL(url);
} catch (MalformedURLException ex) {
throw new CommandFormatException(ex);
}
command.replace = force;
command.headers = headersNode;
command.runtimeName = rtName;
command.serverGroups = serverGroups;
return command.buildRequest(ctx);
}
throw new CommandFormatException("Invalid Options.");
}
use of org.jboss.as.cli.impl.aesh.cmd.deployment.EnableCommand in project wildfly-core by wildfly.
the class DeployHandler method doHandle.
@Override
protected void doHandle(CommandContext ctx) throws CommandLineException {
ParsedCommandLine args = ctx.getParsedCommandLine();
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 boolean unmanaged = this.unmanaged.isPresent(args);
final String path = this.path.getValue(args);
final String name = this.name.getValue(args);
final String rtName = this.rtName.getValue(args);
final String url = this.url.getValue(args);
final boolean force = this.force.isPresent(args);
final boolean disabled = this.disabled.isPresent(args);
final boolean enabled = this.enabled.isPresent(args);
final String serverGroups = this.serverGroups.getValue(args);
final boolean allServerGroups = this.allServerGroups.isPresent(args);
final ModelNode headersNode = headers.toModelNode(ctx);
if (headersNode != null && headersNode.getType() != ModelType.OBJECT) {
throw new CommandFormatException("--headers option has wrong value '" + headersNode + "'");
}
if (path == null && url == null) {
if (name == null) {
throw new CommandLineException("Filesystem path, --url or --name is " + " required.");
}
if (name.equals(ALL)) {
if (force || disabled) {
throw new CommandLineException("force and disabled can't be used " + "when deploying all disabled deployments");
}
EnableAllCommand command = new EnableAllCommand(ctx);
command.allServerGroups = allServerGroups;
command.headers = headersNode;
command.serverGroups = serverGroups;
try {
command.execute(ctx);
} catch (CommandException ex) {
throw new CommandLineException(ex.getLocalizedMessage());
}
return;
} else {
EnableCommand command = new EnableCommand(ctx);
command.allServerGroups = allServerGroups;
command.headers = headersNode;
command.serverGroups = serverGroups;
command.name = name;
try {
command.execute(ctx);
} catch (CommandException ex) {
throw new CommandLineException(ex.getLocalizedMessage());
}
return;
}
}
if (path != null) {
if (url != null) {
throw new CommandLineException("Filesystem path and --url can't be used together.");
}
File f = new File(path);
LegacyBridge c;
if (DeployArchiveCommand.isCliArchive(f)) {
DeployArchiveCommand command = new DeployArchiveCommand(ctx);
command.file = f;
command.script = this.script.getValue(args);
c = command;
} else {
DeployFileCommand command = new DeployFileCommand(ctx, REPLACE_OPTION);
command.allServerGroups = allServerGroups;
command.disabled = disabled;
command.enabled = enabled;
command.file = f;
command.replace = force;
command.headers = headersNode;
command.name = name;
command.runtimeName = rtName;
command.serverGroups = serverGroups;
command.unmanaged = unmanaged;
c = command;
}
try {
c.execute(ctx);
} catch (CommandException ex) {
throw new CommandLineException(ex.getLocalizedMessage());
}
return;
}
if (url != null) {
if (path != null) {
throw new CommandLineException("Filesystem path and --url can't be " + "used together.");
}
DeployUrlCommand command = new DeployUrlCommand(ctx, REPLACE_OPTION);
command.allServerGroups = allServerGroups;
command.disabled = disabled;
command.enabled = enabled;
try {
command.deploymentUrl = new URL(url);
} catch (MalformedURLException ex) {
throw new CommandLineException(ex);
}
command.replace = force;
command.headers = headersNode;
command.runtimeName = rtName;
command.serverGroups = serverGroups;
try {
command.execute(ctx);
} catch (CommandException ex) {
throw new CommandLineException(ex.getLocalizedMessage());
}
}
}
Aggregations