You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@sling.apache.org by Buzzterrier <tj...@blueorigin.com> on 2014/01/08 22:21:39 UTC

Mixin questions

Still getting my feet wet with Sling and jcr. We would like to add some
metadata to the a node of nt:file type. It looks like mixins are the way to
go, but I am having trouble figuring them out. It looks like you create them
in a .cnd file. But where do you put the file? It would be slick to just
drop it somewhere in the sling OSGi structure and have it pick it up on
startup.  Is that possible? Otherwise do I put in the the
"bundles/jcr/resource/src/main/resources/SLING-INF/nodetype" directory and
rebuild the project?

Also I am a bit confused on what is the best way to create a mixin that
extends nt:file.  One example I read has you just do the following:

[acme:taggable] mixin
- acme:tags (STRING) multiple


But I do not see how that gets mixed in the nt:file definition.

Rather would you do something like this?

[acme:taggable] > nt:file mixin
- acme:tags (STRING) multiple

Also, is there anything special I should know about using mixins with rest
calls? All of the examples add content with Mixins using the sling api.

Thx.



--
View this message in context: http://apache-sling.73963.n3.nabble.com/Mixin-questions-tp4030123.html
Sent from the Sling - Users mailing list archive at Nabble.com.

Re: Mixin questions

Posted by Bertrand Delacretaz <bd...@apache.org>.
Hi,

On Wed, Jan 8, 2014 at 10:21 PM, Buzzterrier <tj...@blueorigin.com> wrote:
> ...It looks like mixins are the way to
> go, but I am having trouble figuring them out. It looks like you create them
> in a .cnd file. But where do you put the file? It would be slick to just
> drop it somewhere in the sling OSGi structure and have it pick it up on
> startup.  Is that possible?...

Yes, if you actually need custom mixins (which is a a different
question) you can supply the cnd files in bundles and have them picked
up by Sling when your bundles starts, as part of Sling's content
loading mechanism.

See http://sling.apache.org/documentation/bundles/content-loading-jcr-contentloader.html
for docs, search for "Sling-Nodetypes" there.

There's a number of examples in the Sling codebase, in
bundles/jcr/resource for example.

> ...Also I am a bit confused on what is the best way to create a mixin that
> extends nt:file...

If you want to add arbitrary properties to an nt:file your mixin
doesn't need to extend it, it can just define the additional
properties that you want to allow.

There's a good explanation at
http://stackoverflow.com/questions/5155764/store-metadata-into-jackrabbit-repository
with an example mixin (custom:extensible) that allows setting any
property on the nt:file. There's also a number of default mixins like
mix:title which you can use for common things, see
http://www.day.com/maven/jsr170/javadocs/jcr-2.0/javax/jcr/nodetype/package-summary.html

> ...Also, is there anything special I should know about using mixins with rest
> calls? All of the examples add content with Mixins using the sling api...

It's no different in http calls, the post servlet docs at
http://sling.apache.org/documentation/bundles/manipulating-content-the-slingpostservlet-servlets-post.html
have some info about using mixins.

HTH,
-Bertrand