jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Serge Huber (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-2793) Typo in NodeTypeRegistry
Date Thu, 21 Oct 2010 11:51:17 GMT

    [ https://issues.apache.org/jira/browse/JCR-2793?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12923414#action_12923414
] 

Serge Huber commented on JCR-2793:
----------------------------------

Thanks for your answer Jukka,

Actually, in my mail on the list ( http://markmail.org/thread/l3rrvrasnweb4bsn ), I mentioned
that it might have been caused by the removal of the BasedFileSystem around the NodeTypeRegistry
instance, which was removed for some reason in the RepositoryImpl. 

So the old code in 2.1.1 looked like this : 

RepositoryImpl constructor : 
...
            // create registries
            nsReg = createNamespaceRegistry(new BasedFileSystem(repStore, "/namespaces"));
            ntReg = createNodeTypeRegistry(nsReg, new BasedFileSystem(repStore, "/nodetypes"));
...

Possibly because we moved this into the constructor for example of the NamespaceRegistryImpl
we now have the following : 

RepositoryImpl : 

            // create registries
            context.setNamespaceRegistry(createNamespaceRegistry());
            context.setNodeTypeRegistry(createNodeTypeRegistry());

...
    protected NamespaceRegistryImpl createNamespaceRegistry()
            throws RepositoryException {
        return new NamespaceRegistryImpl(context.getFileSystem());
    }
...
    protected NodeTypeRegistry createNodeTypeRegistry()
            throws RepositoryException {
        return new NodeTypeRegistry(
                context.getNamespaceRegistry(), context.getFileSystem());
    }


In NamespaceRegistryImpl : 

    public NamespaceRegistryImpl(FileSystem fs) throws RepositoryException {
        this.nsRegStore = new BasedFileSystem(fs, "/namespaces");
        load();
    }

And for NodeTypeRegistry : 

    private static final String CUSTOM_NODETYPES_RESOURCE_NAME =
            "nodetypes/custom_nodetypes.xml";

    @SuppressWarnings("unchecked")
    public NodeTypeRegistry(NamespaceRegistry nsReg, FileSystem fs)
            throws RepositoryException {
        this.nsReg = nsReg;
        customNodeTypesResource =
            new FileSystemResource(fs, CUSTOM_NODETYPES_RESOURCE_NAME);

So in comparing the two I assumed that if we removed the BasedFileSystem for a reason, we
might need the "/" back at the beginning of the constant. Because the code right after that
in the NodeTypeRegistry is : 


        try {
            // make sure path to resource exists
            if (!customNodeTypesResource.exists()) {
                customNodeTypesResource.makeParentDirs();
            }
        } catch (FileSystemException fse) {
            String error = "internal error: invalid resource: "
                    + customNodeTypesResource.getPath();
            log.debug(error);
            throw new RepositoryException(error, fse);
        }

which fails because of the exists() clause which calls the following in DatabaseFileSystem
: 


    /**
     * {@inheritDoc}
     */
    public boolean exists(String path) throws FileSystemException {
        if (!initialized) {
            throw new IllegalStateException("not initialized");
        }

        FileSystemPathUtil.checkFormat(path);

        String parentDir = FileSystemPathUtil.getParentDir(path);
        String name = FileSystemPathUtil.getName(path);

The failure is in the checkFormat call that checks if the path starts with a "/". This code
hasn't changed since 2.1.1, so I was assuming it wasn't the source of the problem, but maybe
it needs to change ?

Again, I am not very familiar with the codebase yet, so I didn't know what the best solution
was, I was just basing my analysis on what had been modified.

> Typo in NodeTypeRegistry
> ------------------------
>
>                 Key: JCR-2793
>                 URL: https://issues.apache.org/jira/browse/JCR-2793
>             Project: Jackrabbit Content Repository
>          Issue Type: Bug
>          Components: jackrabbit-core
>    Affects Versions: 2.2.0
>            Reporter: Serge Huber
>             Fix For: 2.2.0
>
>         Attachments: Fix_typo_on_custom_node_types_constant.patch
>
>   Original Estimate: 0.17h
>  Remaining Estimate: 0.17h
>
> It seems a little typo has been introduced in the NodeTypeRegistry, as illustrated in
this stack trace : 
> Caused by: javax.jcr.RepositoryException: internal error: invalid resource: nodetypes/custom_nodetypes.xml
> 	at org.apache.jackrabbit.core.nodetype.NodeTypeRegistry.<init>(NodeTypeRegistry.java:703)
~[jackrabbit-core-2.2-SNAPSHOT.jar:2.2-SNAPSHOT]
> 	at org.apache.jackrabbit.core.RepositoryImpl.createNodeTypeRegistry(RepositoryImpl.java:422)
~[jackrabbit-core-2.2-SNAPSHOT.jar:na]
> 	at org.apache.jackrabbit.core.RepositoryImpl.<init>(RepositoryImpl.java:294) ~[jackrabbit-core-2.2-SNAPSHOT.jar:na]
> This happens when using a DbFileSystem for the root filesystem. This didn't cause a problem
in 2.1.1
> The patch attached to this ticket correct the issue.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message