Forums de discussion

Creating Users Remotely

M M, modifié il y a 12 années.

Creating Users Remotely

New Member Publications: 11 Date d'inscription: 17/06/10 Publications récentes
Hi all. I've been looking at a custom registration process, and would like to be able to create users from a remote machine, using our back end ejb tier to call Liferay remotely. I understand that I am able to do this using Liferay Web Services (and have that working). The problem I have with using the web services is that all exceptions are reported as javax.rmi.RemoteException, rather than PortalExceptions. For example, calling the UserLocalServiceUtil directly will return exceptions like com.liferay.portal.DuplicateUserEmailAddressException, but calling through the SoapService will return javax.rmi.RemoteException with no apparent way to get at the detail.

Is it possible to call the services remotely and maintain all functionality (including receiving the detailed exceptions)?
thumbnail
Hitoshi Ozawa, modifié il y a 12 années.

RE: Creating Users Remotely

Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
I've been experiencing the same problem because it's difficult to know if the error is caused by user already existing or by something else.

I'm currently writing to error log to do a manual check afterwards. Liferay needs a better web service return code if they really are serious about
providing interfaces to developers for system integration.

It may be better to post this to suggestion and recommendation forum instead of here.
thumbnail
Julien Bonjean, modifié il y a 12 années.

RE: Creating Users Remotely

Junior Member Publications: 57 Date d'inscription: 10/06/09 Publications récentes
If you are using user related web service only, you may consider writing your own proxy.
M M, modifié il y a 12 années.

RE: Creating Users Remotely

New Member Publications: 11 Date d'inscription: 17/06/10 Publications récentes
Thanks for the replies. I have this working (sort of) using the HTTP services (e.g. OrganizationServiceHttp). I am having some strange behavior however:

If I call OrganizationServiceHttp.addOrganization(...), the organization is added correctly. If I call the following method however:

OrganizationServiceHttp.updateOrganization(httpPrincipal, organizationId, parentOrganizationId, name, type, recursable, regionId, countryId, statusId, comments, serviceContext);

I get an exception: com.liferay.portal.NoSuchUserException: No User exists with the primary key 0

I'm not sure exactly where this error is coming from, as I use the same HttpPrincipal for both calls. Any ideas?
thumbnail
Hitoshi Ozawa, modifié il y a 12 années.

RE: Creating Users Remotely

Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
I was getting the same error.
It seems you have to create an user who will be in the organization before creating an organization.
I think I included this logic in the web service sample I've made available in Liferay wiki. emoticon
M M, modifié il y a 12 années.

RE: Creating Users Remotely

New Member Publications: 11 Date d'inscription: 17/06/10 Publications récentes
Thanks again. I can't seem to find that wiki entry. Any chance you could link me?
thumbnail
Hitoshi Ozawa, modifié il y a 12 années.

RE: Creating Users Remotely

Liferay Legend Publications: 7942 Date d'inscription: 24/03/10 Publications récentes
It seems to getting more difficult to find things here.

Finally found it. I think it's contained here. If not, I'll search my hdd. We were having the same problem so I know that I got it solved. emoticon
http://www.liferay.com/community/wiki/-/wiki/Main/Web+Service+samples
thumbnail
jelmer kuperus, modifié il y a 12 années.

RE: Creating Users Remotely

Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentes
You can also make use of the hessian / burlap / httpinvoker services.

The http invoker services will give you the correct exceptions for sure. I havent tried the hessian / burlap ones.

See this thread for an example : http://www.liferay.com/community/forums/-/message_boards/message/5504664
M M, modifié il y a 12 années.

RE: Creating Users Remotely

New Member Publications: 11 Date d'inscription: 17/06/10 Publications récentes
I switched to use Spring Remoting (HttpInovker), and have exactly the same behavior described above. I can create an Organization, but can't run an update (No user exists with the primary key 0).

I also tried adding a user to the Organization, but this did not fix the problem. I still got the no user exists exception.

M M:
...
If I call OrganizationServiceHttp.addOrganization(...), the organization is added correctly. If I call the following method however:

OrganizationServiceHttp.updateOrganization(httpPrincipal, organizationId, parentOrganizationId, name, type, recursable, regionId, countryId, statusId, comments, serviceContext);

I get an exception: com.liferay.portal.NoSuchUserException: No User exists with the primary key 0...
thumbnail
jelmer kuperus, modifié il y a 12 années.

RE: Creating Users Remotely (Réponse)

Liferay Legend Publications: 1191 Date d'inscription: 10/03/10 Publications récentes
either pass in null as a serviceContext (the way to go if you dont want to update tags / categories / expandos etc) or make sure you set the correct userId on the serviceContext

eg

ServiceContext ctx = new ServiceContext ();
ctx.setUserId(yourUserId);