jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: [JCR Browser] nodetype.ConstraintViolationException: no matching property definition found for {}
Date Wed, 14 Mar 2007 08:38:42 GMT
Hi,

On 3/14/07, Lubos and Alena Pochman <pochmans@gmail.com> wrote:
> I would be also interested in that. I would not mind doing it
> programatically (if I know how 8-).
> I read JSR-170 spec and jackrabbit website but could not find it, probably
> did not look hard enough 8-).

Our documentation is currently quite lacking, so in many cases you
still need to resort to digging the list archives for the useful bits
of information. I hope we can change that sooner rather than later,
but for now you did exactly the right thing by asking the mailing
list... :-)

So, the best way to create and register new node types is to first
define them using the CND format (see
http://jackrabbit.apache.org/doc/nodetype/cnd.html) and then use the
custom JackrabbitNodeTypeManager API extension from the jackrabbit-api
library to register the new types.

In this case the new node type definition could be something like this:

    [myfile] > nt:file
    - RevisionLabel (STRING)

Once you have the CND file, you can use the JackrabbitNodeTypeManager
API extension like this to register the node type:

    import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;

    Session session = ...;
    JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
        session.getWorkspace().getNodeTypeManager();
    // only register the type if it does not yet exist
    if (!manager.hasNodeType("myfile")) {
        manager.registerNodeTypes(
            JackrabbitNodeTypeManager.TEXT_X_JCR_CND,
            <InputStream for reading your CND file>);
    }

Once you've done this, you can replace "nt:file" with "myfile" in your
original code, and the "RevisionLabel" property will no longer cause
trouble.

BR,

Jukka Zitting

Mime
View raw message