Package gwtappcontainer.server.apps

Examples of gwtappcontainer.server.apps.APIException


  public static void updateContactDetails(int memberId, Member.ContactDetails contactDetails, String login) {
    String email = getEmailFromMemberId(memberId);
   
    if (email == null)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "There is no member with id [" + memberId + "]");
   
    if (! login.equals(email))
      AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
   
View Full Code Here


   
    AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
    SyntaxChecker.ensureValid(contactDetails);
       
    if (memberIds.size() != contactDetails.size())
      throw new APIException(Status.ERROR_RESOURCE_INCORRECTLY_SPECIFIED,
          "List size mismatch. Num of members ids [" + memberIds.size() +
          "] does not match no of contact details [" + contactDetails.size() + "]");
       
        String sql = "update members set " +
            "first_name = ?, middle_name = ?, " +
View Full Code Here

 
  public static void addCenter(long memberId, long centerId, String login) {
   
    String email = getEmailFromMemberId(memberId);
    if (null == email)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "There is no member with id [" + memberId + "]");
   
    if (! email.equals(login))
      AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
   
View Full Code Here

  public static void deleteCenter(int memberId, int centerId, String login) {
   
    Member member = get(memberId, login);
   
    if (null == member)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "There is no member with id [" + memberId + "]");
   
    if (! login.equals(member.contactDetails.email))
      AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
   
    if (centerId == member.owningCenter.id)
      throw new APIException(Status.ERROR_PRECONDITION_FAILURE,
          "Cannot delete owning center [" + centerId + "] for member [" + memberId + "]");
       
    try {
            String sql = "delete from member_centers where member_id = ? and center_id = ?";         
          
View Full Code Here

  }

  public static void addUnlistedProgram(long memberId, UnlistedProgram unlistedProgram, String login) {
       
    if (unlistedProgram.month < 1 || unlistedProgram.month > 12)
      throw new APIException(Status.ERROR_RESOURCE_INCORRECTLY_SPECIFIED,
          "Month should be between 1 and 12");       
   
    if (unlistedProgram.year < 1970 || unlistedProgram.year > Calendar.getInstance().get(Calendar.YEAR))
      throw new APIException(Status.ERROR_RESOURCE_INCORRECTLY_SPECIFIED,
          "Year should be after 1970 and lesser than or equal to current year");
   
    String email = getEmailFromMemberId(memberId);
    if (null == email)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "There is no member with id [" + memberId + "]");
   
    if (! email.equals(login))
      AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
           
View Full Code Here

 
  public static void deleteUnlistedProgram(int unlistedProgramId, String login) { 
    String email = getEmailFromUnlistedProgramId(unlistedProgramId, login);
   
    if (null == email)
      throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
          "There is no unlisted program with id [" + unlistedProgramId + "]");
   
    if (! email.equals(login))
      AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
   
View Full Code Here

      String login) {
   
    AccessController.ensurePrivilege(login, Privileges.EDIT_MEMBER);
   
    if (contactDetails.size() > Limits.Member.MAX_NUMRECORDS_BULKIMPORT)
      throw new APIException(Status.ERROR_OUT_OF_BOUNDS,
          "No of records [" + contactDetails.size() + "] is greater than max allowed [" +
              Limits.Member.MAX_NUMRECORDS_BULKIMPORT + "]");
   
    SyntaxChecker.ensureValid(contactDetails);
   
    List<String> emails = new ArrayList<>();
    Set<String> emailSet = new HashSet<>();
    for (ContactDetails contact : contactDetails) {
      contact.email = contact.email.toLowerCase(); //email always in lower case 
      if (emailSet.contains(contact.email))
        throw new APIException(Status.ERROR_RESOURCE_INCORRECTLY_SPECIFIED,
            "Email [" + contact.email + "] is a duplicate");
     
      emails.add(contact.email);
      emailSet.add(contact.email);
    }
View Full Code Here

      gateKeeper.ensureRole(user, contentAdminRole,
          Role.PORTAL_ADMIN.toString());
     
      //ensure tag is valid
      if (false == isValidTag(tag))
        throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
            "[" + tag + "] is not valid");
           
      ContentRepository repository = new ContentRepository();
     
      ContentProp prop = repository.setContent(html, tag, publish);               
View Full Code Here

      if (null != html9) sb.append(html9);
     
      String content = sb.toString();
     
      if (content.equals(""))
        throw new APIException(Status.ERROR_RESOURCE_INCORRECTLY_SPECIFIED,
            "content cannot be empty");
     
      APIResponse response = setContent(content, tag, publish, user);
      if (response.statusCode != Status.SUCCESS)
        throw new APIException(response.statusCode, response.userFriendlyMessage);
               
      return response;
     
    } catch (Exception ex) {
      return new APIResponse(ex);
View Full Code Here

      ContentProp prop = repository.getContent(tag);
           
      logger.info("received getContent for tag - " + tag);
     
      if (null == prop)
        throw new APIException(Status.ERROR_RESOURCE_DOES_NOT_EXIST,
            "Either tag [" + tag +
            "] is invalid or there is no content for this tag");
     
      //if publish is true anyone can view content, otherwise only valid users
      if (prop.publish == false)
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.