Search in sources :

Example 1 with ErrorUml

use of net.sourceforge.plantuml.ErrorUml in project plantuml-server by plantuml.

the class DiagramResponse method addHeaderForCache.

private void addHeaderForCache(BlockUml blockUml) {
    long today = System.currentTimeMillis();
    // Add http headers to force the browser to cache the image
    final int maxAge = 3600 * 24 * 5;
    response.addDateHeader("Expires", today + 1000L * maxAge);
    response.addDateHeader("Date", today);
    response.addDateHeader("Last-Modified", blockUml.lastModified());
    response.addHeader("Cache-Control", "public, max-age=" + maxAge);
    // response.addHeader("Cache-Control", "max-age=864000");
    response.addHeader("Etag", "\"" + blockUml.etag() + "\"");
    final Diagram diagram = blockUml.getDiagram();
    response.addHeader("X-PlantUML-Diagram-Description", diagram.getDescription().getDescription());
    if (diagram instanceof PSystemError) {
        final PSystemError error = (PSystemError) diagram;
        for (ErrorUml err : error.getErrorsUml()) {
            response.addHeader("X-PlantUML-Diagram-Error", err.getError());
            response.addHeader("X-PlantUML-Diagram-Error-Line", "" + err.getLineLocation().getPosition());
        }
    }
    addHeaders(response);
}
Also used : PSystemError(net.sourceforge.plantuml.PSystemError) ErrorUml(net.sourceforge.plantuml.ErrorUml) Diagram(net.sourceforge.plantuml.core.Diagram)

Aggregations

ErrorUml (net.sourceforge.plantuml.ErrorUml)1 PSystemError (net.sourceforge.plantuml.PSystemError)1 Diagram (net.sourceforge.plantuml.core.Diagram)1