Page 2 of 2 FirstFirst 12
Results 11 to 20 of 20

Thread: JackRabbit and namespaces

  1. #11
    Join Date
    Jul 2006
    Location
    Belgium
    Posts
    33

    Default JR & Namespaces

    Costin,
    I had also posted the question to the JR mailing list. Thi sis the reply I got there, from Tobias (tobias.bocanegra@day.com)
    __________
    "Namespaces are fully supported by jackrabbit since 1.0. and the
    registration works exactly as specified in jsr170 (which is a bit
    troublesome).

    in your application you probably have a 'getRepositorySession' call,
    and there i would setup/check the namespaces for your application, eg:

    1. check if your namespace is already registered
    2. if not, do so.
    3. setup the namespace mapping for your session and application.

    example:

    try {
    s.getNamespaceURI("http://your.com/ns/1");
    } catch (RepositoryException e) {
    // register namespace
    s.getWorkspace().getNamespaceRegistry().registerNa mespace(
    "myapp", "http://your.com/ns/1");
    }
    s.setNamespacePrefix("myapp", "http://your.com/ns/1");
    [....]
    s.getRootNode().getNode("myapp:someNode");
    "
    _____________
    It seems a bit inefficient having to check this at every getSession() call; it seems to make more sense having a kinda Session init() method - which leads me to my earlier conclusion; SessionFactory seems to be the best place to do this.
    Hope it helps,
    Wolf

  2. #12
    Join Date
    Jul 2006
    Location
    Belgium
    Posts
    33

    Default JIRA issue created

    Ref: MOD-303

    Wolf

  3. #13
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    I don't want to argue with the Day guys since they are the main authors behind JR but remapping an unregistration of the namespaces is not supported. Here is a snippet from Jackrabbit 1.2.2 (org.apache.jackrabbit.core.NamespaceRegistryImpl) :

    Code:
    /**
         * {@inheritDoc}
         */
        public void unregisterNamespace(String prefix)
                throws NamespaceException, UnsupportedRepositoryOperationException,
                AccessDeniedException, RepositoryException {
    ...
            /**
             * as we can't guarantee that there are no references to the specified
             * namespace (in names of nodes/properties/node types etc.) we simply
             * don't allow it.
             */
            throw new NamespaceException("unregistering namespaces is not supported.");

    The same goes for remapping:
    Code:
     public void registerNamespace(String prefix, String uri) {
    ...
    
         if (prefixToURI.containsKey(prefix)) {
                /**
                 * prevent remapping of existing prefixes because this would in effect
                 * remove the previously assigned namespace;
                 * as we can't guarantee that there are no references to this namespace
                 * (in names of nodes/properties/node types etc.) we simply don't allow it.
                 */
                throw new NamespaceException("failed to register namespace "
                        + prefix + " -> " + uri
                        + ": remapping existing prefixes is not supported.");
            }
    Maybe I'm missing something but the registration should be done through the Namespace registry which, as pointed about throws exceptions.

    I'll take a look at the email but my understanding is that new registrations are allowed but modifications/removal of existing namespaces is forbidden.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  4. #14
    Join Date
    Jul 2006
    Location
    Belgium
    Posts
    33

    Default Re: JC tampers with JSR-170 spec?

    Hi Costin,
    I posted yoru finding to the JC list (rest assured, to spare you the FUD, I stripped yr name :-)
    I will post their feedback back here.

    Wolf

  5. #15
    Join Date
    Jun 2007
    Posts
    4

    Default any resolution

    Has there been any resolution to this issue or do I have to implement my own JackrabbitSessionFactory? It seems like an important issue to resolve. Ideally I would either like to have a parameter that specifies to re-register the node types or a way to just ignore the namespace if it already exists. Anybody have any suggestions or fixes to this issue? I just want to be able to have the nodetypes registered at startup through spring w/o throwing an exception if the namespace already exists. Any help is appreciated.

  6. #16
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    MOD-303 has been resolved - see JIRA. Have you tried using the latest version of Spring Modules?
    If you still encounter problems, please raise an issue on JIRA.
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

  7. #17
    Join Date
    Jun 2007
    Posts
    4

    Default

    Thanks for the quick reply. I do have the latest 0.8 version of springmodules. I have also taken a look at the source code. From what i've seen, it looks like the JackrabbitSessionFactory calls nodeTypeManager.registerNodeTypes(resource.getInpu tStream(), contentType); on line 67. This apparently calls the jackrabbit NodeTypeManagerImpl class. I noticed that this class has a registerNodeTypes(InputStream, String, boolean) method where the boolean declares whether to re-register existing nodeTypes. However, it looks like the JackrabbitSessionFactory uses the registerNodeTypes(InputStream, String) method which passes boolean=false to the registerNodeTypes(InputStream, String, boolean) method which means it will not re-register the nodeTypes. Is this how you intended this to work? If I understand this correctly, i think a parameter should be added to the JackrabbitSessionFactory class to determine whether to re-register existing node types. What do you think. The error below is what I am currently getting. I am getting this error because my custom nodetypes have already been registered and are being stored in the repository folder in an xml file. I would like to ideally have it just re-register my custom types so i don't get this exception on startup.


    Caused by:
    javax.jcr.RepositoryException: Invalid node type definition: {http://www.bmpcoe.org/jcr/cwe}content already exists: {http://www.bmpcoe.org/jcr/cwe}content already exists
    at org.apache.jackrabbit.core.nodetype.NodeTypeManage rImpl.registerNodeTypes(NodeTypeManagerImpl.java:2 97)
    at org.apache.jackrabbit.core.nodetype.NodeTypeManage rImpl.registerNodeTypes(NodeTypeManagerImpl.java:4 75)
    at org.springmodules.jcr.jackrabbit.JackrabbitSession Factory.registerNodeTypes(JackrabbitSessionFactory .java:67)
    at org.springmodules.jcr.JcrSessionFactory.afterPrope rtiesSet(JcrSessionFactory.java:126)

  8. #18
    Join Date
    Aug 2007
    Posts
    1

    Default Better solution available?

    I've the same problem:

    Here's a part of my configuration
    Code:
    		<property name="contentType">
    			<value>text/x-jcr-cnd</value>
    		</property>			
    		
    		<property name="forceNamespacesRegistration">
    			<value>true</value>
    		</property>
    		<property name="keepNewNamespaces">
    			<value>true</value>
    		</property>
    			
    		<property name="skipExistingNamespaces">
    			<value>true</value>
    		</property>
    Is there an better solution available?

    Thanks

    Peter

  9. #19
    Join Date
    Jun 2008
    Posts
    3

    Default

    Quote Originally Posted by bilobag View Post
    Thanks for the quick reply. I do have the latest 0.8 version of springmodules. I have also taken a look at the source code. From what i've seen, it looks like the JackrabbitSessionFactory calls nodeTypeManager.registerNodeTypes(resource.getInpu tStream(), contentType); on line 67. This apparently calls the jackrabbit NodeTypeManagerImpl class. I noticed that this class has a registerNodeTypes(InputStream, String, boolean) method where the boolean declares whether to re-register existing nodeTypes. However, it looks like the JackrabbitSessionFactory uses the registerNodeTypes(InputStream, String) method which passes boolean=false to the registerNodeTypes(InputStream, String, boolean) method which means it will not re-register the nodeTypes. Is this how you intended this to work? If I understand this correctly, i think a parameter should be added to the JackrabbitSessionFactory class to determine whether to re-register existing node types. What do you think. The error below is what I am currently getting. I am getting this error because my custom nodetypes have already been registered and are being stored in the repository folder in an xml file. I would like to ideally have it just re-register my custom types so i don't get this exception on startup.


    Caused by:
    javax.jcr.RepositoryException: Invalid node type definition:
    I'm having the same issue and I came to the same conclusion. Has there been any progress on this? Did you find another way perhaps?

  10. #20
    Join Date
    Jan 2005
    Location
    Bucharest, Romania
    Posts
    5,403

    Default

    Could you please raise an issue ?

    Thanks,
    Costin Leau
    SpringSource - http://www.SpringSource.com- Spring Training, Consulting, and Support - "From the Source"
    http://twitter.com/costinl
    Please use [ c o d e ] [ / c o d e ] tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •