Package gwtappcontainer.server.apps

Examples of gwtappcontainer.server.apps.APIException


    name = name.toUpperCase();
    //name should not be already present
    RoleEntity entity = getRoleEntity(name);
   
    if (null != entity)
      throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
          "Role [" + name + "] is already present");
   
   
    entity = new RoleEntity();
    entity.name = name;
View Full Code Here


    NamespaceManager.set(NAMESPACE);
   
    RoleEntity entity = getRoleEntity(existingName);   
   
    if (null == entity) { 
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Role [" + existingName + "] does not exist");     
   
               
    //if new name is different - check if it is valid
    existingName = existingName.toUpperCase();
    newName = newName.toUpperCase();
    if (! existingName.equals(newName)) {
      RoleEntity entity2 = getRoleEntity(newName);

      if (null != entity2) {     
        throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
            "Role [" + newName + "] already exists.");             
      }
    }
   
    //save with new name
View Full Code Here

    NamespaceManager.set(NAMESPACE);
   
    RoleEntity entity = getRoleEntity(name);
   
    if (null == entity) {
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Role [" + name + "] does not exist");     
    }
                   
    ofy().delete().entity(entity).now();   
  }
View Full Code Here

  }
 
  public static void add(String email, String firstName, String lastName) {        
         
     if (null != get(email))
       throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
           "[" + email + "] is already present");
    
     try {
         String sql = "insert into teachers values (0, ?, ?, ?)";                             
         try (Connection connection = DriverManager.getConnection(Utils.getCloudSqlURL())) {               
View Full Code Here

public class AccessController {
 
  public static void ensureValidUser(User user) {
    if (null == user)
      throw new APIException(Status.ERROR_LOGIN_REQUIRED,
          "User not logged in");
   
    if (isSuperUser(user.getEmail()))
      return;
   
    UserProp userProp = UserRepository.getUser(user.getEmail());
   
    if (null == userProp)
      throw new APIException(Status.ERROR_INVALID_USER,
          "User [" + user.getEmail() + "] in invalid");   
   
  }
View Full Code Here

   
  }
 
  public static void ensurePrivilege(String login, String privilege) {
    if (null == login)
      throw new APIException(Status.ERROR_LOGIN_REQUIRED,
          "User not logged in");           
   
    if (isSuperUser(login))
      return;       
   
    UserProp userProp = UserRepository.getUser(login);
   
    if (null == userProp)
      throw new APIException(Status.ERROR_INVALID_USER,
          "User [" + login + "] in invalid");
   
    privilege = privilege.toUpperCase();     
         
    if (userProp.privileges == null)
      throw new APIException(Status.ERROR_INSUFFICIENT_PERMISSION,
          "User [" + login + "] does not have privilege [" + privilege + "]");
   
    if ((userProp.privileges != null) &&
        (userProp.privileges.contains(privilege)))
      return;
   
    for (RoleProp roleProp : userProp.roles) {
      if ((roleProp.privileges != null) &&
          roleProp.privileges.contains(privilege))
        return;
    }
   
    throw new APIException(Status.ERROR_INSUFFICIENT_PERMISSION,
        "User [" + login + "] does not have privilege [" + privilege + "]")
  }
View Full Code Here

        "User [" + login + "] does not have privilege [" + privilege + "]")
  }
 
  public static void ensureValidUser(String login) {
    if (null == login)
      throw new APIException(Status.ERROR_LOGIN_REQUIRED,
          "User not logged in");
   
    if (isSuperUser(login))
      return;
   
    UserProp userProp = UserRepository.getUser(login);
   
    if (null == userProp)
      throw new APIException(Status.ERROR_INVALID_USER,
          "User [" + login + "] in invalid");   
   
  }
View Full Code Here

   
  }
 
  public static void ensureLoggedin(User user) {
    if (null == user)
      throw new APIException(Status.ERROR_LOGIN_REQUIRED,
          "User not logged in");     
  }
View Full Code Here

  }
 
  public static ProgramType add(String programTypeName) {
         
     if (null != get(programTypeName))
       throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
           "Program type [" + programTypeName + "] already exists");
    
     try {
         String sql = "insert into program_types values (0, ?)";                     
       
View Full Code Here

  public static void delete(String programTypeName) {
        
       ProgramType programType = get(programTypeName);
     
       if (null == programType)
           throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
                           "Program type [" + programTypeName + "] does not exist");
                                             
       try {
           String sql = "delete from program_types where program_type = ?";                       
         
View Full Code Here

TOP

Related Classes of gwtappcontainer.server.apps.APIException

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.