View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.myfaces.tobago.internal.config;
21  
22  import org.apache.myfaces.tobago.context.ThemeImpl;
23  import org.slf4j.Logger;
24  import org.slf4j.LoggerFactory;
25  
26  import java.net.URL;
27  import java.util.ArrayList;
28  import java.util.List;
29  import java.util.Properties;
30  
31  public class TobagoConfigFragment {
32  
33    private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigFragment.class);
34  
35    private String name;
36    private List<String> before;
37    private List<String> after;
38  
39    private List<String> supportedThemeNames;
40    private String defaultThemeName;
41    private List<String> resourceDirs;
42    private RenderersConfig renderersConfig;
43    private Boolean createSessionSecret;
44    private Boolean checkSessionSecret;
45    private Boolean preventFrameAttacks;
46    private ContentSecurityPolicy contentSecurityPolicy;
47    private Boolean setNosniffHeader;
48    private List<ThemeImpl> themeDefinitions;
49    private URL url;
50    private String sanitizerClass;
51    private Properties sanitizerProperties;
52    private Boolean autoAccessKeyFromLabel;
53    private Boolean classicDateTimePicker;
54  
55    public TobagoConfigFragment() {
56      before = new ArrayList<String>();
57      after = new ArrayList<String>();
58      supportedThemeNames = new ArrayList<String>();
59      resourceDirs = new ArrayList<String>();
60      themeDefinitions = new ArrayList<ThemeImpl>();
61    }
62  
63    public void addSupportedThemeName(final String name) {
64      supportedThemeNames.add(name);
65    }
66  
67    public List<String> getSupportedThemeNames() {
68      return supportedThemeNames;
69    }
70  
71    public String getDefaultThemeName() {
72      return defaultThemeName;
73    }
74  
75    public void setDefaultThemeName(final String defaultThemeName) {
76      this.defaultThemeName = defaultThemeName;
77    }
78  
79    public void addResourceDir(final String resourceDir) {
80      if (!resourceDirs.contains(resourceDir)) {
81        if (LOG.isInfoEnabled()) {
82          LOG.info("adding resourceDir = '{}'", resourceDir);
83        }
84        resourceDirs.add(resourceDir);
85      }
86    }
87  
88    public List<String> getResourceDirs() {
89      return resourceDirs;
90    }
91  
92    public RenderersConfig getRenderersConfig() {
93      return renderersConfig;
94    }
95  
96    public void setRenderersConfig(final RenderersConfig renderersConfig) {
97      this.renderersConfig = renderersConfig;
98    }
99  
100   public String getName() {
101     return name;
102   }
103 
104   public void setName(final String name) {
105     this.name = name;
106   }
107 
108   public List<String> getBefore() {
109     return before;
110   }
111 
112   public void addBefore(final String name) {
113     before.add(name);
114   }
115 
116   public List<String> getAfter() {
117     return after;
118   }
119 
120   public void addAfter(final String name) {
121     after.add(name);
122   }
123 
124   public void addThemeDefinition(final ThemeImpl theme) {
125     themeDefinitions.add(theme);
126   }
127 
128   public List<ThemeImpl> getThemeDefinitions() {
129     return themeDefinitions;
130   }
131 
132   public Boolean getCreateSessionSecret() {
133     return createSessionSecret;
134   }
135 
136   public void setCreateSessionSecret(final String createSessionSecret) {
137     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
138   }
139 
140   public Boolean getCheckSessionSecret() {
141     return checkSessionSecret;
142   }
143 
144   public void setCheckSessionSecret(final String checkSessionSecret) {
145     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
146   }
147 
148   public Boolean getPreventFrameAttacks() {
149     return preventFrameAttacks;
150   }
151 
152   public void setPreventFrameAttacks(final Boolean preventFrameAttacks) {
153     this.preventFrameAttacks = preventFrameAttacks;
154   }
155 
156   public ContentSecurityPolicy getContentSecurityPolicy() {
157     return contentSecurityPolicy;
158   }
159 
160   public void setContentSecurityPolicy(final ContentSecurityPolicy contentSecurityPolicy) {
161     this.contentSecurityPolicy = contentSecurityPolicy;
162   }
163 
164   public Boolean getSetNosniffHeader() {
165     return setNosniffHeader;
166   }
167 
168   public void setSetNosniffHeader(final Boolean setNosniffHeader) {
169     this.setNosniffHeader = setNosniffHeader;
170   }
171 
172   public URL getUrl() {
173     return url;
174   }
175 
176   public void setUrl(final URL url) {
177     this.url = url;
178   }
179 
180   public String getSanitizerClass() {
181     return sanitizerClass;
182   }
183 
184   public void setSanitizerClass(String sanitizerClass) {
185     this.sanitizerClass = sanitizerClass;
186   }
187 
188   public Properties getSanitizerProperties() {
189     return sanitizerProperties;
190   }
191 
192   public void setSanitizerProperties(Properties sanitizerProperties) {
193     this.sanitizerProperties = sanitizerProperties;
194   }
195 
196   public Boolean getAutoAccessKeyFromLabel() {
197     return autoAccessKeyFromLabel;
198   }
199 
200   public void setAutoAccessKeyFromLabel(Boolean autoAccessKeyFromLabel) {
201     this.autoAccessKeyFromLabel = autoAccessKeyFromLabel;
202   }
203 
204   public Boolean getClassicDateTimePicker() {
205     return classicDateTimePicker;
206   }
207 
208   public void setClassicDateTimePicker(String classicDateTimePicker) {
209     this.classicDateTimePicker = Boolean.valueOf(classicDateTimePicker);
210   }
211 
212   @Override
213   public String toString() {
214     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
215   }
216 }