Skip to content

Package: Request

Request

Coverage

1: /*
2: * #%L
3: * *********************************************************************************************************************
4: *
5: * NorthernWind - lightweight CMS
6: * http://northernwind.tidalwave.it - git clone https://bitbucket.org/tidalwave/northernwind-src.git
7: * %%
8: * Copyright (C) 2011 - 2023 Tidalwave s.a.s. (http://tidalwave.it)
9: * %%
10: * *********************************************************************************************************************
11: *
12: * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
13: * the License. You may obtain a copy of the License at
14: *
15: * http://www.apache.org/licenses/LICENSE-2.0
16: *
17: * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
18: * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
19: * specific language governing permissions and limitations under the License.
20: *
21: * *********************************************************************************************************************
22: *
23: *
24: * *********************************************************************************************************************
25: * #L%
26: */
27: package it.tidalwave.northernwind.core.model;
28:
29: import javax.annotation.Nonnull;
30: import javax.annotation.concurrent.Immutable;
31: import java.util.List;
32: import java.util.Locale;
33: import java.util.Optional;
34:
35: /***********************************************************************************************************************
36: *
37: * An object representing an incoming request.
38: *
39: * @author Fabrizio Giudici
40: *
41: **********************************************************************************************************************/
42: @Immutable
43: public interface Request
44: {
45: /*******************************************************************************************************************
46: *
47: * Creates a clone with the given relative URI
48: *
49: * @param relativeUri the relative URI
50: * @return the clone
51: *
52: ******************************************************************************************************************/
53: @Nonnull
54: public Request withRelativeUri (@Nonnull String relativeUri); // TODO: should be ResourcePath
55:
56: /*******************************************************************************************************************
57: *
58: * Returns the base URL of this request.
59: *
60: * @return the base URL
61: *
62: ******************************************************************************************************************/
63: @Nonnull
64: public String getBaseUrl();
65:
66: /*******************************************************************************************************************
67: *
68: * Returns the relative URI of this request.
69: *
70: * @return the relative URI
71: *
72: ******************************************************************************************************************/
73: @Nonnull
74: public String getRelativeUri(); // TODO: should be ResourcePath
75:
76: /*******************************************************************************************************************
77: *
78: * Returns the original relative URI of this request.
79: *
80: * @return the original relative URI
81: *
82: ******************************************************************************************************************/
83: @Nonnull
84: public String getOriginalRelativeUri();
85:
86: /*******************************************************************************************************************
87: *
88: * Returns the locales preferred by the client originating this request.
89: *
90: * @return the preferred locales
91: *
92: ******************************************************************************************************************/
93: @Nonnull
94: public List<Locale> getPreferredLocales();
95:
96: /*******************************************************************************************************************
97: *
98: * Returns a header value.
99: *
100: * @param headerName the name of the header
101: * @return the value of the header
102: *
103: ******************************************************************************************************************/
104: @Nonnull
105: public Optional<String> getHeader (@Nonnull String headerName);
106:
107: /*******************************************************************************************************************
108: *
109: * Returns a header value.
110: *
111: * @param headerName the name of the header
112: * @return the value of the header
113: *
114: ******************************************************************************************************************/
115: @Nonnull
116: public List<String> getMultiValuedHeader (@Nonnull String headerName);
117:
118: /*******************************************************************************************************************
119: *
120: * Returns a parameter value.
121: *
122: * @param parameterName the name of the parameter
123: * @return the value of the parameter
124: *
125: ******************************************************************************************************************/
126: @Nonnull
127: public Optional<String> getParameter (@Nonnull String parameterName);
128:
129: /*******************************************************************************************************************
130: *
131: * Returns a parameter value in form of a list.
132: *
133: * @param parameterName the name of the parameter
134: * @return the value of the parameter
135: *
136: ******************************************************************************************************************/
137: @Nonnull
138: public List<String> getMultiValuedParameter (@Nonnull String parameterName);
139:
140: /*******************************************************************************************************************
141: *
142: * Returns the path params.
143: *
144: * @param siteNode the owner of the params
145: * @return the path params
146: *
147: ******************************************************************************************************************/
148: @Nonnull
149: public ResourcePath getPathParams (@Nonnull SiteNode siteNode);
150: }