Highlighted

How to store data in Java content repository in AEM 6.4

Avatar

Avatar

yash558824

Avatar

yash558824

yash558824

04-10-2018

Hello Friends

I am new to AEM and trying to save data in the java content repository and following the below link :

Adobe Experience Manager Help | Persisting Adobe Experience Manager 5 data in the Java Content Repos...

but as this is for older version of AEM, this was not helpful and i didn't able to save data in the JCR.

by the above link what is clear to me is we have to save all the fields of customer as a property in the JCR node ,

but how to call this service which they have defined is not clear to me.

I have implemented a component which as all the fields shown in example and i have called the simpleservlet using ajax call and i have all the field data in this servlet but dont know what should be next step to call this service and save data in JCR.

Thanks in advance.

Yash

Replies

Highlighted

Avatar

Avatar

Lavanya_Malyala

Avatar

Lavanya_Malyala

Lavanya_Malyala

04-10-2018

Hi Yash,

You can refer to the below helpx article (AEM version: Adobe Experience Manager 6.x).

The aim of the below article is to store customer data in JCR and then retrieve the content which is stored in JCR by triggering the queries. The results of the query will be displayed on the web page in the form of grid table as shown in the below article.

In the below helpx article, search for injestCustData method. This method is responsible for storing customer data in the AEM JCR.

Adobe Experience Manager Help | Querying Adobe Experience Manager 6 data using the Sling getServiceR...

This article uses the Sling method named getServiceResourceResolver to obtain a Session instance. This method replaces the use of the getAdministrativeResourceResolver method, as it deprecated.

so, you must perform the below two tasks, as outlined in the below article, prior to running the sample example mentioned in the helpx article.

1) Create an AEM system user (or system user for AEM 6.1) named data with the permissions

2) Map the user with the Sling Mapper service

To create system user in AEM, please refer:

http://www.aemcq5tutorials.com/tutorials/create-system-user-in-aem/

I hope this information helps!

Regards,

Lavanya Malyala

Highlighted

Avatar

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831

Avatar

Arun_Patidar

MVP

Total Posts

2.9K

Likes

1.0K

Correct Answer

831
Arun_Patidar
MVP

05-10-2018

Hi,

in AEM data is store in JCR in forms of nodes and properties.

So to save data in JCR, you need to create nodes or/and properties.

In your servlet get the data and create node/property using JCR Node API.

Node (Content Repository for Java Technology API Version 2.0)

Example :

Node custNode = customerRoot.addNode("customer"+firstName+lastName+custId);

        //make sure name of node is unique

    custNode.setProperty("id", custId);

    custNode.setProperty("firstName", firstName);

    custNode.setProperty("lastName", lastName);

    custNode.setProperty("phone", phone); 

    custNode.setProperty("desc", desc);

Highlighted

Avatar

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K

Avatar

smacdonald2008

Total Posts

12.7K

Likes

1.4K

Correct Answer

2.3K
smacdonald2008

05-10-2018

Only difference between that older AEM community article and what you need to do now (as these other community members have pointed out) - is you need to use a system user to obtain a session.

Scott's Digital Community: How to create an Adobe Experience Manager System User and use Sling Mappi...