Unable to read input filestream when using content loader to mount folderFileVaultXML feature

Description

Here are the steps to replicate the issue.

 

  1. Create a package with one of the dam assets and renditions included

  2. Now configure WCM IO Mocks to load the content exported into file system

  3. Now load the asset as a resource and then adapt to Asset.class

  4. Finally try reading the stream of original rendition

  5. You shall see a NPE

 

When debugging found that content resource is loaded as null causing this issue. For reference attaching sample snippet i used in my project.

 

 

Looking forward for a workaround or fix for this issue in upcoming releases. Feel free to contact me for any questions or collaborating on testing the fixes.

 

Thanks

Activity

Show:

Stefan Seifert October 18, 2022 at 7:22 AM

this is by design, see my comment in SLING-11499.

the FS resource provider is re-used by sling mocks internally to mount file systems. i will update the javadocs in sling mocks to make the distinction clearer for the load() methods:

  • methods json/fileVault methods import a single file into the in-memory repository, allowing to modifying the content after loading

  • methods folderFileVaultXml and folderJson do not import the content but just “mount” it via FSResourceProvider - this is much more effective for large folders with lots of content because it only reads what’s actually accessed via code. but it comes with the downside that this is a read-only view.

Mahidhar Chaluvadi October 15, 2022 at 6:01 PM

@sseifert - Validated the functionality and worked as expected, and thank you so much for this useful API. However I have 2 concerns. With this FS provider, can we not create resources on the fly? When I tried to use resourceresolver.create API I get UnSupportedOperation error. Similarly adapting to ModifiableValueMap also returns null. Was this intentional? Can we extend this API? Already logged issue for adapting issue on Sling Jira board - SLING-11499 . Can log another issue for unable to create resource issue. Please advise. Thanks

Stefan Seifert September 9, 2022 at 1:42 PM

events via eventadmin should work with RESOURCEPROVIDER_MOCK, although i did not explicitly test it in context of sling-mock/aem-mock. it is/was not enabled by default for RESOURCERESOLVER_MOCK.

please not that listening to OSGi events like TOPIC_RESOURCE_ADDED, TOPIC_RESOURCE_REMOVED, TOPIC_RESOURCE_CHANGED is deprecated for years and should no longer be used nowadays. the correct way is to use a ResourceChangeListener (which will not work with RESOURCERESOLVER_MOCK, but should work with RESOURCEPROVIDER_MOCK and the other resource resolver types).

if you see need more work on this please create a new issue (ideally in the ASF JIRA for sling-mock)

Mahidhar Chaluvadi September 1, 2022 at 3:14 PM

Hello Stefan - I see that in both these ResourceResolver Types, EventAdmin is not bound to RRFOptions, though MockResourceResolverFactory supports taking in eventadmin and MockResourceResolver.commit does indeed send events to Event handlers. Any reason for this? In the event it requires custom code to be written, at what level/layer this should be written? Thanks in advance

Stefan Seifert August 22, 2022 at 1:28 PM

Fixed

Details

Assignee

Reporter

Components

Fix versions

Affects versions

Priority

Created July 21, 2022 at 7:38 PM
Updated October 18, 2022 at 7:22 AM
Resolved August 22, 2022 at 1:28 PM