Package org.serviceconnector.scmp

Examples of org.serviceconnector.scmp.SCMPMessageFault


  public void receive(Exception ex) {
    LOGGER.warn(ex);
    SCMPMessage fault = null;
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling - SCMP Version current
      fault = new SCMPMessageFault(SCMPVersion.CURRENT, SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC");
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPVersion.CURRENT, SCMPError.CONNECTION_EXCEPTION, "broken connection");
    } else if (ex instanceof ConnectionPoolBusyException) {
      fault = new SCMPMessageFault(SCMPVersion.CURRENT, ex, SCMPError.NO_FREE_CONNECTION);
    } else {
      fault = new SCMPMessageFault(SCMPVersion.CURRENT, SCMPError.SC_ERROR, "executing command failed");
    }
    super.receive(fault);
  }
View Full Code Here


    SCMPMessage fault = null;
    SCMPMessage reqMessage = request.getMessage();
    String serviceName = reqMessage.getServiceName();
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling - SCMP Version request
      fault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.OPERATION_TIMEOUT,
          "Operation timeout expired on SC cln change subscription sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.CONNECTION_EXCEPTION,
          "broken connection on SC cln change subscription sid=" + sid);
    } else if (ex instanceof InvalidMaskLengthException) {
      fault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
    } else {
      fault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.SC_ERROR,
          "executing cln change subscription failed sid=" + sid);
    }
    fault.setIsReply(true);
    fault.setServiceName(serviceName);
    fault.setMessageType(SCMPMsgType.CLN_CHANGE_SUBSCRIPTION);
