Foros de discusión

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

thumbnail
Nirav Prajapati, modificado hace 8 años.

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

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
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 hace 8 años.

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

Liferay Legend Mensajes: 1744 Fecha de incorporación: 6/11/08 Mensajes recientes
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 hace 8 años.

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

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
Although the link is for 6.1, same concepts apply in 6.2.
thumbnail
Nikhil Nishchal, modificado hace 8 años.

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

Regular Member Mensajes: 177 Fecha de incorporación: 22/06/12 Mensajes recientes
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 hace 8 años.

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

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
Actually i want to add USERGROUP at the time when user register.
Please help me ..!
thumbnail
David H Nebinger, modificado hace 8 años.

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

Liferay Legend Mensajes: 14919 Fecha de incorporación: 2/09/06 Mensajes recientes
So use a model listener on the User entity. In onAfterCreate() add the user group to the user.
thumbnail
Nirav Prajapati, modificado hace 8 años.

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

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
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 hace 8 años.

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

Expert Mensajes: 483 Fecha de incorporación: 31/07/10 Mensajes recientes
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 hace 8 años.

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

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
Yes i have already do it.but still no any effect.
thumbnail
Harish Kumar, modificado hace 8 años.

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

Expert Mensajes: 483 Fecha de incorporación: 31/07/10 Mensajes recientes
I have tried it using Liferay 7 M6 and its working fine. Please find attached sample hook project
thumbnail
Nirav Prajapati, modificado hace 8 años.

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

Regular Member Mensajes: 133 Fecha de incorporación: 25/06/15 Mensajes recientes
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