Package org.serviceconnector.api

Examples of org.serviceconnector.api.SCServiceException


   * @throws UnsupportedEncodingException
   *             the unsupported encoding exception
   */
  public String getSCVersion() throws SCServiceException, UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - getStateOfServices not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_SC_VERSION);
    String body = this.inspectCall(Constants.DEFAULT_OPERATION_TIMEOUT_SECONDS, urlString);
    URLString urlResponse = new URLString();
    urlResponse.parseResponseURLString(body);
View Full Code Here


   *             encoding of request URL failed<br />
   */
  public boolean isServiceEnabled(int operationTimeout, String serviceName) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - isServiceEnabled not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_STATE, Constants.SERVICE_NAME, serviceName);
    try {
      String body = this.inspectCall(operationTimeout, urlString);
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      String value = urlResponse.getParamValue(serviceName);
      if (value != null && value.equals(Constants.STATE_ENABLED)) {
        return true;
      }
      return false;
    } catch (SCServiceException e) {
      if (e.getSCErrorCode() == SCMPError.SERVICE_NOT_FOUND.getErrorCode()) {
        return false;
      }
      throw e;
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here

   *             encoding of request URL failed<br />
   */
  public Map<String, String> getStateOfServices(int operationTimeout, String serviceNamePattern) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - getStateOfServices not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_STATE, Constants.SERVICE_NAME, serviceNamePattern);
    try {
      String body = this.inspectCall(operationTimeout, urlString);
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      return urlResponse.getParameterMap();
    } catch (SCServiceException serviceEx) {
      return new HashMap<String, String>();
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here

   *             encoding of request URL failed<br />
   */
  public Map<String, String> getServiceConfiguration(int operationTimeout, String serviceName) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - getServiceConfiguration not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_SERVICE_CONF, Constants.SERVICE_NAME, serviceName);
    try {
      String body = this.inspectCall(operationTimeout, urlString);
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      return urlResponse.getParameterMap();
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here

   *             encoding of request URL failed<br />
   */
  public Map<String, String> getWorkload(int operationTimeoutSeconds, String serviceName) throws SCServiceException,
      UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - isServiceEnabled not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_SESSIONS, Constants.SERVICE_NAME, serviceName);
    String body = this.inspectCall(operationTimeoutSeconds, urlString);
    try {
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      return urlResponse.getParameterMap();
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here

   *             encoding of request URL failed<br />
   */
  public Map<String, String> inspectCache(int operationTimeoutSeconds, String serviceName, String cacheId)
      throws SCServiceException, UnsupportedEncodingException {
    if (this.attached == false) {
      throw new SCServiceException("Client not attached - inspectCache not possible.");
    }
    String urlString = URLString.toURLRequestString(Constants.CC_CMD_INSPECT_CACHE, Constants.SERVICE_NAME, serviceName,
        Constants.CACHE_ID, cacheId);
    String body = this.inspectCall(operationTimeoutSeconds, urlString);
    try {
      URLString urlResponse = new URLString();
      urlResponse.parseResponseURLString(body);
      return urlResponse.getParameterMap();
    } catch (UnsupportedEncodingException e) {
      throw new SCServiceException(e.toString());
    }
  }
View Full Code Here

    try {
      inspectCall.setRequestBody(instruction);
      inspectCall.invoke(callback, operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    } catch (Exception e) {
      this.requester.destroy();
      throw new SCServiceException("Inspect request failed. ", e);
    }
    if (instruction.equalsIgnoreCase(Constants.CC_CMD_KILL)) {
      // on KILL SC cannot reply a message
      return null;
    }
    SCMPMessage reply = callback.getMessageSync(operationTimeoutSeconds * Constants.SEC_TO_MILLISEC_FACTOR);
    if (reply.isFault()) {
      SCServiceException ex = new SCServiceException("Inspect 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 void setKeepAliveIntervalSeconds(int keepAliveIntervalSeconds) throws SCServiceException, SCMPValidatorException {
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(Constants.MIN_KPI_VALUE, keepAliveIntervalSeconds, Constants.MAX_KPI_VALUE,
        SCMPError.HV_WRONG_KEEPALIVE_INTERVAL);
    if (this.attached == true) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    this.keepAliveIntervalSeconds = keepAliveIntervalSeconds;
  }
View Full Code Here

  public void setKeepAliveTimeoutSeconds(int keepAliveTimeoutSeconds) throws SCMPValidatorException, SCServiceException {
    // validate in this case its a local needed information
    ValidatorUtility.validateInt(1, keepAliveTimeoutSeconds, Constants.MAX_KP_TIMEOUT_VALUE,
        SCMPError.HV_WRONG_KEEPALIVE_TIMEOUT);
    if (this.attached) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    this.keepAliveTimeoutSeconds = keepAliveTimeoutSeconds;
  }
View Full Code Here

   * @throws SCServiceException
   *             called method after attach
   */
  public void setTCPKeepAlive(boolean tcpKeepAlive) throws SCServiceException {
    if (this.attached) {
      throw new SCServiceException("Can not set property, client is already attached.");
    }
    // sets the TCP keep alive for initiating connections in basic configuration
    AppContext.getBasicConfiguration().setTcpKeepAliveInitiator(tcpKeepAlive);
  }
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.