Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Alternative to deprecated API

Avatar

Level 2

I am working on code refactoring, following the document Deprecated APIs | Adobe Experience Manager.

The documentation states that org.apache.commons.lang.text is deprecated and instead, Commons Lang 3 should be used.

 

Code Snippet

import org.apache.commons.lang.text.StrLookup;

import org.apache.commons.mail.Email;

import com.day.cq.commons.mail.MailTemplate;

Email email = mailTemplate.getEmail(StrLookup.mapLookup(emailParams), HtmlEmail.class);

 

Here emailParams is a map of key and value both as string. "Map<String, String> emailParams".

This getEmail method needs "StrLookup" which is only returned by "mapLookup" method provided by "org.apache.commons.lang.text.StrLookup".

 

The "mapLookup" method provided by "org.apache.commons.lang3.text.StrLookup" returns StrLookup<V>.  https://commons.apache.org/proper/commons-lang/apidocs/org/apache/commons/lang3/text/StrLookup.html

and is not suitable for getEmail method. 

 

I looked into org.apache.commons.text.lookup.StringLookupFactory as well but there is no method which just returns StrLookup.

 

Is there any alternative ? What can be used here ? Please suggest.

 

1 Accepted Solution

Avatar

Correct answer by
Employee

Hi @vikalps98363233 ,

 

AFAIK, no updates have been made to https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/commons/ma... to adapt to it.

 

You may have to keep using this "org.apache.commons.lang.text" only. Also, please raise a support ticket so that if similar cases exist this can be reported.

 

Regards,

Nitesh

 

View solution in original post

2 Replies

Avatar

Correct answer by
Employee

Hi @vikalps98363233 ,

 

AFAIK, no updates have been made to https://developer.adobe.com/experience-manager/reference-materials/6-5/javadoc/com/day/cq/commons/ma... to adapt to it.

 

You may have to keep using this "org.apache.commons.lang.text" only. Also, please raise a support ticket so that if similar cases exist this can be reported.

 

Regards,

Nitesh