Foros de discusión

Add approx. 100 users to liferay in about one rush...

Sascha Jackson, modificado hace 17 años.

Add approx. 100 users to liferay in about one rush...

New Member Mensajes: 7 Fecha de incorporación: 1/09/06 Mensajes recientes
Dear guys,

at the moment I'm evaluating liferay for our university...

Now I wonder if there's a way to add 100 users in like a scripting kind of way. I have those users in a xls-File. It's no prob to code the java class to read out the data. But how is it possible then to add those users to liferay (without accessing the database directly).

Greetz and thank you.
thumbnail
Jorge Ferrer, modificado hace 17 años.

RE: Add approx. 100 users to liferay in about one rush...

Liferay Legend Mensajes: 2871 Fecha de incorporación: 31/08/06 Mensajes recientes
Hi Sascha,

You can use the Liferay Service to do that. If you are accessing a running portal remotely you can user UserServiceHttp from a local class that reads the XLS file and invokes addUser (and optionally updateUser) for each user.
thumbnail
soori n, modificado hace 16 años.

RE: Add approx. 100 users to liferay in about one rush...

Liferay Master Mensajes: 690 Fecha de incorporación: 18/08/04 Mensajes recientes
i am trying to add users using


String URL = "http://localhost";
HttpPrincipal httpPrincipal = new HttpPrincipal(URL, "liferay.com.1", "XXXXX");


UserServiceHttp.addUser(HttpPrincipal httpPrincipal, java.lang.String companyId, boolean autoUserId, java.lang.String userId, boolean autoPassword, java.lang.String password1, java.lang.String password2, boolean passwordReset, java.lang.String emailAddress, java.util.Locale locale, java.lang.String firstName, java.lang.String middleName, java.lang.String lastName, java.lang.String nickName, java.lang.String prefixId, java.lang.String suffixId, boolean male, int birthdayMonth, int birthdayDay, int birthdayYear, java.lang.String jobTitle, java.lang.String organizationId, java.lang.String locationId);


i am getting error like this


