View Javadoc

1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one or more
3    * contributor license agreements.  See the NOTICE file distributed with
4    * this work for additional information regarding copyright ownership.
5    * The ASF licenses this file to You under the Apache License, Version 2.0
6    * (the "License"); you may not use this file except in compliance with
7    * the License.  You may obtain a copy of the License at
8    * 
9    *      http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS,
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14   * See the License for the specific language governing permissions and
15   * limitations under the License.
16   */
17  package org.apache.jetspeed.om.folder.psml;
18  
19  import java.security.AccessController;
20  import java.util.Iterator;
21  import java.util.List;
22  import java.util.Locale;
23  
24  import org.apache.commons.logging.Log;
25  import org.apache.commons.logging.LogFactory;
26  import org.apache.jetspeed.JetspeedActions;
27  import org.apache.jetspeed.om.common.GenericMetadata;
28  import org.apache.jetspeed.om.common.SecurityConstraints;
29  import org.apache.jetspeed.om.folder.Folder;
30  import org.apache.jetspeed.om.folder.FolderNotFoundException;
31  import org.apache.jetspeed.om.folder.MenuDefinition;
32  import org.apache.jetspeed.om.folder.MenuExcludeDefinition;
33  import org.apache.jetspeed.om.folder.MenuIncludeDefinition;
34  import org.apache.jetspeed.om.folder.MenuOptionsDefinition;
35  import org.apache.jetspeed.om.folder.MenuSeparatorDefinition;
36  import org.apache.jetspeed.om.folder.Reset;
37  import org.apache.jetspeed.om.page.Link;
38  import org.apache.jetspeed.om.page.Page;
39  import org.apache.jetspeed.om.page.PageSecurity;
40  import org.apache.jetspeed.page.PageManagerUtils;
41  import org.apache.jetspeed.page.PageNotFoundException;
42  import org.apache.jetspeed.page.document.DocumentException;
43  import org.apache.jetspeed.page.document.DocumentHandlerFactory;
44  import org.apache.jetspeed.page.document.DocumentNotFoundException;
45  import org.apache.jetspeed.page.document.FolderHandler;
46  import org.apache.jetspeed.page.document.Node;
47  import org.apache.jetspeed.page.document.NodeException;
48  import org.apache.jetspeed.page.document.NodeNotFoundException;
49  import org.apache.jetspeed.page.document.NodeSet;
50  import org.apache.jetspeed.page.document.UnsupportedDocumentTypeException;
51  import org.apache.jetspeed.page.document.psml.AbstractNode;
52  import org.apache.jetspeed.page.document.psml.NodeOrderCompartaor;
53  import org.apache.jetspeed.page.document.psml.NodeSetImpl;
54  import org.apache.jetspeed.security.FolderPermission;
55  
56  /***
57   * FolderImpl
58   * 
59   * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
60   * @author <a href="mailto:jford@apache.org">Jeremy Ford </a>
61   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
62   * @version $Id: FolderImpl.java 553584 2007-07-05 18:09:45Z taylor $
63   */
64  public class FolderImpl extends AbstractNode implements Folder, Reset
65  {
66      
67      private NodeSet allNodes;
68      private FolderMetaDataImpl metadata;
69      private FolderHandler folderHandler;
70      private int reservedType = RESERVED_FOLDER_NONE;
71      
72      private static final Log log = LogFactory.getLog(FolderImpl.class);
73  
74      public FolderImpl( String path, FolderMetaDataImpl metadata, DocumentHandlerFactory handlerFactory,
75                         FolderHandler folderHandler )
76      {
77          this.metadata = metadata;
78          this.metadata.setParent(this);
79          this.folderHandler = folderHandler;
80          setPath(path);
81          setReservedType();
82          setHandlerFactory(handlerFactory);
83          setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
84          setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
85      }
86  
87      public FolderImpl( String path, DocumentHandlerFactory handlerFactory, FolderHandler folderHandler )
88      {
89          this.metadata = new FolderMetaDataImpl();
90          this.metadata.setParent(this);
91          this.folderHandler = folderHandler;
92          setPath(path);
93          setReservedType();
94          setHandlerFactory(handlerFactory);
95          setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
96          setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
97      }
98  
99      public FolderImpl()
100     {
101         this.metadata = new FolderMetaDataImpl();
102         this.metadata.setParent(this);
103         setReservedType();
104     }
105 
106     /* (non-Javadoc)
107      * @see org.apache.jetspeed.om.folder.Folder#getSkin()
108      */
109     public String getSkin()
110     {
111         return metadata.getSkin();
112     }
113 
114     /* (non-Javadoc)
115      * @see org.apache.jetspeed.om.folder.Folder#setSkin(java.lang.String)
116      */
117     public void setSkin( String skinName )
118     {
119         metadata.setSkin(skinName);
120     }
121 
122     /* (non-Javadoc)
123      * @see org.apache.jetspeed.om.folder.Folder#getEffectiveDefaultDecorator(java.lang.String)
124      */
125     public String getEffectiveDefaultDecorator(String fragmentType)
126     {
127         // get locally defined decorator
128         String decorator = getDefaultDecorator(fragmentType);
129         if (decorator == null)
130         {
131             // delegate to parent folder
132             Folder parentFolder = (Folder)getParent();
133             if (parentFolder != null)
134             {
135                 return parentFolder.getEffectiveDefaultDecorator(fragmentType);
136             }
137         }
138         return decorator;
139     }
140 
141     /* (non-Javadoc)
142      * @see org.apache.jetspeed.om.folder.Folder#getDefaultDecorator(java.lang.String)
143      */
144     public String getDefaultDecorator( String fragmentType )
145     {
146         return metadata.getDefaultDecorator(fragmentType);
147     }
148 
149     /* (non-Javadoc)
150      * @see org.apache.jetspeed.om.folder.Folder#setDefaultDecorator(java.lang.String, java.lang.String)
151      */
152     public void setDefaultDecorator( String decoratorName, String fragmentType )
153     {
154         metadata.setDefaultDecorator(decoratorName, fragmentType);
155     }
156 
157     /* (non-Javadoc)
158      * @see org.apache.jetspeed.om.folder.Folder#getDocumentOrder()
159      */
160     public List getDocumentOrder()
161     {
162         return metadata.getDocumentOrder();
163     }
164     
165     /* (non-Javadoc)
166      * @see org.apache.jetspeed.om.folder.Folder#setDocumentOrder(java.util.List)
167      */
168     public void setDocumentOrder(List docIndexes)
169     {
170         metadata.setDocumentOrder(docIndexes);
171     }
172 
173     /* (non-Javadoc)
174      * @see org.apache.jetspeed.om.folder.Folder#getDefaultPage()
175      */
176     public String getDefaultPage()
177     {
178         return metadata.getDefaultPage();
179     }
180     
181     /*
182      * (non-Javadoc)
183      * 
184      * @see org.apache.jetspeed.om.folder.Folder#setDefaultPage()
185      */
186     public void setDefaultPage( String defaultPage )
187     {
188         metadata.setDefaultPage(defaultPage);
189     }
190 
191     /***
192      * <p>
193      * getFolders
194      * </p>
195      * 
196      * @param checkAccess flag
197      * @return folders node set
198      * @throws DocumentException
199      */
200     public NodeSet getFolders(boolean checkAccess) throws DocumentException
201     {
202         // get list of all folders
203         NodeSet folders = getAllNodes().subset(FOLDER_TYPE);
204 
205         // filter node set by access
206         if (checkAccess)
207         {
208             folders = checkAccess(folders, JetspeedActions.VIEW);
209         }
210         return folders;
211     }
212 
213     /*
214      * (non-Javadoc)
215      * 
216      * @see org.apache.jetspeed.om.folder.Folder#getFolders()
217      */
218     public NodeSet getFolders() throws DocumentException
219     {
220         // by default enable access checks
221         return getFolders(true);
222     }
223 
224     /***
225      * <p>
226      * getFolder
227      * </p>
228      * 
229      * @param name
230      * @param checkAccess flag
231      * @return folder
232      * @throws FolderNotFoundException
233      * @throws DocumentException
234      */
235     public Folder getFolder(String name, boolean checkAccess) throws FolderNotFoundException, DocumentException
236     {
237         // get folder
238         Folder folder = (Folder) getAllNodes().subset(FOLDER_TYPE).get(name);
239         if (folder == null)
240         {
241             throw new FolderNotFoundException("Jetspeed PSML folder not found: " + name);
242         }
243 
244         // check access
245         if (checkAccess)
246         {
247             folder.checkAccess(JetspeedActions.VIEW);
248         }
249         return folder;
250     }
251 
252     /*
253      * (non-Javadoc)
254      * 
255      * @see org.apache.jetspeed.om.folder.Folder#getFolder(java.lang.String)
256      */
257     public Folder getFolder(String name) throws FolderNotFoundException, DocumentException
258     {
259         // by default enable access checks
260         return getFolder(name, true);
261     }
262 
263     /***
264      * <p>
265      * getPages
266      * </p>
267      * 
268      * @param checkAccess flag
269      * @return pages node set
270      * @throws NodeException
271      */
272     public NodeSet getPages(boolean checkAccess) throws NodeException
273     {
274         // get list of all pages
275         NodeSet pages = getAllNodes().subset(Page.DOCUMENT_TYPE);
276 
277         // filter node set by access
278         if (checkAccess)
279         {
280             pages = checkAccess(pages, JetspeedActions.VIEW);
281         }
282         return pages;
283     }
284 
285     /*
286      * (non-Javadoc)
287      * 
288      * @see org.apache.jetspeed.om.folder.Folder#getPages()
289      */
290     public NodeSet getPages() throws NodeException
291     {
292         // by default enable access checks
293         return getPages(true);
294     }
295 
296     /***
297      * <p>
298      * getPage
299      * </p>
300      * 
301      * @param name
302      * @param checkAccess flag
303      * @return page
304      * @throws PageNotFoundException
305      * @throws NodeException
306      */
307     public Page getPage(String name, boolean checkAccess) throws PageNotFoundException, NodeException
308     {
309         // get page
310         Page page = (Page) getAllNodes().subset(Page.DOCUMENT_TYPE).get(name);
311         if (page == null)
312         {
313             throw new PageNotFoundException("Jetspeed PSML page not found: " + name);
314         }
315 
316         // check access
317         if (checkAccess)
318         {
319             page.checkAccess(JetspeedActions.VIEW);
320         }
321         return page;
322     }
323 
324     /*
325      * (non-Javadoc)
326      * 
327      * @see org.apache.jetspeed.om.folder.Folder#getPage(java.lang.String)
328      */
329     public Page getPage(String name) throws PageNotFoundException, NodeException
330     {
331         // by default enable access checks
332         return getPage(name, true);
333     }
334 
335     /***
336      * <p>
337      * getLinks
338      * </p>
339      * 
340      * @param checkAccess flag
341      * @return links node set
342      * @throws NodeException
343      */
344     public NodeSet getLinks(boolean checkAccess) throws NodeException
345     {
346         // get list of all links
347         NodeSet links = getAllNodes().subset(Link.DOCUMENT_TYPE);
348 
349         // filter node set by access
350         if (checkAccess)
351         {
352             links = checkAccess(links, JetspeedActions.VIEW);
353         }
354         return links;
355     }
356 
357     /*
358      * (non-Javadoc)
359      * 
360      * @see org.apache.jetspeed.om.folder.Folder#getLinks()
361      */
362     public NodeSet getLinks() throws NodeException
363     {
364         // by default enable access checks
365         return getLinks(true);
366     }
367 
368     /***
369      * <p>
370      * getLink
371      * </p>
372      * 
373      * @param name
374      * @param checkAccess flag
375      * @return link
376      * @throws DocumentNotFoundException
377      * @throws NodeException
378      */
379     public Link getLink(String name, boolean checkAccess) throws DocumentNotFoundException, NodeException
380     {
381         // get link
382         Link link = (Link) getAllNodes().subset(Link.DOCUMENT_TYPE).get(name);
383         if (link == null)
384         {
385             throw new DocumentNotFoundException("Jetspeed PSML link not found: " + name);
386         }
387 
388         // check access
389         if (checkAccess)
390         {
391             link.checkAccess(JetspeedActions.VIEW);
392         }
393         return link;
394     }
395 
396     /*
397      * (non-Javadoc)
398      * 
399      * @see org.apache.jetspeed.om.folder.Folder#getLink(java.lang.String)
400      */
401     public Link getLink(String name) throws DocumentNotFoundException, NodeException
402     {
403         // by default enable access checks
404         return getLink(name, true);
405     }
406 
407     /***
408      * <p>
409      * getPageSecurity
410      * </p>
411      * 
412      * @param checkAccess flag
413      * @return page security
414      * @throws DocumentNotFoundException
415      * @throws NodeException
416      */
417     public PageSecurity getPageSecurity(boolean checkAccess) throws DocumentNotFoundException, NodeException
418     {
419         // check access to this folder in place
420         // of access to page security document
421         if (checkAccess)
422         {
423             checkAccess(JetspeedActions.VIEW);
424         }
425 
426         // get pageSecurity
427         PageSecurity pageSecurity = (PageSecurity) getAllNodes().subset(PageSecurity.DOCUMENT_TYPE).get(PageSecurity.DOCUMENT_TYPE);
428         if (pageSecurity == null)
429         {
430             throw new DocumentNotFoundException("Jetspeed PSML page security not found: " + PageSecurity.DOCUMENT_TYPE);
431         }
432         return pageSecurity;
433     }
434 
435     /*
436      * (non-Javadoc)
437      * 
438      * @see org.apache.jetspeed.om.folder.Folder#getPageSecurity()
439      */
440     public PageSecurity getPageSecurity() throws DocumentNotFoundException, NodeException
441     {
442         // by default disable access checks
443         return getPageSecurity(false);
444     }
445 
446     /*
447      * (non-Javadoc)
448      * 
449      * @see org.apache.jetspeed.om.folder.Folder#getAll()
450      */
451     public NodeSet getAll() throws DocumentException
452     {
453         // return secure set of all nodes: enforce access checks
454         // on folders and documents while creating filtered nodes
455         NodeSet nodes = getAllNodes();
456         NodeSet filteredNodes = null;
457         Iterator checkAccessIter = nodes.iterator();
458         while (checkAccessIter.hasNext())
459         {
460             Node node = (Node)checkAccessIter.next();
461             try
462             {
463                 ((AbstractNode) node).checkAccess(JetspeedActions.VIEW);
464                 if (filteredNodes != null)
465                 {
466                     filteredNodes.add(node);
467                 }
468             }
469             catch (SecurityException se)
470             {
471                 if (filteredNodes == null)
472                 {
473                     filteredNodes = new NodeSetImpl(getPath(), ((NodeSetImpl) nodes).getComparator());
474                     Iterator copyIter = nodes.iterator();
475                     while (copyIter.hasNext())
476                     {
477                         Node copyNode = (Node)copyIter.next();
478                         if (copyNode != node)
479                         {
480                             filteredNodes.add(copyNode);
481                         }
482                         else
483                         {
484                             break;
485                         }
486                     }
487                 }
488             }
489         }
490         if (filteredNodes != null)
491         {
492             return filteredNodes;
493         }
494         return nodes;
495     }
496 
497     /***
498      * <p>
499      * getAllNodes
500      * </p>
501      *
502      * @return all nodes immediatley under this
503      * @throws DocumentException
504      */
505     public NodeSet getAllNodes() throws DocumentException
506     {
507         if((allNodes == null) && (folderHandler != null))
508         {            
509             if(metadata.getDocumentOrder() != null)
510             {
511                 if (getPath().endsWith(PATH_SEPARATOR))
512                 {
513                     allNodes = new NodeSetImpl(getPath(), new NodeOrderCompartaor(metadata.getDocumentOrder(), getPath()));
514                 }
515                 else
516                 {
517                     allNodes = new NodeSetImpl(getPath(), new NodeOrderCompartaor(metadata.getDocumentOrder(), getPath() + PATH_SEPARATOR));
518                 }
519             }
520             else
521             {
522                 allNodes = new NodeSetImpl(getPath());
523             }
524 
525             try
526             {
527                 String[] nodeNames = folderHandler.listAll(getPath());
528                 for (int i = 0; i < nodeNames.length; i++)
529                 {
530                     if (!nodeNames[i].equals(FolderMetaDataImpl.DOCUMENT_TYPE))
531                     {
532                         Node node = null;
533                         try
534                         {
535                             if (getPath().endsWith(PATH_SEPARATOR))
536                             {
537                                 String full = PageManagerUtils.concatenatePaths(getPath(), nodeNames[i]); 
538                                 if (!folderHandler.isFolder(full))
539                                 {
540                                     node = getHandlerFactory().getDocumentHandlerForPath(nodeNames[i]).getDocument(getPath() + nodeNames[i]);
541                                 }
542                                 else
543                                 {
544                                     node = folderHandler.getFolder(getPath() + nodeNames[i]);
545                                 }
546                             }
547                             else
548                             {
549                                 String full = PageManagerUtils.concatenatePaths(getPath(), nodeNames[i]); 
550                                 if (!folderHandler.isFolder(full))                                
551                                 //if(nodeNames[i].indexOf(".") > -1)
552                                 {
553                                     node = getHandlerFactory().getDocumentHandlerForPath(nodeNames[i]).getDocument(getPath() + PATH_SEPARATOR + nodeNames[i]);
554                                 }
555                                 else
556                                 {
557                                     node = folderHandler.getFolder(getPath() + PATH_SEPARATOR + nodeNames[i]);
558                                 }
559                             }
560                             node.setParent(this);
561                             allNodes.add(node);
562                         }               
563                         catch (UnsupportedDocumentTypeException e)
564                         {
565                             // Skip unsupported documents
566                             log.info("getAllNodes() Skipping unsupported document: "+nodeNames[i]);
567                         }
568                         catch (Exception e)
569                         {
570                             log.warn("getAllNodes() failed to create Node: "+nodeNames[i]+":"+e.toString(), e);
571                         }
572                     }       
573                 }
574             }
575             catch (FolderNotFoundException fnfe)
576             {
577                 log.error("getAllNodes() unexpected missing folder", fnfe);
578             }
579         }
580         
581         return allNodes;
582     }
583     
584     /***
585      * <p>
586      * getFolderMetaData
587      * </p>
588      *
589      * @return implementation specific folder metadata
590      */
591     public FolderMetaDataImpl getFolderMetaData()
592     {
593         return metadata;
594     }
595 
596     /***
597      * <p>
598      * setFolderHandler
599      * </p>
600      *
601      * @param handler folder handler
602      */
603     public void setFolderHandler(FolderHandler handler)
604     {
605         this.folderHandler = handler;
606     }
607 
608     /***
609      * <p>
610      * getMetadata
611      * </p>
612      *
613      * @see org.apache.jetspeed.page.document.AbstractNode#getMetadata()
614      * @return metadata
615      */
616     public GenericMetadata getMetadata()
617     {        
618         return metadata.getMetadata();
619     }
620 
621     /***
622      * <p>
623      * getSecurityConstraints
624      * </p>
625      *
626      * @see org.apache.jetspeed.om.common.SecureResource#getSecurityConstraints()
627      * @return
628      */
629     public SecurityConstraints getSecurityConstraints()
630     {
631         return metadata.getSecurityConstraints();
632     }
633     /***
634      * <p>
635      * setSecurityConstraints
636      * </p>
637      *
638      * @see org.apache.jetspeed.om.common.SecureResource#setSecurityConstraints(org.apache.jetspeed.om.common.SecurityConstraints)
639      * @param constraints
640      */
641     public void setSecurityConstraints(SecurityConstraints constraints)
642     {
643         metadata.setSecurityConstraints(constraints);
644     }
645 
646     /***
647      * getEffectivePageSecurity
648      *
649      * @see org.apache.jetspeed.om.page.psml.AbstractElementImpl#getEffectivePageSecurity()
650      */
651     public PageSecurity getEffectivePageSecurity()
652     {
653         // return single page security if available
654         PageSecurity pageSecurity = null;
655         try
656         {
657             pageSecurity = getPageSecurity(false);
658             if (pageSecurity != null)
659             {
660                 return pageSecurity;
661             }
662         }
663         catch (NodeException ne)
664         {
665         }
666         catch (NodeNotFoundException nnfe)
667         {
668         }
669 
670         // delegate to parent folder implementation
671         FolderImpl parentFolderImpl = (FolderImpl)getParent();
672         if (parentFolderImpl != null)
673         {
674             return parentFolderImpl.getEffectivePageSecurity();
675         }
676         return null;
677     }
678 
679     /***
680      * <p>
681      * checkPermissions
682      * </p>
683      *
684      * @param path
685      * @param mask
686      * @param checkNodeOnly
687      * @param checkParentsOnly
688      * @throws SecurityException
689      */
690     public void checkPermissions(String path, int mask, boolean checkNodeOnly, boolean checkParentsOnly) throws SecurityException
691     {
692         // check granted folder permissions unless the check is
693         // to be skipped due to explicity granted access
694         if (!checkParentsOnly)
695         {
696             FolderPermission permission = new FolderPermission(path, mask);
697             AccessController.checkPermission(permission);
698         }
699 
700         // if not checking node only, recursively check
701         // all parent permissions in hierarchy
702         if (!checkNodeOnly && (getParent() != null))
703         {
704             ((AbstractNode)getParent()).checkPermissions(mask, false, false);
705         }
706     }
707 
708     /***
709      * <p>
710      * getTitle
711      * </p>
712      *
713      * @see org.apache.jetspeed.page.document.Node#getTitle(java.util.Locale)
714      * @param locale
715      * @return title in specified locale
716      */
717     public String getTitle( Locale locale )
718     {
719         return metadata.getTitle(locale);
720     }
721     /***
722      * <p>
723      * getTitle
724      * </p>
725      *
726      * @see org.apache.jetspeed.om.page.BaseElement#getTitle()
727      * @return title
728      */
729     public String getTitle()
730     {
731         return metadata.getTitle();
732     }
733     /***
734      * <p>
735      * setTitle
736      * </p>
737      *
738      * @see org.apache.jetspeed.om.page.BaseElement#setTitle(java.lang.String)
739      * @param title
740      */
741     public void setTitle( String title )
742     {
743         metadata.setTitle(title);
744     }
745     /***
746      * <p>
747      * getShortTitle
748      * </p>
749      *
750      * @see org.apache.jetspeed.page.document.Node#getShortTitle(java.util.Locale)
751      * @param locale
752      * @return short title in supplied locate
753      */
754     public String getShortTitle( Locale locale )
755     {
756         return metadata.getShortTitle(locale);
757     }
758     /***
759      * <p>
760      * getShortTitle
761      * </p>
762      *
763      * @see org.apache.jetspeed.om.page.BaseElement#getShortTitle()
764      * @return short title
765      */
766     public String getShortTitle()
767     {
768         return metadata.getShortTitle();
769     }
770     /***
771      * <p>
772      * setShortTitle
773      * </p>
774      *
775      * @see org.apache.jetspeed.om.page.BaseElement#setShortTitle(java.lang.String)
776      * @param title
777      */
778     public void setShortTitle( String title )
779     {
780         metadata.setShortTitle(title);
781     }
782     /***
783      * <p>
784      * getType
785      * </p>
786      *
787      * @see org.apache.jetspeed.page.document.Node#getType()
788      * @return type string
789      */
790     public String getType()
791     {
792         return FOLDER_TYPE;
793     }
794     /***
795      * <p>
796      * isHidden
797      * </p>
798      *
799      * @see org.apache.jetspeed.page.document.Node#isHidden()
800      * @return whether folder is hidden
801      */
802     public boolean isHidden()
803     {
804         return metadata.isHidden();
805     }
806     /***
807      * <p>
808      * setHidden
809      * </p>
810      *
811      * @see org.apache.jetspeed.page.document.AbstractNode#setHidden(boolean)
812      * @param hidden
813      */
814     public void setHidden( boolean hidden )
815     {        
816         ((AbstractNode)metadata).setHidden(hidden);
817     }
818 
819     /* (non-Javadoc)
820      * @see org.apache.jetspeed.om.folder.Reset#reset()
821      */
822     public void reset()
823     {
824         allNodes = null;
825         
826     }
827 
828     /***
829      * getMenuDefinitions - get list of menu definitions
830      *
831      * @return definition list
832      */
833     public List getMenuDefinitions()
834     {
835         return metadata.getMenuDefinitions();
836     }
837 
838     /***
839      * newMenuDefinition - creates a new empty menu definition
840      *
841      * @return a newly created MenuDefinition object for use in Folder
842      */
843     public MenuDefinition newMenuDefinition()
844     {
845         return new MenuDefinitionImpl();
846     }
847 
848     /***
849      * newMenuExcludeDefinition - creates a new empty menu exclude definition
850      *
851      * @return a newly created MenuExcludeDefinition object for use in Folder
852      */
853     public MenuExcludeDefinition newMenuExcludeDefinition()
854     {
855         return new MenuExcludeDefinitionImpl();
856     }
857 
858     /***
859      * newMenuIncludeDefinition - creates a new empty menu include definition
860      *
861      * @return a newly created MenuIncludeDefinition object for use in Folder
862      */
863     public MenuIncludeDefinition newMenuIncludeDefinition()
864     {
865         return new MenuIncludeDefinitionImpl();
866     }
867 
868     /***
869      * newMenuOptionsDefinition - creates a new empty menu options definition
870      *
871      * @return a newly created MenuOptionsDefinition object for use in Folder
872      */
873     public MenuOptionsDefinition newMenuOptionsDefinition()
874     {
875         return new MenuOptionsDefinitionImpl();
876     }
877 
878     /***
879      * newMenuSeparatorDefinition - creates a new empty menu separator definition
880      *
881      * @return a newly created MenuSeparatorDefinition object for use in Folder
882      */
883     public MenuSeparatorDefinition newMenuSeparatorDefinition()
884     {
885         return new MenuSeparatorDefinitionImpl();
886     }
887 
888     /***
889      * setMenuDefinitions - set list of menu definitions
890      *
891      * @param definitions definition list
892      */
893     public void setMenuDefinitions(List definitions)
894     {
895         metadata.setMenuDefinitions(definitions);
896     }
897 
898     /***
899      * unmarshalled - notification that this instance has been
900      *                loaded from the persistent store
901      */
902     public void unmarshalled()
903     {
904         // notify super class implementation
905         super.unmarshalled();
906 
907         // default title of pages to name
908         if (getTitle() == null)
909         {
910             setTitle(getTitleName());
911         }
912     }
913     
914     public boolean isReserved()
915     {
916         return (reservedType > RESERVED_FOLDER_NONE);
917     }
918     
919     public int getReservedType()
920     {
921         return reservedType;
922     }
923     
924     private void setReservedType()
925     {
926         String name = getName();
927         if (name != null)
928         {
929             if (name.startsWith(RESERVED_SUBSITE_FOLDER_PREFIX))
930             {
931                 reservedType = RESERVED_FOLDER_SUBSITES;
932             }
933             else if (name.startsWith(RESERVED_FOLDER_PREFIX))            
934             {
935                 if (name.equals(RESERVED_USER_FOLDER_NAME))
936                     reservedType = RESERVED_FOLDER_USERS;
937                 else if (name.equals(RESERVED_ROLE_FOLDER_NAME))
938                     reservedType = RESERVED_FOLDER_ROLES;
939                 else if (name.equals(RESERVED_GROUP_FOLDER_NAME))
940                     reservedType = RESERVED_FOLDER_GROUPS;
941                 else if (name.equals(RESERVED_MEDIATYPE_FOLDER_NAME))
942                     reservedType = RESERVED_FOLDER_MEDIATYPE;
943                 else if (name.equals(RESERVED_LANGUAGE_FOLDER_NAME))
944                     reservedType = RESERVED_FOLDER_LANGUAGE;
945                 else if (name.equals(RESERVED_COUNTRY_FOLDER_NAME))
946                     reservedType = RESERVED_FOLDER_COUNTRY;
947                 else
948                     reservedType = RESERVED_FOLDER_OTHER;            
949             }
950         }
951     }
952     
953 }