Combination View Flat View Tree View
Threads [ Previous | Next ]
toggle
Anonymous
about delete user from the database
November 12, 2007 2:50 PM
Answer

Anonymous

Hi everyone,
I want to delete a user from the database in my program, the code is as follows:

1User user1 = UserServiceUtil.getUserByEmailAddress(companyId, emailAddress);
2              if (user1 != null) {
3        UserServiceUtil.deleteUser(user1.getUserId());
4        }


But i have got the exception:
 1com.liferay.portal.security.auth.PrincipalException: PermissionChecker not initialized
 2    at com.liferay.portal.service.impl.PrincipalBean.getPermissionChecker(PrincipalBean.java:106)
 3    at com.liferay.portal.service.impl.UserServiceImpl.checkPermission(UserServiceImpl.java:409)
 4    at com.liferay.portal.service.impl.UserServiceImpl.checkPermission(UserServiceImpl.java:400)
 5    at com.liferay.portal.service.impl.UserServiceImpl.getUserByEmailAddress(UserServiceImpl.java:188)
 6    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
 7    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
 8    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
 9    at java.lang.reflect.Method.invoke(Method.java:585)
10    at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:304)
11    at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:182)
12    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:149)
13    at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
14    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:171)
15    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:204)
16    at $Proxy41.getUserByEmailAddress(Unknown Source)
17    at com.liferay.portal.service.UserServiceUtil.getUserByEmailAddress(UserServiceUtil.java:145)
18    at com.cosmit.scheduler.servlet.dashboard.dashboardServlet.doPost(dashboardServlet.java:69)
19    at com.cosmit.scheduler.servlet.dashboard.dashboardServlet.doGet(dashboardServlet.java:96)
20    at javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
21    at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
22    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:269)
23    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:188)
24    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:210)
25    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:174)
26    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
27    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:117)
28    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:108)
29    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
30    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:870)
31    at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.processConnection(Http11BaseProtocol.java:665)
32    at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:528)
33    at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:81)
34    at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:685)
35    at java.lang.Thread.run(Thread.java:595)


So how can i initialize the PermissionChecker or with another method to delete the user?
Roman Hoyenko
RE: about delete user from the database
November 12, 2007 4:09 PM
Answer

Roman Hoyenko

Community Moderator

Rank: Liferay Master

Posts: 868

Join Date: October 8, 2007

Recent Posts

Where are you trying to call this method from? Is it in standalone war?
Anonymous
RE: about delete user from the database
November 13, 2007 12:43 AM
Answer

Anonymous

Hi,
I call this in my own web application(a standalone war). I place it in "webapps" folder of the liferay-tomcat4.3.3.
Wilson Man
RE: about delete user from the database
November 13, 2007 12:47 AM
Answer

Wilson Man

LIFERAY STAFF

Rank: Liferay Master

Posts: 580

Join Date: June 21, 2006

Recent Posts

why can't you use UserLocalServiceUtil instead of UserServiceUtil?
Anonymous
RE: about delete user from the database
November 13, 2007 2:27 AM
Answer

Anonymous

Hi,
I try to use UserLocalServiceUtil, now there is another exception:

 1[size=5]2007-11-13 11:18:29,078 WARN  com.liferay.portal.service.impl.ImageLocalUtil (340) - java.io.IOException: closed
 22007-11-13 11:18:29,109 WARN  com.liferay.portal.service.impl.ImageLocalUtil (340) - java.io.IOException: closed
 32007-11-13 11:18:29,109 WARN  com.liferay.portal.service.impl.ImageLocalUtil (340) - java.io.IOException: closed
 42007-11-13 11:18:32,140 ERROR com.liferay.mail.service.jms.MailConsumer (89) - java.lang.ClassNotFoundException: com.liferay.mail.util.DummyHook
 5java.lang.ClassNotFoundException: com.liferay.mail.util.DummyHook
 6    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1359)
 7    at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1205)
 8    at com.liferay.portal.kernel.util.MethodInvoker.invoke(MethodInvoker.java:97)
 9    at com.liferay.portal.kernel.util.MethodInvoker.invoke(MethodInvoker.java:47)
