private static Logger log = Logger.getLogger(PageSystemAction.class);
@Override
protected void preOperations(E form, ActionMessages errors, HttpServletRequest request)
{
UserVO activeUser = (UserVO) request.getSession().getAttribute(Globals.USER_KEY);
EditPanel panel = getPanel();
EntityAccess ea = getEntityAccess(request);
if(panel.getAttribute("system_entityAccess") == null) {
panel.setAttribute("system_entityAccess", ea);
List<UsergroupVO> usergroups = new UsergroupDAO().getList(null, UsergroupDAO.AdminSelect.ALL, new Sort(UsergroupDAO.SORT_NAME, true), null, activeUser);
// load a set usergroup where you do not have rights
boolean usergroupAccess = false;
for(UsergroupVO vo : usergroups) {
if(ea.getOwnerGroup().equals(vo.getId())) {
usergroupAccess = true;
break;
}
}
if(!usergroupAccess) {
UsergroupVO vo = new UsergroupDAO().getById(ea.getOwnerGroup());
usergroups.add(0, vo);
}
Collections.sort(usergroups, new Comparator<UsergroupVO>() {
public int compare(UsergroupVO usergroup1, UsergroupVO usergroup2)
{
return usergroup1.getName().compareTo(usergroup2.getName());
}
});
panel.setAttribute("system_usergroups", usergroups);
if(ea != null) {
UserVO user = (UserVO)request.getSession().getAttribute(Globals.USER_KEY);
Page activePage = panel.getActivePage();
activePage.setEditable(isEditable(panel, user, ea, request));
}
UserVO ownerUser = null;
if(panel.getAttribute("system_ownerUser") == null && ea.getOwnerUser() > 0) {
if(log.isDebugEnabled())
log.debug("load user for owner of entity access");
ownerUser = new UserDAO().getById(ea.getOwnerUser());
panel.setAttribute("system_ownerUser", ownerUser);
}
if(ea instanceof StampedVO) {
StampedVO vo = (StampedVO)ea;
panel.setAttribute("system_isStamped", Boolean.TRUE);
if(panel.getAttribute("system_createUser") == null && vo.getCreateUser() != null && vo.getCreateUser() > 0) {
UserVO user = null;
if(vo.getCreateUser().equals(ea.getOwnerUser())) {
user = ownerUser;
} else {
user = new UserDAO().getById(vo.getCreateUser());
}
panel.setAttribute("system_createUser", user);
}
if(panel.getAttribute("system_modifyUser") == null && vo.getModifyUser() != null && vo.getModifyUser() > 0) {
UserVO user = null;
if(vo.getModifyUser().equals(ea.getOwnerUser())) {
user = ownerUser;
} else if(vo.getModifyUser().equals(vo.getCreateUser())) {
user = ownerUser;
} else {