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.HashMap;
29  import java.util.List;
30  import java.util.Map;
31  import java.util.Properties;
32  
33  public class TobagoConfigFragment {
34  
35    private static final Logger LOG = LoggerFactory.getLogger(TobagoConfigFragment.class);
36  
37    private String name;
38    private List<String> before;
39    private List<String> after;
40  
41    private List<String> supportedThemeNames;
42    private String defaultThemeName;
43    private List<String> resourceDirs;
44    private RenderersConfig renderersConfig;
45    private Boolean createSessionSecret;
46    private Boolean checkSessionSecret;
47    private Boolean preventFrameAttacks;
48    private ContentSecurityPolicy contentSecurityPolicy;
49    private Boolean setNosniffHeader;
50    private List<ThemeImpl> themeDefinitions;
51    private URL url;
52    private String sanitizerClass;
53    private Properties sanitizerProperties;
54    private Boolean autoAccessKeyFromLabel;
55    private Boolean classicDateTimePicker;
56    private Map<String, String> mimeTypes;
57  
58    public TobagoConfigFragment() {
59      before = new ArrayList<String>();
60      after = new ArrayList<String>();
61      supportedThemeNames = new ArrayList<String>();
62      resourceDirs = new ArrayList<String>();
63      themeDefinitions = new ArrayList<ThemeImpl>();
64      mimeTypes = new HashMap<String, String>();
65    }
66  
67    public void addSupportedThemeName(final String name) {
68      supportedThemeNames.add(name);
69    }
70  
71    public List<String> getSupportedThemeNames() {
72      return supportedThemeNames;
73    }
74  
75    public String getDefaultThemeName() {
76      return defaultThemeName;
77    }
78  
79    public void setDefaultThemeName(final String defaultThemeName) {
80      this.defaultThemeName = defaultThemeName;
81    }
82  
83    public void addResourceDir(final String resourceDir) {
84      if (!resourceDirs.contains(resourceDir)) {
85        if (LOG.isInfoEnabled()) {
86          LOG.info("adding resourceDir = '{}'", resourceDir);
87        }
88        resourceDirs.add(resourceDir);
89      }
90    }
91  
92    public List<String> getResourceDirs() {
93      return resourceDirs;
94    }
95  
96    public RenderersConfig getRenderersConfig() {
97      return renderersConfig;
98    }
99  
100   public void setRenderersConfig(final RenderersConfig renderersConfig) {
101     this.renderersConfig = renderersConfig;
102   }
103 
104   public String getName() {
105     return name;
106   }
107 
108   public void setName(final String name) {
109     this.name = name;
110   }
111 
112   public List<String> getBefore() {
113     return before;
114   }
115 
116   public void addBefore(final String name) {
117     before.add(name);
118   }
119 
120   public List<String> getAfter() {
121     return after;
122   }
123 
124   public void addAfter(final String name) {
125     after.add(name);
126   }
127 
128   public void addThemeDefinition(final ThemeImpl theme) {
129     themeDefinitions.add(theme);
130   }
131 
132   public List<ThemeImpl> getThemeDefinitions() {
133     return themeDefinitions;
134   }
135 
136   public Boolean getCreateSessionSecret() {
137     return createSessionSecret;
138   }
139 
140   public void setCreateSessionSecret(final String createSessionSecret) {
141     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
142   }
143 
144   public Boolean getCheckSessionSecret() {
145     return checkSessionSecret;
146   }
147 
148   public void setCheckSessionSecret(final String checkSessionSecret) {
149     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
150   }
151 
152   public Boolean getPreventFrameAttacks() {
153     return preventFrameAttacks;
154   }
155 
156   public void setPreventFrameAttacks(final Boolean preventFrameAttacks) {
157     this.preventFrameAttacks = preventFrameAttacks;
158   }
159 
160   public ContentSecurityPolicy getContentSecurityPolicy() {
161     return contentSecurityPolicy;
162   }
163 
164   public void setContentSecurityPolicy(final ContentSecurityPolicy contentSecurityPolicy) {
165     this.contentSecurityPolicy = contentSecurityPolicy;
166   }
167 
168   public Boolean getSetNosniffHeader() {
169     return setNosniffHeader;
170   }
171 
172   public void setSetNosniffHeader(final Boolean setNosniffHeader) {
173     this.setNosniffHeader = setNosniffHeader;
174   }
175 
176   public URL getUrl() {
177     return url;
178   }
179 
180   public void setUrl(final URL url) {
181     this.url = url;
182   }
183 
184   public String getSanitizerClass() {
185     return sanitizerClass;
186   }
187 
188   public void setSanitizerClass(String sanitizerClass) {
189     this.sanitizerClass = sanitizerClass;
190   }
191 
192   public Properties getSanitizerProperties() {
193     return sanitizerProperties;
194   }
195 
196   public void setSanitizerProperties(Properties sanitizerProperties) {
197     this.sanitizerProperties = sanitizerProperties;
198   }
199 
200   public Boolean getAutoAccessKeyFromLabel() {
201     return autoAccessKeyFromLabel;
202   }
203 
204   public void setAutoAccessKeyFromLabel(Boolean autoAccessKeyFromLabel) {
205     this.autoAccessKeyFromLabel = autoAccessKeyFromLabel;
206   }
207 
208   public Boolean getClassicDateTimePicker() {
209     return classicDateTimePicker;
210   }
211 
212   public void setClassicDateTimePicker(String classicDateTimePicker) {
213     this.classicDateTimePicker = Boolean.valueOf(classicDateTimePicker);
214   }
215 
216   public void addMimeType(String extension, String type) {
217     this.mimeTypes.put(extension, type);
218   }
219 
220   public Map<String, String> getMimeTypes() {
221     return mimeTypes;
222   }
223 
224   @Override
225   public String toString() {
226     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
227   }
228 }