Package org.serviceconnector.scmp

Examples of org.serviceconnector.scmp.SCMPMessageFault


    case PAC:
      // poll request
      scmpMsg = new SCMPPart(true);
      break;
    case EXC:
      scmpMsg = new SCMPMessageFault();
      break;
    case UNDEF:
      throw new EncodingDecodingException("wrong protocol in message not possible to decode");
    default:
      scmpMsg = new SCMPMessage();
View Full Code Here


    String sid = reqMessage.getSessionId();
    LOGGER.warn("receive exception sid=" + sid + " " + ex.toString());
    SCMPMessage fault = null;
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPError.CONNECTION_EXCEPTION, "broken connection on SC sid=" + sid);
    } else if (ex instanceof InvalidMaskLengthException) {
      fault = new SCMPMessageFault(SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
    } else {
      fault = new SCMPMessageFault(SCMPError.SC_ERROR, "executing " + this.msgType + " failed sid=" + sid);
    }
    fault.setSessionId(this.request.getMessage().getSessionId());
    String serviceName = reqMessage.getServiceName();
    // forward server reply to client
    fault.setIsReply(true);
View Full Code Here

      server.removeSession(this.cascSubscription);
    }
    SCMPMessage fault = null;
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC csc unsubscribe sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPError.CONNECTION_EXCEPTION, "broken connection on SC csc unsubscribe sid=" + sid);
    } else if (ex instanceof InvalidMaskLengthException) {
      fault = new SCMPMessageFault(SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
    } else {
      fault = new SCMPMessageFault(SCMPError.SC_ERROR, "executing csc unsubscribe failed sid=" + sid);
    }
    // forward server reply to client
    fault.setIsReply(true);
    fault.setServiceName(serviceName);
    fault.setMessageType(SCMPMsgType.CSC_UNSUBSCRIBE);
View Full Code Here

    if (this.synchronous == false) {
      // offering is only allowed if someone is expecting a message - prevents race conditions, an answer might
      // arrive late after operation timeout already run out, can be ignored
      return;
    }
    SCMPMessage fault = new SCMPMessageFault(ex);
    if (this.answer.offer(fault)) {
      // queue empty object can be added
      return;
    }
    // object could not be added - clear queue and offer again
View Full Code Here

      // finally clause handles exception too
      LOGGER.warn("InterruptedException when waiting for message " + e);
    } finally {
      if (reply == null) {
        // time runs out before message got received
        reply = new SCMPMessageFault(SCMPError.REQUEST_WAIT_ABORT, "");
        reply.setMessageType(SCMPMsgType.UNDEFINED);
        LOGGER.error("Operation did not complete in time, timeout=" + timeoutMillis + "ms aborting callback="
            + this.getClass().getName());
      }
    }
