• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / sitemesh2 / 59

22 Mar 2026 02:30AM UTC coverage: 40.347%. Remained the same
59

push

github

hazendaz
[mvn] Update maven wrapper

698 of 1891 branches covered (36.91%)

Branch coverage included in aggregate %.

1555 of 3693 relevant lines covered (42.11%)

0.42 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/com/opensymphony/sitemesh/webapp/ContentBufferingResponse.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * Copyright 2011-2026 Hazendaz
4
 */
5
package com.opensymphony.sitemesh.webapp;
6

7
import com.opensymphony.module.sitemesh.PageParser;
8
import com.opensymphony.module.sitemesh.PageParserSelector;
9
import com.opensymphony.module.sitemesh.SitemeshBuffer;
10
import com.opensymphony.module.sitemesh.filter.PageResponseWrapper;
11
import com.opensymphony.sitemesh.Content;
12
import com.opensymphony.sitemesh.ContentProcessor;
13

14
import jakarta.servlet.http.HttpServletResponse;
15
import jakarta.servlet.http.HttpServletResponseWrapper;
16

17
import java.io.IOException;
18

19
/**
20
 * The Class ContentBufferingResponse.
21
 *
22
 * @author Joe Walnes
23
 *
24
 * @since SiteMesh 3
25
 */
26
public class ContentBufferingResponse extends HttpServletResponseWrapper {
27

28
    // TODO: Temporary SM3 migration implementation! Wraps SM2 PageResponseWrapper. This class is an evil stopgap.
29
    // Eventually PageResponseWrapper will go away and the functionality will be rolled into this class.
30

31
    /** The page response wrapper. */
32
    private final PageResponseWrapper pageResponseWrapper;
33

34
    /** The content processor. */
35
    private final ContentProcessor contentProcessor;
36

37
    /** The web app context. */
38
    private final SiteMeshWebAppContext webAppContext;
39

40
    /**
41
     * Instantiates a new content buffering response.
42
     *
43
     * @param response
44
     *            the response
45
     * @param contentProcessor
46
     *            the content processor
47
     * @param webAppContext
48
     *            the web app context
49
     */
50
    public ContentBufferingResponse(HttpServletResponse response, final ContentProcessor contentProcessor,
51
            final SiteMeshWebAppContext webAppContext) {
52
        super(new PageResponseWrapper(response, new PageParserSelector() {
×
53
            @Override
54
            public boolean shouldParsePage(String contentType) {
55
                return contentProcessor.handles(contentType);
×
56
            }
57

58
            @Override
59
            public PageParser getPageParser(String contentType) {
60
                // Migration: Not actually needed by PageResponseWrapper, so long as getPage() isn't called.
61
                return null;
×
62
            }
63
        }) {
×
64
            @Override
65
            public void setContentType(String contentType) {
66
                webAppContext.setContentType(contentType);
×
67
                super.setContentType(contentType);
×
68
            }
×
69
        });
70
        this.contentProcessor = contentProcessor;
×
71
        this.webAppContext = webAppContext;
×
72
        pageResponseWrapper = (PageResponseWrapper) getResponse();
×
73
    }
×
74

75
    /**
76
     * Checks if is using stream.
77
     *
78
     * @return true, if is using stream
79
     */
80
    public boolean isUsingStream() {
81
        return pageResponseWrapper.isUsingStream();
×
82
    }
83

84
    /**
85
     * Gets the content.
86
     *
87
     * @return the content
88
     *
89
     * @throws IOException
90
     *             Signals that an I/O exception has occurred.
91
     */
92
    public Content getContent() throws IOException {
93
        SitemeshBuffer content = pageResponseWrapper.getContents();
×
94
        if (content != null) {
×
95
            return contentProcessor.build(content, webAppContext);
×
96
        }
97
        return null;
×
98
    }
99

100
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc