拦截用户访问群组
Intercept user visits a group
我是 liferay 的新手,我需要在用户访问组后使用 Map(groupId, lastVisitedDate) 增强我的用户对象。
有什么想法可以在何时、何地以及如何拦截此请求并使用调用的 groupId 和当前日期增强我的用户?
我通过创建一个扩展 portal.properties 的挂钩解决了我的问题。
在这个属性文件中,我创建了这个 属性
servlet.service.events.pre=org.my.company.project.event.MyCustomAction
MyCustomAction Class 扩展了 Action。
这就是我获得必要信息的方式
@Override
public void run(HttpServletRequest request, HttpServletResponse response)
throws ActionException {
try {
User user = PortalUtil.getUser(request);
ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDisplay.getLayout().getGroup();
[...]
} catch (Exception e) {
throw new ActionException(e);
}
}
我是 liferay 的新手,我需要在用户访问组后使用 Map(groupId, lastVisitedDate) 增强我的用户对象。 有什么想法可以在何时、何地以及如何拦截此请求并使用调用的 groupId 和当前日期增强我的用户?
我通过创建一个扩展 portal.properties 的挂钩解决了我的问题。 在这个属性文件中,我创建了这个 属性
servlet.service.events.pre=org.my.company.project.event.MyCustomAction
MyCustomAction Class 扩展了 Action。
这就是我获得必要信息的方式
@Override
public void run(HttpServletRequest request, HttpServletResponse response)
throws ActionException {
try {
User user = PortalUtil.getUser(request);
ThemeDisplay themeDisplay = (ThemeDisplay) request
.getAttribute(WebKeys.THEME_DISPLAY);
Group group = themeDisplay.getLayout().getGroup();
[...]
} catch (Exception e) {
throw new ActionException(e);
}
}