Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCServiceException


      try {
        LOGGER.debug("SCFileService uploadFile begin");
        uploadFileCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
        LOGGER.debug("SCFileService uploadFile done");
      } catch (Exception e) {
        throw new SCServiceException("Upload file failed. ", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException ex = new SCServiceException("Upload file failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
    } finally {
      // 4. post process, reply to client
      // always delete file session
View Full Code Here


      SCMPFileDownloadCall downloadFileCall = new SCMPFileDownloadCall(this.requester, this.serviceName, this.sessionId);
      downloadFileCall.setRemoteFileName(remoteFileName);
      try {
        downloadFileCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      } catch (Exception e) {
        throw new SCServiceException("Download file failed. ", e);
      }
      // 3. receiving reply and error handling
      SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
      if (reply.isFault()) {
        SCServiceException ex = new SCServiceException("Download file failed.");
        ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
        ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
        throw ex;
      }
      // 4. post process, reply to client
      if (reply.isComposite()) {
        ((SCMPCompositeReceiver) reply).writeBodyAsStream(outStream);
        return;
      }
      outStream.write((byte[]) reply.getBody());
    } catch (IOException e) {
      throw new SCServiceException("Writing to OutputStream failed. ", e);
    } finally {
      // always delete file session
      this.deleteFileSession(operationTimeoutSeconds);
    }
  }
View Full Code Here

    SCServiceCallback callback = new SCServiceCallback(true);
    SCMPFileListCall fileListCall = new SCMPFileListCall(this.requester, this.serviceName);
    try {
      fileListCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      throw new SCServiceException("List files failed. ", e);
    }
    // 3. receiving reply and error handling
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("List files failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    // 4. post process, reply to client
    byte[] body = (byte[]) reply.getBody();
    if (body == null) {
View Full Code Here

    SCMPClnCreateSessionCall createSessionCall = new SCMPClnCreateSessionCall(this.requester, this.serviceName);
    createSessionCall.setEchoIntervalSeconds(Constants.DEFAULT_FILE_SESSION_TIMEOUT_SECONDS);
    try {
      createSessionCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      throw new SCServiceException("Create file session on SC failed. ", e);
    }
    // 3. receiving reply and error handling
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Create file session on SC failed.");
      ex.setSCErrorCode(reply.getHeaderInt(SCMPHeaderAttributeKey.SC_ERROR_CODE));
      ex.setSCErrorText(reply.getHeader(SCMPHeaderAttributeKey.SC_ERROR_TEXT));
      throw ex;
    }
    // 4. post process, reply to client
    this.sessionId = reply.getSessionId();
  }
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

   * @throws SCServiceException
   *             listener is already started<br />
   */
  public void setKeepAliveTimeoutSeconds(int keepAliveTimeoutSeconds) throws SCMPValidatorException, SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, keepAliveTimeoutSeconds, Constants.MAX_KP_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_KEEPALIVE_TIMEOUT);
    this.keepAliveTimeoutSeconds = keepAliveTimeoutSeconds;
View Full Code Here

   * @throws SCServiceException
   *             called method after attach
   */
  public void setTCPKeepAliveInitiator(boolean tcpKeepAliveInitiator) throws SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // sets the TCP keep alive for initiating connections in basic configuration
    AppContext.getBasicConfiguration().setTcpKeepAliveInitiator(tcpKeepAliveInitiator);
  }
View Full Code Here

   * @throws SCServiceException
   *             called method after attach
   */
  public void setTCPKeepAliveListener(boolean tcpKeepAliveListener) throws SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // sets the TCP keep alive for incoming connections in basic configuration
    AppContext.getBasicConfiguration().setTcpKeepAliveListener(tcpKeepAliveListener);
  }
View Full Code Here

   *             listener is already started<br />
   */
  public void setCheckRegistrationTimeoutSeconds(int checkRegistrationTimeoutSeconds) throws SCMPValidatorException,
      SCServiceException {
    if (this.listening == true) {
      throw new SCServiceException("Listener is already started not allowed to set property.");
    }
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, checkRegistrationTimeoutSeconds, Constants.MAX_CRG_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_OPERATION_TIMEOUT);
    this.checkRegistraionTimeoutSeconds = checkRegistrationTimeoutSeconds;
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.