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 java.util.Objects;
23
24 import org.apache.commons.lang3.StringUtils;
25 import org.apache.sling.api.adapter.Adaptable;
26
27 import io.wcm.handler.url.SiteConfig;
28
29
30
31
32 class UrlConfig {
33
34 private final String siteUrl;
35 private final String siteUrlSecure;
36 private final String siteUrlAuthor;
37
38 UrlConfig(Adaptable adaptable) {
39 SiteConfig config = adaptable.adaptTo(SiteConfig.class);
40 if (config != null) {
41 this.siteUrl = config.siteUrl();
42 this.siteUrlSecure = Objects.toString(config.siteUrlSecure(), this.siteUrl);
43 this.siteUrlAuthor = config.siteUrlAuthor();
44 }
45 else {
46 this.siteUrl = null;
47 this.siteUrlSecure = null;
48 this.siteUrlAuthor = null;
49 }
50 }
51
52
53
54
55 public String getSiteUrl() {
56 return this.siteUrl;
57 }
58
59
60
61
62 public String getSiteUrlSecure() {
63 return this.siteUrlSecure;
64 }
65
66
67
68
69 public String getSiteUrlAuthor() {
70 return this.siteUrlAuthor;
71 }
72
73
74
75
76 public boolean isValid() {
77 return StringUtils.isNotEmpty(this.siteUrl);
78 }
79
80
81
82
83 public boolean hasSiteUrlAuthor() {
84 return StringUtils.isNotEmpty(this.siteUrlAuthor);
85 }
86
87 }