我想删除在当前版本中设置了特定属性的文档。如果已设置此属性,则需要删除该文档的所有版本。我当前搜索IsCurrentVersion = TRUE and foo = 'bar'
的实现存在的问题是,只有当前版本被删除,而不是旧版本。所以我认为我需要删除完整的VersionSeries?到目前为止,我使用
doc.delete();
doc.save(RefreshMode.NO_REFRESH);
我找到的每一份文件。如何从该系列中检索所有文档并将其删除?如果我把它添加到一个批次中,效率会更高吗?
您应该调用
delete()
VersionSeries的方法(http://www-304.ibm.com/support/knowledgecenter/SSNW2F_5.2.0/com.ibm.p8.ce.dev.java.doc/com/filenet/api/core/VersionSeries.html)例如,
VersionSeries vs = doc.getVersionSeries();
vs.delete();
vs.save(Refresh.NO_REFRESH);
从文档报价
注意:delete和moveContent方法会影响版本系列中的所有文档版本。也就是说,删除所有文档版本,并移动所有文档版本的内容。
从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");
}