【发布时间】:2019-04-12 06:11:03
【问题描述】:
我是 FileNet 的新手。我们正在使用 P8 内容引擎 - 5.1.0.2 我需要使用 Filenet WCM API 更改现有文档的 MimeType。 Workuround 是下载文档,更改 MimeType 并重新上传文档,但在这种情况下,documnet Id 将更改。我更喜欢更新现有文档而不是重新上传文档。
基本上,我需要通过 Filenet WCM API 以编程方式执行 Changing the content element MIME type 中描述的相同操作。
代码是
public boolean changeDocumnetMimeType(String documentId, String docMimeType) throws IOException {
com.filenet.wcm.api.TransportInputStream in1 = null;
com.filenet.wcm.api.ObjectStore docObjectStore;
com.filenet.wcm.api.Session session;
try {
session = ObjectFactory.getSession(this.applicationId, null, this.user,this.password);
session.setRemoteServerUrl(this.remoteServerUrl);
session.setRemoteServerUploadUrl(this.remoteServerUploadUrl);
session.setRemoteServerDownloadUrl(this.remoteServerDownloadUrl);
docObjectStore = ObjectFactory.getObjectStore(this.objectStoreName, session);
Document doc = (Document) docObjectStore.getObject(BaseObject.TYPE_DOCUMENT, documentId);
in1 = doc.getContent();
System.out.println("documnet MIME type is : " + in1.getMimeType());
//how to Update mimeType for the document???
} catch (Exception ex) {
ex.printStackTrace();
}
if (in1 != null) {
in1.close();
}
return true;
}
提前谢谢你。
【问题讨论】:
-
您所要求的无法完成。文档对象无法更新 contentElements,除非它们是保留的。 MimeType(称为 ContentType)是 ContentTransfer 对象的一个属性。 ContentTransfer 对象保存在 ContentElementList 中。
-
@Christopher Powell 不确定我是否理解您的评论。它不能使用 Document 对象完成还是不能通过 WCM API 完成?该代码只是我尝试为该任务实现的测试示例。
-
无论您使用哪个 API,FileNet 系统都不会让 Document Object(或 Document 的子类)更改已签入的内容。这是(FileNet)文档类的一个约束。然而,注释类将允许在没有保留的情况下更改内容。 FileNet 的结构很像 OOP 语言。您基于文档类创建文档对象。
-
@ChristopherPowell 所以,唯一的选择是创建具有相同内容和新 MimeType 的新文档网并删除旧文档网?谢谢
-
是的。您需要新的预订,因此您需要签出,将内容替换为不同的 MimeType,然后签入。
标签: mime-types filenet-p8 filenet-content-engine