Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCServiceException


   */
  public void disableService(int operationTimeoutSeconds, String serviceName) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      // disableService not possible - client not attached
      throw new SCServiceException("Client not attached - disableService not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_DISABLE, Constants.SERVICE_NAME, serviceName);
    String body = this.manageCall(operationTimeoutSeconds, urlString);
    if (body != null) {
      throw new SCServiceException(body);
    }
  }
View Full Code Here


   */
  public void enableService(int operationTimeoutSeconds, String serviceName) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      // enableService not possible - client not attached
      throw new SCServiceException("Client not attached - enableService not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_ENABLE, Constants.SERVICE_NAME, serviceName);
    String body = this.manageCall(operationTimeoutSeconds, urlString);
    if (body != null) {
      throw new SCServiceException(body);
    }
  }
View Full Code Here

   * @throws UnsupportedEncodingException
   *             encoding of request URL failed<br />
   */
  public void clearCache(int operationTimeoutSeconds) throws SCServiceException, UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - clearCache not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_CLEAR_CACHE);
    String body = this.manageCall(operationTimeoutSeconds, urlString);
    if (body != null) {
      throw new SCServiceException(body);
    }
  }
View Full Code Here

   * @throws UnsupportedEncodingException
   *             encoding of request URL failed<br />
   */
  public void dump(int operationTimeoutSeconds) throws SCServiceException, UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - dump not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_DUMP);
    this.manageCall(operationTimeoutSeconds, urlString);
  }
View Full Code Here

   * @throws UnsupportedEncodingException
   *             encoding of request URL failed<br />
   */
  public void killSC() throws SCServiceException, UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - killSC not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_KILL);
    this.manageCall(Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS, urlString);
    try {
      // sleep to assure kill is sent
View Full Code Here

    try {
      manageCall.setRequestBody(instruction);
      manageCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      this.requester.destroy();
      throw new SCServiceException(instruction + " SC failed.", e);
    }
    if (instruction.equalsIgnoreCase(Constants.CC_CMD_KILL)) {
      // kill SC doesn't reply a message
      return null;
    }
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Manage failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    return (String) reply.getBody();
  }
View Full Code Here

   */
  public SCSubscribeMessage subscribe(int operationTimeoutSeconds, SCSubscribeMessage scSubscribeMessage,
      SCMessageCallback scMessageCallback) throws SCServiceException, SCMPValidatorException {
    // 1. checking preconditions and initialize
    if (this.sessionActive) {
      throw new SCServiceException(this.serviceName + " already subscribed.");
    }
    if (scSubscribeMessage == null) {
      throw new SCMPValidatorException("Subscribe message (scSubscribeMessage) must not be null.");
    }
    if (scMessageCallback == null) {
      throw new SCMPValidatorException("Callback must be set.");
    }
    this.noDataIntervalSeconds = scSubscribeMessage.getNoDataIntervalSeconds();
    String mask = scSubscribeMessage.getMask();
    ValidatorUtility.validateMask(mask, SCMPError.HV_WRONG_MASK);
    this.messageCallback = scMessageCallback;
    this.requester.getSCMPMsgSequenceNr().reset();
    // 2. initialize call & invoke
    SCServiceCallback callback = new SCServiceCallback(true);
    SCMPClnSubscribeCall subscribeCall = new SCMPClnSubscribeCall(this.requester, this.serviceName);
    subscribeCall.setMask(scSubscribeMessage.getMask());
    subscribeCall.setSessionInfo(scSubscribeMessage.getSessionInfo());
    subscribeCall.setNoDataIntervalSeconds(scSubscribeMessage.getNoDataIntervalSeconds());
    subscribeCall.setCompressed(scSubscribeMessage.isCompressed());
    subscribeCall.setRequestBody(scSubscribeMessage.getData());
    try {
      subscribeCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      throw new SCServiceException("Subscribe failed.", e);
    }
    // 3. receiving reply and error handling
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault() || reply.getHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION)) {
      // reply is fault or rejected
      SCServiceException ex = new SCServiceException("Subscribe failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      ex.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
      ex.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
      throw ex;
    }
    // 4. post process, reply to client
    this.sessionId = reply.getSessionId();
    this.sessionActive = true;
View Full Code Here

   */
  public synchronized SCSubscribeMessage changeSubscription(int operationTimeoutSeconds, SCSubscribeMessage scSubscribeMessage)
      throws SCServiceException, SCMPValidatorException {
    // 1. checking preconditions and initialize
    if (this.sessionActive == false) {
      throw new SCServiceException("ChangeSubscription not possible - not subscribed.");
    }
    if (scSubscribeMessage == null) {
      throw new SCMPValidatorException("Subscribe message (scSubscribeMessage) must not be null.");
    }
    String mask = scSubscribeMessage.getMask();
    ValidatorUtility.validateMask(mask, SCMPError.HV_WRONG_MASK);
    this.requester.getSCMPMsgSequenceNr().incrementAndGetMsgSequenceNr();
    // 2. initialize call & invoke
    SCMPClnChangeSubscriptionCall changeSubscriptionCall = new SCMPClnChangeSubscriptionCall(this.requester, this.serviceName,
        this.sessionId);
    changeSubscriptionCall.setMask(scSubscribeMessage.getMask());
    changeSubscriptionCall.setCompressed(scSubscribeMessage.isCompressed());
    changeSubscriptionCall.setRequestBody(scSubscribeMessage.getData());
    changeSubscriptionCall.setSessionInfo(scSubscribeMessage.getSessionInfo());
    SCServiceCallback callback = new SCServiceCallback(true);
    try {
      changeSubscriptionCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      throw new SCServiceException("Change subscription failed.", e);
    }
    // 3. receiving reply and error handling
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault() || reply.getHeaderFlag(SCMPHeaderAttributeKey.REJECT_SESSION)) {
      // reply is fault or rejected
      SCServiceException ex = new SCServiceException("Change subscription failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      ex.setAppErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.APP_ERROR_CODE));
      ex.setAppErrorText(reply.getHeader(SCMPHeaderAttributeKey.APP_ERROR_TEXT));
      throw ex;
    }
    // 4. post process, reply to client
    SCSubscribeMessage replyToClient = new SCSubscribeMessage();
    replyToClient.setData(reply.getBody());
View Full Code Here

   * @throws SCServiceException
   *             listener is already started<br />
   */
  public void setImmediateConnect(boolean immediateConnect) throws SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    this.immediateConnect = immediateConnect;
  }
View Full Code Here

   * @throws SCServiceException
   *             listener is already started<br />
   */
  public void setKeepAliveIntervalSeconds(int keepAliveIntervalSeconds) throws SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    this.keepAliveIntervalSeconds = keepAliveIntervalSeconds;
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.api.SCServiceException

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.