Source Code Cross Referenced for FragmentImpl.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.security.AccessController;
020:        import java.util.Iterator;
021:        import java.util.List;
022:        import java.util.Map;
023:
024:        import org.apache.jetspeed.JetspeedActions;
025:        import org.apache.jetspeed.om.folder.Folder;
026:        import org.apache.jetspeed.om.page.Fragment;
027:        import org.apache.jetspeed.om.page.PageSecurity;
028:        import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
029:        import org.apache.jetspeed.security.FragmentPermission;
030:
031:        /**
032:         * FragmentImpl
033:         *
034:         * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
035:         * @version $Id$
036:         */
037:        public class FragmentImpl extends BaseElementImpl implements  Fragment {
038:            private List fragments;
039:            private String type;
040:            private String skin;
041:            private String decorator;
042:            private String state;
043:            private String mode;
044:            private int layoutRowProperty = -1;
045:            private int layoutColumnProperty = -1;
046:            private String layoutSizesProperty;
047:            private float layoutXProperty = -1.0F;
048:            private float layoutYProperty = -1.0F;
049:            private float layoutZProperty = -1.0F;
050:            private float layoutWidthProperty = -1.0F;
051:            private float layoutHeightProperty = -1.0F;
052:            private String extendedPropertyName1;
053:            private String extendedPropertyValue1;
054:            private String extendedPropertyName2;
055:            private String extendedPropertyValue2;
056:            private List preferences;
057:
058:            private FragmentList fragmentsList;
059:            private FragmentPropertyMap propertiesMap;
060:            private FragmentPreferenceList fragmentPreferences;
061:            private PageImpl page;
062:
063:            public FragmentImpl() {
064:                super (new FragmentSecurityConstraintsImpl());
065:            }
066:
067:            /**
068:             * accessFragments
069:             *
070:             * Access mutable persistent collection member for List wrappers.
071:             *
072:             * @return persistent collection
073:             */
074:            List accessFragments() {
075:                // create initial collection if necessary
076:                if (fragments == null) {
077:                    fragments = DatabasePageManagerUtils.createList();
078:                }
079:                return fragments;
080:            }
081:
082:            /**
083:             * accessPreferences
084:             *
085:             * Access mutable persistent collection member for List wrappers.
086:             *
087:             * @return persistent collection
088:             */
089:            List accessPreferences() {
090:                // create initial collection if necessary
091:                if (preferences == null) {
092:                    preferences = DatabasePageManagerUtils.createList();
093:                }
094:                return preferences;
095:            }
096:
097:            /**
098:             * getPage
099:             *
100:             * Get page implementation that owns fragment.
101:             *
102:             * @return owning page implementation
103:             */
104:            PageImpl getPage() {
105:                return page;
106:            }
107:
108:            /**
109:             * setPage
110:             *
111:             * Set page implementation that owns fragment and
112:             * propagate to all child fragments.
113:             *
114:             * @param page owning page implementation
115:             */
116:            void setPage(PageImpl page) {
117:                // set page implementation
118:                this .page = page;
119:                // propagate to children
120:                if (fragments != null) {
121:                    Iterator fragmentsIter = fragments.iterator();
122:                    while (fragmentsIter.hasNext()) {
123:                        ((FragmentImpl) fragmentsIter.next()).setPage(page);
124:                    }
125:                }
126:            }
127:
128:            /**
129:             * getFragmentById
130:             *
131:             * Retrieve fragment with matching id from
132:             * this or child fragments.
133:             *
134:             * @param id fragment id to retrieve.
135:             * @return matched fragment
136:             */
137:            Fragment getFragmentById(String id) {
138:                // check for match
139:                if (getId().equals(id)) {
140:                    return this ;
141:                }
142:                // match children
143:                if (fragments != null) {
144:                    Iterator fragmentsIter = fragments.iterator();
145:                    while (fragmentsIter.hasNext()) {
146:                        Fragment matchedFragment = ((FragmentImpl) fragmentsIter
147:                                .next()).getFragmentById(id);
148:                        if (matchedFragment != null) {
149:                            return matchedFragment;
150:                        }
151:                    }
152:                }
153:                return null;
154:            }
155:
156:            /**
157:             * removeFragmentById
158:             *
159:             * Remove fragment with matching id from
160:             * child fragments.
161:             *
162:             * @param id fragment id to remove.
163:             * @return removed fragment
164:             */
165:            Fragment removeFragmentById(String id) {
166:                // remove from deep children
167:                if (fragments != null) {
168:                    Iterator fragmentsIter = fragments.iterator();
169:                    while (fragmentsIter.hasNext()) {
170:                        FragmentImpl fragment = (FragmentImpl) fragmentsIter
171:                                .next();
172:                        if (!fragment.getId().equals(id)) {
173:                            Fragment removed = fragment.removeFragmentById(id);
174:                            if (removed != null) {
175:                                return removed;
176:                            }
177:                        } else {
178:                            fragmentsIter.remove();
179:                            return fragment;
180:                        }
181:                    }
182:                }
183:                return null;
184:            }
185:
186:            /**
187:             * getFragmentsByName
188:             *
189:             * Retrieve fragments with matching name including
190:             * this and child fragments.
191:             *
192:             * @param name fragment name to retrieve.
193:             * @return list of matched fragments
194:             */
195:            List getFragmentsByName(String name) {
196:                List matchedFragments = null;
197:                // check for match
198:                if ((getName() != null) && getName().equals(name)) {
199:                    if (matchedFragments == null) {
200:                        matchedFragments = DatabasePageManagerUtils
201:                                .createList();
202:                    }
203:                    matchedFragments.add(this );
204:                }
205:                // match children
206:                if (fragments != null) {
207:                    Iterator fragmentsIter = fragments.iterator();
208:                    while (fragmentsIter.hasNext()) {
209:                        List matchedChildFragments = ((FragmentImpl) fragmentsIter
210:                                .next()).getFragmentsByName(name);
211:                        if (matchedChildFragments != null) {
212:                            if (matchedFragments == null) {
213:                                matchedFragments = matchedChildFragments;
214:                            } else {
215:                                matchedFragments.addAll(matchedChildFragments);
216:                            }
217:                        }
218:                    }
219:                }
220:                return matchedFragments;
221:            }
222:
223:            /**
224:             * getPropertyMemberKeys
225:             *
226:             * Get valid explicit property member keys.
227:             *
228:             * @return list of property member keys with values
229:             */
230:            List getPropertyMemberKeys() {
231:                List keys = DatabasePageManagerUtils.createList();
232:                if (layoutRowProperty >= 0) {
233:                    keys.add(ROW_PROPERTY_NAME);
234:                }
235:                if (layoutColumnProperty >= 0) {
236:                    keys.add(COLUMN_PROPERTY_NAME);
237:                }
238:                if (layoutSizesProperty != null) {
239:                    keys.add(SIZES_PROPERTY_NAME);
240:                }
241:                if (layoutXProperty >= 0.0F) {
242:                    keys.add(X_PROPERTY_NAME);
243:                }
244:                if (layoutYProperty >= 0.0F) {
245:                    keys.add(Y_PROPERTY_NAME);
246:                }
247:                if (layoutZProperty >= 0.0F) {
248:                    keys.add(Z_PROPERTY_NAME);
249:                }
250:                if (layoutWidthProperty >= 0.0F) {
251:                    keys.add(WIDTH_PROPERTY_NAME);
252:                }
253:                if (layoutHeightProperty >= 0.0F) {
254:                    keys.add(HEIGHT_PROPERTY_NAME);
255:                }
256:                if ((extendedPropertyName1 != null)
257:                        && (extendedPropertyValue1 != null)) {
258:                    keys.add(extendedPropertyName1);
259:                }
260:                if ((extendedPropertyName2 != null)
261:                        && (extendedPropertyValue2 != null)) {
262:                    keys.add(extendedPropertyName2);
263:                }
264:                return keys;
265:            }
266:
267:            /**
268:             * getPropertyMember
269:             *
270:             * Get explicit property member.
271:             *
272:             * @param key property name
273:             * @return property setting
274:             */
275:            String getPropertyMember(String key) {
276:                // set fragment explicit property member
277:                if (key.equals(ROW_PROPERTY_NAME)) {
278:                    if (layoutRowProperty >= 0) {
279:                        return String.valueOf(layoutRowProperty);
280:                    }
281:                } else if (key.equals(COLUMN_PROPERTY_NAME)) {
282:                    if (layoutColumnProperty >= 0) {
283:                        return String.valueOf(layoutColumnProperty);
284:                    }
285:                } else if (key.equals(SIZES_PROPERTY_NAME)) {
286:                    return layoutSizesProperty;
287:                } else if (key.equals(X_PROPERTY_NAME)) {
288:                    if (layoutXProperty >= 0.0F) {
289:                        return String.valueOf(layoutXProperty);
290:                    }
291:                } else if (key.equals(Y_PROPERTY_NAME)) {
292:                    if (layoutYProperty >= 0.0F) {
293:                        return String.valueOf(layoutYProperty);
294:                    }
295:                } else if (key.equals(Z_PROPERTY_NAME)) {
296:                    if (layoutZProperty >= 0.0F) {
297:                        return String.valueOf(layoutZProperty);
298:                    }
299:                } else if (key.equals(WIDTH_PROPERTY_NAME)) {
300:                    if (layoutWidthProperty >= 0.0F) {
301:                        return String.valueOf(layoutWidthProperty);
302:                    }
303:                } else if (key.equals(HEIGHT_PROPERTY_NAME)) {
304:                    if (layoutHeightProperty >= 0.0F) {
305:                        return String.valueOf(layoutHeightProperty);
306:                    }
307:                } else if (key.equals(extendedPropertyName1)) {
308:                    return extendedPropertyValue1;
309:                } else if (key.equals(extendedPropertyName2)) {
310:                    return extendedPropertyValue2;
311:                }
312:                return null;
313:            }
314:
315:            /**
316:             * setPropertyMember
317:             *
318:             * Set explicit property member.
319:             *
320:             * @param key property name
321:             * @param value property setting
322:             */
323:            void setPropertyMember(String key, String value) {
324:                // set fragment explicit property member
325:                if (key.equals(ROW_PROPERTY_NAME)) {
326:                    layoutRowProperty = Integer.parseInt(value);
327:                } else if (key.equals(COLUMN_PROPERTY_NAME)) {
328:                    layoutColumnProperty = Integer.parseInt(value);
329:                } else if (key.equals(SIZES_PROPERTY_NAME)) {
330:                    layoutSizesProperty = value;
331:                } else if (key.equals(X_PROPERTY_NAME)) {
332:                    layoutXProperty = Float.parseFloat(value);
333:                } else if (key.equals(Y_PROPERTY_NAME)) {
334:                    layoutYProperty = Float.parseFloat(value);
335:                } else if (key.equals(Z_PROPERTY_NAME)) {
336:                    layoutZProperty = Float.parseFloat(value);
337:                } else if (key.equals(WIDTH_PROPERTY_NAME)) {
338:                    layoutWidthProperty = Float.parseFloat(value);
339:                } else if (key.equals(HEIGHT_PROPERTY_NAME)) {
340:                    layoutHeightProperty = Float.parseFloat(value);
341:                } else if (key.equals(extendedPropertyName1)) {
342:                    extendedPropertyValue1 = value;
343:                } else if (key.equals(extendedPropertyName2)) {
344:                    extendedPropertyValue2 = value;
345:                } else if (extendedPropertyName1 == null) {
346:                    extendedPropertyName1 = key;
347:                    extendedPropertyValue1 = value;
348:                } else if (extendedPropertyName2 == null) {
349:                    extendedPropertyName2 = key;
350:                    extendedPropertyValue2 = value;
351:                } else {
352:                    throw new RuntimeException(
353:                            "Unable to set fragment property " + key
354:                                    + ", extended properties already used.");
355:                }
356:            }
357:
358:            /**
359:             * clearPropertyMember
360:             *
361:             * Clear explicit property member.
362:             *
363:             * @param key property name
364:             */
365:            void clearPropertyMember(String key) {
366:                if (key.equals(ROW_PROPERTY_NAME)) {
367:                    layoutRowProperty = -1;
368:                } else if (key.equals(COLUMN_PROPERTY_NAME)) {
369:                    layoutColumnProperty = -1;
370:                } else if (key.equals(SIZES_PROPERTY_NAME)) {
371:                    layoutSizesProperty = null;
372:                } else if (key.equals(X_PROPERTY_NAME)) {
373:                    layoutXProperty = -1.0F;
374:                } else if (key.equals(Y_PROPERTY_NAME)) {
375:                    layoutYProperty = -1.0F;
376:                } else if (key.equals(Z_PROPERTY_NAME)) {
377:                    layoutZProperty = -1.0F;
378:                } else if (key.equals(WIDTH_PROPERTY_NAME)) {
379:                    layoutWidthProperty = -1.0F;
380:                } else if (key.equals(HEIGHT_PROPERTY_NAME)) {
381:                    layoutHeightProperty = -1.0F;
382:                } else if (key.equals(extendedPropertyName1)) {
383:                    extendedPropertyName1 = null;
384:                    extendedPropertyValue1 = null;
385:                } else if (key.equals(extendedPropertyName2)) {
386:                    extendedPropertyName2 = null;
387:                    extendedPropertyValue2 = null;
388:                }
389:            }
390:
391:            /* (non-Javadoc)
392:             * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getEffectivePageSecurity()
393:             */
394:            public PageSecurity getEffectivePageSecurity() {
395:                // delegate to page implementation
396:                if (page != null) {
397:                    return page.getEffectivePageSecurity();
398:                }
399:                return null;
400:            }
401:
402:            /* (non-Javadoc)
403:             * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getLogicalPermissionPath()
404:             */
405:            public String getLogicalPermissionPath() {
406:                // use page implementation path as base and append name
407:                if ((page != null) && (getName() != null)) {
408:                    return page.getLogicalPermissionPath()
409:                            + Folder.PATH_SEPARATOR + getName();
410:                }
411:                return null;
412:            }
413:
414:            /* (non-Javadoc)
415:             * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#getPhysicalPermissionPath()
416:             */
417:            public String getPhysicalPermissionPath() {
418:                // use page implementation path as base and append name
419:                if ((page != null) && (getName() != null)) {
420:                    return page.getPhysicalPermissionPath()
421:                            + Folder.PATH_SEPARATOR + getName();
422:                }
423:                return null;
424:            }
425:
426:            /* (non-Javadoc)
427:             * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#resetCachedSecurityConstraints()
428:             */
429:            public void resetCachedSecurityConstraints() {
430:                // propagate to super and sub fragments
431:                super .resetCachedSecurityConstraints();
432:                if (fragments != null) {
433:                    Iterator fragmentsIter = fragments.iterator();
434:                    while (fragmentsIter.hasNext()) {
435:                        ((FragmentImpl) fragmentsIter.next())
436:                                .resetCachedSecurityConstraints();
437:                    }
438:                }
439:            }
440:
441:            /* (non-Javadoc)
442:             * @see org.apache.jetspeed.om.page.impl.BaseElementImpl#checkPermissions(java.lang.String, int, boolean, boolean)
443:             */
444:            public void checkPermissions(String path, int mask,
445:                    boolean checkNodeOnly, boolean checkParentsOnly)
446:                    throws SecurityException {
447:                // always check for granted fragment permissions
448:                FragmentPermission permission = new FragmentPermission(path,
449:                        mask);
450:                AccessController.checkPermission(permission);
451:            }
452:
453:            /* (non-Javadoc)
454:             * @see org.apache.jetspeed.om.common.SecuredResource#getConstraintsEnabled()
455:             */
456:            public boolean getConstraintsEnabled() {
457:                if (page != null) {
458:                    return page.getConstraintsEnabled();
459:                }
460:                return false;
461:            }
462:
463:            /* (non-Javadoc)
464:             * @see org.apache.jetspeed.om.common.SecuredResource#getPermissionsEnabled()
465:             */
466:            public boolean getPermissionsEnabled() {
467:                if (page != null) {
468:                    return page.getPermissionsEnabled();
469:                }
470:                return false;
471:            }
472:
473:            /* (non-Javadoc)
474:             * @see org.apache.jetspeed.om.page.Fragment#getType()
475:             */
476:            public String getType() {
477:                return type;
478:            }
479:
480:            /* (non-Javadoc)
481:             * @see org.apache.jetspeed.om.page.Fragment#setType(java.lang.String)
482:             */
483:            public void setType(String type) {
484:                this .type = type;
485:            }
486:
487:            /* (non-Javadoc)
488:             * @see org.apache.jetspeed.om.page.Fragment#getSkin()
489:             */
490:            public String getSkin() {
491:                return skin;
492:            }
493:
494:            /* (non-Javadoc)
495:             * @see org.apache.jetspeed.om.page.Fragment#setSkin(java.lang.String)
496:             */
497:            public void setSkin(String skinName) {
498:                this .skin = skinName;
499:            }
500:
501:            /* (non-Javadoc)
502:             * @see org.apache.jetspeed.om.page.Fragment#getDecorator()
503:             */
504:            public String getDecorator() {
505:                return decorator;
506:            }
507:
508:            /* (non-Javadoc)
509:             * @see org.apache.jetspeed.om.page.Fragment#setDecorator(java.lang.String)
510:             */
511:            public void setDecorator(String decoratorName) {
512:                this .decorator = decoratorName;
513:            }
514:
515:            /* (non-Javadoc)
516:             * @see org.apache.jetspeed.om.page.Fragment#getState()
517:             */
518:            public String getState() {
519:                return state;
520:            }
521:
522:            /* (non-Javadoc)
523:             * @see org.apache.jetspeed.om.page.Fragment#setState(java.lang.String)
524:             */
525:            public void setState(String state) {
526:                this .state = state;
527:            }
528:
529:            /* (non-Javadoc)
530:             * @see org.apache.jetspeed.om.page.Fragment#getMode()
531:             */
532:            public String getMode() {
533:                return mode;
534:            }
535:
536:            /* (non-Javadoc)
537:             * @see org.apache.jetspeed.om.page.Fragment#setMode(java.lang.String)
538:             */
539:            public void setMode(String mode) {
540:                this .mode = mode;
541:            }
542:
543:            /* (non-Javadoc)
544:             * @see org.apache.jetspeed.om.page.Fragment#getFragments()
545:             */
546:            public List getFragments() {
547:                // create and return mutable fragments collection
548:                // filtered by view access
549:                if (fragmentsList == null) {
550:                    fragmentsList = new FragmentList(this );
551:                }
552:                return filterFragmentsByAccess(fragmentsList, true);
553:            }
554:
555:            /* (non-Javadoc)
556:             * @see org.apache.jetspeed.om.page.Fragment#getProperty(java.lang.String)
557:             */
558:            public String getProperty(String propName) {
559:                return (String) getProperties().get(propName);
560:            }
561:
562:            /* (non-Javadoc)
563:             * @see org.apache.jetspeed.om.page.Fragment#getIntProperty(java.lang.String)
564:             */
565:            public int getIntProperty(String propName) {
566:                String propValue = (String) getProperties().get(propName);
567:                if (propValue != null) {
568:                    return Integer.parseInt(propValue);
569:                }
570:                return -1;
571:            }
572:
573:            /* (non-Javadoc)
574:             * @see org.apache.jetspeed.om.page.Fragment#getFloatProperty(java.lang.String)
575:             */
576:            public float getFloatProperty(String propName) {
577:                String propValue = (String) getProperties().get(propName);
578:                if (propValue != null) {
579:                    return Float.parseFloat(propValue);
580:                }
581:                return -1.0F;
582:            }
583:
584:            /* (non-Javadoc)
585:             * @see org.apache.jetspeed.om.page.Fragment#getProperties()
586:             */
587:            public Map getProperties() {
588:                // initialize and return writable properties map
589:                if (propertiesMap == null) {
590:                    propertiesMap = new FragmentPropertyMap(this );
591:                }
592:                return propertiesMap;
593:            }
594:
595:            /* (non-Javadoc)
596:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutRow()
597:             */
598:            public int getLayoutRow() {
599:                // get standard int property
600:                return getIntProperty(ROW_PROPERTY_NAME);
601:            }
602:
603:            /* (non-Javadoc)
604:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutRow(int)
605:             */
606:            public void setLayoutRow(int row) {
607:                // set standard int property
608:                if (row >= 0) {
609:                    getProperties().put(ROW_PROPERTY_NAME, String.valueOf(row));
610:                } else {
611:                    getProperties().remove(ROW_PROPERTY_NAME);
612:                }
613:            }
614:
615:            /* (non-Javadoc)
616:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutColumn()
617:             */
618:            public int getLayoutColumn() {
619:                // get standard int property
620:                return getIntProperty(COLUMN_PROPERTY_NAME);
621:            }
622:
623:            /* (non-Javadoc)
624:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutColumn(int)
625:             */
626:            public void setLayoutColumn(int column) {
627:                // set standard int property
628:                if (column >= 0) {
629:                    getProperties().put(COLUMN_PROPERTY_NAME,
630:                            String.valueOf(column));
631:                } else {
632:                    getProperties().remove(COLUMN_PROPERTY_NAME);
633:                }
634:            }
635:
636:            /* (non-Javadoc)
637:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutSizes()
638:             */
639:            public String getLayoutSizes() {
640:                // get standard string property
641:                return getProperty(SIZES_PROPERTY_NAME);
642:            }
643:
644:            /* (non-Javadoc)
645:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutSizes(java.lang.String)
646:             */
647:            public void setLayoutSizes(String sizes) {
648:                // set standard string property
649:                if (sizes != null) {
650:                    getProperties().put(SIZES_PROPERTY_NAME, sizes);
651:                } else {
652:                    getProperties().remove(SIZES_PROPERTY_NAME);
653:                }
654:            }
655:
656:            /* (non-Javadoc)
657:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutX()
658:             */
659:            public float getLayoutX() {
660:                // get standard float property
661:                return getFloatProperty(X_PROPERTY_NAME);
662:            }
663:
664:            /* (non-Javadoc)
665:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutX(float)
666:             */
667:            public void setLayoutX(float x) {
668:                // set standard float property
669:                if (x >= 0.0F) {
670:                    getProperties().put(X_PROPERTY_NAME, String.valueOf(x));
671:                } else {
672:                    getProperties().remove(X_PROPERTY_NAME);
673:                }
674:            }
675:
676:            /* (non-Javadoc)
677:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutY()
678:             */
679:            public float getLayoutY() {
680:                // get standard float property
681:                return getFloatProperty(Y_PROPERTY_NAME);
682:            }
683:
684:            /* (non-Javadoc)
685:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutY(float)
686:             */
687:            public void setLayoutY(float y) {
688:                // set standard float property
689:                if (y >= 0.0F) {
690:                    getProperties().put(Y_PROPERTY_NAME, String.valueOf(y));
691:                } else {
692:                    getProperties().remove(Y_PROPERTY_NAME);
693:                }
694:            }
695:
696:            /* (non-Javadoc)
697:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutZ()
698:             */
699:            public float getLayoutZ() {
700:                // get standard float property
701:                return getFloatProperty(Z_PROPERTY_NAME);
702:            }
703:
704:            /* (non-Javadoc)
705:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutZ(float)
706:             */
707:            public void setLayoutZ(float z) {
708:                // set standard float property
709:                if (z >= 0.0F) {
710:                    getProperties().put(Z_PROPERTY_NAME, String.valueOf(z));
711:                } else {
712:                    getProperties().remove(Z_PROPERTY_NAME);
713:                }
714:            }
715:
716:            /* (non-Javadoc)
717:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutWidth()
718:             */
719:            public float getLayoutWidth() {
720:                // get standard float property
721:                return getFloatProperty(WIDTH_PROPERTY_NAME);
722:            }
723:
724:            /* (non-Javadoc)
725:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutWidth(float)
726:             */
727:            public void setLayoutWidth(float width) {
728:                // set standard float property
729:                if (width >= 0.0F) {
730:                    getProperties().put(WIDTH_PROPERTY_NAME,
731:                            String.valueOf(width));
732:                } else {
733:                    getProperties().remove(WIDTH_PROPERTY_NAME);
734:                }
735:            }
736:
737:            /* (non-Javadoc)
738:             * @see org.apache.jetspeed.om.page.Fragment#getLayoutHeight()
739:             */
740:            public float getLayoutHeight() {
741:                // get standard float property
742:                return getFloatProperty(HEIGHT_PROPERTY_NAME);
743:            }
744:
745:            /* (non-Javadoc)
746:             * @see org.apache.jetspeed.om.page.Fragment#setLayoutHeight(float)
747:             */
748:            public void setLayoutHeight(float height) {
749:                // set standard float property
750:                if (height >= 0.0F) {
751:                    getProperties().put(HEIGHT_PROPERTY_NAME,
752:                            String.valueOf(height));
753:                } else {
754:                    getProperties().remove(HEIGHT_PROPERTY_NAME);
755:                }
756:            }
757:
758:            /* (non-Javadoc)
759:             * @see org.apache.jetspeed.om.page.Fragment#isReference()
760:             */
761:            public boolean isReference() {
762:                return false; // NYI
763:            }
764:
765:            /* (non-Javadoc)
766:             * @see org.apache.jetspeed.om.page.Fragment#getPreferences()
767:             */
768:            public List getPreferences() {
769:                // return mutable preferences list
770:                // by using list wrapper to manage
771:                // element uniqueness
772:                if (fragmentPreferences == null) {
773:                    fragmentPreferences = new FragmentPreferenceList(this );
774:                }
775:                return fragmentPreferences;
776:            }
777:
778:            /* (non-Javadoc)
779:             * @see org.apache.jetspeed.om.page.Fragment#setPreferences(java.util.List)
780:             */
781:            public void setPreferences(List preferences) {
782:                // set preferences by replacing existing
783:                // entries with new elements if new collection
784:                // is specified
785:                List fragmentPreferences = getPreferences();
786:                if (preferences != fragmentPreferences) {
787:                    // replace all preferences
788:                    fragmentPreferences.clear();
789:                    if (preferences != null) {
790:                        fragmentPreferences.addAll(preferences);
791:                    }
792:                }
793:            }
794:
795:            /**
796:             * filterFragmentsByAccess
797:             *
798:             * Filter fragments list for view access.
799:             *
800:             * @param nodes list containing fragments to check
801:             * @param mutable make returned list mutable
802:             * @return original list if all elements viewable, a filtered
803:             *         partial list, or null if all filtered for view access
804:             */
805:            List filterFragmentsByAccess(List fragments, boolean mutable) {
806:                if ((fragments != null) && !fragments.isEmpty()) {
807:                    // check permissions and constraints, filter fragments as required
808:                    List filteredFragments = null;
809:                    Iterator checkAccessIter = fragments.iterator();
810:                    while (checkAccessIter.hasNext()) {
811:                        Fragment fragment = (Fragment) checkAccessIter.next();
812:                        try {
813:                            // check access
814:                            fragment.checkAccess(JetspeedActions.VIEW);
815:
816:                            // add to filteredFragments fragments if copying
817:                            if (filteredFragments != null) {
818:                                // permitted, add to filteredFragments fragments
819:                                filteredFragments.add(fragment);
820:                            }
821:                        } catch (SecurityException se) {
822:                            // create filteredFragments fragments if not already copying
823:                            if (filteredFragments == null) {
824:                                // not permitted, copy previously permitted fragments
825:                                // to new filteredFragments node set with same comparator
826:                                filteredFragments = DatabasePageManagerUtils
827:                                        .createList();
828:                                Iterator copyIter = fragments.iterator();
829:                                while (copyIter.hasNext()) {
830:                                    Fragment copyFragment = (Fragment) copyIter
831:                                            .next();
832:                                    if (copyFragment != fragment) {
833:                                        filteredFragments.add(copyFragment);
834:                                    } else {
835:                                        break;
836:                                    }
837:                                }
838:                            }
839:                        }
840:                    }
841:
842:                    // return filteredFragments fragments if generated
843:                    if (filteredFragments != null) {
844:                        if (!filteredFragments.isEmpty()) {
845:                            if (mutable) {
846:                                return new FilteredFragmentList(this ,
847:                                        filteredFragments);
848:                            } else {
849:                                return filteredFragments;
850:                            }
851:                        } else {
852:                            return new FilteredFragmentList(this,
853:                                    filteredFragments);
854:                        }
855:                    }
856:                }
857:                return fragments;
858:            }
859:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.