【问题标题】:Upload a newer version of document from within Alfresco repository从 Alfresco 存储库中上传较新版本的文档
【发布时间】:2022-02-11 17:36:41
【问题描述】:

我在 Alfresco 存储库中有两个文档(a.pdf 和 b.pdf)。我想申请/上传 b.pdf 作为新版本的 a.pdf。有什么方法可以使用 Javascript 或 java 代码来做到这一点?

谢谢

【问题讨论】:

    标签: alfresco alfresco-enterprise


    【解决方案1】:

    创建文档,使其可版本化,修改它 创建一个文档,使其可版本化,签出,修改工作副本的内容,再次签入,然后重复该过程,但签入带有版本历史记录并作为主要版本增量的文档:

    // create file, make it versionable
    var doc = userhome.createFile('checkmeout.txt');
    doc.addAspect('cm:versionable');
    doc.content = 'original text';
    
    // check it out and update content on the working copy
    var workingCopy = doc.checkout();
    workingCopy.content = 'updated text 1';
    
    // check it in
    doc = workingCopy.checkin();
    
    // check it out again
    workingCopy = doc.checkout();
    workingCopy.content = 'updated text 2';
    
    // check it in again, but with a version history note and as major version increment
    doc = workingCopy.checkin('a history note', true);
    

    您可以参考下面的 javascript api 链接 https://hub.alfresco.com/t5/alfresco-content-services-hub/javascript-api-cookbook/ba-p/293260

    【讨论】:

      【解决方案2】:

      有一个version service bean 可用于将版本控制应用于可在自定义bean 中使用的文档(节点)。不要忘记在你的 service-context.xml 中注入 versionService <property name="versionService" ref="VersionService"/>

      如果我没记错的话,您可能必须在相关节点上启用版本化方面(cm:versionable)。如果这已经启用,那么还可以查看节点的 VersionHistory。

      创建第二个版本并复制节点 2 的内容。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-24
        • 2018-03-11
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多