Reputation: 1
Is this still the only way or most efficient way to unfile a document from filenet?
static PropertyFilter pf = new PropertyFilter();
pf.addIncludeProperty(new FilterElement(null, null, null, "Containers",
null));
// Get document to be unfiled.
Document doc = Factory.Document.fetchInstance(os, new Id("{8854236F-02D6- 40AB-B4B2-59B6756154D8}"), pf);
// Iterate all folders that contain the document, until the desired
folder is found.
ReferentialContainmentRelationshipSet rcrs = doc.get_Containers();
Iterator iter = rcrs.iterator();
while (iter.hasNext() )
{
ReferentialContainmentRelationship rcr =
(ReferentialContainmentRelationship)iter.next();
Folder folder = (Folder)rcr.get_Tail();
if (folder.get_Id().equals(new Id("{C40106FE-B510-4222-BB42- 6D2FD5D21123}")))
{
rcr.delete();
rcr.save(RefreshMode.REFRESH);
break;
}
}
This code performs what it supposed to do, but sometimes it would take up to 4 hours to unfile one document.
Upvotes: 0
Views: 1255
Reputation: 5782
Unfiling an object from a folder requires just one thing: deleting the corresponding ReferentialContainmentRelationship
object. The latter can be obtained in several ways, but assuming you know the folder you want to unfile from, the most straighforward way is to use the unfile
method on Folder
:
ReferentialContainmentRelationship rcr = folder.unfile(document);
rcr.save(RefreshMode.NO_REFRESH);
The code that you posted seems to be an adaptation of something designated for more generic task. I don't believe the documentation advises to unfile from a single folder in this way. Anyway, unless the document you are unfiling is filed into many thousands of folders, even with that unnecessary complication it is a matter of seconds to unfile it, not hours. There might be something wrong with your system.
Upvotes: 0