留言板

Adding new users programmatically from a single java application

Clemens Schaab,修改在11 年前。

Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi all,

I'am absolutely new to Liferay and now want to create a user with liferay webservices not within portal but from a single java-application from within eclipse. Under Liferay:

Developer documentation I just found one general example of liferay webservices usage and tried to understand the fundamentals.

Within eclipse I created a new Webservice-client by giving it the name of the "Portal_UserService.wsdl", the "Portal_CompanyService.wsdl" and the Portal_OrganizationService.wsdl".

"Portal_UserService" offers me a method to addUser.
"Portal_CompanyService" is necessary to retrieve the company-id I have to pass to the addUser-method.
"Portal_OrganizationService" is not mandatory for this purpose.

The system generated the appropiate Stub classes.

I then created a new test-class to test the adding of a new user. The code in the class is as follows (using some parts of the above mentioned example in liferay developer docu)


	.
	.
	.
	try {
		String remoteUser = "test";
		String password = "Test";
		virtualHost = "localhost";

		String serviceCompanyName = "Portal_CompanyService";
		String serviceUserName = "Portal_UserService";

		// Locate the Company
		CompanyServiceSoapServiceLocator locatorCompany = new CompanyServiceSoapServiceLocator();
		CompanyServiceSoap soapCompany = locatorCompany.getPortal_CompanyService(_getURL(remoteUser, password, serviceCompanyName, true));
		CompanySoap companySoap = soapCompany.getCompanyByVirtualHost(virtualHost);

		// Locate the User service
		UserServiceSoapServiceLocator locatorUser = new UserServiceSoapServiceLocator();
		UserServiceSoap userSoap = locatorUser.getPortal_UserService(_getURL(remoteUser, password, serviceUserName, true));

		ServiceContext context = new ServiceContext();
		context.setPortalURL("http://localhost:8080");
	
		userSoap.addUser(companySoap.getCompanyId(), 
			false, // autoPassword
			"pass1", // String password1
			"pass1", // String password2
			false, // boolean autoScreenName
			"Testuser", // String screenName
			"Testuser@someplace.com", // String emailAddress
			(long) -1, // long facebookId
			"-1", // String openId
			Locale.getDefault().toString(), // Locale locale
			"Test", // String firstName
			"", // String middleName
			"User", // String lastName
			-1, // int prefixId
			-1, // int suffixId
			true, // boolean male
			1, // int birthdayMonth
			1, // int birthdayDay
			1985, // int birthdayYear
			"", // String jobTitle
			new long[0], // long[] groupIds
			new long[0], // long[] organizationIds
			new long[0], // long[] roleIds
			new long[0], // long[] userGroupIds
			false, // boolean sendEmail
			context // ServiceContext serviceContext)
			);

	} 
	catch (Exception e) {
		e.printStackTrace();
	}
	.
	.
	.

	private static URL _getURL(String remoteUser, String password, String serviceName, boolean authenicate) throws Exception {
		// Unauthenticated url
		String url = "http://localhost:8080/api/axis/" + serviceName;

		// Authenticated url
		if (authenicate) {
			url = "http://" + remoteUser + ":" + password + "@localhost:8080/api/secure/axis/" + serviceName;
		}

		return new URL(url);
	}



Liferay is running on the local machine with the given port. The programm did run through without any errors but it did not create the user. I replaced the context parameter in

addUser with null. Then an exception was thrown.
As the documentation in the api is a bit poor, its like fishing in troubled waters.
Can anyone help?

I have some fundamental questions about this topic
1. I think I have to give the remote user to the UserServiceSoap-class because this user has permissions to add a new user, right?
2. I have no understanding of the service-context object. Its meaning is not explained in the liferay-api nor in its documentation. Somehow it seams to be the context to the portal,

but I think the connection to it is done when creating the userSoap-Object.

I would be very obliged for an (a detailed) answer, Clemens
thumbnail
Hitoshi Ozawa,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 7942 加入日期: 10-3-24 最近的帖子
I've written a wiki page with sample code attached on calling liferay's web service to add users.

