Examples of ExceptionProtocol


Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

      }
    }
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message,boolean bool,byte[] key) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes(bool,key));
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
 
  public void ContextException(GaeaContext context,Protocol protocol,GaeaResponse response,String message) throws Exception{
    ExceptionProtocol ep = ExceptionHelper.createError(new Exception());
    ep.setErrorMsg(message);
    protocol.setSdpEntity(ep);
    response.setResponseBuffer(protocol.toBytes());
    context.setGaeaResponse(response);
    this.setInvokeAndFilter(context);
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

   *
   * @param sfe
   * @return
   */
  public static ExceptionProtocol createError(ServiceFrameException sfe) {
    ExceptionProtocol error = new ExceptionProtocol();
    if (sfe != null) {
      if (sfe.getState() == null) {
        sfe.setState(ErrorState.OtherException);
      }
      error.setErrorCode(sfe.getState().getStateNum());

      StringBuilder sbError = new StringBuilder();
      sbError.append("error num:");
      sbError.append(System.nanoTime());
      sbError.append("--state:");
      sbError.append(sfe.getState().toString());
     
      sbError.append("--fromIP:");
      if(sfe.getFromIP()!= null) {
        sbError.append(sfe.getFromIP());
      }
      sbError.append("--toIP:");
      if(sfe.getToIP()!= null) {
        sbError.append(sfe.getToIP());
      }
     
      sbError.append("--Message:");

      if (sfe.getMessage() != null) {
        sbError.append(sfe.getMessage());
      }

      sbError.append(getStackTrace(sfe));

      error.setErrorMsg(sbError.toString());
      error.setFromIP(sfe.getFromIP());
      error.setToIP(sfe.getToIP());
    }
    return error;
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

   * @param fromIP
   * @param toIP
   * @return
   */
  public static ExceptionProtocol createError(ErrorState state, String fromIP, String toIP) {
    ExceptionProtocol error = new ExceptionProtocol();
    if (state == null) {
      state = ErrorState.OtherException;
    }
    error.setErrorCode(state.getStateNum());
    error.setErrorMsg("error num:" + System.nanoTime() + "--state:"
        + state.toString());
    error.setFromIP(fromIP);
    error.setToIP(toIP);
    return error;
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

   * @param toIP
   * @param e
   * @return
   */
  public static ExceptionProtocol createError(ErrorState state, String fromIP, String toIP, Exception e) {
    ExceptionProtocol error = new ExceptionProtocol();
    if (state == null) {
      state = ErrorState.OtherException;
    }
    error.setErrorCode(state.getStateNum());

    StringBuilder sbError = new StringBuilder();
    sbError.append("error num:" + System.nanoTime());
    sbError.append("--state:");
    sbError.append(state.toString());
    if (e != null) {
      sbError.append("--Message:");

      if (e.getMessage() != null) {
        sbError.append(e.getMessage());
      }

      StackTraceElement[] trace = e.getStackTrace();
      if (trace != null) {
        for (int i = 0; i < trace.length; i++) {
          sbError.append(trace[i].toString());
          sbError.append("---");
        }
      }
    }
    error.setErrorMsg(sbError.toString());

    error.setFromIP(fromIP);
    error.setToIP(toIP);
    return error;
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

   *
   * @param e
   * @return
   */
  public static ExceptionProtocol createError(Throwable e) {
    ExceptionProtocol error = new ExceptionProtocol();
    error.setErrorCode(ErrorState.OtherException.getStateNum());

    StringBuilder sbError = new StringBuilder();
    sbError.append("error num:" + System.nanoTime());
    sbError.append("--state:");
    sbError.append(ErrorState.OtherException.toString());
    if (e != null) {
      sbError.append("--Message:");

      if (e.getMessage() != null) {
        sbError.append(e.getMessage());
      }

      StackTraceElement[] trace = e.getStackTrace();
      if (trace != null) {
        for (int i = 0; i < trace.length; i++) {
          sbError.append(trace[i].toString());
          sbError.append("---");
        }
      }
    }
    error.setErrorMsg(sbError.toString());
    error.setFromIP("");
    error.setToIP("");
    return error;
  }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

        } else if(receiveP.getSDPType() == SDPType.Reset){ //服务重启
          logger.info(server.getName()+" server is reboot,system will change normal server!");
          this.createReboot(server);
          return invoke(returnType, typeName, methodName, paras);
        }else if (receiveP.getSDPType() == SDPType.Exception) {
            ExceptionProtocol ep = (ExceptionProtocol)receiveP.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
        } else {
            throw new Exception("userdatatype error!");
        }
    }
View Full Code Here

Examples of com.bj58.spat.gaea.protocol.sdp.ExceptionProtocol

        if (serverPublicProtocol.getSDPType() == SDPType.Handclasp) {
          _handclaspProtocol = (HandclaspProtocol)serverPublicProtocol.getSdpEntity();
            logger.debug("get server publicKey time:" + (System.currentTimeMillis() - startTime) + "ms");
               
        } else if (serverPublicProtocol.getSDPType() == SDPType.Exception) {
            ExceptionProtocol ep = (ExceptionProtocol)serverPublicProtocol.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
        } else if(serverPublicProtocol.getSDPType() == SDPType.Reset){
          throw new RebootException("this server is reboot!");
        } else {
            throw new Exception("userdatatype error!");
        }
           
        logger.info("receive server publicKey sucess!");
        publicKeyProtocol = null;
           
        String keyInfo = serviceConfig.getSecureKey().getInfo();//授权文件
        if(null == keyInfo || "".equals(keyInfo)){
          logger.warn("获取授权文件失败!");
           return false;
        }
           
        String ciphertext = sk.encryptByPublicKeyString(keyInfo, _handclaspProtocol.getData());
        _handclaspProtocol = null;
        serverPublicProtocol = null;
        //----发送客户端公钥去服务器端、并获取服务器端公钥--end---------------------
        //---发送授权文件到服务器端认证--------------------start-------------------------------
        HandclaspProtocol handclaspProtocol_ = new HandclaspProtocol("2",ciphertext);
        Protocol protocol_mw = proxy.createProtocol(handclaspProtocol_);
         
        try {
          scoket.registerRec(protocol_mw.getSessionID());
          scoket.send(protocol_mw.toBytes());//过程4
          logger.info("send keyInfo sucess!");
        } finally {
            //scoket.dispose();
        }
           
        handclaspProtocol_ = null;
        /**
         * 过程5
         * 获取由客户端公钥加密后的DES密钥
         */
        byte [] receiveDESKey = scoket.receive(protocol_mw.getSessionID(), server.getCurrUserCount());
        if(null == receiveDESKey){
          logger.warn("获取DES密钥失败!");
          return false;
        }
        logger.info("receive DESKey sucess!");
          
        HandclaspProtocol handclaspProtocol_mw = null;
        Protocol serverDesKeyProtocol = Protocol.fromBytes(receiveDESKey);
        if (serverDesKeyProtocol.getSDPType() == SDPType.Handclasp) {
          handclaspProtocol_mw = (HandclaspProtocol)serverDesKeyProtocol.getSdpEntity();
        } else if (serverDesKeyProtocol.getSDPType() == SDPType.Exception) {
          ExceptionProtocol ep = (ExceptionProtocol)serverDesKeyProtocol.getSdpEntity();
            throw ThrowErrorHelper.throwServiceError(ep.getErrorCode(), ep.getErrorMsg());
        } else if(serverDesKeyProtocol.getSDPType() == SDPType.Reset){
          throw new RebootException("this server is reboot!");
        } else {
          throw new Exception("userdatatype error!");
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.