View Javadoc

1   /**
2    * This file Copyright (c) 2008-2012 Magnolia International
3    * Ltd.  (http://www.magnolia-cms.com). All rights reserved.
4    *
5    *
6    * This file is dual-licensed under both the Magnolia
7    * Network Agreement and the GNU General Public License.
8    * You may elect to use one or the other of these licenses.
9    *
10   * This file is distributed in the hope that it will be
11   * useful, but AS-IS and WITHOUT ANY WARRANTY; without even the
12   * implied warranty of MERCHANTABILITY or FITNESS FOR A
13   * PARTICULAR PURPOSE, TITLE, or NONINFRINGEMENT.
14   * Redistribution, except as permitted by whichever of the GPL
15   * or MNA you select, is prohibited.
16   *
17   * 1. For the GPL license (GPL), you can redistribute and/or
18   * modify this file under the terms of the GNU General
19   * Public License, Version 3, as published by the Free Software
20   * Foundation.  You should have received a copy of the GNU
21   * General Public License, Version 3 along with this program;
22   * if not, write to the Free Software Foundation, Inc., 51
23   * Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24   *
25   * 2. For the Magnolia Network Agreement (MNA), this file
26   * and the accompanying materials are made available under the
27   * terms of the MNA which accompanies this distribution, and
28   * is available at http://www.magnolia-cms.com/mna.html
29   *
30   * Any modifications to this file must keep this entire header
31   * intact.
32   *
33   */
34  package info.magnolia.module.templatingkit.sites;
35  
36  import info.magnolia.cms.beans.config.URI2RepositoryMapping;
37  import info.magnolia.cms.i18n.I18nContentSupport;
38  import info.magnolia.module.templatingkit.resources.Resource;
39  import info.magnolia.module.templatingkit.style.ThemeReference;
40  
41  import java.util.ArrayList;
42  import java.util.Collection;
43  import java.util.HashMap;
44  import java.util.List;
45  import java.util.Map;
46  
47  
48  /**
49   * Site Configuration Bean.
50   * Default Site configuration merge with the specific user defined site.
51   * <ul>
52   *  <li>TemplateSettings: define the global area settings (under prototype) and template available for the default site setting</li>
53   *  <li>Theme: define the Base Theme class implementation </li>
54   * </ul>
55   * These two sections are also displayed under the Template kit menu / Site Definition / default
56   *
57   * @version $Id$
58   */
59  public class Site {
60  
61      private String name;
62  
63      private boolean enabled = true;
64  
65      private Map<String, Object> parameters = new HashMap<String, Object>();
66  
67      private TemplateSettings templates = new TemplateSettings();
68  
69      private ThemeReference theme = new ThemeReference();
70  
71      private List<Resource> jsFiles = new ArrayList<Resource>();
72  
73      private I18nContentSupport i18n;
74  
75      private List<Domain> domains = new ArrayList<Domain>();
76  
77      private Map<String, URI2RepositoryMapping> mappings = new HashMap<String, URI2RepositoryMapping>();
78  
79      private Map<String, Site> variations = new HashMap<String, Site>();
80  
81      public ThemeReference getTheme() {
82          return theme;
83      }
84  
85      public void setTheme(ThemeReference ref) {
86          this.theme = ref;
87      }
88  
89      public List<Resource> getJsFiles() {
90          return this.jsFiles;
91      }
92  
93      public void setJsFiles(List<Resource> jsFiles) {
94          this.jsFiles = jsFiles;
95      }
96  
97      public void addJsFile(Resource jsFile) {
98          this.jsFiles.add(jsFile);
99      }
100 
101     public TemplateSettings getTemplates() {
102         return this.templates;
103     }
104 
105     public void setTemplates(TemplateSettings templates) {
106         this.templates = templates;
107     }
108 
109     public I18nContentSupport getI18n() {
110         return this.i18n;
111     }
112 
113     public void setI18n(I18nContentSupport i18n) {
114         this.i18n = i18n;
115     }
116 
117     public String getName() {
118         return this.name;
119     }
120 
121     public void setName(String name) {
122         this.name = name;
123     }
124 
125     public boolean isEnabled() {
126         return this.enabled;
127     }
128 
129     public void setEnabled(boolean enabled) {
130         this.enabled = enabled;
131     }
132 
133     public Map<String, Object> getParameters() {
134         return this.parameters;
135     }
136 
137     public void setParameters(Map<String, Object> parameters) {
138         this.parameters = parameters;
139     }
140 
141     public void addParameter(String name, Object parameter) {
142         this.parameters.put(name, parameter);
143     }
144 
145     public Collection<Domain> getDomains() {
146         return domains;
147     }
148 
149     public void setDomains(Collection<Domain> domains) {
150         this.domains.clear();
151         this.domains.addAll(domains);
152     }
153 
154     public void addDomain(Domain domain) {
155         this.domains.add(domain);
156     }
157 
158     public Map<String, URI2RepositoryMapping> getMappings() {
159         return this.mappings;
160     }
161 
162     public void setMappings(Map<String, URI2RepositoryMapping> mappings) {
163         this.mappings = mappings;
164     }
165 
166     public void addMapping(String mappingName, URI2RepositoryMapping mapping) {
167         this.mappings.put(mappingName, mapping);
168     }
169 
170     public Map<String, Site> getVariations() {
171         return variations;
172     }
173 
174     public void setVariations(Map<String, Site> variations) {
175         this.variations = variations;
176     }
177 
178     public void addVariation(String variationName, Site site) {
179         this.variations.put(variationName, site);
180     }
181 
182     @Override
183     public String toString() {
184         return this.name
185         + (this.domains == null ? "" : (", Domains:" + this.domains))
186         + (this.mappings == null ? "" : (", Mappings:" + this.mappings))
187         + (this.i18n == null ? "" : (" I18n:" + this.i18n));
188     }
189 }