View Full Code Here

      // enable services
      boolean success = this.modifyStateOfServices(true, serviceName);
      if (success == false) {
        LOGGER.debug("service=" + serviceName + " not found");
        // SCMP Version request
        scmpReply = new SCMPMessageFault(reqMsg.getSCMPVersion(), SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      responderCallback.responseCallback(request, response);
      return;
    }

    if (Constants.CC_CMD_DISABLE.equalsIgnoreCase(callKey)) {
      // enable services
      boolean success = this.modifyStateOfServices(false, serviceName);
      if (success == false) {
        LOGGER.debug("service=" + serviceName + " not found");
        // SCMP Version request
        scmpReply = new SCMPMessageFault(reqMsg.getSCMPVersion(), SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      responderCallback.responseCallback(request, response);
      return;
    }
    LOGGER.error("wrong manage command body=" + bodyString); // body has bad syntax
    // SCMP Version request
    scmpReply = new SCMPMessageFault(reqMsg.getSCMPVersion(), SCMPError.V_WRONG_MANAGE_COMMAND, bodyString);
    response.setSCMP(scmpReply);
    // initiate responder to send reply
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

    SCMPMessage fault = null;
    String serviceName = this.reqMessage.getServiceName();
    SCMPVersion scmpVersion = this.reqMessage.getSCMPVersion();
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling - SCMP Version request
      fault = new SCMPMessageFault(scmpVersion, SCMPError.OPERATION_TIMEOUT,
          "Operation timeout expired on SC cln subscribe sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(scmpVersion, SCMPError.CONNECTION_EXCEPTION, "broken connection on SC cln subscribe sid="
          + sid);
    } else if (ex instanceof InterruptedException) {
      fault = new SCMPMessageFault(scmpVersion, SCMPError.SC_ERROR, "executing cln subscribe failed, thread interrupted sid="
          + sid);
    } else if (ex instanceof InvalidMaskLengthException) {
      fault = new SCMPMessageFault(scmpVersion, SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
    } else {
      fault = new SCMPMessageFault(scmpVersion, SCMPError.SC_ERROR, "executing cln subscribe failed sid=" + sid);
    }
    // forward reply to client
    fault.setIsReply(true);
    fault.setServiceName(serviceName);
    fault.setMessageType(msgType);
View Full Code Here

    this.headKey = SCMPHeaderKey.EXC;
    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    SCMPMessage encodeExc = new SCMPMessageFault(SCMPVersion.CURRENT);
    encodeExc.setHeader(encodeScmp);
    encodeExc.setBody(body.getBytes());

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeExc);
    } catch (Exception e) {
View Full Code Here

    this.headKey = SCMPHeaderKey.EXC;
    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    SCMPMessage encodeExc = new SCMPMessageFault(SCMPVersion.CURRENT);
    encodeExc.setHeader(encodeScmp);
    encodeExc.setBody(body.getBytes());

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeExc);
    } catch (Exception e) {
View Full Code Here

    this.headKey = SCMPHeaderKey.EXC;
    String header = "msn=" + msgSequenceNr + "\n" + "bty=" + bodyType.getValue() + "\n" + "mty=" + msgType.getValue() + "\n";

    String expectedString = TestUtil.getSCMPString(headKey, header, body);

    SCMPMessage encodeExc = new SCMPMessageFault();
    encodeExc.setHeader(encodeScmp);
    encodeExc.setBody(body.getBytes());

    OutputStream os = new ByteArrayOutputStream();
    try {
      coder.encode(os, encodeExc);
    } catch (Exception e) {
View Full Code Here

    Assert.assertEquals(error.getErrorCode(), result.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE).intValue());
  }

  public static void checkReply(SCMPMessage message) throws Exception {
    if (message.isFault()) {
      SCMPMessageFault fault = (SCMPMessageFault) message;
      Exception ex = fault.getCause();
      if (ex != null) {
        throw ex;
      }
      throw new Exception(fault.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
    }
  }
View Full Code Here

      String sessionId = reqMessage.getSessionId();
      if (reqMessage.isFault()) {
        SCBaseServlet.compositeRegistry.removeSCMPLargeResponse(sessionId);
        SCBaseServlet.compositeRegistry.removeSCMPLargeRequest(sessionId);
        // fault received nothing to to return - delete largeRequest/largeResponse
        SCMPMessageFault scmpFault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.BAD_REQUEST, "messagType="
            + reqMessage.getMessageType());
        scmpFault.setMessageType(reqMessage.getMessageType());
        scmpFault.setLocalDateTime();
        // write reply to servlet output stream
        this.writeResponse(reqMessage, scReply, response);
        return;
      }

      if (this.handleLargeResponse(request, response, reqMessage)) {
        // large message and response has been handled no need to continue
        return;
      }

      if (this.handleLargeRequestNeeded(request, response, reqMessage)) {
        SCMPMessage message = this.handleLargeRequest(request, response, reqMessage);
        if (message == null) {
          // reply inside
          return;
        }
        reqMessage = message;
      }

      String messageTypeString = reqMessage.getMessageType();
      int oti = reqMessage.getHeaderInt(SCMPHeaderAttributeKey.OPERATION_TIMEOUT);

      switch (SCMPMsgType.getMsgType(messageTypeString)) {
      case SRV_CREATE_SESSION:
        scReply = ((SCBaseSessionServlet) this).baseCreateSession(reqMessage, oti);
        break;
      case SRV_DELETE_SESSION:
        scReply = ((SCBaseSessionServlet) this).baseDeleteSession(reqMessage, oti);
        break;
      case SRV_ABORT_SESSION:
        scReply = ((SCBaseSessionServlet) this).baseAbortSession(reqMessage, oti);
        break;
      case SRV_EXECUTE:
        scReply = ((SCBaseSessionServlet) this).baseExecute(reqMessage, oti);
        break;
      case SRV_SUBSCRIBE:
        scReply = ((SCBasePublishServlet) this).baseSubscribe(reqMessage, oti);
        break;
      case SRV_CHANGE_SUBSCRIPTION:
        scReply = ((SCBasePublishServlet) this).baseChangeSubscription(reqMessage, oti);
        break;
      case SRV_UNSUBSCRIBE:
        scReply = ((SCBasePublishServlet) this).baseUnsubscribe(reqMessage, oti);
        break;
      case SRV_ABORT_SUBSCRIPTION:
        scReply = ((SCBasePublishServlet) this).baseAbortSubscription(reqMessage, oti);
        break;
      default:
        scReply = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.BAD_REQUEST, "Unknown message type received.");
        break;
      }
    } catch (Exception e) {
      LOGGER.error("Processing message failed.", e);
      // fault received nothing to to return - delete largeRequest/largeResponse
      SCMPMessageFault scmpFault = new SCMPMessageFault(reqMessage.getSCMPVersion(), SCMPError.SERVER_ERROR,
          "Processing message failed when calling servlet API");
      scmpFault.setMessageType(reqMessage.getMessageType());
      scmpFault.setLocalDateTime();
    }
    this.writeResponse(reqMessage, scReply, response);
  }
View Full Code Here

    if (th instanceof HasFaultResponseException) {
      ((HasFaultResponseException) th).setFaultResponse(response);
      response.write();
      return;
    }
    SCMPMessageFault fault = new SCMPMessageFault(SCMPVersion.LOWEST, SCMPError.SC_ERROR, th.getMessage());
    fault.setMessageType(SCMPMsgType.UNDEFINED);
    response.setSCMP(fault);
    response.write();
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.scmp.SCMPMessageFault

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.