Package org.openmhealth.reference.exception

Examples of org.openmhealth.reference.exception.OmhException


    final boolean granted)
    throws OmhException {
   
    // Verify the authorization code.
    if(authorizationCode == null) {
      throw new OmhException("The authorization code is null.");
    }
    else {
      this.authorizationCode = authorizationCode.getCode();
    }
   
    // Verify the owner.
    if(user == null) {
      throw new OmhException("The user is null.");
    }
    else {
      this.owner = user.getUsername();
    }
   
View Full Code Here


    @JsonProperty(JSON_KEY_GRANTED) final boolean granted)
    throws OmhException {
   
    // Verify the authorization code.
    if(authorizationCode == null) {
      throw new OmhException("The authorization code is null.");
    }
    else {
      this.authorizationCode = authorizationCode;
    }
   
    // Verify the owner.
    if(owner == null) {
      throw new OmhException("The owner is null.");
    }
    else {
      this.owner = owner;
    }
   
View Full Code Here

    final String description,
    final String redirectUri) {
   
    // Basic validation for the authentication token.
    if(authToken == null) {
      throw new OmhException("The authentication token is null.");
    }
    else {
      this.authToken = authToken;
    }
   
    // Basic validation for the name.
    if(name == null) {
      throw new OmhException("The name is null.");
    }
    else {
      this.name = name;
    }
   
    // Basic validation for the description.
    if(description == null) {
      throw new OmhException("The description is null.");
    }
    else {
      this.description = description;
    }
   
    // Basic validation for the redirect URI.
    if(redirectUri == null) {
      throw new OmhException("The redirect URI is null.");
    }
    else {
      try {
        this.redirectUri = new URI(redirectUri);
      }
      catch(URISyntaxException e) {
        throw
          new OmhException(
            "The redirect URI is not a valid URI.",
            e);
      }
     
      // TODO: We may want to do more thorough validation of the request
View Full Code Here

   
    super(numToSkip, numToReturn);
   
    // Validate the schema ID.
    if(schemaId == null) {
      throw new OmhException("The schema ID is missing.");
    }
    else {
      this.schemaId = schemaId;
    }
  }
View Full Code Here

    final String password)
    throws OmhException {
   
    // Validate the username.
    if(username == null) {
      throw new OmhException("The username is missing.");
    }
    else {
      this.username = username;
    }
   
    // Validate the password.
    if(password == null) {
      throw new OmhException("The password is missing.");
    }
    else {
      this.password = password;
    }
  }
View Full Code Here

    // Get the user.
    User user = getUser(username, password);
   
    // Verify that the account is active.
    if(! user.isActivated()) {
      throw new OmhException("The account has not been activated.");
    }
   
    // Create the user's authentication token.
    AuthenticationToken token = new AuthenticationToken(user);
   
View Full Code Here

    final String email,
    final String rootUrl)
    throws OmhException {
   
    if(rootUrl == null) {
      throw new OmhException("The root URL is null.");
    }
   
    // Create the new user from the parameters and a random registration
    // ID.
    this.user =
View Full Code Here

   
    // Verify that the registration key and date align.
    if(registrationKey == null) {
      if(dateRegistered != null) {
        throw
          new OmhException(
            "The account does not have a registration key but " +
              "has a registration date.");
      }
    }
    else {
      if(dateRegistered == null) {
        throw
          new OmhException(
            "The account has a registration key but does not " +
              "have a registration date.");
      }
     
      // Verify that if a registration key was given that it is not empty.
      if(registrationKey.length() == 0) {
        throw new OmhException("The registration key is empty.");
      }
    }
   
    // Verify that the account was not registered after it was activated.
    if(
      (dateRegistered != null) &&
      (dateActivated != null) &&
      dateRegistered > dateActivated) {
     
      throw
        new OmhException(
          "The account was activated before it was registered.");
    }
   
    // Store the registration and activation information.
    this.registrationKey = registrationKey;
View Full Code Here

    return dateActivated;
  }
 
  public void activate() throws OmhException {
    if(isActivated()) {
      throw new OmhException("The account has already been activated.");
    }
   
    if(registrationKey == null) {
      throw
        new OmhException(
          "This account is not elegible for activation.");
    }
   
    dateActivated = System.currentTimeMillis();
  }
View Full Code Here

  public static String validateUsername(
    final String username)
    throws OmhException {
   
    if(username == null) {
      throw new OmhException("The username is null.");
    }
    String trimmedUsername = username.trim();
    if(trimmedUsername.length() == 0) {
      throw new OmhException("The username is empty.");
    }
   
    return trimmedUsername;
  }
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.