Package org.serviceconnector.cmd

Examples of org.serviceconnector.cmd.SCMPValidatorException


      ex.setAttribute(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, DateTimeUtility.getCurrentTimeZoneMillis());
      ex.setMessageType(getKey());
      throw ex;
    } catch (Throwable th) {
      LOGGER.error("validation error", th);
      SCMPValidatorException valExc = new SCMPValidatorException();
      valExc.setMessageType(getKey());
      valExc.setAttribute(SCMPHeaderAttributeKey.LOCAL_DATE_TIME, DateTimeUtility.getCurrentTimeZoneMillis());
      throw valExc;
    }
  }
View Full Code Here


   */
  public static void validateStringLength(int minSizeInc, String stringValue, int maxSizeInc, SCMPError error)
      throws SCMPValidatorException {

    if (stringValue == null) {
      throw new SCMPValidatorException(error, "String value is missing");
    }
    int length = stringValue.getBytes().length;
    if (length < minSizeInc || length > maxSizeInc) {
      throw new SCMPValidatorException(error, "StringValue length=" + length + " is not in range (" + minSizeInc + "-"
          + maxSizeInc + ")");
    }
    byte[] buffer = stringValue.getBytes();
    for (int i = 0; i < buffer.length; i++) {
      if (ValidatorUtility.isCharacterAllowed(buffer[i]) == false) {
        throw new SCMPValidatorException(error, "String value contains forbidden character=" + new String(buffer));
      }
    }
  }
View Full Code Here

   * @throws SCMPValidatorException
   *             the SCMP validator exception
   */
  public static void validateMask(String mask, SCMPError error) throws SCMPValidatorException {
    if (mask == null) {
      throw new SCMPValidatorException(error, "Mask value is missing");
    }
    if (mask.indexOf("%") > -1) {
      throw new SCMPValidatorException(error, "Mask value contains % character=" + mask);
    }
    byte[] buffer = mask.getBytes();
    for (int i = 0; i < buffer.length; i++) {
      if (ValidatorUtility.isCharacterAllowed(buffer[i]) == false) {
        throw new SCMPValidatorException(error, "Mask value contains forbidden character=" + mask);
      }
    }
  }
View Full Code Here

      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
    } catch (Throwable th) {
      LOGGER.error("validation error", th);
      SCMPValidatorException validatorException = new SCMPValidatorException();
      validatorException.setMessageType(getKey());
      throw validatorException;
    }
  }
View Full Code Here

      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
    } catch (Throwable th) {
      LOGGER.error("validation error", th);
      SCMPValidatorException validatorException = new SCMPValidatorException();
      validatorException.setMessageType(getKey());
      throw validatorException;
    }
  }
View Full Code Here

      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
    } catch (Throwable th) {
      LOGGER.error("validation error", th);
      SCMPValidatorException validatorException = new SCMPValidatorException();
      validatorException.setMessageType(getKey());
      throw validatorException;
    }
  }
View Full Code Here

    // 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;
View Full Code Here

    // 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
View Full Code Here

      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
    } catch (Throwable th) {
      LOGGER.error("validation error", th);
      SCMPValidatorException validatorException = new SCMPValidatorException();
      validatorException.setMessageType(getKey());
      throw validatorException;
    }
  }
View Full Code Here

      String maxConnectionsValue = message.getHeader(SCMPHeaderAttributeKey.MAX_CONNECTIONS);
      ValidatorUtility.validateInt(1, maxConnectionsValue, maxSessions, SCMPError.HV_WRONG_MAX_CONNECTIONS);
      int maxConnections = Integer.parseInt(maxConnectionsValue);
      if (maxConnections == 1 && maxSessions != 1) {
        // invalid configuration
        throw new SCMPValidatorException(SCMPError.HV_WRONG_MAX_SESSIONS, "maxSessions must be 1 if maxConnections is 1");
      }
      // portNr - portNr >= 1 && portNr <= 0xFFFF mandatory
      String portNr = message.getHeader(SCMPHeaderAttributeKey.PORT_NR);
      ValidatorUtility.validateInt(Constants.MIN_PORT_VALUE, portNr, Constants.MAX_PORT_VALUE, SCMPError.HV_WRONG_PORTNR);
      // keepAliveInterval mandatory
      String kpi = message.getHeader(SCMPHeaderAttributeKey.KEEP_ALIVE_INTERVAL);
      ValidatorUtility.validateInt(Constants.MIN_KPI_VALUE, kpi, Constants.MAX_KPI_VALUE,
          SCMPError.HV_WRONG_KEEPALIVE_INTERVAL);
      // checkRegistrationInterval mandatory
      String cri = message.getHeader(SCMPHeaderAttributeKey.CHECK_REGISTRATION_INTERVAL);
      ValidatorUtility.validateInt(Constants.MIN_CRI_VALUE, cri, Constants.MAX_CRI_VALUE,
          SCMPError.HV_WRONG_CHECK_REGISTRATION_INTERVAL);
    } catch (HasFaultResponseException ex) {
      // needs to set message type at this point
      ex.setMessageType(getKey());
      throw ex;
    } catch (Throwable th) {
      LOGGER.error("validation error", th);
      SCMPValidatorException validatorException = new SCMPValidatorException();
      validatorException.setMessageType(getKey());
      throw validatorException;
    }
  }
View Full Code Here

TOP

Related Classes of org.serviceconnector.cmd.SCMPValidatorException

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.