2 Replies Latest reply on Nov 8, 2006 4:58 PM by Richard Leherpeur

    Cleanup when a conversation expires

    Richard Leherpeur Novice

      Hello,

      I have a conversation that goes through several steps. During one step, files can be uploaded.
      When the user finished the flow, the @end methods is called, and an entity is persited into the database (with the info how to retrieve the uploaded files in the file system).

      Now if the user doesn't finish the flow (conversation expires), the entity will obvioulsy not be persisted. However, the uploaded files are already on the server.
      My question is simple: what would be the best way to do a cleanup?

      I think that it should be done by the method with the method:

      @Destroy @Remove
      public void destroy() {
      ...
      }
      

      Now the thing is that this method is called whether the conversation ends properly or expires.
      So one way would be to set a "ConversationConpleted" flag in the @end method.
      Then in the destroy method, I'll know whether the cleanup must take place or not.

      Is there any other way to do this? I mean is there any way to annotate a method that would be called in case of conversation expiration and not when the conversation ends properly (thus eliminating the need for a status flag).

      Thanks

      Richard