Source Code Cross Referenced for PageImpl.java in  » Portal » jetspeed-2.1.3 » org » apache » jetspeed » om » page » 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 » jetspeed 2.1.3 » org.apache.jetspeed.om.page.impl 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *      http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         */
017:        package org.apache.jetspeed.om.page.impl;
018:
019:        import java.util.Collection;
020:        import java.util.List;
021:
022:        import org.apache.jetspeed.JetspeedActions;
023:        import org.apache.jetspeed.om.folder.Folder;
024:        import org.apache.jetspeed.om.folder.MenuDefinition;
025:        import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
026:        import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
027:        import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
028:        import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
029:        import org.apache.jetspeed.om.page.Fragment;
030:        import org.apache.jetspeed.om.page.Page;
031:        import org.apache.jetspeed.om.page.PageMetadataImpl;
032:        import org.apache.jetspeed.page.document.impl.DocumentImpl;
033:        import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
034:        import org.apache.ojb.broker.core.proxy.ProxyHelper;
035:
036:        /**
037:         * PageImpl
038:         *
039:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
040:         * @version $Id$
041:         */
042:        public class PageImpl extends DocumentImpl implements  Page {
043:            private Collection fragment;
044:            private String skin;
045:            private String defaultLayoutDecorator;
046:            private String defaultPortletDecorator;
047:            private List menus;
048:
049:            private PageMenuDefinitionList menuDefinitions;
050:            private FragmentImpl removedFragment;
051:
052:            public PageImpl() {
053:                super (new PageSecurityConstraintsImpl());
054:            }
055:
056:            /**
057:             * accessMenus
058:             *
059:             * Access mutable persistent collection member for List wrappers.
060:             *
061:             * @return persistent collection
062:             */
063:            List accessMenus() {
064:                // create initial collection if necessary
065:                if (menus == null) {
066:                    menus = DatabasePageManagerUtils.createList();
067:                    ;
068:                }
069:                return menus;
070:            }
071:
072:            /* (non-Javadoc)
073:             * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
074:             */
075:            public void resetCachedSecurityConstraints() {
076:                // propagate to super and fragments
077:                super .resetCachedSecurityConstraints();
078:                FragmentImpl rootFragment = (FragmentImpl) getRootFragment();
079:                if (rootFragment != null) {
080:                    rootFragment.resetCachedSecurityConstraints();
081:                }
082:            }
083:
084:            /* (non-Javadoc)
085:             * @see org.apache.jetspeed.page.document.impl.NodeImpl#newPageMetadata(java.util.Collection)
086:             */
087:            public PageMetadataImpl newPageMetadata(Collection fields) {
088:                PageMetadataImpl pageMetadata = new PageMetadataImpl(
089:                        PageMetadataLocalizedFieldImpl.class);
090:                pageMetadata.setFields(fields);
091:                return pageMetadata;
092:            }
093:
094:            /* (non-Javadoc)
095:             * @see org.apache.jetspeed.om.page.Page#getSkin()
096:             */
097:            public String getSkin() {
098:                return skin;
099:            }
100:
101:            /* (non-Javadoc)
102:             * @see org.apache.jetspeed.om.page.Page#setSkin(java.lang.String)
103:             */
104:            public void setSkin(String skinName) {
105:                this .skin = skinName;
106:            }
107:
108:            /* (non-Javadoc)
109:             * @see org.apache.jetspeed.om.page.Page#getEffectiveDefaultDecorator(java.lang.String)
110:             */
111:            public String getEffectiveDefaultDecorator(String fragmentType) {
112:                // get locally defined decorator
113:                String decorator = getDefaultDecorator(fragmentType);
114:                if (decorator == null) {
115:                    // delegate to parent folder
116:                    Folder parentFolder = (Folder) ProxyHelper
117:                            .getRealObject(getParent());
118:                    if (parentFolder != null) {
119:                        return parentFolder
120:                                .getEffectiveDefaultDecorator(fragmentType);
121:                    }
122:                }
123:                return decorator;
124:            }
125:
126:            /* (non-Javadoc)
127:             * @see org.apache.jetspeed.om.page.Page#getDefaultDecorator(java.lang.String)
128:             */
129:            public String getDefaultDecorator(String fragmentType) {
130:                // retrieve supported decorator types
131:                if (fragmentType != null) {
132:                    if (fragmentType.equals(Fragment.LAYOUT)) {
133:                        return defaultLayoutDecorator;
134:                    }
135:                    if (fragmentType.equals(Fragment.PORTLET)) {
136:                        return defaultPortletDecorator;
137:                    }
138:                }
139:                return null;
140:            }
141:
142:            /* (non-Javadoc)
143:             * @see org.apache.jetspeed.om.page.Page#getDefaultDecorator(java.lang.String,java.lang.String)
144:             */
145:            public void setDefaultDecorator(String decoratorName,
146:                    String fragmentType) {
147:                // save supported decorator types
148:                if (fragmentType != null) {
149:                    if (fragmentType.equals(Fragment.LAYOUT)) {
150:                        defaultLayoutDecorator = decoratorName;
151:                    }
152:                    if (fragmentType.equals(Fragment.PORTLET)) {
153:                        defaultPortletDecorator = decoratorName;
154:                    }
155:                }
156:            }
157:
158:            /* (non-Javadoc)
159:             * @see org.apache.jetspeed.om.page.Page#getRootFragment()
160:             */
161:            public Fragment getRootFragment() {
162:                // get singleton fragment; no access checks to
163:                // be made for root fragment
164:                if ((fragment != null) && !fragment.isEmpty()) {
165:                    FragmentImpl rootFragment = (FragmentImpl) fragment
166:                            .iterator().next();
167:                    if (rootFragment.getPage() == null) {
168:                        // set page implementation in root and children fragments
169:                        rootFragment.setPage(this );
170:                    }
171:                    return rootFragment;
172:                }
173:                return null;
174:            }
175:
176:            /* (non-Javadoc)
177:             * @see org.apache.jetspeed.om.page.Page#setRootFragment(org.apache.jetspeed.om.page.Fragment)
178:             */
179:            public void setRootFragment(Fragment fragment) {
180:                // add new or reuse singleton fragment
181:                if (fragment instanceof  FragmentImpl) {
182:                    // create singleton collection or remove existing
183:                    // root fragment and save for reuse
184:                    if (this .fragment == null) {
185:                        this .fragment = DatabasePageManagerUtils.createList();
186:                    } else if (!this .fragment.isEmpty()) {
187:                        removedFragment = (FragmentImpl) this .fragment
188:                                .iterator().next();
189:                        this .fragment.clear();
190:                    }
191:
192:                    // add new fragment or copy configuration
193:                    // from previously removed fragment
194:                    if (removedFragment != null) {
195:                        // reuse previously removed fragment
196:                        FragmentImpl addFragment = (FragmentImpl) fragment;
197:                        fragment = removedFragment;
198:                        removedFragment = null;
199:                        // TODO: move this logic to copy methods on implementations
200:                        fragment.setName(addFragment.getName());
201:                        fragment.setTitle(addFragment.getTitle());
202:                        fragment.setShortTitle(addFragment.getShortTitle());
203:                        fragment.setType(addFragment.getType());
204:                        fragment.setSkin(addFragment.getSkin());
205:                        fragment.setDecorator(addFragment.getDecorator());
206:                        fragment.setState(addFragment.getState());
207:                        fragment.setSecurityConstraints(addFragment
208:                                .getSecurityConstraints());
209:                        fragment.getProperties().clear();
210:                        fragment.getProperties().putAll(
211:                                addFragment.getProperties());
212:                        fragment.setPreferences(addFragment.getPreferences());
213:                        fragment.getFragments().clear();
214:                        fragment.getFragments().addAll(
215:                                addFragment.getFragments());
216:                    }
217:                    this .fragment.add(fragment);
218:
219:                    // set page implementation in root and children fragments
220:                    ((FragmentImpl) fragment).setPage(this );
221:                } else if (fragment == null) {
222:                    // delete existing fragment if required, saving
223:                    // removed fragment for later reuse
224:                    if ((this .fragment != null) && !this .fragment.isEmpty()) {
225:                        removedFragment = (FragmentImpl) this .fragment
226:                                .iterator().next();
227:                        this .fragment.clear();
228:                    }
229:                }
230:            }
231:
232:            /* (non-Javadoc)
233:             * @see org.apache.jetspeed.om.page.Page#getFragmentById(java.lang.String)
234:             */
235:            public Fragment getFragmentById(String id) {
236:                // get fragment by id and check access
237:                FragmentImpl rootFragment = (FragmentImpl) getRootFragment();
238:                if (rootFragment != null) {
239:                    Fragment fragment = rootFragment.getFragmentById(id);
240:                    if (fragment != null) {
241:                        try {
242:                            fragment.checkAccess(JetspeedActions.VIEW);
243:                        } catch (SecurityException se) {
244:                            fragment = null;
245:                        }
246:                    }
247:                    return fragment;
248:                }
249:                return null;
250:            }
251:
252:            /* (non-Javadoc)
253:             * @see org.apache.jetspeed.om.page.Page#removeFragmentById(java.lang.String)
254:             */
255:            public Fragment removeFragmentById(String id) {
256:                // remove fragment by id
257:                FragmentImpl rootFragment = (FragmentImpl) getRootFragment();
258:                if (rootFragment != null) {
259:                    if (rootFragment.getId().equals(id)) {
260:                        setRootFragment(null);
261:                        return rootFragment;
262:                    } else {
263:                        return rootFragment.removeFragmentById(id);
264:                    }
265:                }
266:                return null;
267:            }
268:
269:            /* (non-Javadoc)
270:             * @see org.apache.jetspeed.om.page.Page#getFragmentsByName(java.lang.String)
271:             */
272:            public List getFragmentsByName(String name) {
273:                // get fragments by name and filter by access
274:                FragmentImpl rootFragment = (FragmentImpl) getRootFragment();
275:                if (rootFragment != null) {
276:                    // return immutable filtered fragment list
277:                    return rootFragment.filterFragmentsByAccess(rootFragment
278:                            .getFragmentsByName(name), false);
279:                }
280:                return null;
281:            }
282:
283:            /* (non-Javadoc)
284:             * @see org.apache.jetspeed.om.page.Page#getMenuDefinitions()
285:             */
286:            public List getMenuDefinitions() {
287:                // return mutable menu definition list
288:                // by using list wrapper to manage
289:                // element uniqueness
290:                if (menuDefinitions == null) {
291:                    menuDefinitions = new PageMenuDefinitionList(this );
292:                }
293:                return menuDefinitions;
294:            }
295:
296:            /* (non-Javadoc)
297:             * @see org.apache.jetspeed.om.page.Page#newMenuDefinition()
298:             */
299:            public MenuDefinition newMenuDefinition() {
300:                return new PageMenuDefinitionImpl();
301:            }
302:
303:            /* (non-Javadoc)
304:             * @see org.apache.jetspeed.om.page.Page#newMenuExcludeDefinition()
305:             */
306:            public MenuExcludeDefinition newMenuExcludeDefinition() {
307:                return new PageMenuExcludeDefinitionImpl();
308:            }
309:
310:            /* (non-Javadoc)
311:             * @see org.apache.jetspeed.om.page.Page#newMenuIncludeDefinition()
312:             */
313:            public MenuIncludeDefinition newMenuIncludeDefinition() {
314:                return new PageMenuIncludeDefinitionImpl();
315:            }
316:
317:            /* (non-Javadoc)
318:             * @see org.apache.jetspeed.om.page.Page#newMenuOptionsDefinition()
319:             */
320:            public MenuOptionsDefinition newMenuOptionsDefinition() {
321:                return new PageMenuOptionsDefinitionImpl();
322:            }
323:
324:            /* (non-Javadoc)
325:             * @see org.apache.jetspeed.om.page.Page#newMenuSeparatorDefinition()
326:             */
327:            public MenuSeparatorDefinition newMenuSeparatorDefinition() {
328:                return new PageMenuSeparatorDefinitionImpl();
329:            }
330:
331:            /* (non-Javadoc)
332:             * @see org.apache.jetspeed.om.page.Page#setMenuDefinitions(java.util.List)
333:             */
334:            public void setMenuDefinitions(List definitions) {
335:                // set menu definitions by replacing
336:                // existing entries with new elements if
337:                // new collection is specified
338:                List menuDefinitions = getMenuDefinitions();
339:                if (definitions != menuDefinitions) {
340:                    // replace all menu definitions
341:                    menuDefinitions.clear();
342:                    if (definitions != null) {
343:                        menuDefinitions.addAll(definitions);
344:                    }
345:                }
346:            }
347:
348:            /* (non-Javadoc)
349:             * @see org.apache.jetspeed.page.document.Node#getType()
350:             */
351:            public String getType() {
352:                return DOCUMENT_TYPE;
353:            }
354:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.