Expand my Community achievements bar.

Introducing Adobe LLM Optimizer: Own your brand’s presence in AI-Powered search and discovery
SOLVED

Alternate for this API com.adobe.cq.addres API

Avatar

Level 4

Hi All ,

 

 

We are using  com.adobe.cq.addres API to get Coordinates in our Service Class.But this is deprecated as part of 
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/release-notes/de....
What we could use instead of above API.Any suggestion are appreciated.
Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 9

The com.adobe.cq.address API (including GeocodeProvider and LocationManager) has been deprecated as of AEM 6.4 and later versions, with no direct replacement provided within the AEM Java API itself. 

The com.adobe.cq.address.api.Address class seems designed to be adaptable from a resource or request and provides getters and setters for address properties. To remove its usage, you essentially need to replace the source of the address data and how you access it. Since AEM Cloud Service emphasizes external services, the most common approach is to integrate with a third-party geocoding API.

Your new approach will likely involve either:

  1. Storing address data in AEM (but not using com.adobe.cq.address.api.Address): This is for cases where the address information is content-centric and managed within AEM, e.g., an office location for a component.
  2. Fetching address data from an external system: This is for cases where address information comes from a system of record (CRM, ERP, e-commerce platform, etc.).
  3. A combination of both: Storing basic address content in AEM, but then using an external geocoding service to get coordinates.

 

General implementation steps with a third-party geocoding API:

  1. Choose a geocoding API: Select the provider that best fits your requirements (accuracy, cost, features).
  2. Obtain an API key: Register with the chosen provider to get your API key.
  3. Create an OSGi service: In your AEM project, create an OSGi service that will encapsulate the logic for calling the external geocoding API.
  4. Make HTTP requests: Use an HttpClient to send requests to the geocoding API's endpoint.
    • Construct the URL with the address you want to geocode and your API key.
    • Set appropriate headers (e.g., Accept: application/json).
    • Handle the response: parse the JSON to extract the latitude and longitude.
    • Implement error handling and retry mechanisms.
  5. Inject the service: Inject your new geocoding OSGi service into any other AEM components or services that need to get coordinates.
  6. Configuration: It's highly recommended to externalize the API key and potentially the API endpoint URL using OSGi configurations. This allows you to easily update these values without code changes and for different environments (dev, stage, prod).
 

View solution in original post

1 Reply

Avatar

Correct answer by
Level 9

The com.adobe.cq.address API (including GeocodeProvider and LocationManager) has been deprecated as of AEM 6.4 and later versions, with no direct replacement provided within the AEM Java API itself. 

The com.adobe.cq.address.api.Address class seems designed to be adaptable from a resource or request and provides getters and setters for address properties. To remove its usage, you essentially need to replace the source of the address data and how you access it. Since AEM Cloud Service emphasizes external services, the most common approach is to integrate with a third-party geocoding API.

Your new approach will likely involve either:

  1. Storing address data in AEM (but not using com.adobe.cq.address.api.Address): This is for cases where the address information is content-centric and managed within AEM, e.g., an office location for a component.
  2. Fetching address data from an external system: This is for cases where address information comes from a system of record (CRM, ERP, e-commerce platform, etc.).
  3. A combination of both: Storing basic address content in AEM, but then using an external geocoding service to get coordinates.

 

General implementation steps with a third-party geocoding API:

  1. Choose a geocoding API: Select the provider that best fits your requirements (accuracy, cost, features).
  2. Obtain an API key: Register with the chosen provider to get your API key.
  3. Create an OSGi service: In your AEM project, create an OSGi service that will encapsulate the logic for calling the external geocoding API.
  4. Make HTTP requests: Use an HttpClient to send requests to the geocoding API's endpoint.
    • Construct the URL with the address you want to geocode and your API key.
    • Set appropriate headers (e.g., Accept: application/json).
    • Handle the response: parse the JSON to extract the latitude and longitude.
    • Implement error handling and retry mechanisms.
  5. Inject the service: Inject your new geocoding OSGi service into any other AEM components or services that need to get coordinates.
  6. Configuration: It's highly recommended to externalize the API key and potentially the API endpoint URL using OSGi configurations. This allows you to easily update these values without code changes and for different environments (dev, stage, prod).