• 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/compatability/PageParser2ContentProcessor.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * Copyright 2011-2026 Hazendaz
4
 */
5
package com.opensymphony.sitemesh.compatability;
6

7
import com.opensymphony.module.sitemesh.Factory;
8
import com.opensymphony.module.sitemesh.HTMLPage;
9
import com.opensymphony.module.sitemesh.Page;
10
import com.opensymphony.module.sitemesh.PageParser;
11
import com.opensymphony.module.sitemesh.SitemeshBuffer;
12
import com.opensymphony.module.sitemesh.filter.HttpContentType;
13
import com.opensymphony.sitemesh.Content;
14
import com.opensymphony.sitemesh.ContentProcessor;
15
import com.opensymphony.sitemesh.SiteMeshContext;
16
import com.opensymphony.sitemesh.webapp.SiteMeshWebAppContext;
17

18
import jakarta.servlet.http.HttpServletRequest;
19

20
import java.io.IOException;
21

22
/**
23
 * Adapts a SiteMesh 2 {@link PageParser} to a SiteMesh 3 {@link ContentProcessor}.
24
 *
25
 * @author Joe Walnes
26
 *
27
 * @since SiteMesh 3
28
 */
29
public class PageParser2ContentProcessor implements ContentProcessor {
30

31
    /** The factory. */
32
    private final Factory factory;
33

34
    /**
35
     * Instantiates a new page parser 2 content processor.
36
     *
37
     * @param factory
38
     *            the factory
39
     */
40
    public PageParser2ContentProcessor(Factory factory) {
×
41
        this.factory = factory;
×
42
    }
×
43

44
    /**
45
     * Handles.
46
     *
47
     * @param context
48
     *            the context
49
     *
50
     * @return true, if successful
51
     */
52
    @Override
53
    public boolean handles(SiteMeshContext context) {
54
        SiteMeshWebAppContext webAppContext = (SiteMeshWebAppContext) context;
×
55
        return !factory.isPathExcluded(extractRequestPath(webAppContext.getRequest()));
×
56
    }
57

58
    /**
59
     * Extract request path.
60
     *
61
     * @param request
62
     *            the request
63
     *
64
     * @return the string
65
     */
66
    private String extractRequestPath(HttpServletRequest request) {
67
        String servletPath = request.getServletPath();
×
68
        String pathInfo = request.getPathInfo();
×
69
        String query = request.getQueryString();
×
70
        return (servletPath == null ? "" : servletPath) + (pathInfo == null ? "" : pathInfo)
×
71
                + (query == null ? "" : "?" + query);
×
72
    }
73

74
    @Override
75
    public boolean handles(String contentType) {
76
        return factory.shouldParsePage(contentType);
×
77
    }
78

79
    /**
80
     * Builds the.
81
     *
82
     * @param buffer
83
     *            the buffer
84
     * @param context
85
     *            the context
86
     *
87
     * @return the content
88
     *
89
     * @throws IOException
90
     *             Signals that an I/O exception has occurred.
91
     */
92
    @Override
93
    public Content build(SitemeshBuffer buffer, SiteMeshContext context) throws IOException {
94
        HttpContentType httpContentType = new HttpContentType(context.getContentType());
×
95
        PageParser pageParser = factory.getPageParser(httpContentType.getType());
×
96
        Page page = pageParser.parse(buffer);
×
97
        return new HTMLPage2Content((HTMLPage) page);
×
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