Package com.trendrr.strest

Examples of com.trendrr.strest.StrestHttpException


  public void handleGET(DynMap params) throws StrestException {
    if (!Values.UPGRADE.equalsIgnoreCase(request.getHeader(CONNECTION)) ||
        !WEBSOCKET.equalsIgnoreCase(request.getHeader(Names.UPGRADE))) {
      log.info("WEBSOCKET NOT AN UPGRADE REQUEST");
      throw new StrestHttpException(400, "Websocket upgrade path, no upgrade headers present");
    }
   
    /*
     * This logic is cut and pasted from the netty websocket handler
     * 
View Full Code Here


       
       
          } catch (StrestHttpException e) {
            throw e;
          } catch (Exception x) {
            StrestHttpException e = StrestHttpException.INTERNAL_SERVER_ERROR();
            e.setCause(x);
            log.error("Caught", x);
            throw e;
          }
    } catch (StrestHttpException e) {
      response.status(e.getCode(), e.getMessage());
      response.txnStatus(StrestUtil.HEADERS.TXN_STATUS_VALUES.COMPLETE);
      //run the error filters
      if (controller != null) {
        for (StrestControllerFilter f : controller.getFilters()) {
                f.error(controller, response.getResponse(), e);
View Full Code Here

        lock.end();
      }
    }
   
    if (!StrestUtil.isTxnMulti(this.request)) {
      throw new StrestHttpException(400, "Strest-Txn-Accept must be multi for this action!");
    }   
    connections.addConnection(this.getTxnConnection());
    this.setSendResponse(false); //make sure to not send a default response.
  }
View Full Code Here

 
  public void register(String username, StrestConnectionTxn con) throws StrestException {
   
    if (onlineNow.putIfAbsent(username, con) != null) {
      //already a user with that name
      throw new StrestHttpException(501, "That username is taken");
    }
   
    //store the username in the connection local storage
    con.getChannelStorage().put("username", username);
   
View Full Code Here

  public void notifyMessage(StrestConnectionTxn con) throws StrestException {
    String username = (String)con.getChannelStorage().get("username");
    if (this.notifyMessage.putIfAbsent(username, con) != null) {
      //already a user with that name
      throw new StrestHttpException(501, "That username is registered for messages!");
    }
   

  }
View Full Code Here

  }
 
  public void send(String to, String from, String message) throws StrestException {
    StrestConnectionTxn con = this.notifyMessage.get(to);
    if (con == null) {
      throw new StrestHttpException(501, "Unknown user");
    }
    DynMap mp = new DynMap();
    mp.put("to", to);
    mp.put("from", from);
    mp.put("message", message);
View Full Code Here

 
  @Override
  public void handleGET(DynMap params) throws StrestException {
    String username = params.get(String.class, "username");
    if (username == null) {
      throw new StrestHttpException(501, "username is mandatory!");
    }
    Users.instance().register(username, this.getTxnConnection());
    this.response.setHeader(StrestUtil.HEADERS.TXN_STATUS, StrestUtil.HEADERS.TXN_STATUS_VALUES.CONTINUE);
  }
View Full Code Here

TOP

Related Classes of com.trendrr.strest.StrestHttpException

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.