use of org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm in project head by mifos.
the class RolesPermissionsAction method manage.
@TransactionDemarcate(joinToken = true)
public ActionForward manage(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
SessionUtils.setCollectionAttribute(RolesAndPermissionConstants.ACTIVITYLIST, ((RolesPermissionsBusinessService) getService()).getActivities(), request);
Short roleId = Short.valueOf(rolesPermissionsActionForm.getId());
RoleBO role = ((RolesPermissionsBusinessService) getService()).getRole(roleId);
List<ActivityRestrictionDto> activityRestrictionDtoList = rolesPermissionServiceFacade.getRoleActivitiesRestrictions(roleId);
Map<Short, ActivityRestrictionDto> activityRestrictionDtoMap = new HashMap<Short, ActivityRestrictionDto>();
for (ActivityRestrictionDto activityRestrictionDto : activityRestrictionDtoList) {
activityRestrictionDtoMap.put(activityRestrictionDto.getActivityRestrictionTypeId(), activityRestrictionDto);
}
rolesPermissionsActionForm.setActivityRestrictionDtoMap(activityRestrictionDtoMap);
rolesPermissionsActionForm.setName(role.getName());
SessionUtils.setAttribute(Constants.BUSINESS_KEY, role, request);
return mapping.findForward(ActionForwards.manage_success.toString());
}
use of org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm 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());
}
use of org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm in project head by mifos.
the class RolesPermissionsAction method create.
@TransactionDemarcate(validateAndResetToken = true)
public ActionForward create(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
UserContext userContext = (UserContext) SessionUtils.getAttribute(Constants.USER_CONTEXT_KEY, request.getSession());
List<ActivityEntity> activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, request);
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
rolesPermissionServiceFacade.createRole(userContext.getId(), rolesPermissionsActionForm.getName(), getActivityIds(getActivities(activities, rolesPermissionsActionForm.getActivities())), rolesPermissionsActionForm.getActivityRestrictionDtoToPersistList());
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm in project head by mifos.
the class RolesPermissionsAction method preview.
@TransactionDemarcate(joinToken = true)
public ActionForward preview(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) form;
SessionUtils.setAttribute(Constants.BUSINESS_KEY, ((RolesPermissionsBusinessService) getService()).getRole(Short.valueOf(rolesPermissionsActionForm.getId())), request);
return mapping.findForward(ActionForwards.preview_success.toString());
}
use of org.mifos.security.rolesandpermission.struts.actionforms.RolesPermissionsActionForm in project head by mifos.
the class ActivityTag method doEndTag.
@SuppressWarnings("unchecked")
@Override
public int doEndTag() throws JspException {
RoleTempleteBuilder builder = new RoleTempleteBuilder();
List<ActivityEntity> activities;
try {
activities = (List<ActivityEntity>) SessionUtils.getAttribute(RolesAndPermissionConstants.ACTIVITYLIST, (HttpServletRequest) pageContext.getRequest());
activities = filterActivities(activities);
RoleBO role = (RoleBO) SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
RolesPermissionsActionForm rolesPermissionsActionForm = (RolesPermissionsActionForm) pageContext.getSession().getAttribute("rolesPermissionsActionForm");
if (rolesPermissionsActionForm != null && rolesPermissionsActionForm.getActivities().size() > 0) {
List<ActivityEntity> flitered = filterActivities(getActivities(activities, rolesPermissionsActionForm.getActivities()));
Set<Short> activitySet = convertToIdSet(flitered);
builder.setCurrentActivites(activitySet);
} else if (role != null) {
List<ActivityEntity> flitered = filterActivities(new ArrayList<ActivityEntity>(role.getActivities()));
Set<Short> activitySet = convertToIdSet(flitered);
builder.setCurrentActivites(activitySet);
}
Map<Short, ActivityRestrictionDto> activityRestrictionDtoMap = rolesPermissionsActionForm.getActivityRestrictionDtoMap();
if (activityRestrictionDtoMap == null) {
activityRestrictionDtoMap = new HashMap<Short, ActivityRestrictionDto>();
}
builder.setActivityRestrictionDtoMap(activityRestrictionDtoMap);
SessionUtils.getAttribute(Constants.BUSINESS_KEY, (HttpServletRequest) pageContext.getRequest());
StringBuilder sb = builder.getRolesTemplete(activities);
pageContext.getOut().print(sb.toString());
} catch (IOException e) {
throw new JspException(e);
} catch (PageExpiredException e1) {
throw new JspException(e1);
}
return EVAL_PAGE;
}
Aggregations