jackrabbit session.importXML()不尊重uuid

时间:2015-01-08 11:52:30

标签: jackrabbit jcr

我一直在尝试使用

将xml数据导入JCR
session.importXML("/", resource, ImportUUIDBehavior.IMPORT_UUID_COLLISION_THROW); 

第一次它工作正常,但是当我再次导入相同的数据时,即使xml中的uid相同,它也不会抛出异常。它只是将记录添加到数据库中。这意味着我的记录每次导入时都会不断添加到数据库中

如果我在同一个会话中导入xml两次,则抛出异常。如果我在不同的会话中导入xml,它不会抛出异常。我对jackrabbit代码做了一些调试。在从xml jackrabbit导入数据时,它会遍历每条记录,如果它有唯一的id,那么它会尝试查找记录是否已经存在,显然即使它存在也找不到。如果记录已在同一会话中导入,则会找到它。

这是我的XML。

<?xml version="1.0" encoding="UTF-8"?>
<sv:node xmlns:jcr="http://www.jcp.org/jcr/1.0"
     xmlns:pb="http://pb.com/pb/hubble/projects/1.0/"
     xmlns:sv="http://www.jcp.org/jcr/sv/1.0"
     sv:name="Viewpoint">
<sv:property sv:name="jcr:primaryType" sv:type="Name">
    <sv:value>pb:component</sv:value>
</sv:property>
<sv:property sv:name="jcr:uuid" sv:type="String">
    <sv:value>cbd43fb6-3530-11e4-8920-164230d1df67</sv:value>
</sv:property>
<sv:property sv:name="className" sv:type="String">
    <sv:value>com.pb.viewpoint.common.model.Component</sv:value>
</sv:property>
<sv:property sv:name="jcr:title" sv:type="String">
    <sv:value>Viewpoint</sv:value>
</sv:property>
<sv:property sv:name="pb:licensed" sv:type="Boolean">
    <sv:value>true</sv:value>
</sv:property>
<sv:node sv:name="pb:roles" jcr:primaryType="pb:role">
    <sv:node sv:name="Community Administrator">
        <sv:property sv:name="jcr:primaryType" sv:type="Name">
            <sv:value>pb:role</sv:value>
        </sv:property>
        <sv:property sv:name="jcr:uuid" sv:type="String">
            <sv:value>cbd441d2-3530-11e4-8920-164230d1df67</sv:value>
        </sv:property>
        <sv:property sv:name="className" sv:type="String">
            <sv:value>com.pb.viewpoint.common.model.Role</sv:value>
        </sv:property>
        <sv:property sv:name="jcr:title" sv:type="String">
            <sv:value>Community Administrator</sv:value>
        </sv:property>
        <sv:property sv:name="pb:nameDisplayKey" sv:type="String">
            <sv:value>roleNameKey.CommunityAdministrator</sv:value>
        </sv:property>
        <sv:property sv:name="pb:categoryDisplayKey" sv:type="String">
            <sv:value>categoryKey.Administrative</sv:value>
        </sv:property>
        <sv:property sv:name="pb:category" sv:type="String">
            <sv:value>Administrative</sv:value>
        </sv:property>
        <sv:property sv:name="pb:type" sv:type="String">
            <sv:value>ADMINISTRATOR</sv:value>
        </sv:property>
        <sv:node sv:name="pb:entitlements" jcr:primaryType="pb:entitlement">
            <sv:node sv:name="VIEWPOINT_LIST_ROLE_MAPPINGS">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>cbd44308-3530-11e4-8920-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_LIST_ROLE_MAPPINGS</sv:value>
                </sv:property>
            </sv:node>
            <sv:node sv:name="VIEWPOINT_UPDATE_ROLE_MAPPINGS">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>cbd44434-3530-11e4-8920-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_UPDATE_ROLE_MAPPINGS</sv:value>
                </sv:property>
            </sv:node>
            <sv:node sv:name="VIEWPOINT_LIST_COMMUNITIES">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>85438386-343b-11e4-99ba-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_LIST_COMMUNITIES</sv:value>
                </sv:property>
            </sv:node>
            <sv:node sv:name="VIEWPOINT_UPDATE_COMMUNITIES">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>854385fc-343b-11e4-99ba-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_UPDATE_COMMUNITIES</sv:value>
                </sv:property>
            </sv:node>
            <sv:node sv:name="VIEWPOINT_VIEW_COMMUNITY_TO_VAULT_DATABASE_MAPPINGS">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>cbd4465a-3530-11e4-8920-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_VIEW_COMMUNITY_TO_VAULT_DATABASE_MAPPINGS</sv:value>
                </sv:property>
            </sv:node>
            <sv:node sv:name="VIEWPOINT_EDIT_COMMUNITY_TO_VAULT_DATABASE_MAPPINGS">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>cbd4484e-3530-11e4-8920-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_EDIT_COMMUNITY_TO_VAULT_DATABASE_MAPPINGS</sv:value>
                </sv:property>
            </sv:node>
            <sv:node sv:name="VIEWPOINT_VIEW_ENGAGEONE_SERVER">
                <sv:property sv:name="jcr:primaryType" sv:type="Name">
                    <sv:value>pb:entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:uuid" sv:type="String">
                    <sv:value>8543873c-343b-11e4-99ba-164230d1df67</sv:value>
                </sv:property>
                <sv:property sv:name="className" sv:type="String">
                    <sv:value>com.pb.viewpoint.common.model.Entitlement</sv:value>
                </sv:property>
                <sv:property sv:name="jcr:title" sv:type="String">
                    <sv:value>VIEWPOINT_VIEW_ENGAGEONE_SERVER</sv:value>
                </sv:property>
            </sv:node>
        </sv:node>
    </sv:node>
</sv:node>

这种奇怪的行为是否有任何原因,我做错了什么?

1 个答案:

答案 0 :(得分:0)

有人说我在数据库支持的Jackrabbit中没有看到这种行为。

我只观察过InMemory Jackrabbit中阻止我写测试的行为