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

Mat*_*adt 3 data-modeling alfresco

一个腐败的动态内容模型,以露天(5.0.d CE)部署和激活.

我的意思是腐败,内容模型无效,因为使用了不存在的错误类型.就像是:

<property name="my:name">
    <type>test</type>
</property>
Run Code Online (Sandbox Code Playgroud)

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

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

Repository > Data Dictionary > Models 
Run Code Online (Sandbox Code Playgroud)

然后不幸地通过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
Run Code Online (Sandbox Code Playgroud)

在启动时.

我现在的问题是如何在不访问正在运行的Alfresco存储库实例的情况下再次停用此损坏的模型,这无法再访问数据字典>模型文件夹.

我已经尝试将具有相同型号名称的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>
Run Code Online (Sandbox Code Playgroud)

小智 6

部署到数据字典的任何模型都作为原始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
Run Code Online (Sandbox Code Playgroud)

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