[英]Acquiring retrieval name for latest version of a document in a DocumentSet using FileNet API
我有這段代碼:
Folder fold = Factory.Folder.fetchInstance(os, folderPath, null);
DocumentSet docs = fold.get_ContainedDocuments();
Iterator it = docs.iterator();
Document retr;
try {
while (it.hasNext()) {
retr = (Document)it.next();
String name = retr.get_Name();
System.out.println(name);
if(name.equals(fileName)) {
System.out.println("Match Found");
System.out.println("Document Name : " + retr.get_Name());
return retr;
}
}
} catch (Exception e) {
e.printStackTrace();
}
目前,此代碼適用於檢索具有特定文件名的文檔。 我想添加到它,以便它也可以選擇具有該名稱的文件的最新版本。 我該怎么辦?
我已經考慮在現有的內部添加一個額外的,但我擔心影響性能。
這是您可以獲得最新版本文檔的方法
Folder fold = Factory.Folder.fetchInstance(os, folderPath, null);
DocumentSet docs = fold.get_ContainedDocuments();
Iterator it = docs.iterator();
Document retr;
try {
while (it.hasNext()) {
retr = (Document)it.next();
String name = retr.get_Name();
System.out.println(name);
if(name.equals(fileName)) {
System.out.println("Match Found");
System.out.println("Document Name : " + retr.get_Name());
//here you are checking the document for the name. It also can happen that, this document might have more than version but the title remained same for each version. You can get the latest version like
return retr.get_CurrentVersion();
}
}
} catch (Exception e) {
e.printStackTrace();
}
如果您正在提交文件(或文件的子類),則包含的文件將是當前文件版本。 在這種情況下,當前文檔版本是(按使用順序):
您不能使用Folder.file
方法將特定文檔版本歸檔到文件夾中,因此您將始終在文件夾中擁有包含最新版本的DocumentSet
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.