Alfresco:如何用自举模型覆盖(损坏的)动态内容模型?

标签 alfresco data-modeling

已部署并激活损坏的动态内容模型Alfresco (5.0.d CE)。

我所说的损坏是指内容模型无效,因为使用了不存在的错误类型。像这样的东西:

<property name="my:name">
    <type>test</type>
</property>

“测试”显然无效 - 但模型中的错误在这里并不重要。

因此,这个内容模型被动态部署到

Repository > Data Dictionary > Models 

然后不幸地通过 Alfresco API 调用激活(而不是通过 Share UI;因为 Share UI 通常在实际允许激活之前检查模型是否有效)。

这会导致 Alfresco 存储库不再启动但失败并显示错误:

2016-01-19 18:17:11,780 ERROR [org.springframework.web.context.ContextLoader] [localhost-startStop-1] Context initialization failed
org.alfresco.service.namespace.NamespaceException: A namespace prefix is not registered for uri my.test.model

启动时。

我现在的问题是如何在无法访问正在运行的 Alfresco 存储库实例的情况下再次停用这个损坏的模型,这将无法再访问 Data Dictionary > Models 文件夹。

我已经尝试将具有相同模型名称的 customModel.xml 和 custom-model-context.xml 等部署到/alfresco/tomcat/shared/classes/alfresco/extension 文件夹中,但这似乎并没有覆盖动态模型。 启动 Alfresco 时,仍然出现上述错误。

有什么想法吗?谢谢!

仅供引用,这是我用来覆盖旧文件的更正后的虚拟 customModel.xml 文件,它只是与损坏的文件具有相同的模型名称:

<?xml version="1.0" encoding="UTF-8"?>

<!-- Custom Model -->

<!-- Note: This model is pre-configured to load at startup of the Repository.  So, all custom -->
<!--       types and aspects added here will automatically be registered -->

<model name="my:testModel" xmlns="http://www.alfresco.org/model/dictionary/1.0">

   <!-- Optional meta-data about the model -->
   <description>Custom Model</description>
   <author></author>
   <version>1.0</version>

   <imports>
      <!-- Import Alfresco Dictionary Definitions -->
      <import uri="http://www.alfresco.org/model/dictionary/1.0" prefix="d"/>
      <!-- Import Alfresco Content Domain Model Definitions -->
      <import uri="http://www.alfresco.org/model/content/1.0" prefix="cm"/>
   </imports>

   <!-- Introduction of new namespaces defined by this model -->
   <!-- NOTE: The following namespace custom.model should be changed to reflect your own namespace -->
   <namespaces>
      <namespace uri="my.test.model" prefix="my"/>
   </namespaces>

</model>

最佳答案

任何部署到数据字典的模型都作为原始 XML 文件存储在内容存储中。在这种情况下,最简单的解决方案是找到该 XML 文件并使用您列出的更正模型更新其内容。 通过对 alf_node、alf_qname、alf_node_properties、alf_content_data 和 alf_content_url 表执行数据库查询,您应该能够轻松识别任何模型文件,即执行这样的查询

select alf_content_url.content_url
from alf_node
    left join alf_qname on alf_node.type_qname_id = alf_qname.id
    left join alf_node_properties on alf_node_properties.node_id = alf_node.id
    join alf_content_data on alf_content_data.id = alf_node_properties.long_value
    left join alf_content_url on alf_content_url.id = alf_content_data.content_url_id
where
    alf_qname.local_name = 'dictionaryModel'
    and alf_content_url.content_url is not null

模型更正后,重新启动应该可以正常工作,因为只有 QName 实际上存储在数据库中,但其他所有内容总是从 XML 文件(类路径或内容存储)重新加载。

关于Alfresco:如何用自举模型覆盖(损坏的)动态内容模型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34883278/

相关文章:

alfresco - 如何禁用露天缩略图生成

alfresco - 如何在 Alfresco 中执行并行 CMIS 请求?

mysql - AlFresco 手动设置

sql - 启用/禁用/删除数据库行及其引用的最佳实践?

java - ephesoft 中不存在 webscanner.nocache.js

alfresco - 创建站点时如何在 Alfresco Share 中创建多个文件夹?

sql - Postgres : one table with many columns or several tables with fewer columns?

nhibernate - 数据库建模或数据库设计: Which comes first?

sql - 如何从表 A 中引用表 B 行两次?

swift - SQL 的核心数据建模