Search in sources :

Example 1 with ActivityEntity

use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.

the class RolesPermissionServiceFacadeWebTier method deleteRole.

@Override
public void deleteRole(Integer versionNo, Short roleId) throws Exception {
    RolesPermissionsBusinessService rolesPermissionsBusinessService = new RolesPermissionsBusinessService();
    RoleBO role = rolesPermissionsBusinessService.getRole(roleId);
    role.setVersionNo(versionNo);
    validateIfRoleAssignedToPersonnel(role);
    try {
        StaticHibernateUtil.startTransaction();
        legacyRolesPermissionsDao.delete(role);
        StaticHibernateUtil.flushSession();
        for (ActivityEntity ae : legacyRolesPermissionsDao.getActivities()) {
            StaticHibernateUtil.getSessionTL().refresh(ae);
        }
        StaticHibernateUtil.commitTransaction();
    } catch (PersistenceException e) {
        StaticHibernateUtil.rollbackTransaction();
        throw new MifosRuntimeException(e);
    } finally {
        StaticHibernateUtil.closeSession();
    }
}
Also used : RolesPermissionsBusinessService(org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) PersistenceException(org.mifos.framework.exceptions.PersistenceException) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO) MifosRuntimeException(org.mifos.core.MifosRuntimeException)

Example 2 with ActivityEntity

use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.

the class LegacyRolesPermissionsDao method retrieveOneActivityEntity.

public ActivityEntity retrieveOneActivityEntity(int lookUpId) throws PersistenceException {
    Map<String, Object> queryParameters = new HashMap<String, Object>();
    LookUpValueEntity aLookUpValueEntity = getPersistentObject(LookUpValueEntity.class, lookUpId);
    queryParameters.put("aLookUpValueEntity", aLookUpValueEntity);
    Object obj = execUniqueResultNamedQuery(NamedQueryConstants.GETACTIVITYENTITY, queryParameters);
    if (null != obj) {
        return (ActivityEntity) obj;
    }
    return null;
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) HashMap(java.util.HashMap) LookUpValueEntity(org.mifos.application.master.business.LookUpValueEntity)

Example 3 with ActivityEntity

use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.

the class LegacyRolesPermissionsDao method createActivityForReports.

public int createActivityForReports(short parentActivity, String lookUpDescription) throws HibernateException, PersistenceException, ServiceException, ActivityGeneratorException {
    StaticHibernateUtil.startTransaction();
    int lookUpId = createLookUpValue(DynamicLookUpValueCreationTypes.BirtReport, lookUpDescription);
    insertLookUpValueLocale(lookUpId, lookUpDescription);
    ActivityEntity activityEntity = createActivityEntity(parentActivity, lookUpId);
    RoleBO role = getPersistentObject(RoleBO.class, RolesAndPermissionConstants.ADMIN_ROLE);
    role.getActivities().add(activityEntity);
    StaticHibernateUtil.commitTransaction();
    return lookUpId;
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) RoleBO(org.mifos.security.rolesandpermission.business.RoleBO)

Example 4 with ActivityEntity

use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.

the class LegacyRolesPermissionsDao method calculateDynamicActivityId.

public int calculateDynamicActivityId() throws ServiceException, ActivityGeneratorException {
    int activityId = 0;
    for (ActivityEntity activity : new RolesPermissionsBusinessService().getActivities()) {
        if (activity.getId().intValue() < activityId) {
            activityId = activity.getId();
        }
    }
    if (activityId <= Short.MIN_VALUE) {
        throw new ActivityGeneratorException();
    }
    int newActivityId = activityId - 1;
    return newActivityId;
}
Also used : RolesPermissionsBusinessService(org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService) ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) ActivityGeneratorException(org.mifos.security.activity.ActivityGeneratorException)

Example 5 with ActivityEntity

use of org.mifos.security.rolesandpermission.business.ActivityEntity in project head by mifos.

the class RolesPermissionsAction method update.

@TransactionDemarcate(validateAndResetToken = true)
public ActionForward update(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
    RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
    UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
    List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
    rolesPermissionServiceFacade.updateRole(Short.parseShort(rolesPermissionsActionForm.getId()), userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
    // MIFOS-3530: update all currently logged users
    for (String loggedUser : getLoggedUsers(request)) {
        this.authenticationAuthorizationServiceFacade.reloadUserDetailsForSecurityContext(loggedUser);
    }
    return mapping.findForward(ActionForwards.update_success.toString());
}
Also used : ActivityEntity(org.mifos.security.rolesandpermission.business.ActivityEntity) UserContext(org.mifos.security.util.UserContext) RolesPermissionsActionForm(org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm) ArrayList(java.util.ArrayList) List(java.util.List) TransactionDemarcate(org.mifos.framework.util.helpers.TransactionDemarcate)

Aggregations

ActivityEntity (org.mifos.security.rolesandpermission.business.ActivityEntity)42 PersistenceException (org.mifos.framework.exceptions.PersistenceException)13 MifosRuntimeException (org.mifos.core.MifosRuntimeException)12 Test (org.junit.Test)10 LookUpValueEntity (org.mifos.application.master.business.LookUpValueEntity)9 RoleBO (org.mifos.security.rolesandpermission.business.RoleBO)9 ArrayList (java.util.ArrayList)8 UserContext (org.mifos.security.util.UserContext)8 HibernateException (org.hibernate.HibernateException)7 ActivityGeneratorException (org.mifos.security.activity.ActivityGeneratorException)7 ApplicationException (org.mifos.framework.exceptions.ApplicationException)6 ServiceException (org.mifos.framework.exceptions.ServiceException)6 RolesPermissionsBusinessService (org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService)6 HibernateProcessException (org.mifos.framework.exceptions.HibernateProcessException)5 SystemException (org.mifos.framework.exceptions.SystemException)5 IOException (java.io.IOException)4 MessageLookup (org.mifos.application.master.MessageLookup)4 SecurityException (org.mifos.framework.exceptions.SecurityException)4 List (java.util.List)3 UserContextFactory (org.mifos.accounts.servicefacade.UserContextFactory)3