Package org.openmhealth.reference.exception

Examples of org.openmhealth.reference.exception.OmhException


    // Validate the number of elements to skip.
    if(numToSkip == null) {
      this.numToSkip = DEFAULT_NUMBER_TO_SKIP;
    }
    else if(numToSkip < 0) {
      throw new OmhException(
        "The number to skip must be 0 or positive: " + numToSkip);
    }
    else {
      this.numToSkip = numToSkip;
    }

    // Validate the number of elements to return.
    if(numToReturn == null) {
      this.numToReturn = DEFAULT_NUMBER_TO_RETURN;
    }
    else if(numToReturn <= 0) {
      throw new OmhException(
        "The number to return must be positive: " + numToReturn);
    }
    else if(numToReturn > DEFAULT_NUMBER_TO_RETURN) {
      throw new OmhException(
        "The number to return is greater than the allowed " +
          "default (" +
          DEFAULT_NUMBER_TO_RETURN +
          "): " +
          numToReturn);
View Full Code Here


    final long schemaVersion)
    throws OmhException {
   
    // Validate the schema ID.
    if(schemaId == null) {
      throw new OmhException("The schema ID is missing.");
    }
    else {
      this.schemaId = schemaId;
    }
   
View Full Code Here

   
    super(thirdParty, code, creationTime, expirationTime, scopes, state);
   
    // Store the MongoDB ID.
    if(dbId == null) {
      throw new OmhException("The MongoDB ID is missing.");
    }
    else {
      this.dbId = dbId;
    }
  }
View Full Code Here

    super(owner, schemaId, schemaVersion, metaData, data);
   
    // Store the MongoDB ID.
    if(dbId == null) {
      throw new OmhException("The MongoDB ID is missing.");
    }
    else {
      this.dbId = dbId;
    }
  }
View Full Code Here

      throw
        new InvalidAuthenticationException(
          "The authentication token is missing.");
    }
    if(schemaId == null) {
      throw new OmhException("The schema ID is missing.");
    }
    if(data == null) {
      throw new OmhException("The data is missing.");
    }
   
    this.authToken = authToken;
    this.schemaId = schemaId;
    this.version = version;
View Full Code Here

    // Check to be sure the schema is known.
    MultiValueResult<? extends Schema> schemas =
      Registry.getInstance().getSchemas(schemaId, version, 0, 1);
    if(schemas.count() == 0) {
      throw
        new OmhException(
          "The schema ID, '" +
            schemaId +
            "', and version, '" +
            version +
            "', pair is unknown.");
    }
    Schema schema = schemas.iterator().next();
   
    // Get the user that owns this token.
    User requestingUser = authToken.getUser();
   
    // Parse the data.
    JsonNode dataNode;
    try {
      dataNode =
        JSON_FACTORY
          .createJsonParser(data).readValueAs(JsonNode.class);
    }
    catch(JsonParseException e) {
      throw new OmhException("The data was not well-formed JSON.", e);
    }
    catch(JsonProcessingException e) {
      throw new OmhException("The data was not well-formed JSON.", e);
    }
    catch(IOException e) {
      throw new OmhException("The data could not be read.", e);
    }
   
    // Make sure it is a JSON array.
    if(! (dataNode instanceof ArrayNode)) {
      throw new OmhException("The data was not a JSON array.");
    }
    ArrayNode dataArray = (ArrayNode) dataNode;
   
    // Get the number of data points.
    int numDataPoints = dataArray.size();
   
    // Create the result list of data points.
    List<Data> dataPoints = new ArrayList<Data>(numDataPoints);
   
    // Create a new ObjectMapper that will be used to convert the meta-data
    // node into a MetaData object.
    ObjectMapper mapper = new ObjectMapper();
   
    // For each element in the array, be sure it is a JSON object that
    // represents a valid data point for this schema.
    for(int i = 0; i < numDataPoints; i++) {
      // Get the current data point.
      JsonNode dataPoint = dataArray.get(i);
     
      // Validate that it is a JSON object.
      if(! (dataPoint instanceof ObjectNode)) {
        throw
          new OmhException(
            "A data point was not a JSON object: " + i);
      }
      ObjectNode dataObject = (ObjectNode) dataPoint;
     
      // Attempt to get the meta-data;
      MetaData metaData = null;
      JsonNode metaDataNode = dataObject.get(Data.JSON_KEY_METADATA);
      if(metaDataNode != null) {
        metaData = mapper.convertValue(metaDataNode, MetaData.class);
      }
     
      // Attempt to get the schema data.
      JsonNode schemaData = dataObject.get(Data.JSON_KEY_DATA);
     
      // If the data is missing, fail the request.
      if(schemaData == null) {
        throw
          new OmhException(
            "A data point's '" +
              Data.JSON_KEY_DATA +
              "' field is missing.");
      }
     
View Full Code Here

    super(id, version, schema, controller);
   
    // Store the MongoDB ID.
    if(dbId == null) {
      throw new OmhException("The MongoDB ID is missing.");
    }
    else {
      this.dbId = dbId;
    }
  }
View Full Code Here

   
    super(owner, id, sharedSecret, name, description, redirectUri);
   
    // Store the MongoDB ID.
    if(dbId == null) {
      throw new OmhException("The MongoDB ID is missing.");
    }
    else {
      this.dbId = dbId;
    }
  }
View Full Code Here

      final ValidationController controller)
    throws OmhException {

    // Validate the ID.
    if(id == null) {
      throw new OmhException("The ID is null.");
    }
    else if(id.trim().length() == 0) {
      throw new OmhException("The ID is empty.");
    }
    else {
      this.id = validateId(id);
    }

    // Validate the version.
    this.version = validateVersion(version);
   
    // Make sure the schema is not null.
    if(schema == null) {
      throw new OmhException("The schema is null.");
    }
    try {
      this.schema =
        new Concordia(
          new ByteArrayInputStream(schema.toString().getBytes()),
          controller);
    }
    catch(IllegalArgumentException e) {
      throw new OmhException("The schema is missing.", e);
    }
    catch(ConcordiaException e) {
      throw new OmhException("The schema is invalid.", e);
    }
    catch(IOException e) {
      throw new OmhException("The schema cannot be read.", e);
    }
  }
View Full Code Here

      creationTime,
      expirationTime);
   
    // Store the MongoDB ID.
    if(dbId == null) {
      throw new OmhException("The MongoDB ID is missing.");
    }
    else {
      this.dbId = dbId;
    }
  }
View Full Code Here

TOP

Related Classes of org.openmhealth.reference.exception.OmhException

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.