Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCManagedMessage


        .getCachingMethod(reply.getHeader(SCMPHeaderAttributeKey.CACHING_METHOD));

    if (nrOfAppendix != null) {
      replyToClient = this.pollAppendices(operationTimeoutSeconds, nrOfAppendix, scMessage.getCacheId());
    } else if (cachingMethod == SC_CACHING_METHOD.INITIAL) {
      replyToClient = new SCManagedMessage();
      replyToClient.setCachingMethod(cachingMethod);
    } else {
      replyToClient = new SCMessage();
    }
View Full Code Here


   * @throws SCServiceException
   *             the SC service exception
   */
  private SCManagedMessage pollAppendices(int operationTimeoutSeconds, int nrOfAppendix, String cacheId)
      throws SCServiceException {
    SCManagedMessage managedMsg = new SCManagedMessage();
    managedMsg.setCachingMethod(SC_CACHING_METHOD.INITIAL);

    SCMPClnExecuteCall clnExecutePollCall = new SCMPClnExecuteCall(this.requester, this.serviceName, this.sessionId);
    clnExecutePollCall.setCacheId(cacheId);
    // appendices need to be read from cache
    for (int readApp = 1; readApp <= nrOfAppendix; readApp++) {
      clnExecutePollCall.setAppendixNr(readApp);
      SCServiceCallback cbk = new SCServiceCallback(true);
      try {
        clnExecutePollCall.invoke(cbk, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Execute poll request failed. ", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = cbk.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException scEx = new SCServiceException("Execute poll failed.");
        scEx.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        scEx.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw scEx;
      }

      SCAppendMessage appendix = new SCAppendMessage();
      appendix.setData(reply.getBody());
      appendix.setDataLength(reply.getBodyLength());
      appendix.setCompressed(reply.getHeaderFlag(SCMPHeaderAttributeKey.COMPRESSION));
      appendix.setSessionId(this.sessionId);
      appendix.setCacheId(reply.getCacheId());
      appendix.setCached(reply.getHeaderFlag(SCMPHeaderAttributeKey.CACHED));
      appendix.setCachePartNr(reply.getHeader(SCMPHeaderAttributeKey.CACHE_PARTN_NUMBER));
      appendix.setMessageInfo(reply.getHeader(SCMPHeaderAttributeKey.MSG_INFO));
      appendix.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
      appendix.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
      appendix.setCachingMethod(SC_CACHING_METHOD.APPEND);
      managedMsg.addAppendix(appendix);
    }
    return managedMsg;
  }
View Full Code Here

    // 4: read data from cache and verify
    SCMessage response = sessionService1.execute(request);
    this.checkAppendices(response, 3);
    Assert.assertTrue("cached flag wrong value", response.isCached());
    SCManagedMessage managedMessage = (SCManagedMessage) response;
    Assert.assertTrue("cached flag wrong value", managedMessage.getAppendixes().get(0).isCached());
    Assert.assertTrue("cached flag wrong value", managedMessage.getAppendixes().get(1).isCached());
    Assert.assertTrue("cached flag wrong value", managedMessage.getAppendixes().get(2).isCached());
  }
View Full Code Here

  }

  protected void checkAppendices(SCMessage scMessage, int expectedNrOfApp) {
    Assert.assertTrue("response not of type managed message", scMessage.isManaged());
    Assert.assertEquals(SC_CACHING_METHOD.INITIAL, scMessage.getCachingMethod());
    SCManagedMessage managedMessage = (SCManagedMessage) scMessage;
    Assert.assertEquals("unexpected number of appendices found in managed data", expectedNrOfApp,
        managedMessage.getNrOfAppendixes());
    int i = 0;
    for (SCAppendMessage scAppendMessage : managedMessage.getAppendixes()) {
      String body = (String) scAppendMessage.getData();
      if (body.startsWith(i + "") == false) {
        Assert.fail("unexpected appnendix body: " + body);
      }
      i++;
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCManagedMessage

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.