Search in sources :

Example 1 with MCRChangeTracker

use of org.mycore.frontend.xeditor.tracker.MCRChangeTracker in project mycore by MyCoRe-Org.

the class MCRDebugTarget method handleSubmission.

@Override
public void handleSubmission(ServletContext context, MCRServletJob job, MCREditorSession session, String parameter) throws Exception {
    job.getResponse().setContentType("text/html; charset=UTF-8");
    PrintWriter out = job.getResponse().getWriter();
    out.println("<html><body>");
    Map<String, String[]> parameters = job.getRequest().getParameterMap();
    session.getSubmission().setSubmittedValues(parameters);
    Document result = session.getEditedXML().clone();
    MCRChangeTracker tracker = session.getChangeTracker().clone();
    List<Step> steps = new ArrayList<>();
    for (String label; (label = tracker.undoLastBreakpoint(result)) != null; ) steps.add(0, new Step(label, result.clone()));
    result = session.getEditedXML().clone();
    result = MCRChangeTracker.removeChangeTracking(result);
    result = session.getXMLCleaner().clean(result);
    steps.add(new Step("After cleaning", result));
    result = session.getPostProcessor().process(result);
    steps.add(new Step("After postprocessing", result));
    for (int i = 0; i < steps.size(); i++) {
        if (i == steps.size() - 3)
            outputParameters(parameters, out);
        steps.get(i).output(out);
    }
    out.println("</body></html>");
    out.close();
}
Also used : MCRChangeTracker(org.mycore.frontend.xeditor.tracker.MCRChangeTracker) ArrayList(java.util.ArrayList) Document(org.jdom2.Document) PrintWriter(java.io.PrintWriter)

Aggregations

PrintWriter (java.io.PrintWriter)1 ArrayList (java.util.ArrayList)1 Document (org.jdom2.Document)1 MCRChangeTracker (org.mycore.frontend.xeditor.tracker.MCRChangeTracker)1