04:44:11,011 ERROR [LogInterceptor] RuntimeException in method: public abstract com.liferay.portal.model.User com.liferay.portal.service.UserLocalService.addUser(java.lang.String,java.lang.String,boolean,java.lang.String,boolean,java.lang.String,java.lang.String,boolean,java.lang.String,java.util.Locale,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean,int,int,int,java.lang.String,java.lang.String,java.lang.String,boolean) throws com.liferay.portal.SystemException,com.liferay.portal.PortalException:
java.lang.NullPointerException
04:44:11,012 ERROR [LogInterceptor] EJBException in method: public abstract com.liferay.portal.model.User com.liferay.portal.service.UserService.addUser(java.lang.String,boolean,java.lang.String,boolean,java.lang.String,java.lang.String,boolean,java.lang.String,java.util.Locale,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,java.lang.String,boolean,int,int,int,java.lang.String,java.lang.String,java.lang.String) throws com.liferay.portal.SystemException,com.liferay.portal.PortalException,java.rmi.RemoteException, causedBy:
java.lang.NullPointerException
04:44:11,012 ERROR [STDERR] java.lang.reflect.InvocationTargetException
04:44:11,012 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor349.invoke(Unknown Source)
04:44:11,012 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
04:44:11,012 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
04:44:11,012 ERROR [STDERR] at com.liferay.portal.kernel.util.MethodInvoker.invoke(MethodInvoker.java:150)
04:44:11,012 ERROR [STDERR] at com.liferay.portal.kernel.util.MethodInvoker.invoke(MethodInvoker.java:47)
04:44:11,012 ERROR [STDERR] at com.liferay.portal.servlet.TunnelServlet.doPost(TunnelServlet.java:91)
04:44:11,012 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
04:44:11,013 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
04:44:11,013 ERROR [STDERR] at com.liferay.portal.kernel.servlet.PortalServletWrapper.service(PortalServletWrapper.java:88)
04:44:11,013 ERROR [STDERR] at javax.servlet.http.HttpServlet.service(HttpServlet.java:810)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:428)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:830)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.jsr77.Jsr77Filter.doFilter(Jsr77Filter.java:77)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
04:44:11,013 ERROR [STDERR] at com.liferay.filters.secure.SecureFilter.doFilter(SecureFilter.java:143)
04:44:11,013 ERROR [STDERR] at com.liferay.portal.kernel.servlet.PortalFilterWrapper.doFilter(PortalFilterWrapper.java:80)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler$CachedChain.doFilter(WebApplicationHandler.java:821)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:471)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:568)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1530)
04:44:11,013 ERROR [STDERR] at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:633)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.HttpContext.handle(HttpContext.java:1482)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.HttpServer.service(HttpServer.java:909)
04:44:11,013 ERROR [STDERR] at org.jboss.jetty.Jetty.service(Jetty.java:456)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.HttpConnection.service(HttpConnection.java:816)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:982)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.HttpConnection.handle(HttpConnection.java:833)
04:44:11,013 ERROR [STDERR] at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:244)
04:44:11,013 ERROR [STDERR] at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:357)
04:44:11,013 ERROR [STDERR] at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:534)
04:44:11,014 ERROR [STDERR] Caused by: java.rmi.ServerException: EJBException:; nested exception is:
javax.ejb.EJBException: RuntimeException
04:44:11,014 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.handleException(LogInterceptor.java:365)
04:44:11,014 ERROR [STDERR] at org.jboss.ejb.plugins.LogInterceptor.invoke(LogInterceptor.java:209)
04:44:11,014 ERROR [STDERR] at org.jboss.ejb.plugins.ProxyFactoryFinderInterceptor.invoke(ProxyFactoryFinderInterceptor.java:136)
04:44:11,014 ERROR [STDERR] at org.jboss.ejb.SessionContainer.internalInvoke(SessionContainer.java:648)
04:44:11,014 ERROR [STDERR] at org.jboss.ejb.Container.invoke(Container.java:954)
04:44:11,014 ERROR [STDERR] at sun.reflect.GeneratedMethodAccessor218.invoke(Unknown Source)
04:44:11,014 ERROR [STDERR] at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
04:44:11,014 ERROR [STDERR] at java.lang.reflect.Method.invoke(Method.java:585)
04:44:11,014 ERROR [STDERR] at org.jboss.mx.interceptor.ReflectedDispatcher.invoke(ReflectedDispatcher.java:155)
04:44:11,014 ERROR [STDERR] at org.jboss.mx.server.Invocation.dispatch(Invocation.java:94)
04:44:11,014 ERROR [STDERR] at org.jboss.mx.server.Invocation.invoke(Invocation.java:86)
04:44:11,014 ERROR [STDERR] at org.jboss.mx.server.AbstractMBeanInvoker.invoke(AbstractMBeanInvoker.java:264)
04:44:11,014 ERROR [STDERR] at org.jboss.mx.server.MBeanServerImpl.invoke(MBeanServerImpl.java:659)
04:44:11,014 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker$MBeanServerAction.invoke(LocalInvoker.java:169)
04:44:11,014 ERROR [STDERR] at org.jboss.invocation.local.LocalInvoker.invoke(LocalInvoker.java:118)
04:44:11,014 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invokeLocal(InvokerInterceptor.java:209)
04:44:11,014 ERROR [STDERR] at org.jboss.invocation.InvokerInterceptor.invoke(InvokerInterceptor.java:195)
04:44:11,015 ERROR [STDERR] at org.jboss.proxy.TransactionInterceptor.invoke(TransactionInterceptor.java:61)
04:44:11,015 ERROR [STDERR] at org.jboss.proxy.SecurityInterceptor.invoke(SecurityInterceptor.java:70)
04:44:11,015 ERROR [STDERR] at org.jboss.proxy.ejb.StatelessSessionInterceptor.invoke(StatelessSessionInterceptor.java:112)
04:44:11,015 ERROR [STDERR] at org.jboss.proxy.ClientContainer.invoke(ClientContainer.java:100)
04:44:11,015 ERROR [STDERR] at $Proxy311.addUser(Unknown Source)

thumbnail
Jorge Ferrer, modificado hace 16 años.

RE: Add approx. 100 users to liferay in about one rush...

Liferay Legend Mensajes: 2871 Fecha de incorporación: 31/08/06 Mensajes recientes
Hi Soori,

You have to authenticate as an admin user to be able to add new users. Use HTTP basic auth for example doing:


String URL = "http://user:passwd@localhost";


edit (Aug28th): I was missing the '@' sign in the above sample URL.
thumbnail
soori n, modificado hace 16 años.

RE: Add approx. 100 users to liferay in about one rush...

Liferay Master Mensajes: 690 Fecha de incorporación: 18/08/04 Mensajes recientes
That worked Jorge
Cheers Once again
thumbnail
Michal Fleischhans, modificado hace 16 años.

RE: Add approx. 100 users to liferay in about one rush...

New Member Mensajes: 11 Fecha de incorporación: 14/02/07 Mensajes recientes
Sascha Jackson:
Dear guys,

at the moment I'm evaluating liferay for our university...

Now I wonder if there's a way to add 100 users in like a scripting kind of way. I have those users in a xls-File. It's no prob to code the java class to read out the data. But how is it possible then to add those users to liferay (without accessing the database directly).

Greetz and thank you.


Hi Sascha,
you can use liferay api to do that, but I wouldn't do so. Using liferay api you make your application portal dependent. I would use LDAP as an enterprise identity standard. You can fill it up programatically and liferay synchronizes with it. Another advantage is, that the same LDAP can be used in the future for another services like email, jabber, .......... and you still have your users at one place. I have portal with 30.000 users and this was the only way I considered.

