【问题标题】:Filnet API Copy FileFilnet API 复制文件
【发布时间】:2019-02-28 11:18:00
【问题描述】:

我需要使用 API 在 filenet 上复制文件并更新现有文件的属性,在使用 进行搜索后,我制作了以下示例,但出现错误

row = (RepositoryRow) it.next();
            Id id = row.getProperties().get("Id").getIdValue();
            Document document = Factory.Document.fetchInstance(os, id, null);

            System.out.println("current document is : "+document.get_Name());

            Document docCopy = (Document)Factory.Document.fetchInstance(os, id, null); 

            Properties prop = docCopy.getProperties();
                prop.putValue("PT_DocumentNumber", newDocNo);

            docCopy.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
            docCopy.save(RefreshMode.NO_REFRESH);

            // file into folder
            folder = Factory.Folder.getInstance(os, ClassNames.FOLDER, new Id("myFOlder"));
            ReferentialContainmentRelationship rcr = folder.file(docCopy, AutoUniqueName.AUTO_UNIQUE, "New Document via Webservice", DefineSecurityParentage.DO_NOT_DEFINE_SECURITY_PARENTAGE);
            rcr.save(RefreshMode.NO_REFRESH);

我得到的错误如下

[2/28/19 12:31:58:721 AST] 000000bc SystemErr     R com.filenet.api.exception.EngineRuntimeException: FNRCE0042E: E_NOT_SUPPORTED: This method is not supported in the context of this session or object. Checkin must be performed on a reservation object. failedBatchItem=0 errorStack={
at com.filenet.engine.persist.VersionablePersister.validateCheckin(VersionablePersister.java:558)
at 

【问题讨论】:

  • 这是您想要实现的目标。文档的新版本或新版本系列中的实际副本。当前代码只获取文档两次。签入将失败,因为该文档未签出,因此它会给出错误,因为您只能对预订进行签入。

标签: java filenet-p8 filenet-content-engine


【解决方案1】:

简单地说,你所做的就是获取ID

Id id = row.getProperties().get("Id").getIdValue();

然后你得到源文件

Document document = Factory.Document.fetchInstance(os, id, null);

然后你会得到相同的源文档,只是引用变量不同

Document docCopy = (Document)Factory.Document.fetchInstance(os, id, null); 

两者是同一份文件,这里没有复制!因此,当您尝试使用以下方式签入文档时:

docCopy.checkin(AutoClassify.DO_NOT_AUTO_CLASSIFY, CheckinType.MAJOR_VERSION);
docCopy.save(RefreshMode.NO_REFRESH);

引擎抛出一个错误,因为文档一开始就没有被签出(因此没有捕获任何保留对象来进行更改)。

Checkin must be performed on a reservation object.

【讨论】:

    猜你喜欢
    • 2015-03-25
    • 2016-08-04
    • 2012-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-12-19
    相关资源
    最近更新 更多