public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws Exception {
Log log = LogFactory.getLog(AddResourcesAction.class);
HttpSession session = request.getSession();
WebUser user = SessionUtils.getWebUser(session);
WebUserPreferences preferences = user.getWebPreferences();
AddResourcesForm addForm = (AddResourcesForm) form;
ActionForward forward = checkSubmit(request, mapping, form, Constants.USER_PARAM, user.getId());
if (forward != null) {
BaseValidatorForm spiderForm = (BaseValidatorForm) form;
if (spiderForm.isCancelClicked() || spiderForm.isResetClicked()) {
log.trace("removing pending resources list");
SessionUtils.removeList(session, Constants.PENDING_RESOURCES_SES_ATTR);
} else if (spiderForm.isAddClicked()) {
log.trace("adding to pending resources list");
SessionUtils.addToList(session, Constants.PENDING_RESOURCES_SES_ATTR, addForm.getAvailableResources());
} else if (spiderForm.isRemoveClicked()) {
log.trace("removing from pending resources list");
SessionUtils.removeFromList(session, Constants.PENDING_RESOURCES_SES_ATTR, addForm
.getPendingResources());
}
return forward;
}
log.trace("getting pending resources list");
List<String> pendingResourceIds = SessionUtils.getListAsListStr(request.getSession(),
Constants.PENDING_RESOURCES_SES_ATTR);
StringBuffer resourcesAsString = new StringBuffer();
int count = 0;
for (String pendingId : pendingResourceIds) {
if (count != 0) {
resourcesAsString.append(DashboardUtils.DASHBOARD_DELIMITER);
}
resourcesAsString.append(pendingId);
count++;
}
SessionUtils.removeList(session, Constants.PENDING_RESOURCES_SES_ATTR);
RequestUtils.setConfirmation(request, "admin.user.confirm.AddResource");
preferences.setPreference(addForm.getKey(), resourcesAsString);
return returnSuccess(request, mapping);
}