ICEfaces
  1. ICEfaces
  2. ICE-6205

ACE fileEntry callback support

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 2.0-Beta2
    • Fix Version/s: 2.0.1
    • Component/s: ACE-Components
    • Labels:
      None
    • Environment:
      ACE

      Description

      Modify FileEntryPhaseListener to make use of FileEntryCallback. The idea being that when files are saved, they will not go to the file-system, but will be processed by this interface, allowing for in-memory processing of the files. Typically this is so that the files may be stored in a database, or may be virus scanned before being saved.

        Activity

        Hide
        Mark Collette added a comment -

        This functionality is analogous to ice:inputFile's outputStream property ( ICE-2198 ), but has been enhanced to use an interface with explicit notification of beginning and ending of the writing, which helped certain scenarios that go beyond just the typical database BLOB scenario.

        Show
        Mark Collette added a comment - This functionality is analogous to ice:inputFile's outputStream property ( ICE-2198 ), but has been enhanced to use an interface with explicit notification of beginning and ending of the writing, which helped certain scenarios that go beyond just the typical database BLOB scenario.
        Hide
        Mark Collette added a comment -

        All directions for the file processing have to be stored in the session, as it occurs in pre restore view phase, when there is no component tree, and thus no access to the fileEntry component's properties. So, we've decided to store the text of the EL expression to the callback object in the session. That way no actual bean object graph will be stored there. This way the EL expression will be evaluated within the current lifecycle, and not in a previous one, which might have otherwise created issues with stale request object references.

        The caveat of this whole scenario is that the EL expression is evaluated in the part of the lifecycle when view and page scopes are likely not available. The application, session and request scopes should all be fine.

        Show
        Mark Collette added a comment - All directions for the file processing have to be stored in the session, as it occurs in pre restore view phase, when there is no component tree, and thus no access to the fileEntry component's properties. So, we've decided to store the text of the EL expression to the callback object in the session. That way no actual bean object graph will be stored there. This way the EL expression will be evaluated within the current lifecycle, and not in a previous one, which might have otherwise created issues with stale request object references. The caveat of this whole scenario is that the EL expression is evaluated in the part of the lifecycle when view and page scopes are likely not available. The application, session and request scopes should all be fine.
        Hide
        Mark Collette added a comment - - edited

        Testing of failure scenarios shows that:

        1. When the callback EL has an invalid bean reference, no exception is thrown at all, and the callback evaluates to null, so the FileEntryPhaseListener treats it as a file-system upload.

        2. When the callback EL has an invalid getter method reference, an exception is thrown: javax.el.PropertyNotFoundException: Property 'callbackish' not found on type org.icefaces.fileentry.FileBean. This results in the the FileEntryPhaseListener stopping, the file not being processed, no RequestParameterMap being created, in the ajax postback returns an empty update of just the ViewState.

        3. When the file is prefailed and the callback throws a RuntimeException in it's begin method, the FileEntryPhaseListener has a generic catch(Ecxeption) clause that marks the file as INVALID, then the lifecycles continues, the fileEntryListener is called, the FacesMessage is rendered, and the page is updated.

        It's the same for a RuntimeException in the callback's begin (non-prefail) and write methods.

        4. When the callback's end method throws a RuntimeException, this results in the the FileEntryPhaseListener stopping, the file not being processed, nothing getting logged, and the error html page being returned to the browser, which does not display it since it's not an xml updates response.

        Show
        Mark Collette added a comment - - edited Testing of failure scenarios shows that: 1. When the callback EL has an invalid bean reference, no exception is thrown at all, and the callback evaluates to null, so the FileEntryPhaseListener treats it as a file-system upload. 2. When the callback EL has an invalid getter method reference, an exception is thrown: javax.el.PropertyNotFoundException: Property 'callbackish' not found on type org.icefaces.fileentry.FileBean. This results in the the FileEntryPhaseListener stopping, the file not being processed, no RequestParameterMap being created, in the ajax postback returns an empty update of just the ViewState. 3. When the file is prefailed and the callback throws a RuntimeException in it's begin method, the FileEntryPhaseListener has a generic catch(Ecxeption) clause that marks the file as INVALID, then the lifecycles continues, the fileEntryListener is called, the FacesMessage is rendered, and the page is updated. It's the same for a RuntimeException in the callback's begin (non-prefail) and write methods. 4. When the callback's end method throws a RuntimeException, this results in the the FileEntryPhaseListener stopping, the file not being processed, nothing getting logged, and the error html page being returned to the browser, which does not display it since it's not an xml updates response.
        Hide
        Mark Collette added a comment - - edited

        Fixing the failure scenarios:

        1. Code now detects when the callback is set but evaluates to null (but no exception, which is scenario 2), and if in Development Project Stage, it logs a warning. The upload still continues on to the file-system.

        2. Code now catches the ELException, and if in Development Project Stage, it logs an error. Then re-throws the exception, so that the file will not be saved to the file-system. Shows a FacesMessage that there's a server application issue.

        3. and 4. For all scenarios, an error is logged and a FacesMessage is shown.

        Show
        Mark Collette added a comment - - edited Fixing the failure scenarios: 1. Code now detects when the callback is set but evaluates to null (but no exception, which is scenario 2), and if in Development Project Stage, it logs a warning. The upload still continues on to the file-system. 2. Code now catches the ELException, and if in Development Project Stage, it logs an error. Then re-throws the exception, so that the file will not be saved to the file-system. Shows a FacesMessage that there's a server application issue. 3. and 4. For all scenarios, an error is logged and a FacesMessage is shown.
        Hide
        Mark Collette added a comment -

        Added callback support to fileEntry component.
        Subversion 24117

        Added test code for callback feature of fileEntry component. Test code is in forms 18 - 24 in: icefaces2/ace/test/web/fileEntry.xhtml
        Also fixed the test code, which was referencing the old infos property, that had been renamed to results.
        Subversion 24118

        Show
        Mark Collette added a comment - Added callback support to fileEntry component. Subversion 24117 Added test code for callback feature of fileEntry component. Test code is in forms 18 - 24 in: icefaces2/ace/test/web/fileEntry.xhtml Also fixed the test code, which was referencing the old infos property, that had been renamed to results. Subversion 24118

          People

          • Assignee:
            Mark Collette
            Reporter:
            Mark Collette
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: