private AlertProvider alertProvider;
private TagProvider tagProvider;
public String execute()
{
ReportUser user = null;
try
{
if (command.equals("edit"))
{
user = userProvider.getUser(new Integer(id));
}
else
{
user = new ReportUser();
}
reports = user.getReports();
userAlerts = user.getAlerts();
if (command.equals("edit") && !submitOk && !submitDuplicate)
{
id = user.getId().intValue();
name = user.getName();
password = user.getPassword();
passwordConfirm = user.getPassword();
externalId = user.getExternalId();
email = user.getEmail();
reportGroups = user.getGroups();
scheduler = user.isScheduler();
advancedScheduler = user.isAdvancedScheduler();
logViewer = user.isLogViewer();
rootAdmin= user.isRootAdmin();
reportAdmin = user.isReportAdmin();
dataSourceAdmin = user.isDataSourceAdmin();
parameterAdmin = user.isParameterAdmin();
userAdmin = user.isUserAdmin();
groupAdmin = user.isGroupAdmin();
chartAdmin = user.isChartAdmin();
alertAdmin = user.isAlertAdmin();
dashboard = user.isDashboardUser();
alerts = user.isAlertUser();
uploader = user.isUploader();
schedulerAdmin = user.isSchedulerAdmin();
tags = tagProvider.getTagsForObject(user.getId(), ReportUser.class, ORTag.TAG_TYPE_UI);
if (reportGroups != null) Collections.sort(reportGroups);
if (user.getDefaultReport() != null)
{
reportId = user.getDefaultReport().getId().intValue();
}
groupIds = null;
}
if (!submitOk && !submitDuplicate) return INPUT;
if (password == null || password.trim().length() < 1 || !password.equals(passwordConfirm))
{
addActionError(LocalStrings.ERROR_INVALID_PASSWORD);
return INPUT;
}
if (submitDuplicate)
{
command = "add";
user.setId(null);
user.setRoles(new TreeSet<String>());
if (user.getName().equals(name))
{
name = "Copy of ".concat(name);
}
}
user.setName(name);
user.setPassword(password);
user.setExternalId(externalId);
user.setEmail(email);
user.setGroups(convertIdsToGroups(groupIds));
user.setAlertAdmin(alertAdmin);
user.setChartAdmin(chartAdmin);
user.setDataSourceAdmin(dataSourceAdmin);
user.setGroupAdmin(groupAdmin);
user.setLogViewer(logViewer);
user.setParameterAdmin(parameterAdmin);
user.setReportAdmin(reportAdmin);
user.setRootAdmin(rootAdmin);
user.setScheduler(scheduler);
user.setAdvancedScheduler(advancedScheduler);
user.setUserAdmin(userAdmin);
user.setDashboardUser(dashboard);
user.setAlertUser(alerts);
user.setUploader(uploader);
user.setSchedulerAdmin(schedulerAdmin);
if (reportId > 0)
{
user.setDefaultReport(reportProvider.getReport(new Integer(reportId)));
}
else
{
user.setDefaultReport(null);
}
if (command.equals("edit"))
{
userProvider.updateUser(user);
ReportUser currentUser = (ReportUser) ActionContext.getContext().getSession().get(ORStatics.REPORT_USER);
if ((currentUser != null) && (currentUser.getId().equals(user.getId())))
{
session.put(ORStatics.REPORT_USER, user);
}
}