private String getFormat(CommandContext ctx) throws CommandFormatException { String reportFormat = formatArg.getValue(ctx.getParsedCommandLine(), false); if (reportFormat == null) { reportFormat = "xml"; } return reportFormat; }
@Override protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ModelNode req = new ModelNode(); final ModelNode address = req.get(Util.ADDRESS); if(ctx.isDomainMode()) { address.add(Util.HOST, host.getValue(ctx.getParsedCommandLine(), true)); address.add(Util.SERVER, server.getValue(ctx.getParsedCommandLine(), true)); } address.add(Util.SUBSYSTEM, Util.DATASOURCES); req.get(Util.OPERATION).set(Util.INSTALLED_DRIVERS_LIST); return req; }
@Override protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final String op = operation.getValue(ctx.getParsedCommandLine()); if (op == null) { throw new CommandFormatException("Invalid operation"); } ModelNode mn = ctx.buildRequest(op); return mn; }
protected ModelNode initRequest(CommandContext ctx) throws CommandFormatException { ModelNode request = new ModelNode(); ModelNode address = request.get(Util.ADDRESS); if(isDependsOnProfile() && ctx.isDomainMode()) { final String profileName = profile.getValue(ctx.getParsedCommandLine()); if(profileName == null) { throw new CommandFormatException("WARNING: --profile argument is required for the complete description."); } address.add(Util.PROFILE, profileName); } for(OperationRequestAddress.Node node : getRequiredAddress()) { address.add(node.getType(), node.getName()); } address.add(getRequiredType(), "?"); return request; }
private void setStringValue(final ParsedCommandLine args, final ModelNode op, ArgumentWithValue arg, String paramName) throws CommandFormatException { if(!arg.isPresent(args)) { return; } final String value = arg.getValue(args); if (value == null) { throw new CommandFormatException(arg.getFullName() + " is missing value."); } op.get(paramName).set(value); } }
protected String[] getLinks(ArgumentWithValue linksArg, final ParsedCommandLine args) throws CommandFormatException { final String deploymentsStr = linksArg.getValue(args); final String[] deployments; if(deploymentsStr == null) { deployments = null; } else { deployments = deploymentsStr.split(",+"); if(deployments.length == 0) { throw new CommandFormatException(linksArg.getFullName() + " is missing value."); } } return deployments; }
@Override public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine(); final String name = this.name.getValue(parsedCmd); if(name == null || name.isEmpty()) { throw new CommandFormatException("Required argument " + this.name.getFullName() + " is not specified."); } final OperationRequestAddress address = getAddress(ctx, false); ModelNode req = Util.buildRequest(ctx, address, Util.READ_ATTRIBUTE); req.get(Util.NAME).set(name); if( resolve.isPresent(parsedCmd)){ req.get(Util.RESOLVE_EXPRESSIONS).set(true); } final String includeDefaults = this.includeDefaults.getValue(parsedCmd); if(includeDefaults != null && !includeDefaults.isEmpty()) { req.get(Util.INCLUDE_DEFAULTS).set(includeDefaults); } if(verbose.isPresent(parsedCmd)) { final ModelNode composite = new ModelNode(); composite.get(Util.OPERATION).set(Util.COMPOSITE); composite.get(Util.ADDRESS).setEmptyList(); final ModelNode steps = composite.get(Util.STEPS); steps.add(req); steps.add(Util.buildRequest(ctx, address, Util.READ_RESOURCE_DESCRIPTION)); req = composite; } return req; }
@Override protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ModelNode req = new ModelNode(); final ModelNode address = req.get(Util.ADDRESS); if(ctx.isDomainMode()) { address.add(Util.HOST, host.getValue(ctx.getParsedCommandLine(), true)); address.add(Util.SERVER, server.getValue(ctx.getParsedCommandLine(), true)); } address.add(Util.SUBSYSTEM, Util.DATASOURCES); req.get(Util.OPERATION).set(Util.INSTALLED_DRIVERS_LIST); return req; }
private void setStringValue(final ParsedCommandLine args, final ModelNode op, ArgumentWithValue arg, String paramName) throws CommandFormatException { if(!arg.isPresent(args)) { return; } final String value = arg.getValue(args); if (value == null) { throw new CommandFormatException(arg.getFullName() + " is missing value."); } op.get(paramName).set(value); } }
@Override protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final String op = operation.getValue(ctx.getParsedCommandLine()); if (op == null) { throw new CommandFormatException("Invalid operation"); } ModelNode mn = ctx.buildRequest(op); return mn; }
private String getFormat(CommandContext ctx) throws CommandFormatException { String reportFormat = formatArg.getValue(ctx.getParsedCommandLine(), false); if (reportFormat == null) { reportFormat = "xml"; } return reportFormat; }
protected String[] getLinks(ArgumentWithValue linksArg, final ParsedCommandLine args) throws CommandFormatException { final String deploymentsStr = linksArg.getValue(args); final String[] deployments; if(deploymentsStr == null) { deployments = null; } else { deployments = deploymentsStr.split(",+"); if(deployments.length == 0) { throw new CommandFormatException(linksArg.getFullName() + " is missing value."); } } return deployments; }
@Override public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine(); final String name = this.name.getValue(parsedCmd); if(name == null || name.isEmpty()) { throw new CommandFormatException("Required argument " + this.name.getFullName() + " is not specified."); } final OperationRequestAddress address = getAddress(ctx, false); ModelNode req = Util.buildRequest(ctx, address, Util.READ_ATTRIBUTE); req.get(Util.NAME).set(name); if( resolve.isPresent(parsedCmd)){ req.get(Util.RESOLVE_EXPRESSIONS).set(true); } final String includeDefaults = this.includeDefaults.getValue(parsedCmd); if(includeDefaults != null && !includeDefaults.isEmpty()) { req.get(Util.INCLUDE_DEFAULTS).set(includeDefaults); } if(verbose.isPresent(parsedCmd)) { final ModelNode composite = new ModelNode(); composite.get(Util.OPERATION).set(Util.COMPOSITE); composite.get(Util.ADDRESS).setEmptyList(); final ModelNode steps = composite.get(Util.STEPS); steps.add(req); steps.add(Util.buildRequest(ctx, address, Util.READ_RESOURCE_DESCRIPTION)); req = composite; } return req; }
@Override protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { format = getFormat(ctx); targetPath = new File(targetFileArg.getValue(ctx.getParsedCommandLine(), true)).toPath(); if (Files.notExists(targetPath.getParent()) || !Files.isDirectory(targetPath.getParent())) { throw new OperationFormatException("Incorrect destination directory " + targetPath.getParent()); } DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder(); builder.setOperationName("product-info"); builder.getModelNode().get(FILE).set(true); builder.getModelNode().get("format").set(format); ModelNode request = builder.buildRequest(); return request; }
protected void setBooleanArgument(final ParsedCommandLine args, final ModelNode op, ArgumentWithValue arg, String paramName) throws CommandFormatException { if(!arg.isPresent(args)) { return; } final String value = arg.getValue(args); if(value == null) { throw new CommandFormatException(arg.getFullName() + " is missing value."); } if(value.equalsIgnoreCase(Util.TRUE)) { op.get(paramName).set(true); } else if(value.equalsIgnoreCase(Util.FALSE)) { op.get(paramName).set(false); } else { throw new CommandFormatException("Invalid value for " + arg.getFullName() + ": '" + value + "'"); } }
@Override protected void doHandle(CommandContext ctx) throws CommandLineException { final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine(); final String actionValue = action.getValue(parsedCmd); if(actionValue == null) { throw new CommandFormatException("Action argument is missing: " + ACTION_ADD + " or " + ACTION_REMOVE); } if(ACTION_ADD.equals(actionValue)) { addModule(ctx, parsedCmd); } else if(ACTION_REMOVE.equals(actionValue)) { removeModule(parsedCmd, ctx); } else { throw new CommandFormatException("Unexpected action '" + actionValue + "', expected values: " + ACTION_ADD + ", " + ACTION_REMOVE); } }
@Override public ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { final ParsedCommandLine parsedCmd = ctx.getParsedCommandLine(); ic.deploymentName = null; ic.serverGroup = null; String deploymentName = name.getValue(parsedCmd); if (name != null) { ic.deploymentName = deploymentName; } ic.serverGroup = serverGroup.getValue(parsedCmd); return ic.buildRequest(ctx); }
protected void assertNotPresent(ArgumentWithoutValue arg, ParsedCommandLine args) throws CommandFormatException { if(arg.isPresent(args)) { throw new CommandFormatException(arg.getFullName() + " is not allowed with action '" + action.getValue(args) + "'"); } }
protected ModelNode initRequest(CommandContext ctx) throws CommandFormatException { ModelNode request = new ModelNode(); ModelNode address = request.get(Util.ADDRESS); if(isDependsOnProfile() && ctx.isDomainMode()) { final String profileName = profile.getValue(ctx.getParsedCommandLine()); if(profileName == null) { throw new CommandFormatException("WARNING: --profile argument is required for the complete description."); } address.add(Util.PROFILE, profileName); } for(OperationRequestAddress.Node node : getRequiredAddress()) { address.add(node.getType(), node.getName()); } address.add(getRequiredType(), "?"); return request; }
@Override protected ModelNode buildRequestWithoutHeaders(CommandContext ctx) throws CommandFormatException { format = getFormat(ctx); targetPath = new File(targetFileArg.getValue(ctx.getParsedCommandLine(), true)).toPath(); if (Files.notExists(targetPath.getParent()) || !Files.isDirectory(targetPath.getParent())) { throw new OperationFormatException("Incorrect destination directory " + targetPath.getParent()); } DefaultOperationRequestBuilder builder = new DefaultOperationRequestBuilder(); builder.setOperationName("product-info"); builder.getModelNode().get(FILE).set(true); builder.getModelNode().get("format").set(format); ModelNode request = builder.buildRequest(); return request; }