【问题标题】:JCR node type nt:file is not allowed as child's node type for parent node typeJCR 节点类型 nt:file 不允许作为父节点类型的子节点类型
【发布时间】:2013-07-23 00:08:35
【问题描述】:

我在 exoplatform 配置文件实体中添加了一个“soc:music”(nt:file)子节点(与原始“soc:avatar”节点相同),但在存储到 JCR 时失败。我用谷歌搜索错误,似乎很少提及它。你知道如何解决吗?谢谢。奇怪的是原来的“soc:avatar”节点运行良好。

<nodeType name="soc:profiledefinition" isMixin="false" hasOrderableChildNodes="false">
...
  <childNodeDefinition name="soc:avatar" defaultPrimaryType="nt:file" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
    <requiredPrimaryTypes>
      <requiredPrimaryType>nt:file</requiredPrimaryType>
    </requiredPrimaryTypes>
  </childNodeDefinition>

..
  <childNodeDefinition name="soc:music" defaultPrimaryType="nt:file" autoCreated="false" mandatory="false" onParentVersion="COPY" protected="false" sameNameSiblings="false">
    <requiredPrimaryTypes>
      <requiredPrimaryType>nt:file</requiredPrimaryType>
    </requiredPrimaryTypes>
  </childNodeDefinition>
</childNodeDefinitions>

-----错误信息--

2013-07-23 10:58:27,401 | ERROR | Error during the processAction phase [portal:UIPortalApplication<http-nio-0.0.0.0-8080-exec-1>]
org.chromattic.api.UndeclaredRepositoryException: javax.jcr.nodetype.ConstraintViolationException: Can't add node soc:music to /production/soc:provid
rs/soc:organization/soc:test1/soc:profile node type nt:file is not allowed as child's node type for parent node type
        at org.chromattic.core.DomainSession.persist(DomainSession.java:470) ~[chromattic.core-1.2.1.jar:na]
        at org.chromattic.core.ObjectContext.addChild(ObjectContext.java:236) ~[chromattic.core-1.2.1.jar:na]
        at org.chromattic.core.mapper.onetoone.hierarchical.JCRNamedChildParentPropertyMapper.set(JCRNamedChildParentPropertyMapper.java:90) ~[chroma
tic.core-1.2.1.jar:na]
        at org.chromattic.core.mapper.PropertyMapper$2.invoke(PropertyMapper.java:88) ~[chromattic.core-1.2.1.jar:na]
        at org.chromattic.core.ObjectContext.invoke(ObjectContext.java:74) ~[chromattic.core-1.2.1.jar:na]
        at org.exoplatform.social.core.chromattic.entity.ProfileEntity_Chromattic.setMusic(ProfileEntity_Chromattic.java:102) ~[social-component-core
4.0.0-SNAPSHOT.jar:4.0.0-SNAPSHOT]
        at org.exoplatform.social.core.storage.impl.IdentityStorageImpl._saveProfile(IdentityStorageImpl.java:621) ~[social-component-core-4.0.0-SNAP
HOT.jar:4.0.0-SNAPSHOT]

【问题讨论】:

    标签: file profile jcr nt


    【解决方案1】:

    像这样更改节点类型定义时要小心,它可能会影响系统中现有的数据。您必须考虑此修改的“迁移”。 我们使用的是 Chromattic,因此节点类型的定义必须映射到 java 类。您已经更改了 soc:profiledefinition,因此您还必须在 ProfileEntity.java 中添加 soc:music 定义(在包 org.exoplatform.social.core.chromattic。实体)。

    希望对你有帮助, 明赫

    【讨论】:

    • 谢谢。实际上,我已经在 ProfileEntity.java 中添加了 soc:music 定义,但仍然无法通过验证。所以暂时,我硬编码不验证代码中的新子节点 soc:music。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-03-20
    • 1970-01-01
    • 2016-10-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多