Storing and viewing External Files

I really like the fact that in Administration -> Server log, we have the option to choose the log file, click “Show Tail” and the contents of the log are being displayed.

  1. Is it possible to have the same functionality for viewing external files?
  2. I would like to create a similar form where I enter a query and when the user clicks OK, it will invoke a bean that will connect to an external system and display the results in the textArea just like in the Server Log screen. How can I go about doing that? Do you mind sharing the steps or code to reproduce the functionality?
  1. To show server log tail, we use RandomAccessFile to have direct access to the local (for the server) log file. On the other hand, FileStorage is designed to be location-agnostic and be able to transfer files of any size through streams.
    For the default FileStorage implementation, you can deduce the absolute path in the file system to an uploaded file by its FileDescriptor. But I wouldn’t recommend such direct access. Better load the file into memory or to a temporary file and then use the same technic as in Server Log to show its content.

  2. You can borrow code from com.haulmont.cuba.core.sys.LogControlImpl#getTail method.