View Full Code Here

    this.tempSubscription.getServer().removeSession(tempSubscription);
    SCMPMessage fault = null;
    String serviceName = this.reqMessage.getServiceName();
    if (ex instanceof IdleTimeoutException) {
      // operation timeout handling
      fault = new SCMPMessageFault(SCMPError.OPERATION_TIMEOUT, "Operation timeout expired on SC cln subscribe sid=" + sid);
    } else if (ex instanceof IOException) {
      fault = new SCMPMessageFault(SCMPError.CONNECTION_EXCEPTION, "broken connection on SC cln subscribe sid=" + sid);
    } else if (ex instanceof InterruptedException) {
      fault = new SCMPMessageFault(SCMPError.SC_ERROR, "executing cln subscribe failed, thread interrupted sid=" + sid);
    } else if (ex instanceof InvalidMaskLengthException) {
      fault = new SCMPMessageFault(SCMPError.HV_WRONG_MASK, ex.getMessage() + " sid=" + sid);
    } else {
      fault = new SCMPMessageFault(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

      try {
        // get state of all services
        scmpReply.setBody(this.getStateOfServicesString(serviceName));
      } catch (Exception e) {
        LOGGER.debug("service=" + serviceName + " not found");
        scmpReply = new SCMPMessageFault(SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_SESSIONS.equalsIgnoreCase(callKey)) {
      // state for service requested
      LOGGER.debug("sessions request for service=" + serviceName);
      try {
        // get sessions of all services
        scmpReply.setBody(this.getSessionsOfServicesString(serviceName));
      } catch (Exception e) {
        LOGGER.debug("service=" + serviceName + " not found");
        scmpReply = new SCMPMessageFault(SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_SERVICE_CONF.equalsIgnoreCase(callKey)) {
      LOGGER.debug("service configuration request for serviceName=" + serviceName);
      try {
        scmpReply.setBody(this.getServiceConfigurationString(serviceName));
      } catch (Exception e) {
        LOGGER.debug("service=" + serviceName + " not found");
        scmpReply = new SCMPMessageFault(SCMPError.SERVICE_NOT_FOUND, serviceName);
      }
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_INSPECT_CACHE.equalsIgnoreCase(callKey)) {
      String cacheId = urlRequestString.getParamValue("cacheId");
      LOGGER.debug("cache inspect for serviceName=" + serviceName + ", cacheId=" + cacheId);
      String cacheInspectString = this.getCacheInspectString(serviceName, serviceName + Constants.UNDERLINE + cacheId);
      scmpReply.setBody(cacheInspectString);
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }
    if (Constants.CC_CMD_SC_VERSION.equalsIgnoreCase(callKey)) {
      LOGGER.debug("sc version request");
      String scVersion = Constants.CC_CMD_SC_VERSION + Constants.EQUAL_SIGN + SCVersion.CURRENT;
      scmpReply.setBody(scVersion);
      response.setSCMP(scmpReply);
      // initiate responder to send reply
      responderCallback.responseCallback(request, response);
      return;
    }

    LOGGER.error("wrong inspect command body=" + bodyString); // body has bad syntax
    scmpReply = new SCMPMessageFault(SCMPError.V_WRONG_INSPECT_COMMAND, bodyString);
    response.setSCMP(scmpReply);
    // initiate responder to send reply
    responderCallback.responseCallback(request, response);
  }
View Full Code Here

      LOGGER.trace("timeout receive publication timer datapointer subscriptionId " + subscriptionId);
      subscription = subscriptionRegistry.getSubscription(subscriptionId);
      if (subscription == null) {
        LOGGER.trace("subscription not found - already deleted subscriptionId=" + subscriptionId);
        // subscription has already been deleted
        SCMPMessageFault fault = new SCMPMessageFault(SCMPError.SUBSCRIPTION_NOT_FOUND, subscriptionId);
        fault.setMessageType(reqMsg.getMessageType());
        response.setSCMP(fault);
      } else {
        // tries polling from queue
        SCMPMessage message = this.publishMessageQueue.getMessage(subscriptionId);
        if (message == null) {
          LOGGER.trace("no message found on queue - subscription timeout set up no data message subscriptionId="
              + subscriptionId);
          // no message found on queue - subscription timeout set up no data message
          reqMsg.setHeaderFlag(SCMPHeaderAttributeKey.NO_DATA);
          reqMsg.setIsReply(true);
          this.response.setSCMP(reqMsg);
        } else {
          LOGGER.trace("message found on queue - subscription timeout set up reply message subscriptionId="
              + subscriptionId);
          // set up reply
          SCMPMessage reply = null;
          if (message.isPart()) {
            // message from queue is of type part - outgoing must be part too, no poll request
            reply = new SCMPPart(false);
          } else {
            reply = new SCMPMessage();
          }
          reply.setServiceName(reqMsg.getHeader(SCMPHeaderAttributeKey.SERVICE_NAME));
          reply.setSessionId(subscriptionId);
          reply.setMessageType(reqMsg.getMessageType());
          reply.setIsReply(true);

          // message polling successful
          reply.setBody(message.getBody());
          reply.setHeader(SCMPHeaderAttributeKey.MESSAGE_SEQUENCE_NR, message.getMessageSequenceNr());
          String messageInfo = message.getHeader(SCMPHeaderAttributeKey.MSG_INFO);
          if (messageInfo != null) {
            reply.setHeader(SCMPHeaderAttributeKey.MSG_INFO, messageInfo);
          }
          reply.setHeader(SCMPHeaderAttributeKey.MASK, message.getHeader(SCMPHeaderAttributeKey.MASK));
          reply.setBody(message.getBody());
          this.response.setSCMP(reply);
        }
      }
    } catch (Exception ex) {
      LOGGER.warn("timeout expired procedure failed, " + ex.getMessage());
      SCMPMessageFault scmpFault = new SCMPMessageFault(SCMPError.SERVER_ERROR, ex.getMessage());
      scmpFault.setMessageType(SCMPMsgType.RECEIVE_PUBLICATION);
      scmpFault.setLocalDateTime();
      response.setSCMP(scmpFault);
    } finally {
      if (subscription != null) {
        // reset subscription timeout to ECI
        subscriptionRegistry.resetSubscriptionTimeout(subscription, subscription.getSubscriptionTimeoutMillis());
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(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(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(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

      // last package arrived
      out.close();
      httpCon = session.getHttpURLConnection();
      if (httpCon.getResponseCode() != HttpResponseStatus.OK.getCode()) {
        // error handling
        SCMPMessageFault fault = new SCMPMessageFault(SCMPError.FILE_UPLOAD_FAILED, httpCon.getResponseMessage());
        LOGGER.warn("Upload file failed =" + httpCon.getResponseMessage());
        return fault;
      }
      httpCon.disconnect();
      session.stopStreaming();
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.