10    at com.liferay.mail.service.jms.MailConsumer._onMessage(MailConsumer.java:117)
11    at com.liferay.mail.service.jms.MailConsumer.onMessage(MailConsumer.java:85)
12    at org.apache.activemq.ActiveMQMessageConsumer.dispatch(ActiveMQMessageConsumer.java:854)
13    at org.apache.activemq.ActiveMQSessionExecutor.dispatch(ActiveMQSessionExecutor.java:99)
14    at org.apache.activemq.ActiveMQSessionExecutor.iterate(ActiveMQSessionExecutor.java:166)
15    at org.apache.activemq.thread.PooledTaskRunner.runTask(PooledTaskRunner.java:117)
16    at org.apache.activemq.thread.PooledTaskRunner.access$100(PooledTaskRunner.java:26)
17    at org.apache.activemq.thread.PooledTaskRunner$1.run(PooledTaskRunner.java:44)
18    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:650)
19    at edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:675)
20    at java.lang.Thread.run(Thread.java:595)[/size]


By the way, which file can i configure to avoid the appearance of "Terms of Use" site, when a new user login in?
Roman Hoyenko
RE: about delete user from the database
November 13, 2007 8:30 AM
Answer

Roman Hoyenko

Community Moderator

Rank: Liferay Master

Posts: 868

Join Date: October 8, 2007

Recent Posts

regarding the terms of use:

look at the portal.properties file, it has almost all the settings in it.

To modify the settings set up portal-ext.properties and change it there (they will override portal.properties)
Mreetunjay Sharma
RE: about delete user from the database
April 24, 2014 2:34 AM
Answer

Mreetunjay Sharma

Rank: Junior Member

Posts: 29

Join Date: May 20, 2013

Recent Posts

Hi Roman,

I am getting the same exception, when I am trying to delete user from liferay databade by using following code.

User user1 = UserServiceUtil.getUserByEmailAddress(companyId, emailAddress);
if (user1 != null) {
UserServiceUtil.deleteUser(user1.getUserId());
}

Please help me !!
Sushil Patidar
RE: about delete user from the database
April 24, 2014 4:52 AM
Answer

Sushil Patidar

Rank: Regular Member

Posts: 230

Join Date: October 30, 2011

Recent Posts

Hi,
Set permission checker before calling the delete method.
1
2 PermissionThreadLocal.setPermissionChecker(permissionChecker);
3User user1 = UserServiceUtil.getUserByEmailAddress(companyId, emailAddress);
4if (user1 != null) {
5UserServiceUtil.deleteUser(user1.getUserId());
6   


I hope it helps.

Regards
Mreetunjay Sharma
RE: about delete user from the database
May 4, 2014 9:17 PM
Answer

Mreetunjay Sharma

Rank: Junior Member

Posts: 29

Join Date: May 20, 2013

Recent Posts

Thanks Sushil for your reply.

But how can I get permission checker object, so that I can pass it to
PermissionThreadLocal.setPermissionChecker(permissionChecker);

Thank & Regards,
Mreetunjay Sharma
bhargavi m
RE: about delete user from the database
May 4, 2014 10:37 PM
Answer

bhargavi m

Rank: Junior Member

Posts: 43

Join Date: April 5, 2012

Recent Posts

This may be you are looking for

ThemeDisplay themeDisplay = (ThemeDisplay)request.getAttribute(WebKeys.THEME_DISPLAY);
PermissionChecker permissionChecker = themeDisplay.getPermissionChecker();


U can find more in fallowing links
https://www.liferay.com/web/guest/community/wiki/-/wiki/Main/Using+Liferay%27s+Permission+System+from+a+portlet

http://cdn.docs.liferay.com/portal/6.1/javadocs/com/liferay/portal/security/permission/PermissionChecker.html
Mreetunjay Sharma
RE: about delete user from the database
May 4, 2014 11:38 PM
Answer

Mreetunjay Sharma

Rank: Junior Member

Posts: 29

Join Date: May 20, 2013

Recent Posts

Thanks Bhargavi..!!