use of org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService 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();
}
}
use of org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService 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;
}
use of org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService 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.business.service.RolesPermissionsBusinessService in project head by mifos.
the class RoleTempleteBuilderIntegrationTest method testGetRolesTemplete.
@Test
public void testGetRolesTemplete() throws Exception {
List<ActivityEntity> activities = new RolesPermissionsBusinessService().getActivities();
StringBuilder stringBuilder = new RoleTempleteBuilder().getRolesTemplete(activities);
Assert.assertNotNull(stringBuilder);
Assert.assertTrue(stringBuilder.toString().contains("Can create new role"));
Assert.assertTrue(stringBuilder.toString().contains("Can modify a role"));
Assert.assertTrue(stringBuilder.toString().contains("Can delete a role"));
}
use of org.mifos.security.rolesandpermission.business.service.RolesPermissionsBusinessService in project head by mifos.
the class BirtReportsUploadActionStrutsTest method testUpgradePathNotRuined.
@Test
public void testUpgradePathNotRuined() throws Exception {
// TODO Temporary solution to avoid unsuccessful test on some machines
// Retrieve initial activities information
List<ActivityEntity> activities = new RolesPermissionsBusinessService().getActivities();
int newActivityId = activities.get(activities.size() - 1).getId() + 1;
// Upload a report creating an activity for the report
FormFile file = new MockFormFile("testFilename.rptdesign");
BirtReportsUploadActionForm actionForm = new BirtReportsUploadActionForm();
setRequestPathInfo("/birtReportsUploadAction.do");
addRequestParameter("method", "upload");
actionForm.setFile(file);
actionForm.setReportTitle("exsitTitle");
actionForm.setReportCategoryId("1");
actionForm.setIsActive("1");
setActionForm(actionForm);
actionPerform();
Assert.assertEquals(0, getErrorSize());
Assert.assertNotNull(request.getAttribute("report"));
// Simulate an future activities upgrade
AddActivity activity = null;
try {
activity = new AddActivity((short) newActivityId, SecurityConstants.ORGANIZATION_MANAGEMENT, "no name");
activity.upgrade(StaticHibernateUtil.getSessionTL().connection());
} catch (Exception e) {
legacyRolesPermissionsDao.delete(request.getAttribute("report"));
StaticHibernateUtil.flushSession();
throw e;
}
// Undo
ReportsBO report = (ReportsBO) request.getAttribute("report");
removeReport(report.getReportId());
}
Aggregations