You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Marc Speck <ma...@gmail.com> on 2008/08/08 16:57:49 UTC

Sling-Initial-Content and WebDav with custom node type

1. Is it possible to load files with <Sling-Initial-Content> into a custom
node type? When I try it with foo.png and foo.xml (which contains the
definitions), jcr:data is always 0.

1.1 How can I debug the loading of initial content? I install the bundle
from Eclipse with maven autoInstallBundle but breakpoints e.g. in
org.apache.sling.jcr.contentloader.internal.Loader.registerBundleInternal()
are never met. Debuging servlet calls works fine.


2. WebDav: create custom node types
When adding files with WebDav, I want to put the files into a customized
node type (that inherits from nt:resource). The only way to do is, is
writing a handler like:

public class NodeTypeHandler extends
org.apache.jackrabbit.server.io.DefaultHandler

and add in file webdav-resource-config.xml of bundle
org.apache.sling.jcr.webdav something like

    <iomanager>
        <iohandler>
            <class name="NodeTypeHandler" />
        </iohandler>
.....
    </iomanager>
    <propertymanager>
        <propertyhandler>
            <class name="NodeTypeHandler " />
        </propertyhandler>
.....
    </propertymanager>


or is there a easier way? I first thought of a quick hack: adding a listener
to NODE_ADDED and add a mixin to new nodes. But this is somewhat a waste of
resources and also does not allow to have custom node types. Converting node
types is not possible with jackrabbit as far as I know.

Re: Sling-Initial-Content and WebDav with custom node type

Posted by Marc Speck <ma...@gmail.com>.
Thanks for the quick response.

node type? When I try it with foo.png and foo.xml (which contains the
>> definitions), jcr:data is always 0.
>>
>
> 1. Is it possible to load files with <Sling-Initial-Content> into a custom
> This is definitely not good. My question: should the node be called foo or
> foo.png ? In case it should be called foo, the only solution I have out of
> my belly is to prefill the data into the repository and export it with
> system view export to re-import it through the bundle. The other mechanisms
> have IIRC no way of easily importing binary data.
>
> Ehrm, thinking of it, there might be a way: How about naming your image
> file as foo instead of foo.png. This way the node foo would be created and
> additional settings would be taking from foo.xml.
>
> If the node should be called foo.png, the descriptor should be foo.png.xml.
>

I forgot that foo.png was in a sub folder and so the name of foo.xml was not
relevant (I thought). As you write, naming foo.png and foo.png.xml is
correct. However, this still does not work and having looked into
Loader.installFromPath(), I also do not understand how it could work. The
first entry is foo.png for which a descriptor is found but no provider. So
the file is created with type nt:file even though it should have been
f:PageBox. What do I miss here?


foo.png.xml:

<node>
    <primaryNodeType>f:PageBox</primaryNodeType>
    <property>
        <name>f:title</name>
        <value>the tile of my first PageBox</value>
        <type>String</type>
    </property>
</node>


Node Type:

[f:PageBox] > nt:resource,mix:versionable
  - 'title' (String)
    version



> 1.1 How can I debug the loading of initial content? I install the bundle
> from Eclipse with maven autoInstallBundle but breakpoints e.g. in
> org.apache.sling.jcr.contentloader.internal.Loader.registerBundleInternal()
> are never met. Debuging servlet calls works fine.
>

The registerBundleInternal is called when a new bundle is installed - e.g.
> on system startup or by BundleContext.install as per an BundleEvent.


Yes, that's what I want.


> I usually run Sling from the standalone launcher with debugging enabled and
> connecting from Eclipse I can easily set a breakpoint and get landed.


Oem, breakpoints in Loader.registerBundleInternal() did not work with
jetty:run but with launchpad/app everything works fine (for what reasons so
ever).



> 2. WebDav: create custom node types
>> When adding files with WebDav, I want to put the files into a customized
>> node type (that inherits from nt:resource). The only way to do is, is
>> writing a handler like:
>>
>> public class NodeTypeHandler extends
>> org.apache.jackrabbit.server.io.DefaultHandler
>>
>
>
>
> Yes, this is the intent of the SimpleWebDAVServlet.
>
>
>> and add in file webdav-resource-config.xml of bundle
>> org.apache.sling.jcr.webdav something like
>>
>
> That is the current state. My intention is to have this configurable in a
> more flexible way, than hacking up the bundle (this is not really a good
> solution, right ;-) ).
>
> But currently, it is unfortunately the only solution due to lack of time of
> finding a better one. If you come up with a better more flexible solution
> (e.g. by some ConfigurationAdmin configuration or so), you are very welcome
> to hint at it.


