1 /*
2 * #%L
3 * wcm.io
4 * %%
5 * Copyright (C) 2014 wcm.io
6 * %%
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * #L%
19 */
20 package io.wcm.handler.url;
21
22 import io.wcm.handler.url.impl.modes.DefaultUrlMode;
23 import io.wcm.handler.url.impl.modes.FullUrlForceNonSecureUrlMode;
24 import io.wcm.handler.url.impl.modes.FullUrlForceSecureUrlMode;
25 import io.wcm.handler.url.impl.modes.FullUrlProtocolRelativeUrlMode;
26 import io.wcm.handler.url.impl.modes.FullUrlUrlMode;
27 import io.wcm.handler.url.impl.modes.NoHostnameUrlMode;
28
29 /**
30 * Default URL modes sufficient for the most usecases.
31 */
32 public final class UrlModes {
33
34 private UrlModes() {
35 // constants only
36 }
37
38 /**
39 * Default mode: Does generate a full externalized URL only if both siteUrl and siteUrlSecure parameter
40 * are set in context-specific configuration. If not set, only URLs without hostname are generated.
41 *
42 * <p>
43 * If the target is an internal content page, siteUrl or siteUrlSecure is chosen automatically depending on the secure
44 * state of the page.
45 * </p>
46 */
47 public static final UrlMode DEFAULT = new DefaultUrlMode();
48
49 /**
50 * Does generate a externalized URL without any protocol and hostname,
51 * independent of any setting in context-specific configuration.
52 */
53 public static final UrlMode NO_HOSTNAME = new NoHostnameUrlMode();
54
55 /**
56 * Enforce the generation of a full URL with protocol and hostname.
57 *
58 * <p>
59 * If the target is an internal content page, siteUrl or siteUrlSecure is chosen automatically depending on the secure
60 * state of page.
61 * </p>
62 *
63 * <p>
64 * On author instance always the author URL is used.
65 * </p>
66 */
67 public static final UrlMode FULL_URL = new FullUrlUrlMode(false);
68
69 /**
70 * Enforce the generation of a full URL with protocol and hostname and non-secure mode.
71 *
72 * <p>
73 * On author instance always the author URL is used.
74 * </p>
75 */
76 public static final UrlMode FULL_URL_FORCENONSECURE = new FullUrlForceNonSecureUrlMode(false);
77
78 /**
79 * Enforce the generation of a full URL with protocol and hostname and secure mode.
80 *
81 * <p>
82 * If siteUrlSecure is not set, siteUrl is used.
83 * </p>
84 *
85 * <p>
86 * On author instance always the author URL is used.
87 * </p>
88 */
89 public static final UrlMode FULL_URL_FORCESECURE = new FullUrlForceSecureUrlMode(false);
90
91 /**
92 * Enforce the generation of a full URL with hostname and "//" as protocol (protocol-relative mode).
93 *
94 * <p>
95 * Using "//" instead of "http://" or "https://" results in using the same protocol as the current request in the
96 * browser.
97 * </p>
98 *
99 * <p>
100 * On author instance always the author URL is used.
101 * </p>
102 */
103 public static final UrlMode FULL_URL_PROTOCOLRELATIVE = new FullUrlProtocolRelativeUrlMode(false);
104
105 /**
106 * Enforce the generation of a full URL with protocol and hostname.
107 *
108 * <p>
109 * If the target is an internal content page, siteUrl or siteUrlSecure is chosen automatically depending on the secure
110 * state of page.
111 * </p>
112 *
113 * <p>
114 * Always uses the Site URLs configured for the publish instance, even if running on an author instance.
115 * </p>
116 */
117 public static final UrlMode FULL_URL_PUBLISH = new FullUrlUrlMode(true);
118
119 /**
120 * Enforce the generation of a full URL with protocol and hostname and non-secure mode.
121 *
122 * <p>
123 * Always uses the Site URLs configured for the publish instance, even if running on an author instance.
124 * </p>
125 */
126 public static final UrlMode FULL_URL_PUBLISH_FORCENONSECURE = new FullUrlForceNonSecureUrlMode(true);
127
128 /**
129 * Enforce the generation of a full URL with protocol and hostname and secure mode.
130 *
131 * <p>
132 * If siteUrlSecure is not set, siteUrl is used.
133 * </p>
134 *
135 * <p>
136 * Always uses the Site URLs configured for the publish instance, even if running on an author instance.
137 * </p>
138 */
139 public static final UrlMode FULL_URL_PUBLISH_FORCESECURE = new FullUrlForceSecureUrlMode(true);
140
141 /**
142 * Enforce the generation of a full URL with hostname and "//" as protocol (protocol-relative mode).
143 *
144 * <p>
145 * Using "//" instead of "http://" or "https://" results in using the same protocol as the current request in the
146 * browser.
147 * </p>
148 *
149 * <p>
150 * Always uses the Site URLs configured for the publish instance, even if running on an author instance.
151 * </p>
152 */
153 public static final UrlMode FULL_URL_PUBLISH_PROTOCOLRELATIVE = new FullUrlProtocolRelativeUrlMode(true);
154
155 }