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.apache.myfaces.tobago.internal.util.Deprecation;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  import java.net.URL;
28  import java.util.ArrayList;
29  import java.util.List;
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 List<ThemeImpl> themeDefinitions;
48    private URL url;
49  
50    public TobagoConfigFragment() {
51      before = new ArrayList<String>();
52      after = new ArrayList<String>();
53      supportedThemeNames = new ArrayList<String>();
54      resourceDirs = new ArrayList<String>();
55      themeDefinitions = new ArrayList<ThemeImpl>();
56    }
57  
58    public void addSupportedThemeName(String name) {
59      supportedThemeNames.add(name);
60    }
61  
62    public List<String> getSupportedThemeNames() {
63      return supportedThemeNames;
64    }
65  
66    public String getDefaultThemeName() {
67      return defaultThemeName;
68    }
69  
70    public void setDefaultThemeName(String defaultThemeName) {
71      this.defaultThemeName = defaultThemeName;
72    }
73  
74    public void addResourceDir(String resourceDir) {
75      if (!resourceDirs.contains(resourceDir)) {
76        if (LOG.isInfoEnabled()) {
77          LOG.info("adding resourceDir = '{}'", resourceDir);
78        }
79        resourceDirs.add(resourceDir);
80      }
81    }
82  
83    public List<String> getResourceDirs() {
84      return resourceDirs;
85    }
86  
87    /** @deprecated since 1.5.0 */
88    @Deprecated
89    public void setAjaxEnabled(String value) {
90      Deprecation.LOG.error("Ajax is always enabled!");
91    }
92  
93    public RenderersConfig getRenderersConfig() {
94      return renderersConfig;
95    }
96  
97    public void setRenderersConfig(RenderersConfig renderersConfig) {
98      this.renderersConfig = renderersConfig;
99    }
100 
101   public String getName() {
102     return name;
103   }
104 
105   public void setName(String name) {
106     this.name = name;
107   }
108 
109   public List<String> getBefore() {
110     return before;
111   }
112 
113   public void addBefore(String name) {
114     before.add(name);
115   }
116 
117   public List<String> getAfter() {
118     return after;
119   }
120 
121   public void addAfter(String name) {
122     after.add(name);
123   }
124 
125   public void addThemeDefinition(ThemeImpl theme) {
126     themeDefinitions.add(theme);
127   }
128 
129   public List<ThemeImpl> getThemeDefinitions() {
130     return themeDefinitions;
131   }
132 
133   public Boolean getCreateSessionSecret() {
134     return createSessionSecret;
135   }
136 
137   public void setCreateSessionSecret(String createSessionSecret) {
138     this.createSessionSecret = Boolean.valueOf(createSessionSecret);
139   }
140 
141   public Boolean getCheckSessionSecret() {
142     return checkSessionSecret;
143   }
144 
145   public void setCheckSessionSecret(String checkSessionSecret) {
146     this.checkSessionSecret = Boolean.valueOf(checkSessionSecret);
147   }
148 
149   public Boolean getPreventFrameAttacks() {
150     return preventFrameAttacks;
151   }
152 
153   public void setPreventFrameAttacks(Boolean preventFrameAttacks) {
154     this.preventFrameAttacks = preventFrameAttacks;
155   }
156 
157   public ContentSecurityPolicy getContentSecurityPolicy() {
158     return contentSecurityPolicy;
159   }
160 
161   public void setContentSecurityPolicy(ContentSecurityPolicy contentSecurityPolicy) {
162     this.contentSecurityPolicy = contentSecurityPolicy;
163   }
164 
165   /** @deprecated since 1.5.0 */
166   @Deprecated
167   public void setFixResourceOrder(String value) {
168     Deprecation.LOG.error("Config fix-resource-order not longer supported. (Is always activated).");
169   }
170 
171   /** @deprecated since 1.5.0 */
172   @Deprecated
173   public void setFixLayoutTransparency(String value) {
174     Deprecation.LOG.error("Config fix-layout-transparency not longer supported. (Is always activated).");
175   }
176 
177   public URL getUrl() {
178     return url;
179   }
180 
181   public void setUrl(URL url) {
182     this.url = url;
183   }
184 
185   @Override
186   public String toString() {
187     return name != null ? name : "(id=" + System.identityHashCode(this) + ")";
188   }
189 }