Nice to see that your intention and my wish match; there is just reality
between us. I'll see whether I can invest some cycles of my day dreaming to
the configuration.

Marc

Re: Sling-Initial-Content and WebDav with custom node type

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Marc,

Marc Speck schrieb:
> 1. Is it possible to load files with <Sling-Initial-Content> into a custom
> node type? When I try it with foo.png and foo.xml (which contains the
> definitions), jcr:data is always 0.

This is definitely not good. My question: should the node be called foo 
or foo.png ? In case it should be called foo, the only solution I have 
out of my belly is to prefill the data into the repository and export it 
with system view export to re-import it through the bundle. The other 
mechanisms have IIRC no way of easily importing binary data.

Ehrm, thinking of it, there might be a way: How about naming your image 
file as foo instead of foo.png. This way the node foo would be created 
and additional settings would be taking from foo.xml.

If the node should be called foo.png, the descriptor should be foo.png.xml.

> 
> 1.1 How can I debug the loading of initial content? I install the bundle
> from Eclipse with maven autoInstallBundle but breakpoints e.g. in
> org.apache.sling.jcr.contentloader.internal.Loader.registerBundleInternal()
> are never met. Debuging servlet calls works fine.

The registerBundleInternal is called when a new bundle is installed - 
e.g. on system startup or by BundleContext.install as per an BundleEvent.

I usually run Sling from the standalone launcher with debugging enabled 
and connecting from Eclipse I can easily set a breakpoint and get landed.

> 
> 
> 2. WebDav: create custom node types
> When adding files with WebDav, I want to put the files into a customized
> node type (that inherits from nt:resource). The only way to do is, is
> writing a handler like:
> 
> public class NodeTypeHandler extends
> org.apache.jackrabbit.server.io.DefaultHandler

Yes, this is the intent of the SimpleWebDAVServlet.

> 
> and add in file webdav-resource-config.xml of bundle
> org.apache.sling.jcr.webdav something like

That is the current state. My intention is to have this configurable in 
a more flexible way, than hacking up the bundle (this is not really a 
good solution, right ;-) ).

But currently, it is unfortunately the only solution due to lack of time 
of finding a better one. If you come up with a better more flexible 
solution (e.g. by some ConfigurationAdmin configuration or so), you are 
very welcome to hint at it.

Hope this helps a bit.

Regards
Felix
> 
>     <iomanager>
>         <iohandler>
>             <class name="NodeTypeHandler" />
>         </iohandler>
> .....
>     </iomanager>
>     <propertymanager>
>         <propertyhandler>
>             <class name="NodeTypeHandler " />
>         </propertyhandler>
> .....
>     </propertymanager>
> 
> 
> or is there a easier way? I first thought of a quick hack: adding a listener
> to NODE_ADDED and add a mixin to new nodes. But this is somewhat a waste of
> resources and also does not allow to have custom node types. Converting node
> types is not possible with jackrabbit as far as I know.
> 

Re: Sling-Initial-Content and WebDav with custom node type

Posted by Marc Speck <ma...@gmail.com>.
> 1. Is it possible to load files with <Sling-Initial-Content> into a custom
>> node type? When I try it with foo.png and foo.xml (which contains the
>> definitions), jcr:data is always 0.
>>
>>  Which version of the contentloader are you using? This functionality has
> been added after the 2.0.2-incubator release.
>

I built it from trunk, revision 684703.
Marc

Re: Sling-Initial-Content and WebDav with custom node type

Posted by Carsten Ziegeler <cz...@apache.org>.
Marc Speck schrieb:
> 1. Is it possible to load files with <Sling-Initial-Content> into a custom
> node type? When I try it with foo.png and foo.xml (which contains the
> definitions), jcr:data is always 0.
> 
Which version of the contentloader are you using? This functionality has 
been added after the 2.0.2-incubator release.

Carsten

-- 
Carsten Ziegeler
cziegeler@apache.org