I have a few questions about the innards of JSPWiki and how it saves pages. I suspect Janne and Murray know the answer to these.

As you know, I am investigating how to make workflows serializable. For a given workflow to be serializable, it will likely require that *everything* we stash in a Workflow also be serializable. In the current PreSaveWikiPageTask, we stash a bunch of Strings plus the WikiContext, then retrieve it later in SaveWikiPageTask. The "SaveWikiPageTask" code is below.

     // Retrieve attributes
WikiContext context = (WikiContext) getWorkflow().getAttribute( PRESAVE_WIKI_CONTEXT ); String proposedText = (String) getWorkflow().getAttribute( FACT_PROPOSED_TEXT );

     WikiEngine engine = context.getEngine();
     WikiPage page = context.getPage();

     // Let the rest of the engine handle actual saving.
     engine.getPageManager().putPageText( page, proposedText );

     // Refresh the context for post save filtering.
     engine.getPage( page.getName() );
     engine.textToHTML( context, proposedText );
engine.getFilterManager().doPostSaveFiltering( context, proposedText );

As you can see, we expect to be able to retrieve WikiContext as a Workflow attribute called PRESAVE_WIKI_CONTEXT, which was stashed by PreSaveTask.

My question is, is there anything special about the WikiContext that we retrieve, which is passed to textToHTML() and doPostSaveFiltering()? Could we create a synthetic one instead? In other words, I am proposing that in PreSaveTask we stash the WikiPage name as a string, then pick it up in SaveTask and use it to manufacture a new, fake WikiContext with the correct WikiPage.

Why this could be important: if the WikiContext does not necessarily need to be the original one (created by the user), that would mean we wouldn't need to stick it in the Workflow. Which would make the "save wiki page" workflow serializable.

Conversely, if the WikiContext used by textToHTML() and doPostSaveFiltering() *has to be* the same WikiContext (and not created synthetically), then we've got to keep stashing it as a workflow attribute, and thus (here's the punchline)... we will never to be able to persist workflows.

So, what do you think?

One more thing. Why do we call textToHTML() as part of the **save** process? Here is what textToHTML() does (lightly edited):

boolean runFilters = "true ".equals(m_variableManager.getValue(context,PROP_RUNFILTERS,"true"));
    if( runFilters )
pagedata = m_filterManager.doPreTranslateFiltering( context, pagedata );

    result = m_renderingManager.getHTML( context, pagedata );

    if( runFilters )
result = m_filterManager.doPostTranslateFiltering( context, result );

I seem to recall something about needing to run textToHTML() so that access rules and other meta-data were re-read correctly...


Andrew

Reply via email to