1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package io.wcm.handler.url.impl.modes;
21
22 import org.apache.commons.lang3.StringUtils;
23 import org.apache.sling.api.adapter.Adaptable;
24
25 import io.wcm.handler.url.SiteConfig;
26
27
28
29
30 class UrlConfig {
31
32 private final String siteUrl;
33 private final String siteUrlSecure;
34 private final String siteUrlAuthor;
35
36 UrlConfig(Adaptable adaptable) {
37 SiteConfig config = adaptable.adaptTo(SiteConfig.class);
38 if (config != null) {
39 this.siteUrl = config.siteUrl();
40 this.siteUrlSecure = StringUtils.defaultString(config.siteUrlSecure(), this.siteUrl);
41 this.siteUrlAuthor = config.siteUrlAuthor();
42 }
43 else {
44 this.siteUrl = null;
45 this.siteUrlSecure = null;
46 this.siteUrlAuthor = null;
47 }
48 }
49
50
51
52
53 public String getSiteUrl() {
54 return this.siteUrl;
55 }
56
57
58
59
60 public String getSiteUrlSecure() {
61 return this.siteUrlSecure;
62 }
63
64
65
66
67 public String getSiteUrlAuthor() {
68 return this.siteUrlAuthor;
69 }
70
71
72
73
74 public boolean isValid() {
75 return StringUtils.isNotEmpty(this.siteUrl);
76 }
77
78
79
80
81 public boolean hasSiteUrlAuthor() {
82 return StringUtils.isNotEmpty(this.siteUrlAuthor);
83 }
84
85 }