I want to set up a process to remove all links benath a specified folder. The only way to delete a link using the Java Application Interface is using the DeleteLink class, and the only way to construct an object of this class is based on a FolderListItem object. Ultimately the only way I have found to delete links is something like this:
- Begin with aFolderTreeobject.
- Create anIFolderobject based on a the specific folder path, using FolderTree.getFolder(String linkPath).
- Create aFolderListusing the IFolder.
- Create an iterator over objects/links in that path, usingFolderList.iterator().</li>
- For each entry, use FolderListItem.isLink() to determine whether the item is a link.
- If so, construct aDeleteLinkobject from the FolderlistItem, and send the request to the Automation Engine.
This will delete the links directly under just the specified directory, but will not delete links from subdirectories. To delete links under sub-directories, one would have to return to the IFolder, and use the subfolder() method to proceed to subfolders, in a recursive way.
I thought it might be possible to use SearchObject to list only the links under a specified folder path, but there does not appear to be a way to do this. One can list all objects including links, and then parse them one at a time, checking whether a particular search result is a link. But the one still has the challenge of converting a SearchResultItem to something that can be used with DeleteLink. Perhaps this could be done using the internal use only FolderListItem constructor, but I have not tried this.
Is there a better way to recursively remove links under a specified folder path?