FileTracker throwing exception

Symptom

When using the FileTracker.getTrackingInfo in your plugin, it will throw an NPObject error exception if one folder of the FileTracker directory is empty (main or sub-folders) and if the file is not tracked yet.

Work around


Since we don’t have the code of the applet available to fix this, the only work around is to catch the JavasSript error returned by the applet (NPObject exception).
Just catch the error, this is actually catch by Dojo in the out-of-the-box ICN:

try {
    var filesTracked = FileTracker.getTrackingInfo({
        documentInfo: documentInfo
    });
    if (filesTracked) {
        return filesTracked[0];
    }
} catch (err) {}
return null;

Investigation

I spend some time figuring this out so here is what I found. It happens if the file does not exist for the item you want to get tracking information, which is obviously the case if the whole FileTracker folder is empty, but can also be if it’s not,.

If the FileTracker does not find the tracking information using the UDBasedTracker (they are the hidden folder containing icnFInfo.properties files and FYI, the name of the folder is actually a hash based on the version series), it falls back to a user defined file attribute mode (see my post on how works the FileTracker in ICN for more information). in this mode in will go through all files in the FileTracker directrory (recursively). However, it exists a bug. If there is no file in one folder, a NullPointerException occurs since it is trying to use a file instantiated in the loop (which is never entered since there is no file).

 

Leave a Reply