Read a xml file from file system and store as jcr:data in crx | Community
Skip to main content
New Participant
February 26, 2018
Solved

Read a xml file from file system and store as jcr:data in crx

  • February 26, 2018
  • 22 replies
  • 14082 views

Hi,

In AEM, how to read a xml file from file system and store the content as jcr:data into sling:folder node using Java?

Any sample or tutorial available, kindly help.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by smacdonald2008

Here is the HELPX article that was created based on this thread -- Scott's Digital Community: Creating a Custom Watched Folder Service for Adobe Experience Manager 6.3

22 replies

New Participant
March 7, 2018

OK smacdonald2008 tnx.. it works Sorry did not notice that point.

smacdonald2008
New Participant
March 7, 2018

In AEM 6.3 - when you use this code --

ResourceResolver resourceResolver = resolverFactory.getAdministrativeResourceResolver(null);

            session = resourceResolver.adaptTo(Session.class);

You need to whitelist the OSGi bundle. This give permission to use this call. We always recommend using this in your DEV test AEM instance to make code shorter - when you put into production - you should use System User and Sling Mapping service.

That is why we put this note right after the code:

Note:

For code brevity, this code example uses repository.loginAdministrative(null) rmethod. This is used simply to keep the code shorter. If you are using this in Production, the recommended way is to create a system user and use the Sling Mapping Service. For more information, see Querying Adobe Experience Manager 6 data using the Sling getServiceResourceResolver method.

To ensure that the code works, you must whitelist the AEM bundle. Use the Symbolic name of the OSGi bundle. For more information, see https://forums.adobe.com/thread/2355506.

TO learn how to white list the bundle - read this thread - https://forums.adobe.com/thread/2355506.

You need to enter the SYMBOLIC NAME OF THE BUNDLE. You can get this value here. Notice you can open the bundle in WinRar and open the MANIFEST File....

New Participant
March 7, 2018

Thanks smacdonald2008 i tried to install the bundle. Getting below error, any idea what could be wrong?

smacdonald2008
New Participant
March 6, 2018

The article is live and the URL is posted.

New Participant
March 6, 2018

hi smacdonald2008

The article is still not available. kindly let know when it will it be available

smacdonald2008
New Participant
March 2, 2018

We are wrapping up this today - it works very nicely as a custom AEM Service with an AEM Scheduler Service -- all discussed in the new article.

New Participant
March 2, 2018

Thanks smacdonald2008​.

Looking forward to this on Monday.

smacdonald2008
smacdonald2008Accepted solution
New Participant
March 1, 2018

Here is the HELPX article that was created based on this thread -- Scott's Digital Community: Creating a Custom Watched Folder Service for Adobe Experience Manager 6.3

smacdonald2008
New Participant
March 1, 2018

Its an AEM OSGi service written in Java.. Then anothet AEM scheduler service invokes the custom service that reads the XML file and places it within the JCR.

New Participant
March 1, 2018

Thanks smacdonald2008 .

Is this based on AEM workbench process?

Also we need to store the xml file in sling:folder (not nt:folder) as jcr:data (binary), as this is the expected format by the prefill osgi service that we have deployed already. This xml will be read in adaptive form through prefill service