http://www.liferay.com/community/wiki/-/wiki/Main/Web+Service+samples
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Hitoshi,

I have read your article before writing my thread. But it doesn't help for answering my questions!

Best regards, Clemens
thumbnail
Olaf Kock,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 6403 加入日期: 08-9-23 最近的帖子
Then an exception was thrown

well, it would help to get some more detailed information as the actual exception might give away the root cause of your problem

1. I think I have to give the remote user to the UserServiceSoap-class because this user has permissions to add a new user, right?

Yes - and by default you have the user id (e.g. it's numeric) to authenticate with the webservice, unless you configure otherwise (see your _getURL method)

2. I have no understanding of the service-context object

You're right - it contains a lot of portal context that it carries into the method. The easiest way to see what is actually used from this bucket, is to go through the sourcecode of UserLocalServiceImpl.addUser. Just briefly looking at this code looks like it's optional as there are lots of checks for null - check the source to see the parts that you'll be missing
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf, thanks for your answer!

This is the text of the exception: Has something to do with authentication


AxisFault
 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
 faultSubcode: 
 faultString: java.rmi.RemoteException
 faultActor: 
 faultNode: 
 faultDetail: 
	{http://xml.apache.org/axis/}hostname:CSC-Laptop

java.rmi.RemoteException
	at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
	at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
	at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.endElement(AbstractSAXParser.java:601)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEndElement(XMLDocumentFragmentScannerImpl.java:1782)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(XMLDocumentFragmentScannerImpl.java:2938)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(XMLDocumentScannerImpl.java:648)
	at com.sun.org.apache.xerces.internal.impl.XMLNSDocumentScannerImpl.next(XMLNSDocumentScannerImpl.java:140)
	at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(XMLDocumentFragmentScannerImpl.java:511)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:808)
	at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(XML11Configuration.java:737)
	at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(XMLParser.java:119)
	at com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser.parse(AbstractSAXParser.java:1205)
	at com.sun.org.apache.xerces.internal.jaxp.SAXParserImpl$JAXPSAXParser.parse(SAXParserImpl.java:522)
	at javax.xml.parsers.SAXParser.parse(SAXParser.java:395)
	at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
	at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
	at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
	at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
	at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
	at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
	at org.apache.axis.client.Call.invoke(Call.java:2767)
	at org.apache.axis.client.Call.invoke(Call.java:2443)
	at org.apache.axis.client.Call.invoke(Call.java:2366)
	at org.apache.axis.client.Call.invoke(Call.java:1812)
	at com.liferay.portal.service.http.Portal_UserServiceSoapBindingStub.addUser(Portal_UserServiceSoapBindingStub.java:1622)
	at Test_Portal_TeamService.main(Test_Portal_TeamService.java:53)



The easiest way to see what is actually used from this bucket, is to go through the sourcecode of UserLocalServiceImpl.addUser.

My Code does not use UserLocalServiceImpl, it uses UserServiceSoap.addUser. Stepping through this code leads into the following code-fragment

    public com.liferay.portal.model.UserSoap addUser(long companyId, boolean autoPassword, java.lang.String password1, java.lang.String password2, boolean autoScreenName, java.lang.String screenName, java.lang.String emailAddress, long facebookId, java.lang.String openId, java.lang.String locale, java.lang.String firstName, java.lang.String middleName, java.lang.String lastName, int prefixId, int suffixId, boolean male, int birthdayMonth, int birthdayDay, int birthdayYear, java.lang.String jobTitle, long[] groupIds, long[] organizationIds, long[] roleIds, long[] userGroupIds, boolean sendEmail, com.liferay.portal.service.ServiceContext serviceContext) throws java.rmi.RemoteException {
        if (super.cachedEndpoint == null) {
            throw new org.apache.axis.NoEndPointException();
        }
        org.apache.axis.client.Call _call = createCall();
        _call.setOperation(_operations[9]);
        _call.setUseSOAPAction(true);
        _call.setSOAPActionURI("");
        _call.setSOAPVersion(org.apache.axis.soap.SOAPConstants.SOAP11_CONSTANTS);
        _call.setOperationName(new javax.xml.namespace.QName("urn:http.service.portal.liferay.com", "addUser"));

        setRequestHeaders(_call);
        setAttachments(_call);
 try {    java.lang.Object _resp = _call.invoke(new java.lang.Object[] {new java.lang.Long(companyId), new java.lang.Boolean(autoPassword), password1, password2, new java.lang.Boolean(autoScreenName), screenName, emailAddress, new java.lang.Long(facebookId), openId, locale, firstName, middleName, lastName, new java.lang.Integer(prefixId), new java.lang.Integer(suffixId), new java.lang.Boolean(male), new java.lang.Integer(birthdayMonth), new java.lang.Integer(birthdayDay), new java.lang.Integer(birthdayYear), jobTitle, groupIds, organizationIds, roleIds, userGroupIds, new java.lang.Boolean(sendEmail), serviceContext});

        if (_resp instanceof java.rmi.RemoteException) {
            throw (java.rmi.RemoteException)_resp;
        }
        else {
            extractAttachments(_call);
            try {
                return (com.liferay.portal.model.UserSoap) _resp;
            } catch (java.lang.Exception _exception) {
                return (com.liferay.portal.model.UserSoap) org.apache.axis.utils.JavaUtils.convert(_resp, com.liferay.portal.model.UserSoap.class);
            }
        }
  } catch (org.apache.axis.AxisFault axisFaultException) {
  throw axisFaultException;
}

the line
try { java.lang.Object _resp = _call.invoke (...)
throws the exception.

Besides for that I copied the liferay-sources and was looking for the class you mentioned. Windows could not find it.

So my questions still remain alive.
Would be nice if you had any further help for me! Thank you very much, Clemens
thumbnail
Olaf Kock,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 6403 加入日期: 08-9-23 最近的帖子
Sorry, looks like I read too quickly and missed the "webservice" part - I assumed you used the java API directly, e.g. from another webapp/plugin. This way it would have been easy to step into the implementation as it would have been running in the same process. Liferay's API usually is built along some conventions: UserService is implemented in UserServiceImpl and remotely available - of course, if you access it through Webservices, you don't get UserServiceImpl but the Webservice-Endpoint that just delegates to the webservice (UserServiceSoap). The implementation for UserService typically checks for permissions, then delegates to UserLocalService, which is typically implemented by UserLocalServiceImpl - this class implements all the heavy lifting, e.g. the real functionality. (Note the various *Service, *LocalService variations)

Typically *Service and *LocalService have very similar interfaces, and they're both available from Java applications running in the same container (e.g. tomcat) that Liferay is running in. The code for the implementations lives in portal-impl.jar, it definitely is contained in the sourcecode for Liferay, just not in portal-service.jar which is typically available to plugins and just contains (e.g.) UserLocalServiceClp which delegates to the actual implementation.

You can read about this in ServiceBuilder documentation - Servicebuilder is the component that is used in Liferay to build all the API-level interfaces.

So - coming back to your question (and without debugging the code myself, it'd take some time to reproduce), here's what you can quickly do: Just package your code as webapplication or portlet, deploy it in tomcat and don't go for the Soap-Interface but either through UserService (e.g. call the all-static UserServiceUtil.addUser()) or omit the permission checks and just use UserLocalServiceUtil.addUser(...)) - run all of this in the debugger and single step to see what's required in the implementation of that method.
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,
thank you very much for your detailed answer. I develop under Liferay 6.1, some functionallities have changed there to version 6.0.
Olaf Kock:

You can read about this in ServiceBuilder documentation - Servicebuilder is the component that is used in Liferay to build all the API-level interfaces.

ServiceBuilder is one of these objects that no longer exists in Version 6.1!

Besides I have now seen that the user was created. It just isn't displayed in the Liferay-GUI for some reason (not if I go under portal -> users and organisations) but I can access it programmatically.
I don't know why, but if you do so, I would be glad to hear the reason!

And another short question is if you know what "virtual-host" means in the context of liferay. The next line was part of the example I found at liferay but the meaning of virtual-host isn't clear to me!
 CompanySoap companySoap = soapCompany.getCompanyByVirtualHost(virtualHost); 

Thanks so much, Clemens
thumbnail
Olaf Kock,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 6403 加入日期: 08-9-23 最近的帖子
Clemens Schaab:
ServiceBuilder is one of these objects that no longer exists in Version 6.1!

ServiceBuilder is well alive - it's not a class or interface but a build-time tool that generates the API level of Liferay.
Clemens Schaab:
Besides I have now seen that the user was created. It just isn't displayed in the Liferay-GUI for some reason (not if I go under portal -> users and organisations) but I can access it programmatically.
I don't know why, but if you do so, I would be glad to hear the reason!

if you can't see the user despite the data being there, the reason typically is in the full-text-index (aka lucene). Go to ControlPanel/Server/Server Administration and click "Reindex search index" - this will show the user in the user list. Why creating a user through the API doesn't add it to the index is beyond me, sorry - this should be automatic.
Clemens Schaab:
And another short question is if you know what "virtual-host" means in the context of liferay. The next line was part of the example I found at liferay but the meaning of virtual-host isn't clear to me!
 CompanySoap companySoap = soapCompany.getCompanyByVirtualHost(virtualHost); 

This would be worth a separate question, but as you already have my attention: You can have many different instances in Liferay. The technical name for an instance is "company". In order for Liferay to know which instance you want to access, it uses the virtual host name - e.g. depending on the host name you use, you can display different content. This in mandatory on the company/instance level and optional on a site/organization level.
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,
thank you very much again for your detailed answer. I do not want to "abuse" you any more but a small question still remains:
Olaf Kock:

ServiceBuilder is well alive - it's not a class or interface but a build-time tool that generates the API level of Liferay.

I thought it is a class in version 6.0 as I found it in the API there, but could not find it in the 6.1 API! I will have a look as soon as possible at the ServiceBuilder you meant!


if you can't see the user despite the data being there, the reason typically is in the full-text-index (aka lucene). Go to ControlPanel/Server/Server Administration and click "Reindex search index" - this will show the user in the user list. Why creating a user through the API doesn't add it to the index is beyond me, sorry - this should be automatic.

Olaf, I did as you mentioned, but the user is not displayed. It is the only user created programmatically and it is the only user with a different email-adress. All other users (those that are coming from Liferay itself and the ones that I created via GUI are there and have the same email-adresses! Programmatically I list all the users within a loop and if this "strange" user is in turn, I change his email adress and right afterwards let it display. Everything works well. But if I comment out the line by which I change his email and just list all the users again this "strange" user still has his old email-adress???


This would be worth a separate question, but as you already have my attention: You can have many different instances in Liferay. The technical name for an instance is "company". In order for Liferay to know which instance you want to access, it uses the virtual host name - e.g. depending on the host name you use, you can display different content. This in mandatory on the company/instance level and optional on a site/organization level.

Thank you very much for this pretty good explanation. It helps me much for understanding emoticon
thumbnail
Olaf Kock,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 6403 加入日期: 08-9-23 最近的帖子
Clemens Schaab:
Olaf, I did as you mentioned, but the user is not displayed. It is the only user created programmatically and it is the only user with a different email-adress. All other users (those that are coming from Liferay itself and the ones that I created via GUI are there and have the same email-adresses! Programmatically I list all the users within a loop and if this "strange" user is in turn, I change his email adress and right afterwards let it display. Everything works well. But if I comment out the line by which I change his email and just list all the users again this "strange" user still has his old email-adress???


Sounds strange. Can you post code?
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Olaf Kock:

Sounds strange. Can you post code?

No problem!

public class Test_Portal_TeamService {
	public static void main(String[] args) {

		try {
			String remoteUser = "Test";
			String password = "Test";
			String virtualHost = "localhost";

			String serviceCompanyName = "Portal_CompanyService";
			String serviceOrganization = "Portal_OrganizationService";
			String serviceUserName = "Portal_UserService";

			// Locate the Company
			CompanyServiceSoapServiceLocator locatorCompany = new CompanyServiceSoapServiceLocator();
			CompanyServiceSoap soapCompany = locatorCompany.getPortal_CompanyService(_getURL(remoteUser, password, serviceCompanyName, true));
			CompanySoap companySoap = soapCompany.getCompanyByVirtualHost(virtualHost);

			// Locate the User service
			UserServiceSoapServiceLocator locatorUser = new UserServiceSoapServiceLocator();
			UserServiceSoap userSoap = locatorUser.getPortal_UserService(_getURL(remoteUser, password, serviceUserName, true));

			UserSoap[] allUsers = userSoap.getCompanyUsers(companySoap.getCompanyId(), 0, userSoap.getCompanyUsersCount(companySoap.getCompanyId())-1);
			for (UserSoap user : allUsers) {
				System.out.println("Firstname: " + user.getFirstName() + " Lastname: " + user.getLastName() + " Login-name: " + user.getScreenName() + " password: " + user.getPassword() + " user_id: " + user.getUserId() + " Email: " + user.getEmailAddress());
				
				if (user.getLastName().equals("NewUser")) {
					user.setEmailAddress("newuser@liferay.com");
					System.out.println("User email-adress again: " + user.getEmailAddress() + " CompanyId: " + user.getCompanyId() + " UserID: " + user.getUserId() + " Screenname: " + user.getScreenName());
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private static URL _getURL(String remoteUser, String password, String serviceName, boolean authenicate) throws Exception {
		// Unauthenticated url
		String url = "http://localhost:8080/api/axis/" + serviceName;

		// Authenticated url
		if (authenicate) {
			url = "http://" + remoteUser + ":" + password + "@localhost:8080/api/secure/axis/" + serviceName;
		}
		return new URL(url);
	}
}



That's all. Nothing really spectacular.

TestUser "Test" belongs to the userGroup "Administrators"!
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,

I went on a bit with coding but whatever I try, it has no effect on the GUI. Last attempt was to add a given regular organization as parent to another given regular organization. Programatically it worked but it had no effect in the GUI as well.
Doing the same things in the GUI works without any problems.
I think I am doing something basically wrong in using the webservices, don't I?
thumbnail
Olaf Kock,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 6403 加入日期: 08-9-23 最近的帖子
In this code you're not creating any user - and you're only changing the user email address locally instead of publishing it back to the server. UserSoap will be changed locally but not on the server. See the UserService which is the interface for the actual business logic, particularly the update* methods. You'll also find them in your code generated from WSDL.

The main difference is that the interface "User" as well as its WS-counterpart UserSoap are just containers for the data, while UserService is used to persist this data.
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,
with this explanation I am sure we are shortly before solving the problem. Excellent!

Olaf Kock:
In this code you're not creating any user

thats right, because I thought I had created the user before. I give you the code by which I thought I would have created it (the code refers to the one I gave you in my last note).

		
			ServiceContext context = new ServiceContext();
			context.setPortalURL("http://localhost:8080");
			
			 userSoap.addUser(companySoap.getCompanyId(),
			 false, // autoPassword
			 "newUser", // String password1
			 "newUser", // String password2
			 false, // boolean autoScreenName
			 "NewUser", // String screenName
			 "newuser@abashh.de", // String emailAddress
			 (long) -1, // long facebookId
			 "-1", // String openId
			 Locale.getDefault().toString(), // Locale locale               
			 "New", // String firstName
			 "", // String middleName
			 "User", // String lastName
			 -1, // int prefixId
			 -1, // int suffixId
			 true, // boolean male
			 1, // int birthdayMonth
			 1, // int birthdayDay
			 1985, // int birthdayYear
			 "", // String jobTitle
			 new long[0], // long[] groupIds
			 new long[0], // long[] organizationIds
			 new long[0], // long[] roleIds
			 new long[0], // long[] userGroupIds
			 false, // boolean sendEmail
			 context // ServiceContext serviceContext)
			 );

Olaf Kock:

- and you're only changing the user email address locally instead of publishing it back to the server. UserSoap will be changed locally but not on the server. See the UserService which is the interface for the actual business logic, particularly the update* methods. You'll also find them in your code generated from WSDL.

With this explanation I understand, why the changed email adress would not have an effect in the GUI, because I changed it just locally and not on the server.
But I do not understand, why the user is not created on the server. I use userSoap, and userSoap is of type UserServiceSoap so following your explanation it should have been inserted on the server.
I then replaced userSoap.addUser(...) with UserServiceUtil.addUser (...) (replacing parameter Locale.getDefault().toString with Locale.getDefault()) and hoped that would work. But
first: I am not sure about the difference between the two objects and
second: I got an error then


13.02.2013 08:19:06 com.liferay.portal.kernel.log.Jdk14LogImpl error
SCHWERWIEGEND: BeanLocator is null
com.liferay.portal.kernel.bean.BeanLocatorException: BeanLocator has not been set
	at com.liferay.portal.kernel.bean.PortalBeanLocatorUtil.locate(PortalBeanLocatorUtil.java:72)
	at com.liferay.portal.service.UserServiceUtil.getService(UserServiceUtil.java:1338)
	at com.liferay.portal.service.UserServiceUtil.addUser(UserServiceUtil.java:203)
	at Test_Portal_TeamService.main(Test_Portal_TeamService.java:207)


If I had understood you correctly the method userSoap.addUser(...) should have worked. I am now pretty excited because I am convinced that the solution is in the air!!!
Do you have any idea, why it did not work?

Olaf Kock:

The main difference is that the interface "User" as well as its WS-counterpart UserSoap are just containers for the data, while UserService is used to persist this data.

Thank you very much for that!

Clemens
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,
I tried the given liveray-soap-example again and I cound create a new UserGroup that was also visible in liferay that means updated on the server. The code doing this is

			
	UserGroupSoap newUserGroup = usergroupsoap.getUserGroup("NewGroup");
	System.out.println("Added user group named " + groupName);
	long users[] = { 12206 };
	userSoap.addUserGroupUsers(newUserGroup.getUserGroupId(), users);

12206 is the id of a user I created over the GUI of liferay, not programmatically! userSoap is the object as always!
That means, that creating new stuff on the server basically works. It must be the method addUser I am using that fails somehow. Maybe the given context needs some more information - or proper ones?

Best regards, Clemens
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,

would be good for me to know, if I stil can expect an answer from you or not.
If not, okay, than we have to find another solution for our problem here.

It just helps me with our ongoing plannings. Thanks in advance for your answer!
thumbnail
Olaf Kock,修改在11 年前。

RE: Adding new users programmatically from a single java application

Liferay Legend 帖子: 6403 加入日期: 08-9-23 最近的帖子
...vacation is over, I'm back - sorry for the delay. Did you solve your problems? As usual after vacation, I'm quite swamped - maybe someone else could step in if your problem still persists.
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,
hope you had some relaxing days off. Unfortunatelly no one else stepped in. So my problem still exists.
My post from 12. February 2013 describes what I have been trying after your last explanations.

Best regards, Clemens
Clemens Schaab,修改在11 年前。

RE: Adding new users programmatically from a single java application

New Member 帖子: 12 加入日期: 13-2-7 最近的帖子
Hi Olaf,

could you, please, answer my post from february, the 7th 2013. Thanks for that!