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

Alfresco: how to override a (corrupt) dynamic content model with a bootstrapped one?

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

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

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

其中 "test" 显然无效 - 但模型中的错误在这里并不重要。

因此,此内容模型已动态部署到

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 文件夹。

我已经尝试在 /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>

我现在的解决方案是删除 /alf_data/contentstore/ 的部分内容(我大致知道模型是什么时候部署的)。因为它都是 .bin 格式,所以我不确定我还删除了哪些其他文件,但不是太多 ;-) 之后,Alfresco至少又要开始了。

任何部署到数据字典的模型都作为原始 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 存储在数据库中,但其他所有内容始终 re-loaded 来自 XML 文件(类路径或内容存储)。

我认为您可以执行 grep 来搜索文件系统中的文件。现在太晚了...