sincerelly Michal
thumbnail
Rich Sezov, modificado hace 16 años.

RE: Add approx. 100 users to liferay in about one rush...

Regular Member Mensajes: 220 Fecha de incorporación: 7/02/07 Mensajes recientes
I'm importing about 1500 users using Liferay's API and the extension environment. This makes it very easy if you don't have an LDAP infrastructure or don't want to use web services. If you do have an LDAP infrastructure, you can also use it to first import the users into Liferay, and then use Liferay to sync those users over to LDAP (which is how we're using it).

Since my users are coming from a legacy system, I can get them out of a different database. So once I've done that, there are basically two calls: one adds the Organization the users belong to, and then I loop through the user list and add all the users to that Organization.

Here are the two relevant calls:


myOrg = OrganizationLocalServiceUtil.addOrganization(userId,						parentOrg, "My Organization",						regionId.longValue(), countryId.longValue(), 12017,						false);


This code adds the Organization to Liferay's database. It returns an Organization object which holds all of the data about that organization, including the newly generated Organization ID.


lrUser = UserLocalServiceUtil.addUser(userId,
	companyId, false, "password", "password", true,
	"", email, themeDisplay.getLocale(), firstName, "",
	lastName, 0, 0, true,1, 1, 1970, "", nbmeOrg.getOrganizationId(), 0, false);


This code inserts the new user into Liferay.

Hope this helps!
Nagakiran Muddana, modificado hace 13 años.

RE: Add approx. 100 users to liferay in about one rush...

New Member Mensajes: 2 Fecha de incorporación: 14/09/10 Mensajes recientes
Hi Richard,
I am looking for the data load with life ray API.
Can you please share the procedure that you have done to accomplish the same.

Thanks in advance,
Nagakiran.
thumbnail
Richard Sezov, modificado hace 13 años.

RE: Add approx. 100 users to liferay in about one rush...

Regular Member Mensajes: 220 Fecha de incorporación: 7/02/07 Mensajes recientes
Hi Nagakiran,

Wow, this post is over three years old, and was written before I was employed by Liferay (but I was using Liferay at my previous employer). Though the method call has likely changed from what I wrote above, the procedure will be the same. You'll want to use the API call UserLocalServiceUtil.addUser(...) to add users to Liferay. Of course, nowadays, it's best to do this with a portlet rather than with an Ext plugin. Otherwise, the procedure is the same:

1. Grab your users from wherever you're storing them (database, file, etc.).

2. Loop through them and add them to Liferay using the single call to UserLocalServiceUtil.addUser.

Unless I'm not understanding your question correctly, that's all there is to it.

--Rich
Kevin Britton, modificado hace 13 años.

RE: Add approx. 100 users to liferay in about one rush...

New Member Mensajes: 9 Fecha de incorporación: 14/09/10 Mensajes recientes
Richard Sezov:
Hi Nagakiran,

Wow, this post is over three years old, and was written before I was employed by Liferay (but I was using Liferay at my previous employer). Though the method call has likely changed from what I wrote above, the procedure will be the same. You'll want to use the API call UserLocalServiceUtil.addUser(...) to add users to Liferay. Of course, nowadays, it's best to do this with a portlet rather than with an Ext plugin. Otherwise, the procedure is the same:

1. Grab your users from wherever you're storing them (database, file, etc.).

2. Loop through them and add them to Liferay using the single call to UserLocalServiceUtil.addUser.

Unless I'm not understanding your question correctly, that's all there is to it.

--Rich


Speaking for myself, thanks for resurrecting this thread!

I'm a newbie to LifeRay (v6.0), and looking to port over users from a legacy (homemade) system. I'm not a Java developer -- most of my programming background is in PHP. If I were approaching this in PHP, I'd query my list of users, loop through and create new INPUT queries in the right format. But LifeRay is a ton more complex than that, and I get the impression that wouldn't work 'atall.

I understand the concepts behind the steps you list above, but I'm stuck at step 1 when it comes to implementing it via the API. I've looked through a TON of posts on here for advice on a variety of topics, and I keep seeing references to the API, but all seem to require a certain pre-knowledge in how to invoke it. Is there a starter document I'm missing?

Once I get the users ported over, I'm confident in my abilities to navigate the GUI and build our site. But at this point, the API seems quite intimidating. Any pointers or links to documentation for API beginners you can provide would be helpful.

Thanks!

~KB
Paul Butenko, modificado hace 11 años.

RE: Add approx. 100 users to liferay in about one rush...

Junior Member Mensajes: 38 Fecha de incorporación: 2/07/10 Mensajes recientes
Hello,
User import can be done by using UserLocalServiceUtil.
In short you can read some CSV file wich contains user's data and then store it to liferray.
Here you can find more detailed information.

BR,
Paul