Hi Stefan

This did the trick:

<Sling-Initial-Content>
   SLING-INF/apps/test.json;overwriteProperties:=true;path:=/apps,
   SLING-INF/apps/test;overwrite:=false;path:=/apps/test
</Sling-Initial-Content>

Now, I am running into an issue /bin/test. I can create a folder using the old 
content package but I cannot do the same with Bundle Content.

I get this exception:

rg.apache.sling.jcr.contentloader.internal.BundleContentLoader Cannot load 
initial content for bundle com.headwire.sling.multipackageupdate : Item is 
protected.
javax.jcr.nodetype.ConstraintViolationException: Item is protected.
        at 
org.apache.jackrabbit.oak.jcr.session.ItemImpl$ItemWriteOperation.checkPreconditions(ItemImpl.java:98)
 [org.apache.jackrabbit.oak-jcr:1.8.8]
        at 
org.apache.jackrabbit.oak.jcr.session.NodeImpl$35.checkPreconditions(NodeImpl.java:1368)
 [org.apache.jackrabbit.oak-jcr:1.8.8]
        at 
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.prePerform(SessionDelegate.java:615)
 [org.apache.jackrabbit.oak-jcr:1.8.8]
        at 
org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate.perform(SessionDelegate.java:205)
 [org.apache.jackrabbit.oak-jcr:1.8.8]
        at 
org.apache.jackrabbit.oak.jcr.session.ItemImpl.perform(ItemImpl.java:112) 
[org.apache.jackrabbit.oak-jcr:1.8.8]
        at 
org.apache.jackrabbit.oak.jcr.session.NodeImpl.internalSetProperty(NodeImpl.java:1365)
 [org.apache.jackrabbit.oak-jcr:1.8.8]
        at 
org.apache.jackrabbit.oak.jcr.session.NodeImpl.setProperty(NodeImpl.java:435) 
[org.apache.jackrabbit.oak-jcr:1.8.8]

Is there a way to fix this?

- Andy

> On Aug 1, 2019, at 2:46 PM, Stefan Seifert <[email protected]> wrote:
> 
> you did not document which value you have put to the Sling-Initial-Content 
> header of your bundle.
> i assume it is something like:
> 
> <resource-path>;overwrite:=true;ignoreImportProviders:=xml;path:=/apps
> 
> so, by definition [1], it's cleans everything below /apps.
> 
> in your case you only want to deploy to /apps/test, but also you want to set 
> some properties on /apps/test itself.
> that's a usecase that is indeed not ideally supported from the content loader 
> in combination with JSON file format.
> 
> for this special case you may combine multiple entries in 
> Sling-InitialContent, e.g.
> 
> <resource-path-1>;overwrite:=true;ignoreImportProviders:=xml;path:=/apps/test,
> <resource-path-2>;overwriteProperties:=true;path:=/apps
> 
> resource-path-1 contains all your json files of the application, 
> resource-path-2 just on test.json with the properties for the /apps/test node.
> 
> please note: i've not tested this if this works at all! i never encountered 
> this usecase myself. maybe you can change your usecase to avoid properties on 
> the root node of the content load path.
> 
> stefan
> 
> [1] 
> https://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html
> 
> 
> 
>> -----Original Message-----
>> From: Andreas Schaefer [mailto:[email protected]]
>> Sent: Thursday, August 1, 2019 11:12 PM
>> To: dev
>> Subject: Sling Initial Content with Root Folder properties
>> 
>> Hi
>> 
>> This might be a stupid question but I am stumbling here.
>> 
>> If I have a folder structure like:
>> 
>> /apps
>>      /test
>>              /subtest
>> 
>> And I want to add properties to /apps/test like jcr:title.
>> For that I would need to create a file like this:
>> 
>> SLING-INF/apps/test.json
>> 
>> Now how would it set the sling initial content configuration to make
>> /apps/test to be updated but does not whip out /apps.
>> In the old, content package model we had .content.xml inside /apps/test so
>> there was no issue with having the root node properties updated.
>> 
>> Cheers - Andy Schaefer
> 

Reply via email to