Fórum

Find location of UserLocalServiceUtil.addUser()/.updateUser(

thumbnail
Nirav Prajapati, modificado 8 Anos atrás.

Find location of UserLocalServiceUtil.addUser()/.updateUser(

Regular Member Postagens: 133 Data de Entrada: 25/06/15 Postagens Recentes
hello friends,

i am using liferay version 6.2

i want to modify user registration functionality which is already given by sign in portlet .

i want the location of UserLocalServiceUtil.addUser() or UserLocalServiceUtil.updateUser() in the source of liferay.
thumbnail
Sandeep Nair, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Liferay Legend Postagens: 1744 Data de Entrada: 06/11/08 Postagens Recentes
What kind of modification are you looking for? If you want to just override some service, I will suggest you write wrapper hook. Please see the following link

https://www.liferay.com/documentation/liferay-portal/6.1/development/-/ai/overriding-a-portal-servi-4
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
Although the link is for 6.1, same concepts apply in 6.2.
thumbnail
Nikhil Nishchal, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Regular Member Postagens: 176 Data de Entrada: 22/06/12 Postagens Recentes
You can use service wrapper hooks, If you want some changes like trigger on user creation, you can also use model listner hook on User.
thumbnail
Nirav Prajapati, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Regular Member Postagens: 133 Data de Entrada: 25/06/15 Postagens Recentes
Actually i want to add USERGROUP at the time when user register.
Please help me ..!
thumbnail
David H Nebinger, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser( (Resposta)

Liferay Legend Postagens: 14916 Data de Entrada: 02/09/06 Postagens Recentes
So use a model listener on the User entity. In onAfterCreate() add the user group to the user.
thumbnail
Nirav Prajapati, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Regular Member Postagens: 133 Data de Entrada: 25/06/15 Postagens Recentes
i have created a hook type project and add one class fil and prtal.properties under WEB-INF//src/packagename folder but stll it will not work.


Following are the code which show userid but i want to add usergroup @ user creation instead of showing userid.


public class trafficListner extends BaseModelListener<user> {
		@Override
		public void onAfterCreate(User model) throws ModelListenerException {
			// TODO Auto-generated method stub
			
			System.out.println("User Id="+model.getUserId());
			super.onAfterCreate(model);
		}
}
</user>

liferay-hook.xml

<!--?xml version="1.0"?-->

<hook>
<portal-properties>portal.properties</portal-properties>
</hook>

How it will perform???
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
Hi

Did you created portal.properties file in your hook and added the entry so that liferay knows about your custom listener

value.object.listener.com.liferay.portal.model.User=


please follow this link

append your custom listener class in this property along with default one
thumbnail
Nirav Prajapati, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Regular Member Postagens: 133 Data de Entrada: 25/06/15 Postagens Recentes
Yes i have already do it.but still no any effect.
thumbnail
Harish Kumar, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Expert Postagens: 483 Data de Entrada: 31/07/10 Postagens Recentes
I have tried it using Liferay 7 M6 and its working fine. Please find attached sample hook project
thumbnail
Nirav Prajapati, modificado 8 Anos atrás.

RE: Find location of UserLocalServiceUtil.addUser()/.updateUser(

Regular Member Postagens: 133 Data de Entrada: 25/06/15 Postagens Recentes
I have successfully done with the use of ModelListener.
Following is the code for it.


public class UserGroupListner extends BaseModelListener<user>{
	
	@Override
	public void onAfterCreate(User user) throws ModelListenerException {
		// TODO Auto-generated method stub
		 System.out.println(user.getFullName() + "THIS USER IS CREATED yupi !!!!!!!!!!!!!!!!!!!!!!!!!!!");
			UserGroup userGroup=null;
			System.out.println(PropsUtil.get("usergroupname"));

			try {
				userGroup=UserGroupLocalServiceUtil.getUserGroup(user.getCompanyId(), PropsUtil.get("usergroupname"));
				/*System.out.println(userGroup.getUserGroupId());*/
			} catch (PortalException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (SystemException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			try {
				UserGroupLocalServiceUtil.addUserUserGroup(user.getUserId(), userGroup.getUserGroupId());
				
			} catch (SystemException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}

	}

}
</user>


Following is the portal.properties file.


value.object.listener.com.liferay.portal.model.User=com.service.traffic.hook.UserGroupListner