Hi,
I have defined the class UserLoginEvent in package
org.xwiki.observation.event
Then in order to be notified I think we could change the LoginSubmitAction
class render() it the message is null we could notify the listener of a
successful login.
Index: xwiki-core/src/main/java/com/xpn/xwiki/web/LoginSubmitAction.java
===================================================================
--- xwiki-core/src/main/java/com/xpn/xwiki/web/LoginSubmitAction.java
(revision 19222)
+++ xwiki-core/src/main/java/com/xpn/xwiki/web/LoginSubmitAction.java
(working copy)
@@ -22,14 +22,25 @@
import javax.servlet.http.HttpServletResponse;
+import org.xwiki.observation.ObservationManager;
+import org.xwiki.observation.event.UserLoginEvent;
+
import com.xpn.xwiki.XWikiContext;
import com.xpn.xwiki.XWikiException;
-public class LoginSubmitAction extends XWikiAction {
- public String render(XWikiContext context) throws XWikiException {
- String msg = (String)context.get("message");
- if(msg != null && !msg.trim().equals("")) {
+public class LoginSubmitAction extends XWikiAction
+{
+ public String render(XWikiContext context) throws XWikiException
+ {
+ String msg = (String) context.get("message");
+ if (msg != null && !msg.trim().equals("")) {
context.getResponse().setStatus(HttpServletResponse.SC_FORBIDDEN);
+ } else {
+ ObservationManager om = (ObservationManager)
Utils.getComponent(ObservationManager.class);
+ if (om != null) {
+ om.notify(new UserLoginEvent(context.getDoc().getWikiName()
+ ":" + context.getDoc().getFullName()),
+ context.getDoc(), context);
+ }
}
return "login";
}
Next thing is I am still not sure is how the listener are added. In existing
save and delete I could not find how it has added listeners. to OM.