Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
XePage |
|
| 1.0;1 |
1 | /** | |
2 | * Copyright (c) 2014-2015, Thindeck.com | |
3 | * All rights reserved. | |
4 | * | |
5 | * Redistribution and use in source and binary forms, with or without | |
6 | * modification, are permitted provided that the following conditions | |
7 | * are met: 1) Redistributions of source code must retain the above | |
8 | * copyright notice, this list of conditions and the following | |
9 | * disclaimer. 2) Redistributions in binary form must reproduce the above | |
10 | * copyright notice, this list of conditions and the following | |
11 | * disclaimer in the documentation and/or other materials provided | |
12 | * with the distribution. 3) Neither the name of the thindeck.com nor | |
13 | * the names of its contributors may be used to endorse or promote | |
14 | * products derived from this software without specific prior written | |
15 | * permission. | |
16 | * | |
17 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | |
18 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT | |
19 | * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
20 | * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL | |
21 | * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, | |
22 | * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | |
23 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | |
24 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | |
25 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | |
26 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | |
27 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | |
28 | * OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | */ | |
30 | package com.thindeck.cockpit; | |
31 | ||
32 | import com.jcabi.manifests.Manifests; | |
33 | import com.thindeck.api.Base; | |
34 | import java.io.IOException; | |
35 | import lombok.EqualsAndHashCode; | |
36 | import org.takes.Request; | |
37 | import org.takes.facets.auth.XeIdentity; | |
38 | import org.takes.facets.auth.XeLogoutLink; | |
39 | import org.takes.facets.auth.social.XeGithubLink; | |
40 | import org.takes.facets.flash.XeFlash; | |
41 | import org.takes.rs.xe.XeAppend; | |
42 | import org.takes.rs.xe.XeChain; | |
43 | import org.takes.rs.xe.XeDate; | |
44 | import org.takes.rs.xe.XeLinkHome; | |
45 | import org.takes.rs.xe.XeLinkSelf; | |
46 | import org.takes.rs.xe.XeLocalhost; | |
47 | import org.takes.rs.xe.XeMillis; | |
48 | import org.takes.rs.xe.XeSLA; | |
49 | import org.takes.rs.xe.XeSource; | |
50 | import org.takes.rs.xe.XeWrap; | |
51 | ||
52 | /** | |
53 | * Default page in Xembly. | |
54 | * | |
55 | * @author Yegor Bugayenko (yegor@teamed.io) | |
56 | * @version $Id$ | |
57 | * @since 0.1 | |
58 | * @checkstyle ClassDataAbstractionCouplingCheck (500 lines) | |
59 | */ | |
60 | 1 | @EqualsAndHashCode(callSuper = true) |
61 | public final class XePage extends XeWrap { | |
62 | ||
63 | /** | |
64 | * Ctor. | |
65 | * @param base Base | |
66 | * @param req Request | |
67 | * @param src Source | |
68 | * @throws IOException If fails | |
69 | */ | |
70 | public XePage(final Base base, | |
71 | final Request req, final XeSource... src) throws IOException { | |
72 | 2 | super(XePage.make(base, req, src)); |
73 | 2 | } |
74 | ||
75 | /** | |
76 | * Make it. | |
77 | * @param base Base | |
78 | * @param req Request | |
79 | * @param src Source | |
80 | * @return Response | |
81 | * @throws IOException If fails | |
82 | */ | |
83 | private static XeSource make(final Base base, | |
84 | final Request req, final XeSource... src) throws IOException { | |
85 | 2 | assert base != null; |
86 | 2 | return new XeAppend( |
87 | "page", | |
88 | new XeMillis(false), | |
89 | new XeChain(src), | |
90 | new XeDate(), | |
91 | new XeSLA(), | |
92 | new XeLinkHome(req), | |
93 | new XeLinkSelf(req), | |
94 | new XeLocalhost(), | |
95 | new XeIdentity(req), | |
96 | new XeFlash(req), | |
97 | new XeGithubLink(req, Manifests.read("Thindeck-GithubId")), | |
98 | new XeLogoutLink(req), | |
99 | new XeAppend( | |
100 | "version", | |
101 | new XeAppend("name", Manifests.read("Thindeck-Version")), | |
102 | new XeAppend("rev", Manifests.read("Thindeck-Revision")), | |
103 | new XeAppend("date", Manifests.read("Thindeck-Date")) | |
104 | ), | |
105 | new XeMillis(true) | |
106 | ); | |
107 | } | |
108 | ||
109 | } |