Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
sasi Kanth
Email notification to Administrator while User creation
29. Juli 2009 05:26
Antwort

sasi Kanth

Rang: Junior Member

Nachrichten: 35

Eintrittsdatum: 1. Juli 2009

Neue Beiträge

An email notification has to be delivered to Administrator when a new user is registered from Create
Account.

To achieve this we have written a Model Listener Hook on User model and the code implemented in the OnAfterCreate.


In the Liferay 5.2.3, I have got following error message and distructing the protlet

1[jsp:165] java.lang.UnsupportedOperationException : Not supported yet.
2at EmailHookAction.onBeforeCreate(EmailHookAction.java:90)



Please help on this, i did not understand what is that UnsupportedOperationException and it is showing the error at "onBeforeCreate" method itself
sasi Kanth
RE: Email notification to Administrator while User creation
4. August 2009 04:11
Antwort

sasi Kanth

Rang: Junior Member

Nachrichten: 35

Eintrittsdatum: 1. Juli 2009

Neue Beiträge

Please give some solution or do u require more explanation on this.


Reply mee

Thanks

Rgds
Tomas Polesovsky
RE: Email notification to Administrator while User creation
4. August 2009 04:46
Antwort

Tomas Polesovsky

LIFERAY STAFF

Rang: Liferay Master

Nachrichten: 644

Eintrittsdatum: 13. Februar 2009

Neue Beiträge

Hi,

does your EmailHookAction extends BaseModelListener or you've just implemented ModelListener?

If you've just implemented ModelListener, all your methods, that you don't use, should be empty (like here: BaseModelListener.java).
sasi Kanth
RE: Email notification to Administrator while User creation
11. August 2009 22:51
Antwort

sasi Kanth

Rang: Junior Member

Nachrichten: 35

Eintrittsdatum: 1. Juli 2009

Neue Beiträge

I have implemented ModelListener only and left all the unused methods empty, still i am facing the same problem.


Could you please explain in detail or plz give some example.


Thanks

rgds
Tomas Polesovsky
RE: Email notification to Administrator while User creation
12. August 2009 13:19
Antwort

Tomas Polesovsky

LIFERAY STAFF

Rang: Liferay Master

Nachrichten: 644

Eintrittsdatum: 13. Februar 2009

Neue Beiträge

Hi,

could you show me your ModelListener implementation and post a bit longer error stacktrace, please?

-- tom
sasi Kanth
RE: Email notification to Administrator while User creation
4. September 2009 03:26
Antwort

sasi Kanth

Rang: Junior Member

Nachrichten: 35

Eintrittsdatum: 1. Juli 2009

Neue Beiträge

Sorry for the late reply

