【问题标题】:Whats the correct and efficient way to delete a versioned document in Filenet P8 4.5 or higher?在 Filenet P8 4.5 或更高版本中删除版本化文档的正确有效方法是什么?
【发布时间】:2015-03-20 12:34:33
【问题描述】:
我想删除在当前版本中设置了特定属性的文档。如果已设置此属性,则需要删除该文档的所有版本。
我当前搜索IsCurrentVersion = TRUE and foo = 'bar' 的实现有一个问题,即只有当前版本被删除,而不是旧版本。所以我假设我需要删除完整的 VersionSeries ?
直到现在我使用
doc.delete();
doc.save(RefreshMode.NO_REFRESH);
对于我找到的每个文档。如何从系列中检索所有文档并将它们也删除?如果我将它添加到批处理中会更有效吗?
【问题讨论】:
标签:
java
filenet-p8
filenet
filenet-content-engine
【解决方案2】:
从 FileNet 中删除文档所有版本的方法
public void deleteDocumentFromCE(String filenetDocGUID) throws Exception
{
System.out.println("In deleteDocumentFromCE() method");
System.out.println("Input Parameter filenetDocGUID is : " + filenetDocGUID);
Document document = null;
UserContext uc = null;
ObjectStore os = null;
Subject subject = null;
VersionSeries vs = null;
try
{
if (filenetDocGUID != null)
{
getCESession(); //This method will get the CE session and set it in ceSessionData private class variable
os = ceSessionData.getObjectStore();
System.out.println("ObjectStore fetched from CESession static reference is : " + os.get_Name());
subject = ceSessionData.getSubject();
System.out.println("Subject fetched from CESession static reference.");
uc = UserContext.get();
uc.pushSubject(subject);
if (os != null)
{
document = Factory.Document.fetchInstance(os, filenetDocGUID, null);
vs = document.get_VersionSeries();
vs.delete();
vs.save(RefreshMode.NO_REFRESH);
System.out.println("All Document Versions deleted : " + filenetDocGUID);
}
else
{
System.out.println("Error :: Object Store is not available.");
}
}
}
catch (Exception e)
{
System.out.println("Exception in deleteDocumentFromCE() Method : "+ e.getMessage());
//pass the error to the calling method
throw new Exception("System Error occurred while deleting the document in CE.. "+e.getMessage());
}
finally
{
if (uc != null)
uc.popSubject();
}
System.out.println("End of deleteDocumentFromCE() method");
}