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: How to start thinking in JCR
Date Sat, 07 Apr 2007 07:57:05 GMT

On 4/3/07, Nandana Mihindukulasooriya <nandana.cse@gmail.com> wrote:
> Does all properties have to have a namespace prefix ? When I tried
> to register the node types using the CompactNodeTypeDefReader it
> gave an error caused by "UnknownPrefixException".

You can have properties in the default namespace with no namespace
prefix. Since Jackrabbit 1.0.1 there hasn't been a need to include the
default namespace prefixes in the CND file (see JCR-383), so I don't
think that's an issue with your CND file.

Check that the "blog" prefix definition is included in the CND file
you feed to Jackrabbit, and that there's no typo in the property
definition. I'm not sure if the CND you included in your message is
the one you're using since you had replaced parts with "...".

> Like Node class's hasNode() method is there convinient methods to check
> whether a namespace prefix is already registered ?

Not really. You can use the Session.getNamespacePrefix() method and
catch the exception if needed. However, since the 1.1 release
Jackrabbit has automatically registered the namespaces included in the
CND files given for registration, so you shouldn't need to worry about
that. See JCR-349 for the details.

> and to check whether a Node Type is already registed ? I didn't find such
> methods in NodeTypeManager or NamespaceRegistry Interfaces of JCR.
> I used the NodeTypeManagerImpl which inplements the
> JackrabbitNodeTypeManager Interface.

In the 1.1 release we added the
JackrabbitNodeTypeManager.hasNodeType() utility method designed for
just this purpose. See JCR-521 for the details.

> But in the mailing list
> // only register the type if it does not yet exist
>     if (!manager.hasNodeType("myfile"))
> is used to check this. Is that method not available in Jackrabbit 1.0 ?

No, only in Jackrabbit 1.1 and higher. I suggest that you use the
latest Jackrabbit release in your work.

> To create a the repository I used the TransientRepository class which
> created me a default repository configuration file. But if I am using JNDI binding
> do I have to create a repository.xml by my self ? Is there a way to specify
> to create a default configuration ?

It depends on how you do the JNDI binding. For example if you follow
the deployment model 2 instructions for Tomcat
(http://jackrabbit.apache.org/doc/deploy/howto-model2.html), you need
to specify the path to the repository.xml configuration file. You can
use the default one created by TransientRepository.

> Where can I find contrib/compact-nt tools ?

The code in the compact-nt contrib project was moved to
org.apache.jackrabbit.core.nodetype.compact within the jackrabbit-core
component. Nowadays you shouldn't need to access the functionality
directly, instead use the JackrabbitNodeTypeManager extension

> [blog:user] > mix:referenceable
> - blog:nickname  (string) mandatory
> - blog:email  (string) mandatory
> - blog:password (string) mandatory
> + blog:library (nt:folder) =nt:folder mandatory autocreated
> + blog:blogSpace (nt:folder) =nt:folder mandatory autocreated

You'll want to make blog:user extend nt:hierarchyNode to make it
possible to create blog:user nodes within nt:folder.

Also, there's a chance to drop the explicit blog:library and
blog:blogSpace child node definitions if you make blog:user extend
nt:folder. Then you could simply have "library" and "blog" subfolders
within the user node, or even avoid those subfolders entirely and rely
on node types to detect which child nodes are blog entries and which
are other resources. It's a tradeoff between flexibility and more
completely specifying the content structure.

I would actually suggest we take this opportunity for extra
flexibility since it gives some very nice late binding benefits when
we later start defining the URL mapping for the application.


Jukka Zitting

View raw message