Message Boards

How to override validateScreenName method from UserLocalServiceImpl

Apurb Choudhary, modified 3 Years ago.

How to override validateScreenName method from UserLocalServiceImpl

New Member Post: 1 Join Date: 4/18/21 Recent Posts

Hi,

I have a requirement where I need to override the validateScreenName() method from UserLocalServiceImpl.

I need to change this:

String friendlyURL = FriendlyURLNormalizerUtil.normalize(
			StringPool.SLASH + screenName);

to this:

long userId = CounterLocalService.increment();
String friendlyURL = FriendlyURLNormalizerUtil.normalize(
			StringPool.SLASH + userId);

I tried writing servicewrapper to copy paste the UserLocalServiceImpl but I was getting another issue where I was not able to resolve the dependency for:

EmailAddressGenerator emailAddressGenerator =
			EmailAddressGeneratorFactory.getInstance();

and other singleton calls like this.

I am using liferay 7.0

Please suggest.

Apurb

thumbnail
Mohammed Yasin, modified 3 Years ago.

RE: How to override validateScreenName method from UserLocalServiceImpl

Liferay Master Posts: 591 Join Date: 8/8/14 Recent Posts

Hi ,

You can try creating osgi module implementing FriendlyURLNormalizer.class and having higher service rank, you can add ur custom logic in that.

You can refer  below default code and customize accordingly.

https://github.com/liferay/liferay-portal/blob/7.0.x/portal-impl/src/com/liferay/portal/util/FriendlyURLNormalizerImpl.java