Source Code Cross Referenced for ThemeImpl.java in  » Portal » liferay-portal-4.4.2 » com » liferay » portal » model » impl » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » liferay portal 4.4.2 » com.liferay.portal.model.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /**
002:         * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
003:         *
004:         * Permission is hereby granted, free of charge, to any person obtaining a copy
005:         * of this software and associated documentation files (the "Software"), to deal
006:         * in the Software without restriction, including without limitation the rights
007:         * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
008:         * copies of the Software, and to permit persons to whom the Software is
009:         * furnished to do so, subject to the following conditions:
010:         *
011:         * The above copyright notice and this permission notice shall be included in
012:         * all copies or substantial portions of the Software.
013:         *
014:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
015:         * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
016:         * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
017:         * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
018:         * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
019:         * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
020:         * SOFTWARE.
021:         */package com.liferay.portal.model.impl;
022:
023:        import com.liferay.portal.kernel.util.StringMaker;
024:        import com.liferay.portal.kernel.util.StringPool;
025:        import com.liferay.portal.kernel.util.Validator;
026:        import com.liferay.portal.model.Theme;
027:        import com.liferay.portal.theme.ThemeCompanyLimit;
028:        import com.liferay.portal.theme.ThemeGroupLimit;
029:        import com.liferay.portal.util.PortalUtil;
030:        import com.liferay.portal.util.PropsValues;
031:        import com.liferay.portal.velocity.VelocityResourceListener;
032:        import com.liferay.util.ListUtil;
033:
034:        import java.util.Collections;
035:        import java.util.HashMap;
036:        import java.util.List;
037:        import java.util.Map;
038:        import java.util.Properties;
039:
040:        import org.apache.commons.logging.Log;
041:        import org.apache.commons.logging.LogFactory;
042:
043:        /**
044:         * <a href="ThemeImpl.java.html"><b><i>View Source</i></b></a>
045:         *
046:         * @author Brian Wing Shun Chan
047:         *
048:         */
049:        public class ThemeImpl extends PluginBaseImpl implements  Theme {
050:
051:            public static final String PLUGIN_TYPE = "theme";
052:
053:            public static String getDefaultRegularThemeId() {
054:                return _DEFAULT_REGULAR_THEME_ID;
055:            }
056:
057:            public static String getDefaultWapThemeId() {
058:                return _DEFAULT_WAP_THEME_ID;
059:            }
060:
061:            public ThemeImpl() {
062:            }
063:
064:            public ThemeImpl(String themeId) {
065:                _themeId = themeId;
066:            }
067:
068:            public ThemeImpl(String themeId, String name) {
069:                _themeId = themeId;
070:                _name = name;
071:            }
072:
073:            public String getThemeId() {
074:                return _themeId;
075:            }
076:
077:            public String getPluginId() {
078:                return getThemeId();
079:            }
080:
081:            public String getPluginType() {
082:                return PLUGIN_TYPE;
083:            }
084:
085:            public ThemeCompanyLimit getThemeCompanyLimit() {
086:                return _themeCompanyLimit;
087:            }
088:
089:            public void setThemeCompanyLimit(ThemeCompanyLimit themeCompanyLimit) {
090:                _themeCompanyLimit = themeCompanyLimit;
091:            }
092:
093:            public boolean isCompanyAvailable(long companyId) {
094:                return isAvailable(getThemeCompanyLimit(), companyId);
095:            }
096:
097:            public ThemeGroupLimit getThemeGroupLimit() {
098:                return _themeGroupLimit;
099:            }
100:
101:            public void setThemeGroupLimit(ThemeGroupLimit themeGroupLimit) {
102:                _themeGroupLimit = themeGroupLimit;
103:            }
104:
105:            public boolean isGroupAvailable(long groupId) {
106:                return isAvailable(getThemeGroupLimit(), groupId);
107:            }
108:
109:            public long getTimestamp() {
110:                return _timestamp;
111:            }
112:
113:            public void setTimestamp(long timestamp) {
114:                _timestamp = timestamp;
115:            }
116:
117:            public String getName() {
118:                return _name;
119:            }
120:
121:            public void setName(String name) {
122:                _name = name;
123:            }
124:
125:            public String getRootPath() {
126:                return _rootPath;
127:            }
128:
129:            public void setRootPath(String rootPath) {
130:                _rootPath = rootPath;
131:            }
132:
133:            public String getTemplatesPath() {
134:                return _templatesPath;
135:            }
136:
137:            public void setTemplatesPath(String templatesPath) {
138:                _templatesPath = templatesPath;
139:            }
140:
141:            public String getCssPath() {
142:                return _cssPath;
143:            }
144:
145:            public void setCssPath(String cssPath) {
146:                _cssPath = cssPath;
147:            }
148:
149:            public String getImagesPath() {
150:                return _imagesPath;
151:            }
152:
153:            public void setImagesPath(String imagesPath) {
154:                _imagesPath = imagesPath;
155:            }
156:
157:            public String getJavaScriptPath() {
158:                return _javaScriptPath;
159:            }
160:
161:            public void setJavaScriptPath(String javaScriptPath) {
162:                _javaScriptPath = javaScriptPath;
163:            }
164:
165:            public String getVirtualPath() {
166:                return _virtualPath;
167:            }
168:
169:            public void setVirtualPath(String virtualPath) {
170:                if (_warFile && Validator.isNull(virtualPath)) {
171:                    virtualPath = PropsValues.THEME_VIRTUAL_PATH;
172:                }
173:
174:                _virtualPath = virtualPath;
175:            }
176:
177:            public String getTemplateExtension() {
178:                return _templateExtension;
179:            }
180:
181:            public void setTemplateExtension(String templateExtension) {
182:                _templateExtension = templateExtension;
183:            }
184:
185:            public Properties getSettings() {
186:                return _settings;
187:            }
188:
189:            public String getSetting(String key) {
190:                return _settings.getProperty(key);
191:            }
192:
193:            public void setSetting(String key, String value) {
194:                _settings.setProperty(key, value);
195:            }
196:
197:            public boolean getWapTheme() {
198:                return _wapTheme;
199:            }
200:
201:            public boolean isWapTheme() {
202:                return _wapTheme;
203:            }
204:
205:            public void setWapTheme(boolean wapTheme) {
206:                _wapTheme = wapTheme;
207:            }
208:
209:            public List getColorSchemes() {
210:                List colorSchemes = ListUtil.fromCollection(_colorSchemesMap
211:                        .values());
212:
213:                Collections.sort(colorSchemes);
214:
215:                return colorSchemes;
216:            }
217:
218:            public Map getColorSchemesMap() {
219:                return _colorSchemesMap;
220:            }
221:
222:            public boolean hasColorSchemes() {
223:                if (_colorSchemesMap.size() > 0) {
224:                    return true;
225:                } else {
226:                    return false;
227:                }
228:            }
229:
230:            public String getServletContextName() {
231:                return _servletContextName;
232:            }
233:
234:            public void setServletContextName(String servletContextName) {
235:                _servletContextName = servletContextName;
236:
237:                if (Validator.isNotNull(_servletContextName)) {
238:                    _warFile = true;
239:                } else {
240:                    _warFile = false;
241:                }
242:            }
243:
244:            public boolean getWARFile() {
245:                return _warFile;
246:            }
247:
248:            public boolean isWARFile() {
249:                return _warFile;
250:            }
251:
252:            public String getContextPath() {
253:                String virtualPath = getVirtualPath();
254:
255:                if (Validator.isNotNull(virtualPath)) {
256:                    return virtualPath;
257:                }
258:
259:                if (isWARFile()) {
260:                    StringMaker sm = new StringMaker();
261:
262:                    sm.append(StringPool.SLASH);
263:                    sm.append(getServletContextName());
264:
265:                    return sm.toString();
266:                } else {
267:                    return PortalUtil.getPathContext();
268:                }
269:            }
270:
271:            public boolean getLoadFromServletContext() {
272:                return _loadFromServletContext;
273:            }
274:
275:            public boolean isLoadFromServletContext() {
276:                return _loadFromServletContext;
277:            }
278:
279:            public void setLoadFromServletContext(boolean loadFromServletContext) {
280:                _loadFromServletContext = loadFromServletContext;
281:            }
282:
283:            public String getVelocityResourceListener() {
284:                if (_loadFromServletContext) {
285:                    return VelocityResourceListener.SERVLET_SEPARATOR;
286:                } else {
287:                    return VelocityResourceListener.THEME_LOADER_SEPARATOR;
288:                }
289:            }
290:
291:            public int compareTo(Object obj) {
292:                if (obj == null) {
293:                    return -1;
294:                }
295:
296:                Theme theme = (Theme) obj;
297:
298:                return getName().compareTo(theme.getName());
299:            }
300:
301:            public boolean equals(Object obj) {
302:                if (obj == null) {
303:                    return false;
304:                }
305:
306:                Theme theme = null;
307:
308:                try {
309:                    theme = (Theme) obj;
310:                } catch (ClassCastException cce) {
311:                    return false;
312:                }
313:
314:                String themeId = theme.getThemeId();
315:
316:                if (getThemeId().equals(themeId)) {
317:                    return true;
318:                } else {
319:                    return false;
320:                }
321:            }
322:
323:            protected boolean isAvailable(ThemeCompanyLimit limit, long id) {
324:                boolean available = true;
325:
326:                if (_log.isDebugEnabled()) {
327:                    _log.debug("Check if theme " + getThemeId()
328:                            + " is available for " + id);
329:                }
330:
331:                if (limit != null) {
332:                    List includes = limit.getIncludes();
333:                    List excludes = limit.getExcludes();
334:
335:                    if ((includes.size() != 0) && (excludes.size() != 0)) {
336:
337:                        // Since includes and excludes are specified, check to
338:                        // make sure the current company id is included and also
339:                        // not excluded
340:
341:                        if (_log.isDebugEnabled()) {
342:                            _log.debug("Check includes and excludes");
343:                        }
344:
345:                        available = limit.isIncluded(id);
346:
347:                        if (available) {
348:                            available = !limit.isExcluded(id);
349:                        }
350:                    } else if ((includes.size() == 0) && (excludes.size() != 0)) {
351:
352:                        // Since no includes are specified, check to make sure
353:                        // the current company id is not excluded
354:
355:                        if (_log.isDebugEnabled()) {
356:                            _log.debug("Check excludes");
357:                        }
358:
359:                        available = !limit.isExcluded(id);
360:                    } else if ((includes.size() != 0) && (excludes.size() == 0)) {
361:
362:                        // Since no excludes are specified, check to make sure
363:                        // the current company id is included
364:
365:                        if (_log.isDebugEnabled()) {
366:                            _log.debug("Check includes");
367:                        }
368:
369:                        available = limit.isIncluded(id);
370:                    } else {
371:
372:                        // Since no includes or excludes are specified, this
373:                        // theme is available for every company
374:
375:                        if (_log.isDebugEnabled()) {
376:                            _log.debug("No includes or excludes set");
377:                        }
378:
379:                        available = true;
380:                    }
381:                }
382:
383:                if (_log.isDebugEnabled()) {
384:                    _log.debug("Theme " + getThemeId() + " is "
385:                            + (!available ? "NOT " : "") + "available for "
386:                            + id);
387:                }
388:
389:                return available;
390:            }
391:
392:            private static final String _DEFAULT_REGULAR_THEME_ID = PortalUtil
393:                    .getJsSafePortletId(PropsValues.DEFAULT_REGULAR_THEME_ID);
394:
395:            private static final String _DEFAULT_WAP_THEME_ID = PortalUtil
396:                    .getJsSafePortletId(PropsValues.DEFAULT_WAP_THEME_ID);
397:
398:            private static Log _log = LogFactory.getLog(ThemeImpl.class);
399:
400:            private String _themeId;
401:            private ThemeCompanyLimit _themeCompanyLimit;
402:            private ThemeGroupLimit _themeGroupLimit;
403:            private long _timestamp;
404:            private String _name;
405:            private String _rootPath = "/";
406:            private String _templatesPath = "${root-path}/templates";
407:            private String _cssPath = "${root-path}/css";
408:            private String _imagesPath = "${root-path}/images";
409:            private String _javaScriptPath = "${root-path}/javascript";
410:            private String _virtualPath = StringPool.BLANK;
411:            private String _templateExtension = "vm";
412:            private Properties _settings = new Properties();
413:            private boolean _wapTheme;
414:            private Map _colorSchemesMap = new HashMap();
415:            private String _servletContextName = StringPool.BLANK;
416:            private boolean _warFile;
417:            private boolean _loadFromServletContext;
418:
419:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.