Examples of UsersRepositoryException


Examples of org.apache.james.user.api.UsersRepositoryException

        final EntityTransaction transaction = entityManager.getTransaction();
        try {
            transaction.begin();
            if (entityManager.createNamedQuery("deleteUserByName").setParameter("name", name).executeUpdate() < 1) {
                transaction.commit();
                throw new UsersRepositoryException("User " + name + " does not exist");
            } else {
                transaction.commit();
            }
        } catch (PersistenceException e) {
            getLogger().debug("Failed to remove user", e);
            if (transaction.isActive()) {
                transaction.rollback();
            }
            throw new UsersRepositoryException("Failed to remove user " + name, e);
        } finally {
            entityManager.close();
        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

        try {
            return (Long) entityManager.createNamedQuery("containsUser").setParameter("name", name.toLowerCase()).getSingleResult() > 0;
        } catch (PersistenceException e) {
            getLogger().debug("Failed to find user", e);
            throw new UsersRepositoryException("Failed to find user" + name, e);
        } finally {
            entityManager.close();
        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

        try {
            return ((Long) entityManager.createNamedQuery("countUsers").getSingleResult()).intValue();
        } catch (PersistenceException e) {
            getLogger().debug("Failed to find user", e);
            throw new UsersRepositoryException("Failed to count users", e);
        } finally {
            entityManager.close();
        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

        try {
            return Collections.unmodifiableList(entityManager.createNamedQuery("listUserNames").getResultList()).iterator();

        } catch (PersistenceException e) {
            getLogger().debug("Failed to find user", e);
            throw new UsersRepositoryException("Failed to list users", e);
        } finally {
            entityManager.close();
        }
    }
View Full Code Here

Examples of org.apache.james.user.api.UsersRepositoryException

     * org.apache.james.user.lib.AbstractUsersRepository#doAddUser(java.lang.String, java.lang.String)
     */
    protected void doAddUser(String username, String password) throws UsersRepositoryException {
        String lowerCasedUsername = username.toLowerCase();
        if (contains(lowerCasedUsername)) {
            throw new UsersRepositoryException(lowerCasedUsername + " already exists.");
        }
        EntityManager entityManager = entityManagerFactory.createEntityManager();
        final EntityTransaction transaction = entityManager.getTransaction();
        try {
            transaction.begin();
            JPAUser user = new JPAUser(lowerCasedUsername, password, algo);
            entityManager.persist(user);
            transaction.commit();
        } catch (PersistenceException e) {
            getLogger().debug("Failed to save user", e);
            if (transaction.isActive()) {
                transaction.rollback();
            }
            throw new UsersRepositoryException("Failed to add user" + username, e);
        } finally {
            entityManager.close();
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.