hook code is :

 1public class EmailHookAction implements ModelListener {
 2
 3    public void onAfterCreate(BaseModel model) throws ModelListenerException {
 4        //Add your implementation here
 5        com.liferay.portal.model.User mdlObj
 6                = (com.liferay.portal.model.User) model;
 7        try
 8        {
 9              InternetAddress  from = new InternetAddress("xxxxxx");
10              InternetAddress  to = new InternetAddress("xxxxxx");
11              String subject = "Creation of new account ";
12              String mess;
13              mess = "User Registered\n";
14              mess = mess + "Email ID : "+mdlObj.getEmailAddress();
15              MailMessage mailMessage = new MailMessage(from, to, subject,mess,true);
16              MailServiceUtil.sendEmail(mailMessage);
17        }
18        catch(Exception e )
19        {
20            System.out.println(e);
21        }
22      
23     System.out.println("email notification after registration");
24    }
25
26    public void onAfterAddAssociation(Object arg0, String arg1, Object arg2) throws ModelListenerException {
27        //Add your implementation here      
28    }
29
30    public void onAfterRemove(BaseModel model) throws ModelListenerException {
31        //Add your implementation here      
32    }
33
34    public void onAfterRemoveAssociation(Object arg0, String arg1, Object arg2) throws ModelListenerException {
35        //Add your implementation here    
36    }
37
38    public void onAfterUpdate(BaseModel model) throws ModelListenerException {
39        //Add your implementation here      
40    }
41
42    public void onBeforeAddAssociation(Object arg0, String arg1, Object arg2) throws ModelListenerException {
43        //Add your implementation here      
44    }
45
46    public void onBeforeCreate(BaseModel model) throws ModelListenerException {
47        //Add your implementation here      
48    }
49
50    public void onBeforeRemove(BaseModel model) throws ModelListenerException {
51        //Add your implementation here
52      }
53
54    public void onBeforeRemoveAssociation(Object arg0, String arg1, Object arg2) throws ModelListenerException {
55        //Add your implementation here
56     }
57
58    public void onBeforeUpdate(BaseModel model) throws ModelListenerException {
59        //Add your implementation here
60     }
61
62    public void onAfterCreate(Object arg0) throws ModelListenerException {
63        throw new UnsupportedOperationException("Not supported yet.mmmmm");
64    }
65
66    public void onAfterRemove(Object arg0) throws ModelListenerException {
67        throw new UnsupportedOperationException("Not supported yet.");
68    }
69
70    public void onAfterUpdate(Object arg0) throws ModelListenerException {
71        throw new UnsupportedOperationException("Not supported yet.");
72    }
73
74    public void onBeforeCreate(Object arg0) throws ModelListenerException {
75        throw new UnsupportedOperationException("Not supported yet.");
76    }
77
78    public void onBeforeRemove(Object arg0) throws ModelListenerException {
79        throw new UnsupportedOperationException("Not supported yet.");
80    }
81
82    public void onBeforeUpdate(Object arg0) throws ModelListenerException {
83    throw new UnsupportedOperationException("Not supported yet.");
84    }


The error message is

 110:24:55,640 ERROR [jsp:165] java.lang.UnsupportedOperationException: Not supported yet.
 2        at EmailHookAction.onBeforeCreate(EmailHookAction.java:105)
 3        at com.liferay.portal.model.InvokerModelListener.onBeforeCreate(InvokerModelListener.java:155)
 4        at com.liferay.portal.service.persistence.UserPersistenceImpl.update(UserPersistenceImpl.java:434)
 5        at com.liferay.portal.service.impl.UserLocalServiceImpl.addUser(UserLocalServiceImpl.java:335)
 6        at com.liferay.portal.service.impl.UserServiceImpl.addUser(UserServiceImpl.java:186)
 7        at com.liferay.portal.service.UserServiceUtil.addUser(UserServiceUtil.java:92)
 8        at com.liferay.portlet.login.action.CreateAccountAction.addUser(CreateAccountAction.java:229)
 9        at com.liferay.portlet.login.action.CreateAccountAction.processAction(CreateAccountAction.java:95)
10        at com.liferay.portal.struts.PortletRequestProcessor.process(PortletRequestProcessor.java:180)
11        at com.liferay.portlet.StrutsPortlet.processAction(StrutsPortlet.java:197)
12        at com.sun.portal.portletcontainer.appengine.filter.FilterChainImpl.doFilter(FilterChainImpl.java:98)
13        at com.liferay.portal.kernel.portlet.PortletFilterUtil.doFilter(PortletFilterUtil.java:57)
14        at com.liferay.portlet.InvokerPortletImpl.invoke(InvokerPortletImpl.java:632)
15        at com.liferay.portlet.InvokerPortletImpl.invokeAction(InvokerPortletImpl.java:664)
16        at com.liferay.portlet.InvokerPortletImpl.processAction(InvokerPortletImpl.java:359)
17        at com.liferay.portal.action.LayoutAction.processPortletRequest(LayoutAction.java:604)
18        at com.liferay.portal.action.LayoutAction.processLayout(LayoutAction.java:428)
19        at com.liferay.portal.action.LayoutAction.execute(LayoutAction.java:195)
20        at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:431)
21        at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:236)


Please analyse and help me.

Thank you
Dmitry Babain
RE: Email notification to Administrator while User creation
4. September 2009 08:43
Antwort

Dmitry Babain

Rang: Regular Member

Nachrichten: 238

Eintrittsdatum: 23. November 2008

Neue Beiträge

this can be caused by registering duplicate hooks, for example, your previous version actually was throwing this "unsupported" exception, you created and deployed new version, but deploy was broken. It happens sometimes.

Or - may be, but why not - you should simply remove all those (Object arg0) methods. They are obviously not needed anyway
sasi Kanth
RE: Email notification to Administrator while User creation
10. September 2009 03:28
Antwort

sasi Kanth

Rang: Junior Member

Nachrichten: 35

Eintrittsdatum: 1. Juli 2009

Neue Beiträge

Dmitry Babain:
this can be caused by registering duplicate hooks, for example, your previous version actually was throwing this "unsupported" exception, you created and deployed new version, but deploy was broken. It happens sometimes.

Or - may be, but why not - you should simply remove all those (Object arg0) methods. They are obviously not needed anyway



As the class is abstract class in 5.2.3 so i cant remove the methods.

Thanks

Sasikath
Tomas Polesovsky
RE: Email notification to Administrator while User creation
17. September 2009 12:53
Antwort

Tomas Polesovsky

LIFERAY STAFF

Rang: Liferay Master

Nachrichten: 644

Eintrittsdatum: 13. Februar 2009

Neue Beiträge

Hi, sorry for delay.

Question: why do you have multiple definitions of the onBeforeCreate method?

146    public void onBeforeCreate(BaseModel model) throws ModelListenerException {
247        //Add your implementation here      
348    }


174  public void onBeforeCreate(Object arg0) throws ModelListenerException {
275        throw new UnsupportedOperationException("Not supported yet.");
376    }


I think you should have only one.

-- tom
atul patel
RE: Email notification to Administrator while User creation
19. März 2010 17:48
Antwort

atul patel

Rang: Regular Member

Nachrichten: 192

Eintrittsdatum: 17. November 2006

Neue Beiträge

I just noticed this posting from some time ago.

To save someone some headaches that reads this thread... Don't throw an UnsupportedException for methods you don't implement.

Just leave them empty.