Package org.hpi.dialogue.protocol.service

Examples of org.hpi.dialogue.protocol.service.HPIClientProtocol


        try {
            this.validate();

            String serverAddress = this.parent.getServerAddress().getString();
            int portNumber = Integer.parseInt(this.parent.getPortNumber().getString());
            this.clientProtocol = new HPIClientProtocol(serverAddress, portNumber);

            String nickname = this.parent.getUser().getString();
            String password = this.parent.getPassword().getString();
            this.loggedUser = new User(nickname, password);
View Full Code Here


    }
   
    public void run() {
        Alert a = null;
        try {
            HPIClientProtocol hpiClientProtocol = this.parent.getParent().getParent().getHPIClientProtocol();
            LoginResponse loginResponse = this.parent.getParent().getParent().getLoginResponse();
           
            ExecuteInvokerResponse executeInvokerResponse = hpiClientProtocol.executeInvoker(loginResponse.getSessionId(), this.parent.getInvokerId());
            if (executeInvokerResponse.getStatus().equals(Response.Status.SUCCESS)) {
                HPIUiAlert.show("Execution Invoker Response", executeInvokerResponse.getMessage(), "Ok", this.parent.getForm());
            } else {
                HPIUiAlert.show("Error on execution Invoker", executeInvokerResponse.getMessage(), "Ok", this.parent.getForm());
            }
View Full Code Here

   
    public void run() {
        try {
            LoginResponse loginResponse = this.parent.getParent().getLoginResponse();
            this.invokerId = this.parent.getFormList().getString(this.parent.getFormList().getSelectedIndex());
            HPIClientProtocol clientProtocol = this.parent.getParent().getHPIClientProtocol();
           
            DescribeInvokerResponse describeInvokerResponse = clientProtocol.describeInvoker(loginResponse.getSessionId(), invokerId);
            if (describeInvokerResponse.getStatus().equals(Response.Status.SUCCESS)) {
                Invoker invoker = describeInvokerResponse.getInvoker();
               
                this.lblInvokerId = new StringItem("Invoker Id: ",  invoker.getId());
                this.lblInvokerDescription = new StringItem("Invoker Description: ",  invoker.getDescription());
View Full Code Here

      SSDContextManager ssdCtx = SSDContextManager.build(settingsFile);
      SSDRootObject ssdSettingsData = ssdCtx.getRootObject();

      SSDObjectNode ssdConfiguration = ssdSettingsData.getNode(HPIConstants.CONFIGURATIONS_CONFIG_SERVER);
      int portNumber = Integer.parseInt(ssdConfiguration.getLeaf(HPIConstants.CONFIGURATIONS_PORT_NUMBER).getValue());
      HPIClientProtocol clientProtocol = new HPIClientProtocol("127.0.0.1", portNumber);
      ServerShutdownResponse shutdownResponse = clientProtocol.serverShutdown();
     
      log.info(shutdownResponse.getMessage());
    } catch (Exception e) {
      log.error(e);
      System.exit(1);
View Full Code Here

    if (server.contains(":")) {
      String[] serverAndPort = server.split(":");
      server = serverAndPort[0];
      port = Integer.parseInt(serverAndPort[1]);
    }
    return new HPIClientProtocol(server, port);
  }
View Full Code Here

 
  /**
   * @param args
   */
  public static void main(String[] args) {
    HPIClientProtocol clientProtocol = null;
    try {
      ConsoleParameters consoleParameters = ConsoleParameters.getInstance(args);
     
      // -server[-s]
      String serverParam = null;
      if (!GeneralsHelper.isStringOk(serverParam = consoleParameters.getValue("-server")) &&
          !GeneralsHelper.isStringOk(serverParam = consoleParameters.getValue("-s"))) {
        throw new HPIUsageException();
      }
     
      // -user[-u]
      String userParam = null;
      if (!GeneralsHelper.isStringOk(userParam = consoleParameters.getValue("-user")) &&
          !GeneralsHelper.isStringOk(userParam = consoleParameters.getValue("-u"))) {
        throw new HPIUsageException();
      }
     
      // -password[-p]
      String passwordParam = null;
      if (!GeneralsHelper.isStringOk(passwordParam = consoleParameters.getValue("-password")) &&
          !GeneralsHelper.isStringOk(passwordParam = consoleParameters.getValue("-p"))) {
        throw new HPIUsageException();
      }
     
      // create the client protocol instance and tries do login
      clientProtocol = connectClientProtocol(serverParam.trim());
      LoginResponse loginResponse = clientProtocol.doLogin(new User(userParam, passwordParam));
      if (loginResponse.getStatus().equals(Response.Status.SUCCESS)) {
        BufferedReader stdIn = new BufferedReader(new InputStreamReader(System.in));
        String command = null;
        System.out.print("User connected successfully\n");
        printPossibilities();
        System.out.print("client's command > ");
       
        while ((command = stdIn.readLine()) != null) {
          command = command.trim();
          command = command.replace(";", "");
          command = "-" + command;
          ConsoleParameters innerParam = ConsoleParameters.getInstance(command.trim().split(" "));
         
          String paramValue = null;
          String response = null;
         
          if (GeneralsHelper.isStringOk(paramValue = innerParam.getValue(ListInvokersService.COMMAND))) { // list
            response = new ListInvokersService(loginResponse.getSessionId()).execute(clientProtocol);
          } else if (GeneralsHelper.isStringOk(paramValue = innerParam.getValue(DescribeInvokerService.COMMAND))) { // describe
            response = new DescribeInvokerService(loginResponse.getSessionId(), paramValue).execute(clientProtocol);
          } else if (GeneralsHelper.isStringOk(paramValue = innerParam.getValue(ExecuteInvokerService.COMMAND))) { // execute
            response = new ExecuteInvokerService(loginResponse.getSessionId(), paramValue).execute(clientProtocol);
          } else if (GeneralsHelper.isStringOk(paramValue = innerParam.getValue(ServerShutdownService.COMMAND))) { // shutdown
            response = new ServerShutdownService().execute(clientProtocol);
          } else if (GeneralsHelper.isStringOk(paramValue = innerParam.getValue(LogoffService.COMMAND))) { // exit
            response = new LogoffService(loginResponse.getSessionId()).execute(clientProtocol);
           
            System.out.println(response);
            System.out.println("Bye!");
            break;
          } else {
            printPossibilities();
          }
         
          if (GeneralsHelper.isStringOk(response)) {
            System.out.println("Server's response > " + response);
          }
          System.out.print("client's command > ");
        }
      } else {
        throw new IllegalStateException(loginResponse.getMessage());
      }
    } catch (HPIUsageException e) {
      System.out.println("hpi (all parameters are mandatories)");
      System.out.println("  -server[-s]    the target server (e.g.)\"127.0.0.1\", the port number is optional (e.g.)\"127.0.0.1:4444\" default is \"4444\"");
      System.out.println("  -user[u]       the user name");
      System.out.println("  -password[p]   the user password");
    } catch (Exception e) {
      System.out.println("Error: " + e.getMessage());
      e.printStackTrace();
    } finally {
      if (clientProtocol != null) {
        clientProtocol.closeSocket();
      }
    }

  }
View Full Code Here

TOP

Related Classes of org.hpi.dialogue.protocol.service.HPIClientProtocol

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.