Search in sources :

Example 1 with SecurityException

use of org.mifos.framework.exceptions.SecurityException in project head by mifos.

the class LegacyRolesPermissionsDao method getUserRoles.

/**
     * This function returns the PersonRoles object which contains the person
     * information and the set of all the roles related to that user
     *
     * @param uid
     *            user id
     * @return PersonRoles
     * @throws HibernateProcessException
     */
public Set getUserRoles(short uid) throws SystemException, ApplicationException {
    Set roles = null;
    try {
        Session session = StaticHibernateUtil.getSessionTL();
        Query personRoles = session.getNamedQuery(NamedQueryConstants.GETPERSONROLES);
        personRoles.setShort("ID", uid);
        List<PersonRoles> lst = personRoles.list();
        if (null != lst && lst.size() > 0) {
            PersonRoles pr = lst.get(0);
            roles = pr.getRoles();
        }
    } catch (HibernateException he) {
        throw new SecurityException(SecurityConstants.GENERALERROR, he);
    }
    return roles;
}
Also used : Set(java.util.Set) Query(org.hibernate.Query) HibernateException(org.hibernate.HibernateException) PersonRoles(org.mifos.security.util.PersonRoles) SecurityException(org.mifos.framework.exceptions.SecurityException) Session(org.hibernate.Session)

Example 2 with SecurityException

use of org.mifos.framework.exceptions.SecurityException in project head by mifos.

the class OfficePersistence method getPersonnelOffices.

/**
     * This function is used to get the list of the offices under the given
     * personnel office under any user at any time
     *
     * @param officeid
     *            office id of the person
     * @return List list of the offices under him
     * @throws HibernateProcessException
     */
public List<OfficeSearch> getPersonnelOffices(Short officeid) throws SystemException, ApplicationException {
    HierarchyManager hm = HierarchyManager.getInstance();
    String pattern = hm.getSearchId(officeid) + "%";
    List<OfficeSearch> lst = null;
    try {
        Session session = StaticHibernateUtil.getSessionTL();
        Query officeSearch = session.getNamedQuery(NamedQueryConstants.GETOFFICESEARCH);
        officeSearch.setString(SecurityConstants.PATTERN, pattern);
        lst = officeSearch.list();
    } catch (HibernateException he) {
        throw new SecurityException(SecurityConstants.GENERALERROR, he);
    }
    return lst;
}
Also used : HierarchyManager(org.mifos.security.authorization.HierarchyManager) Query(org.hibernate.Query) HibernateException(org.hibernate.HibernateException) OfficeSearch(org.mifos.security.util.OfficeSearch) SecurityException(org.mifos.framework.exceptions.SecurityException) Session(org.hibernate.Session)

Example 3 with SecurityException

use of org.mifos.framework.exceptions.SecurityException in project head by mifos.

the class OfficePersistence method getOffices.

/**
     * This function is used to initialise the the hirerchy manager which is
     * paert of the security module which keeps the cache of officeid to office
     * search id so that it can find office under given person without going to
     * database every time
     *
     * @return List of OfficeSearch objects which contains office is and
     *         associated searchid
     * @throws HibernateProcessException
     */
public List<OfficeSearch> getOffices() throws SystemException, ApplicationException {
    List<OfficeSearch> lst = null;
    try {
        Session session = StaticHibernateUtil.getSessionTL();
        Query queryOfficeSearchList = session.getNamedQuery(NamedQueryConstants.GETOFFICESEARCHLIST);
        lst = queryOfficeSearchList.list();
    } catch (HibernateException he) {
        throw new SecurityException(SecurityConstants.GENERALERROR, he);
    }
    return lst;
}
Also used : Query(org.hibernate.Query) HibernateException(org.hibernate.HibernateException) OfficeSearch(org.mifos.security.util.OfficeSearch) SecurityException(org.mifos.framework.exceptions.SecurityException) Session(org.hibernate.Session)

Aggregations

HibernateException (org.hibernate.HibernateException)3 Query (org.hibernate.Query)3 Session (org.hibernate.Session)3 SecurityException (org.mifos.framework.exceptions.SecurityException)3 OfficeSearch (org.mifos.security.util.OfficeSearch)2 Set (java.util.Set)1 HierarchyManager (org.mifos.security.authorization.HierarchyManager)1 PersonRoles (org.mifos.security.util.PersonRoles)1