Package org.crsh.shell

Examples of org.crsh.shell.ShellResponse$Error


    Error handleGenericException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
        String errorId = LoggingUtil.generateErrorId();
        String errorMessage = generateLogErrorMessage(errorId) + " - Processing error";
        log.error(errorMessage, ex);

        Error error = new Error();
        error.setHttpStatusCode("500");
        error.setDeveloperMessage(messageSource.getMessage("api.genericException.developerMessage", null, request.getLocale()));
        error.setUserMessage(messageSource.getMessage("api.genericException.userMessage", null, request.getLocale()));
        error.setMoreInfo("support@knappsack.com");
        error.setErrorId(errorId);

        response.setStatus(500);

        return error;
    }
View Full Code Here


    Error handleEntityNotFoundException(Exception ex, HttpServletRequest request, HttpServletResponse response) {
        String errorId = LoggingUtil.generateErrorId();
        String errorMessage = generateLogErrorMessage(errorId) + " - No entity found";
        log.error(errorMessage, ex);

        Error error = new Error();
        error.setHttpStatusCode("400");
        error.setDeveloperMessage(messageSource.getMessage("api.entityNotFoundException.developerMessage=", null, request.getLocale()));
        error.setUserMessage(messageSource.getMessage("api.entityNotFoundException.userMessage", null, request.getLocale()));
        error.setMoreInfo("support@knappsack.com");
        error.setErrorId(errorId);

        response.setStatus(400);

        return error;
    }
View Full Code Here

    Error handleAccessDeniedException(AccessDeniedException ex, HttpServletRequest request, HttpServletResponse response) {
        String errorId = LoggingUtil.generateErrorId();
        String errorMessage = generateLogErrorMessage(errorId) + " - Access Denied";
        log.error(errorMessage, ex);

        Error error = new Error();
        error.setHttpStatusCode("403");
        error.setDeveloperMessage(messageSource.getMessage("api.accessDenied.developerMessage", null, request.getLocale()));
        error.setUserMessage(messageSource.getMessage("api.accessDenied.userMessage", null, request.getLocale()));
        error.setMoreInfo("support@knappsack.com");
        error.setErrorId(errorId);

        response.setStatus(403);

        return error;
    }
View Full Code Here

      exitMsg = e.getMessage();
      exitStatus = ERROR;
    }
    finally {
      // get command output
      ShellResponse response = context.getResponse();
      if (response instanceof ShellResponse.Ok) {
        // Ok
      }
      else {
        String errorMsg;

        // Set the exit status to Error
        exitStatus = ERROR;

        if (response != null) {
          errorMsg = "Error during command execution : " + response.getMessage();
        }
        else {
          errorMsg = "Error during command execution";
        }
        err.println(errorMsg);
View Full Code Here

    ServerAutomaton server = new ServerAutomaton(serverOOS, serverOIS);

    ShellProcess process = server.createProcess("hello");
    BaseProcessContext context = BaseProcessContext.create(process);
    context.execute();
    ShellResponse response = context.getResponse();
    assertInstance(ShellResponse.Close.class, response);

    //
    assertJoin(t);
  }
View Full Code Here

    final AtomicReference<Throwable> error = new AtomicReference<Throwable>();
    Thread u = new Thread() {
      @Override
      public void run() {
        context.execute();
        ShellResponse response = context.getResponse();
        assertInstance(ShellResponse.Cancelled.class, response);
      }
    };
    u.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {
      public void uncaughtException(Thread t, Throwable e) {
View Full Code Here

  }

  public void process(String request, ShellProcessContext processContext) throws IOException {
    this.processContext = processContext;
    try {
      ShellResponse resp = execute(request);
      processContext.end(resp);
    } finally {
      this.processContext = null;
    }
  }
View Full Code Here

  public ShellProcess createProcess(String request) {
    log.log(Level.FINE, "Invoking request " + request);
    String trimmedRequest = request.trim();
    final StringBuilder msg = new StringBuilder();
    final ShellResponse response;
    if ("bye".equals(trimmedRequest) || "exit".equals(trimmedRequest)) {
      response = ShellResponse.close();
    } else {
      ReplResponse r = repl.eval(this, request);
      if (r instanceof ReplResponse.Response) {
View Full Code Here

  }

  public void execute(ShellProcessContext processContext) {
    ClassLoader previous = crash.setCRaSHLoader();
    try {
      ShellResponse resp;
      thread = Thread.currentThread();

      //
      String userName = crash.user != null ? crash.user.getName() : "unauthenticated";
      CRaSHSession.accessLog.log(Level.FINE, "User " + userName + " executes " + request);
View Full Code Here

    } else {
      throw new IllegalStateException();
    }

    //
    ShellResponse response = null;
    try {
      out.writeObject(new ClientMessage.Execute(processContext.getWidth(), processContext.getHeight(), process.line));
      out.flush();

      //
View Full Code Here

TOP

Related Classes of org.crsh.shell.ShellResponse$Error

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.