예제 #1
0
  /**
   * Creates a CLI script for adding socket-binding to AS7
   *
   * @param socketBinding object representing socket-binding
   * @return string containing created CLI script
   * @throws CliScriptException if required attributes are missing
   * @deprecated Generate this from the ModelNode.
   */
  private static String createSocketBindingScript(SocketBindingBean socketBinding)
      throws CliScriptException {
    String errMsg = " in socket-binding must be set.";
    Utils.throwIfBlank(socketBinding.getSocketPort(), errMsg, "Port");
    Utils.throwIfBlank(socketBinding.getSocketName(), errMsg, "Name");

    CliAddScriptBuilder builder = new CliAddScriptBuilder();
    StringBuilder resultScript =
        new StringBuilder("/socket-binding-group=standard-sockets/socket-binding=");

    resultScript.append(socketBinding.getSocketName()).append(":add(");
    resultScript.append("port=").append(socketBinding.getSocketPort());

    builder.addProperty("interface", socketBinding.getSocketInterface());

    resultScript.append(builder.asString()).append(")");

    return resultScript.toString();
  }
예제 #2
0
  /**
   * Creates CliCommandAction for adding a Socket-Binding
   *
   * @param socket Socket-Binding
   * @return created CliCommandAction for adding the Socket-Binding
   * @throws CliScriptException if required attributes for a creation of the CLI command of the
   *     Security-Domain are missing or are empty (security-domain-name)
   */
  public static CliCommandAction createSocketBindingCliAction(SocketBindingBean socket)
      throws CliScriptException {
    String errMsg = " in socket-binding must be set.";
    Utils.throwIfBlank(socket.getSocketPort(), errMsg, "Port");
    Utils.throwIfBlank(socket.getSocketName(), errMsg, "Name");

    ModelNode serverCmd = new ModelNode();
    serverCmd.get(ClientConstants.OP).set(ClientConstants.ADD);
    serverCmd.get(ClientConstants.OP_ADDR).add("socket-binding-group", "standard-sockets");
    serverCmd.get(ClientConstants.OP_ADDR).add("socket-binding", socket.getSocketName());

    serverCmd.get("port").set(socket.getSocketPort());

    CliApiCommandBuilder builder = new CliApiCommandBuilder(serverCmd);
    builder.addProperty("interface", socket.getSocketInterface());

    return new CliCommandAction(
        ServerMigrator.class, createSocketBindingScript(socket), builder.getCommand());
  }