Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events
SOLVED

How to sync content publish to author environment in AEM cloud

Avatar

Level 3

Hi All,
I created custom form which has first name, last name and company name, authored form component and published page in publish environment 

Access the publish environment on that page, When the user submits a form, data needs to be stored in the author environment.

Is Sling Content Distribution Reverse content(publish to author )will work an AEM cloud environment ?
https://experienceleague.adobe.com/en/docs/experience-manager-cloud-service/content/release-notes/ae...

I wrote a servlet that works well in the author environment. When a user submits data to the author, it can be stored in author environment ,

When the end user(publish page) submits a form, that information must be saved in the author environment .


CC:   @arunpatidar  @EstebanBustamante  @Raja_Reddy @Kamal_Kishor  @Shashi_Mulugu 

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

@naruk89179065 

 

Please assure that you are running command in the same folder where private.key file is present. Please cross-check the filename also once


Aanchal Sikka

View solution in original post

12 Replies

Avatar

Community Advisor

@naruk89179065 Why are you bringing the user generated content (UGC) from form submission into Author instance? Normally the UGC should be stored separate data store than AEM or form can be submitted to Marketo and the AEM instances can read those submitted forms. What is the use case of bringing to AEM author , just for reporting? Also the submitted form data will fill up the author if there is spam attack on these forms and can bring the author down. My 2 cents!

Using SCD it will replicate the submitted data in one publish to all the other publish instances. 

thanks @Saravanan_Dharmaraj 

We created custom form, it's around 50 user's information that needs to be stored on the page in the author environment, If end user requires content modification, it should allow  content author  for modification, If that content is available in the author environment, it will be easy to make content modification


 




Avatar

Community Advisor

@naruk89179065 

 

Is this functionality added on an Intranet site or public site?

 

  • This is possible to send content from publish to author via hacks like Servlet. BUT ITS NOT RECOMMENDED.  Please be careful with the Servlet approach, use access tokens to validate the request between author and publish. It should not open a security issue, where someone can post n number of requests to author to store user info.
  • In general, as @Saravanan_Dharmaraj suggested, its UGC content and should be out of AEM. 
  • SCD does not support reverse replication. 

Aanchal Sikka

Avatar

Level 3

thanks @aanchal-sikka 
Do you have piece of code for Servlet to authenticate author environment  

Avatar

Level 1

thanks @aanchal-sikka 

thorough token authorization ,able to submit data in author instance

Avatar

Level 3

@aanchal-sikka 
I followed by below blog 
https://techrevel.blog/2023/09/06/access-restricted-resources-on-aemaacs-with-java-and-service-accou...
When I run the command in the terminal, it shows

Could not find private key from private.key


openssl pkcs8 -topk8 -inform PEM -outform DER -in private.key -out privateKey.pem -nocrypt


Avatar

Correct answer by
Community Advisor

@naruk89179065 

 

Please assure that you are running command in the same folder where private.key file is present. Please cross-check the filename also once


Aanchal Sikka

Avatar

Level 1

thanks @aanchal-sikka 
Its working fine till June 4th, 2024 , After Jwt  token is not working 
Just print's  below log  message , then Its throws exception 
logger.debug("Jwts Builder " + Jwts.builder());

io.jsonwebtoken.lang.UnknownClassException: Unable to load class named [io.jsonwebtoken.impl.DefaultJwtBuilder] from the thread context, current, or system/application ClassLoaders.  All heuristics have been exhausted.  Class could not be found.  Have you remembered to include the jjwt-impl.jar in your runtime classpath?

 Added Embedded dependency below files

<embedded>

<groupId>io.jsonwebtoken</groupId>

<artifactId>jjwt-api</artifactId>

<type>jar</type>

<target>

/apps/www-packages/application/install</target>

</embedded>

<embedded>

<groupId>io.jsonwebtoken</groupId>

<artifactId>jjwt-impl</artifactId>

<type>jar</type>

<target>

/apps/www-packages/application/install</target>

</embedded>

<embedded>

<groupId>io.jsonwebtoken</groupId>

<artifactId>jjwt-jackson</artifactId>

<type>jar</type>

<target>

/apps/www-packages/application/install</target>

</embedded>

Avatar

Community Advisor

@KotiReddyNa 

 

Requesting you to please cross-check, if there has been any version updates for the dependencies, 


Aanchal Sikka

Avatar

Employee Advisor

In AEM CS I would store this information in the user profile and request that the usersync feature is enabled.

 

Nevertheless this information will not reach the authoring instance when using usersync, which is correct. If you want users to store data in publish and being able to review/modify it on publish, you need probably to rely on an external storage, as the usersync is not working this way, and sling content distribution does not work on AEM CS this way either.