}
// Create approval workflow for page save; add the diffed, proposed
// and old text versions as Facts for the approver (if approval is required)
// If submitter is authenticated, any reject messages will appear in his/her workflow inbox.
WorkflowBuilder builder = WorkflowBuilder.getBuilder( this );
Principal submitter = context.getCurrentUser();
Task prepTask = new PageManager.PreSaveWikiPageTask( context, proposedText );
Task completionTask = new PageManager.SaveWikiPageTask();
String diffText = m_differenceManager.makeDiff( context, oldText, proposedText );
boolean isAuthenticated = context.getWikiSession().isAuthenticated();
Fact[] facts = new Fact[5];
facts[0] = new Fact( PageManager.FACT_PAGE_NAME, page.getName() );
facts[1] = new Fact( PageManager.FACT_DIFF_TEXT, diffText );
facts[2] = new Fact( PageManager.FACT_PROPOSED_TEXT, proposedText );
facts[3] = new Fact( PageManager.FACT_CURRENT_TEXT, oldText);
facts[4] = new Fact( PageManager.FACT_IS_AUTHENTICATED, Boolean.valueOf( isAuthenticated ) );
String rejectKey = isAuthenticated ? PageManager.SAVE_REJECT_MESSAGE_KEY : null;
Workflow workflow = builder.buildApprovalWorkflow( submitter,
PageManager.SAVE_APPROVER,
prepTask,
PageManager.SAVE_DECISION_MESSAGE_KEY,
facts,
completionTask,