use of org.mifos.security.activity.ActivityGeneratorException 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.activity.ActivityGeneratorException in project head by mifos.
the class BirtReportsUploadAction method upload.
public ActionForward upload(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
BirtReportsUploadActionForm uploadForm = (BirtReportsUploadActionForm) form;
ReportsPersistence rp = new ReportsPersistence();
ReportsCategoryBO category = rp.getPersistentObject(ReportsCategoryBO.class, Short.valueOf(uploadForm.getReportCategoryId()));
if (isReportAlreadyExist(request, uploadForm.getReportTitle(), category)) {
return mapping.findForward(ActionForwards.preview_failure.toString());
}
short parentActivity = category.getActivityId();
int newActivityId;
String activityNameHead = "Can view ";
try {
newActivityId = legacyRolesPermissionsDao.calculateDynamicActivityId();
legacyRolesPermissionsDao.createActivityForReports(parentActivity, activityNameHead + uploadForm.getReportTitle());
} catch (ActivityGeneratorException ex) {
ActionErrors errors = new ActionErrors();
errors.add(ex.getKey(), new ActionMessage(ex.getKey()));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward(ActionForwards.preview_failure.toString());
}
FormFile formFile = uploadForm.getFile();
uploadFile(formFile);
ReportsBO reportBO = createOrUpdateReport(category, newActivityId, uploadForm.getReportTitle(), Short.valueOf(uploadForm.getIsActive()), formFile.getFileName(), uploadForm.getIsDW());
allowActivityPermission(reportBO, newActivityId);
request.setAttribute("report", reportBO);
return mapping.findForward(ActionForwards.create_success.toString());
}
use of org.mifos.security.activity.ActivityGeneratorException in project head by mifos.
the class ReportsCategoryAction method addNewCategory.
public ActionForward addNewCategory(ActionMapping mapping, ActionForm form, HttpServletRequest request, @SuppressWarnings("unused") HttpServletResponse response) throws Exception {
logger.debug("In ReportsCategoryAction:addNewCategory Method: ");
ReportsCategoryActionForm defineNewCategoryForm = (ReportsCategoryActionForm) form;
String categoryName = defineNewCategoryForm.getCategoryName();
ReportsCategoryBO reportsCategoryBO = new ReportsCategoryBO();
int newActivityId;
try {
newActivityId = legacyRolesPermissionsDao.calculateDynamicActivityId();
} catch (ActivityGeneratorException agex) {
ActionErrors errors = new ActionErrors();
errors.add(agex.getKey(), new ActionMessage(agex.getKey()));
request.setAttribute(Globals.ERROR_KEY, errors);
return mapping.findForward(ActionForwards.preview_failure.toString());
}
Short parentActivityId = SecurityConstants.REPORTS_MANAGEMENT;
legacyRolesPermissionsDao.createActivityForReports(parentActivityId, categoryName);
reportsCategoryBO.setActivityId((short) newActivityId);
reportsCategoryBO.setReportCategoryName(categoryName);
new ReportsPersistence().createOrUpdate(reportsCategoryBO);
return mapping.findForward(ActionForwards.create_success.toString());
}
Aggregations