Package gwtappcontainer.server.apps

Examples of gwtappcontainer.server.apps.APIException


  }

  public static ProgramType addPractise(String programTypeName, String practiseName) {
    ProgramType programType = get(programTypeName);
    if (null == programType)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Program type [" + programTypeName + "] does not exist");
   
    Practise practise = PractiseRepository.get(practiseName);
    if (null == practise)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Practise [" + practiseName + "] does not exist");
   
    practiseName = practiseName.toLowerCase();
    if (programType.practises.contains(practiseName))
      return programType;
View Full Code Here


 
  @ApiMethod(path = "getrolesforloggedinuser", httpMethod = HttpMethod.GET)
  public APIResponse getRolesForLoggedInUser(User user) {   
    try {                   
      if (user == null) {
        throw new APIException(Status.ERROR_LOGIN_REQUIRED, "Login required");
      }
     
      String email = user.getEmail();
      APIResponse resp = getRolesForUser(email);
             
View Full Code Here

  }
 
  public static ProgramType deletePractise(String programTypeName, String practiseName) {
    ProgramType programType = get(programTypeName);
    if (null == programType)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Program type [" + programTypeName + "] does not exist");
   
    Practise practise = PractiseRepository.get(practiseName);
    if (null == practise)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Practise [" + practiseName + "] does not exist");
   
    practiseName = practiseName.toLowerCase();
    if (! programType.practises.contains(practiseName))
      return programType;
View Full Code Here

    try {
      UserRepository userRepository = new UserRepository();
      List<UserProp> allProps = userRepository.getAllUsers();
     
      if (0 == allProps.size()) {
        throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST, "No users available");       
      }
     
      APIResponse resp = new APIResponse();
      resp.statusCode = Status.SUCCESS;
      resp.object = allProps;
View Full Code Here

    email = email.toLowerCase();
   
    UserEntity entity = ofy().load().type(UserEntity.class).id(email).get();
   
    if (entity != null)
      throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
          "There is already an existing user with email [" + email + "]");
   
    entity = new UserEntity();
    entity.email = email;
    ofy().save().entity(entity).now();   
View Full Code Here

    email = email.toLowerCase();
   
    UserEntity entity = ofy().load().type(UserEntity.class).id(email).get();
   
    if (entity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "There is no existing user with email [" + email + "]");
   
    ofy().delete().entity(entity).now()
  }
View Full Code Here

    email = email.toLowerCase();
    privilege = privilege.toUpperCase();
    UserEntity entity = ofy().load().type(UserEntity.class).id(email).get();
   
    if (entity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "User [" + email + "] not found");
   
    if (! PrivilegeRepository.getAllPrivileges().contains(privilege))
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Privilege [" + privilege + "] is not valid");
   
    if (entity.privileges.contains(privilege))
      throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
          "User [" + email + "] already has privilege [" + privilege + "]");
   
    entity.privileges.add(privilege);
    ofy().save().entity(entity).now();
   
View Full Code Here

    NamespaceManager.set(NAMESPACE);
    email = email.toLowerCase();   
    UserEntity entity = ofy().load().type(UserEntity.class).id(email).get();
   
    if (entity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "User [" + email + "] not found");
   
    privilege = privilege.toUpperCase();
    if (! PrivilegeRepository.getAllPrivileges().contains(privilege))
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Privilege [" + privilege + "] is not valid");
   
    if (! entity.privileges.contains(privilege))
      throw new APIException(Status.ERROR_RESOURCE_ALREADY_EXISTS,
          "User [" + email + "] already does not have privilege [" + privilege + "]");
   
    entity.privileges.remove(privilege);
    ofy().save().entity(entity).now();
  }
View Full Code Here

   
    NamespaceManager.set(NAMESPACE);
    email = email.toLowerCase();   
    UserEntity userEntity = ofy().load().type(UserEntity.class).id(email).get();   
    if (userEntity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "User [" + email + "] not found");
   
    role = role.toUpperCase();       
    Ref<RoleEntity> roleEntity = ofy().load().type(RoleEntity.class).
        filter("role", role).first();   
    if (roleEntity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Role [" + role + "] not found");
   
    userEntity.roles.add(roleEntity);
    ofy().save().entity(userEntity).now();
  }
View Full Code Here

   
    NamespaceManager.set(NAMESPACE);
    email = email.toLowerCase();   
    UserEntity userEntity = ofy().load().type(UserEntity.class).id(email).get();   
    if (userEntity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "User [" + email + "] not found");
   
    role = role.toUpperCase();       
    Ref<RoleEntity> roleEntity = ofy().load().type(RoleEntity.class).
        filter("role", role).first();   
    if (roleEntity == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "Role [" + role + "] not found");
   
    userEntity.roles.remove(roleEntity);
    ofy().save().entity(userEntity).now();
  }
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.