Exemplo n.º 1
0
  /**
   * Creates a CLI script for adding a Connector
   *
   * @param connAS7 object of migrated connector
   * @return string containing created CLI script
   * @throws CliScriptException if required attributes are missing
   * @deprecated Generate this from the ModelNode.
   */
  private static String createConnectorScript(ConnectorAS7Bean connAS7) throws CliScriptException {
    String errMsg = " in connector must be set.";
    Utils.throwIfBlank(connAS7.getScheme(), errMsg, "Scheme");
    Utils.throwIfBlank(connAS7.getSocketBinding(), errMsg, "Socket-binding");
    Utils.throwIfBlank(connAS7.getConnectorName(), errMsg, "Connector name");
    Utils.throwIfBlank(connAS7.getProtocol(), errMsg, "Protocol");

    CliAddScriptBuilder builder = new CliAddScriptBuilder();
    StringBuilder resultScript = new StringBuilder("/subsystem=web/connector=");

    resultScript.append(connAS7.getConnectorName()).append(":add(");

    builder.addProperty("socket-binding", connAS7.getSocketBinding());
    builder.addProperty("enable-lookups", connAS7.getEnableLookups());
    builder.addProperty("max-post-size", connAS7.getMaxPostSize());
    builder.addProperty("max-save-post-size", connAS7.getMaxSavePostSize());
    builder.addProperty("max-connections", connAS7.getMaxConnections());
    builder.addProperty("protocol", connAS7.getProtocol());
    builder.addProperty("proxy-name", connAS7.getProxyName());
    builder.addProperty("proxy-port", connAS7.getProxyPort());
    builder.addProperty("redirect-port", connAS7.getRedirectPort());
    builder.addProperty("scheme", connAS7.getScheme());
    builder.addProperty("secure", connAS7.getSecure());
    builder.addProperty("enabled", connAS7.getEnabled());

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

    return resultScript.toString();
  }
Exemplo n.º 2
0
  /**
   * Creates a CLI script for adding virtual-server to AS7
   *
   * @param virtualServer object representing migrated virtual-server
   * @return string containing created CLI script
   * @deprecated Generate this from the ModelNode.
   */
  private static String createVirtualServerScript(VirtualServerBean virtualServer)
      throws CliScriptException {
    String errMsg = "in virtual-server (engine in AS5) must be set";
    Utils.throwIfBlank(virtualServer.getVirtualServerName(), errMsg, "Server name");

    CliAddScriptBuilder builder = new CliAddScriptBuilder();
    StringBuilder resultScript = new StringBuilder("/subsystem=web/virtual-server=");
    resultScript.append(virtualServer.getVirtualServerName()).append(":add(");

    builder.addProperty("enable-welcome-root", virtualServer.getEnableWelcomeRoot());
    builder.addProperty("default-web-module", virtualServer.getDefaultWebModule());

    String aliases = "";
    if (virtualServer.getAliasName() != null) {
      StringBuilder aliasBuilder = new StringBuilder();
      for (String alias : virtualServer.getAliasName()) {
        aliasBuilder.append(", \"").append(alias).append("\"");
      }

      aliases = aliasBuilder.toString();
      aliases = aliases.replaceFirst(", ", "");

      if (!aliases.isEmpty()) {
        aliases = ", alias=[" + aliases + "]";
      }
    }

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

    return resultScript.toString();
  }
Exemplo n.º 3
0
  /**
   * Creates CliCommandAction for adding a Virtual-Server
   *
   * @param server Virtual-Server
   * @return created CliCommandAction for adding the Virtual-Server
   * @throws CliScriptException if required attributes for a creation of the CLI command of the
   *     Virtual-Server are missing or are empty (server-name)
   */
  public static CliCommandAction createVirtualServerCliAction(VirtualServerBean server)
      throws CliScriptException {
    String errMsg = "in virtual-server (engine in AS5) must be set";
    Utils.throwIfBlank(server.getVirtualServerName(), errMsg, "Server name");

    ModelNode serverCmd = new ModelNode();
    serverCmd.get(ClientConstants.OP).set(ClientConstants.ADD);
    serverCmd.get(ClientConstants.OP_ADDR).add("subsystem", "web");
    serverCmd.get(ClientConstants.OP_ADDR).add("virtual-server", server.getVirtualServerName());

    if (server.getAliasName() != null) {
      ModelNode aliasesNode = new ModelNode();
      for (String alias : server.getAliasName()) {
        ModelNode aliasNode = new ModelNode();

        aliasNode.set(alias);
        aliasesNode.add(aliasNode);
      }
      serverCmd.get("alias").set(aliasesNode);
    }

    CliApiCommandBuilder builder = new CliApiCommandBuilder(serverCmd);

    builder.addProperty("enable-welcome-root", server.getEnableWelcomeRoot());
    builder.addProperty("default-web-module", server.getDefaultWebModule());

    return new CliCommandAction(
        ServerMigrator.class, createVirtualServerScript(server), builder.getCommand());
  }
Exemplo n.º 4
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();
  }
Exemplo n.º 5
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());
  }
Exemplo n.º 6
0
  /**
   * Creates a list of CliCommandActions for adding a Connector
   *
   * @param connAS7 Connector
   * @return created list containing CliCommandActions for adding the Connector
   * @throws CliScriptException if required attributes for a creation of the CLI command of the
   *     Connector are missing or are empty (socket-binding, connector-name, protocol)
   */
  private static List<CliCommandAction> createConnectorCliAction(ConnectorAS7Bean connAS7)
      throws CliScriptException {
    String errMsg = " in connector must be set.";
    Utils.throwIfBlank(connAS7.getScheme(), errMsg, "Scheme");
    Utils.throwIfBlank(connAS7.getSocketBinding(), errMsg, "Socket-binding");
    Utils.throwIfBlank(connAS7.getConnectorName(), errMsg, "Connector name");
    Utils.throwIfBlank(connAS7.getProtocol(), errMsg, "Protocol");

    List<CliCommandAction> actions = new LinkedList();

    actions.add(
        new CliCommandAction(
            ServerMigrator.class,
            createConnectorScript(connAS7),
            createConnectorModelNode(connAS7)));

    if (connAS7.getScheme().equals("https")) {
      actions.add(
          new CliCommandAction(
              ServerMigrator.class, createSSLConfScript(connAS7), createSSLConfModelNode(connAS7)));
    }

    return actions;
  }