Package com.baasbox.exception

Examples of com.baasbox.exception.InvalidJsonException


                          ODocument attrObj = new ODocument(dao.USER_ATTRIBUTES_CLASS);
                          try{
                              if (nonAppUserAttributes!=null) attrObj.fromJSON(nonAppUserAttributes.toString());
                              else attrObj.fromJSON("{}");
                          }catch (OSerializationException e){
                                  throw new InvalidJsonException (dao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER + " is not a valid JSON object",e);
                          }
                          PermissionsHelper.grantRead(attrObj, RoleDao.getRole(DefaultRoles.REGISTERED_USER.toString()));
                          PermissionsHelper.grantRead(attrObj, RoleDao.getRole(DefaultRoles.ANONYMOUS_USER.toString()));       
                          PermissionsHelper.grantRead(attrObj, friendRole);                               
                          PermissionsHelper.changeOwner(attrObj,userRid );
                          profile.field(dao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER,attrObj);
                          attrObj.save();
                  }
                 
                    /*    these attributes are visible by:
                     *    User
                     */                               
                  {
                          ODocument attrObj = new ODocument(dao.USER_ATTRIBUTES_CLASS);
                          try{
                            if (privateAttributes!=null) attrObj.fromJSON(privateAttributes.toString());
                            else attrObj.fromJSON("{}");
                          }catch (OSerializationException e){
                                  throw new InvalidJsonException (dao.ATTRIBUTES_VISIBLE_ONLY_BY_THE_USER + " is not a valid JSON object",e);
                          }
                          profile.field(dao.ATTRIBUTES_VISIBLE_ONLY_BY_THE_USER, attrObj);
                          PermissionsHelper.changeOwner(attrObj, userRid);                                       
                          attrObj.save();
                  }
                 
                    /*    these attributes are visible by:
                     *    Friends
                     *    User
                     */                               
                 {
                          ODocument attrObj = new ODocument(dao.USER_ATTRIBUTES_CLASS);
                          try{       
                             if (friendsAttributes!=null) attrObj.fromJSON(friendsAttributes.toString());
                             else attrObj.fromJSON("{}");
                          }catch (OSerializationException e){
                                  throw new InvalidJsonException (dao.ATTRIBUTES_VISIBLE_BY_FRIENDS_USER + " is not a valid JSON object",e);
                          }
                          PermissionsHelper.grantRead(attrObj, friendRole);                               
                          PermissionsHelper.changeOwner(attrObj, userRid);
                          profile.field(dao.ATTRIBUTES_VISIBLE_BY_FRIENDS_USER, attrObj);
                          attrObj.save();
                  }
                 
                    /*    these attributes are visible by:
                     *    Registered user
                     *    Friends
                     *    User
                     */                               
                 {
                          ODocument attrObj = new ODocument(dao.USER_ATTRIBUTES_CLASS);
                          try{
                            if (appUsersAttributes!=null) attrObj.fromJSON(appUsersAttributes.toString());
                             else attrObj.fromJSON("{}");
                          }catch (OSerializationException e){
                                  throw new InvalidJsonException (dao.ATTRIBUTES_VISIBLE_BY_REGISTERED_USER + " is not a valid JSON object",e);
                          }
                          attrObj.field("_social",new HashMap());
                          PermissionsHelper.grantRead(attrObj, RoleDao.getRole(DefaultRoles.REGISTERED_USER.toString()));      
                          PermissionsHelper.changeOwner(attrObj, userRid);
                          profile.field(dao.ATTRIBUTES_VISIBLE_BY_REGISTERED_USER, attrObj);
                          attrObj.save();
                  }
                   
                  //system info
                  {
                    ODocument attrObj = new ODocument(dao.USER_ATTRIBUTES_CLASS);
                    attrObj.field(dao.USER_LOGIN_INFO, new ArrayList() );
                    attrObj.field(dao.USER_SIGNUP_DATE, signupDate==null?new Date():signupDate);
                    PermissionsHelper.changeOwner(attrObj, userRid);
                    profile.field(dao.ATTRIBUTES_SYSTEM, attrObj);  
                  }
                 
                  profile.field(dao.USER_SIGNUP_DATE, signupDate==null?new Date():signupDate);
                  //this is useful when you want to know if the username was automatically generated
                  profile.field(UserDao.GENERATED_USERNAME,generated);
                 
                  PermissionsHelper.grantRead(profile, RoleDao.getRole(DefaultRoles.REGISTERED_USER.toString()));
                  PermissionsHelper.grantRead(profile, RoleDao.getRole(DefaultRoles.ANONYMOUS_USER.toString()));
                  PermissionsHelper.changeOwner(profile, userRid);
                 
                 
                  profile.save();
                  DbHelper.commitTransaction();
        }catch( OSerializationException e ){
            DbHelper.rollbackTransaction();
            throw new InvalidJsonException(e);
        }catch( InvalidJsonException e ){
            DbHelper.rollbackTransaction();
            throw e;
        }catch( UserAlreadyExistsException e ){
            DbHelper.rollbackTransaction();
View Full Code Here


      profile.save();
      profile.reload();

      return profile;
    }catch (OSerializationException e){
      throw new InvalidJsonException(e);
    }catch (Exception e){
      throw e;
    }
  }//updateProfile with role
View Full Code Here

      dao.update(doc,(ODocument) (new ODocument()).fromJSON(bodyJson.toString()));
      dao.save(doc);
      DbHelper.commitTransaction();
    }catch (OSerializationException e){
      DbHelper.rollbackTransaction();
      throw new InvalidJsonException(e);
    }catch (UpdateOldVersionException e){
      DbHelper.rollbackTransaction();
      throw new UpdateOldVersionException("Are you trying to create a document with a @version field?");
    }
   
View Full Code Here

        ODocument metaDoc=(new ODocument()).fromJSON("{ 'meta' : " + meta + "}");
        doc.merge(metaDoc, true, false);
      }
      dao.save(doc);
    }catch (OSerializationException e){
      throw new InvalidJsonException(e);
    }catch (Throwable e){
      throw e;
    }
    return doc;
  }
View Full Code Here

TOP

Related Classes of com.baasbox.exception.InvalidJsonException

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.