Package org.milowski.db

Examples of org.milowski.db.DBConnection


  
   public User findUserByEmail(final String email)
      throws SQLException
   {
      final Slot<User> user = new Slot<User>();
      final DBConnection connection = getConnection();
      try {
         connection.query(USER_BY_EMAIL, new DBQueryHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setString(1, email);
            }
View Full Code Here


  
   public Iterator<User> getUsers(boolean all)
      throws SQLException
   {
      final Slot<Iterator<User>> result = new Slot<Iterator<User>>();
      final DBConnection connection = getConnection();
      try {
         connection.query(all ? USERS : GLOBAL_USERS, new DBQueryHandler() {
            public boolean shouldClose() { return false; }
            public void onResults(ResultSet set)
               throws SQLException
            {
               result.set(new DBIterator<User>(set,new DBResultConstructor<User>() {
View Full Code Here

   {
      DBCache<UUID,Group> cache = realmGroupCaches.get(realm);
      if (cache.getNamed(alias)!=null) {
         return null;
      }
      DBConnection connection = getConnection();
      try {
         int id = connection.create(CREATE_GROUP,LAST_ID_FROM_GROUPS, new DBUpdateHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setInt(1,realm.getId());
               s.setString(2,uuid.toString());
View Full Code Here

   public Iterator<Group> getGroups(final Realm realm)
      throws SQLException
   {
      final Slot<Iterator<Group>> result = new Slot<Iterator<Group>>();
      final DBCache<UUID,Group> cache = realmGroupCaches.get(realm);
      final DBConnection connection = getConnection();
      try {
         connection.query(GROUPS, new DBQueryHandler() {
            public boolean shouldClose() { return false; }
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setInt(1,realm.getId());
View Full Code Here

   {
      // Check for realm conflicts with specified alias
      final Slot<Boolean> found = new Slot<Boolean>(false);
      if (alias!=null) {
         // check realm against alias
         DBConnection connection = getConnection();
         try {
            connection.query(REALM_USER_BY_ALIAS, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setString(2,alias);
               }
               public void onResults(ResultSet set)
                  throws SQLException
               {
                  found.set(set.next());
               }
            });
            if (found.get()) {
               return false;
            }
            // check inherited aliases
            connection.query(REALM_USER_HAS_INHERITED_ALIAS, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setString(2,alias);
               }
               public void onResults(ResultSet set)
                  throws SQLException
               {
                  found.set(set.next());
               }
            });
            if (found.get()) {
               return false;
            }
         } finally {
            release(connection);
         }
      }
      //
      if (alias==null) {
         // Check inherited alias against local aliases
         DBConnection connection = getConnection();
         try {
            connection.query(REALM_USER_BY_ALIAS, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setString(2,user.getAlias());
View Full Code Here

   {
      if (!isRealmUserAliasAvailable(realm,user,alias)) {
         return null;
      }
      final Timestamp tstamp = new Timestamp((new Date()).getTime());
      DBConnection connection = getConnection();
      try {
         int id = connection.create(CREATE_REALM_USER,LAST_ID_FROM_REALM_USERS, new DBUpdateHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setInt(1,realm.getId());
               s.setInt(2,user.getId());
View Full Code Here

  
   public RealmUser findRealmUserByEmail(final Realm realm,final String email)
      throws SQLException
   {
      final Slot<RealmUser> ruser = new Slot<RealmUser>();
      final DBConnection connection = getConnection();
      try {
         connection.query(REALM_USER_BY_EMAIL, new DBQueryHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setInt(1,realm.getId());
               s.setString(2, email);
            }
            public void onResults(ResultSet set)
               throws SQLException
            {
               if (set.next()) {
                  ruser.set(realmUserCaches.get(realm).get(set.getInt(1)));
               }
            }
         });
         if (ruser.get()!=null) {
            return ruser.get();
         }
         final User user = findUserByEmail(email);
         if (user!=null) {
            connection.query(REALM_USER_BY_USER, new DBQueryHandler() {
               public void prepare(PreparedStatement s)
                  throws SQLException
               {
                  s.setInt(1,realm.getId());
                  s.setInt(2, user.getId());
View Full Code Here

   public Iterator<RealmUser> getRealmUsers(final Realm realm)
      throws SQLException
   {
      final DBCache<UUID,RealmUser> cache = realmUserCaches.get(realm);
      final Slot<Iterator<RealmUser>> result = new Slot<Iterator<RealmUser>>();
      final DBConnection connection = getConnection();
      try {
         connection.query(REALM_USERS, new DBQueryHandler() {
            public boolean shouldClose() { return false; }
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setInt(1,realm.getId());
View Full Code Here

    */
   public User.Authenticated isAuthenticated(final Realm realm,final UUID session)
      throws SQLException
   {
      final Slot<User.Authenticated> retval = new Slot<User.Authenticated>();
      DBConnection connection = getConnection();
      try {
         connection.query(USER_SESSION, new DBQueryHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setString(1,session.toString());
            }
View Full Code Here

   }
  
   public void expireSession(final UUID session)
      throws SQLException
   {
      DBConnection connection = getConnection();
      try {
         connection.update(DELETE_SESSION, new DBUpdateHandler() {
            public void prepare(PreparedStatement s)
               throws SQLException
            {
               s.setString(1,session.toString());
            }
View Full Code Here

TOP

Related Classes of org.milowski.db.DBConnection

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.