• 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/module/sitemesh/mapper/CookieDecoratorMapper.java
1
/*
2
 * SPDX-License-Identifier: Apache-2.0
3
 * Copyright 2011-2026 Hazendaz
4
 */
5
/*
6
 * Title:        CookieDecoratorMapper
7
 * Description:
8
 *
9
 * This software is published under the terms of the OpenSymphony Software
10
 * License version 1.1, of which a copy has been included with this
11
 * distribution in the LICENSE.txt file.
12
 */
13

14
package com.opensymphony.module.sitemesh.mapper;
15

16
import com.opensymphony.module.sitemesh.Config;
17
import com.opensymphony.module.sitemesh.Decorator;
18
import com.opensymphony.module.sitemesh.DecoratorMapper;
19
import com.opensymphony.module.sitemesh.Page;
20

21
import jakarta.servlet.http.Cookie;
22
import jakarta.servlet.http.HttpServletRequest;
23

24
import java.util.Properties;
25

26
/**
27
 * The CookieDecoratorMapper will map a suitable decorator based on a cookie value.
28
 * <p>
29
 * The CookieDecoratorMapper is configured via one properties. <code>cookie.name</code> - the cookie which contains the
30
 * name of the decorator which will be mapped.
31
 *
32
 * @author Paul Hammant
33
 *
34
 * @see com.opensymphony.module.sitemesh.DecoratorMapper
35
 */
36
public class CookieDecoratorMapper extends AbstractDecoratorMapper {
×
37

38
    /** The cookie name. */
39
    private String cookieName;
40

41
    @Override
42
    public void init(Config config, Properties properties, DecoratorMapper parent) throws InstantiationException {
43
        super.init(config, properties, parent);
×
44
        cookieName = properties.getProperty("cookie.name", null);
×
45
        if (cookieName == null) {
×
46
            throw new InstantiationException("'cookie.name' name parameter not set for this decorator mapper");
×
47
        }
48
    }
×
49

50
    @Override
51
    public Decorator getDecorator(HttpServletRequest request, Page page) {
52
        Decorator result = null;
×
53
        Cookie[] cookies = request.getCookies();
×
54
        if (cookies != null) {
×
55
            for (Cookie cookie : cookies) {
×
56
                if (cookie.getName().equals(cookieName)) {
×
57
                    result = getNamedDecorator(request, cookie.getValue());
×
58
                }
59
            }
60
        }
61
        return result == null ? super.getDecorator(request, page) : result;
×
62
    }
63
}
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