Coverage report

  %line %branch
org.apache.jetspeed.om.folder.psml.FolderImpl
0% 
0% 

 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 595429 2007-11-15 20:20:41Z smilek $
 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  0
     private int reservedType = RESERVED_FOLDER_NONE;
 71  
     
 72  0
     private static final Log log = LogFactory.getLog(FolderImpl.class);
 73  
 
 74  
     public FolderImpl( String path, FolderMetaDataImpl metadata, DocumentHandlerFactory handlerFactory,
 75  
                        FolderHandler folderHandler )
 76  0
     {
 77  0
         this.metadata = metadata;
 78  0
         this.metadata.setParent(class="keyword">this);
 79  0
         this.folderHandler = folderHandler;
 80  0
         setPath(path);
 81  0
         setReservedType();
 82  0
         setHandlerFactory(handlerFactory);
 83  0
         setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
 84  0
         setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
 85  0
     }
 86  
 
 87  
     public FolderImpl( String path, DocumentHandlerFactory handlerFactory, FolderHandler folderHandler )
 88  0
     {
 89  0
         this.metadata = new FolderMetaDataImpl();
 90  0
         this.metadata.setParent(class="keyword">this);
 91  0
         this.folderHandler = folderHandler;
 92  0
         setPath(path);
 93  0
         setReservedType();
 94  0
         setHandlerFactory(handlerFactory);
 95  0
         setPermissionsEnabled(handlerFactory.getPermissionsEnabled());
 96  0
         setConstraintsEnabled(handlerFactory.getConstraintsEnabled());
 97  0
     }
 98  
 
 99  
     public FolderImpl()
 100  0
     {
 101  0
         this.metadata = new FolderMetaDataImpl();
 102  0
         this.metadata.setParent(class="keyword">this);
 103  0
         setReservedType();
 104  0
     }
 105  
 
 106  
     /* (non-Javadoc)
 107  
      * @see org.apache.jetspeed.om.folder.Folder#getSkin()
 108  
      */
 109  
     public String getSkin()
 110  
     {
 111  0
         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  0
         metadata.setSkin(skinName);
 120  0
     }
 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  0
         String decorator = getDefaultDecorator(fragmentType);
 129  0
         if (decorator == null)
 130  
         {
 131  
             // delegate to parent folder
 132  0
             Folder parentFolder = (Folder)getParent();
 133  0
             if (parentFolder != null)
 134  
             {
 135  0
                 return parentFolder.getEffectiveDefaultDecorator(fragmentType);
 136  
             }
 137  
         }
 138  0
         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  0
         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  0
         metadata.setDefaultDecorator(decoratorName, fragmentType);
 155  0
     }
 156  
 
 157  
     /* (non-Javadoc)
 158  
      * @see org.apache.jetspeed.om.folder.Folder#getDocumentOrder()
 159  
      */
 160  
     public List getDocumentOrder()
 161  
     {
 162  0
         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  0
         metadata.setDocumentOrder(docIndexes);
 171  0
     }
 172  
 
 173  
     /* (non-Javadoc)
 174  
      * @see org.apache.jetspeed.om.folder.Folder#getDefaultPage()
 175  
      */
 176  
     public String getDefaultPage()
 177  
     {
 178  0
         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  0
         metadata.setDefaultPage(defaultPage);
 189  0
     }
 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  0
         NodeSet folders = getAllNodes().subset(FOLDER_TYPE);
 204  
 
 205  
         // filter node set by access
 206  0
         if (checkAccess)
 207  
         {
 208  0
             folders = checkAccess(folders, JetspeedActions.VIEW);
 209  
         }
 210  0
         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  0
         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  0
         Folder folder = (Folder) getAllNodes().subset(FOLDER_TYPE).get(name);
 239  0
         if (folder == null)
 240  
         {
 241  0
             throw new FolderNotFoundException("Jetspeed PSML folder not found: " + name);
 242  
         }
 243  
 
 244  
         // check access
 245  0
         if (checkAccess)
 246  
         {
 247  0
             folder.checkAccess(JetspeedActions.VIEW);
 248  
         }
 249  0
         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  0
         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  0
         NodeSet pages = getAllNodes().subset(Page.DOCUMENT_TYPE);
 276  
 
 277  
         // filter node set by access
 278  0
         if (checkAccess)
 279  
         {
 280  0
             pages = checkAccess(pages, JetspeedActions.VIEW);
 281  
         }
 282  0
         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  0
         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  0
         Page page = (Page) getAllNodes().subset(Page.DOCUMENT_TYPE).get(name);
 311  0
         if (page == null)
 312  
         {
 313  0
             throw new PageNotFoundException("Jetspeed PSML page not found: " + name);
 314  
         }
 315  
 
 316  
         // check access
 317  0
         if (checkAccess)
 318  
         {
 319  0
             page.checkAccess(JetspeedActions.VIEW);
 320  
         }
 321  0
         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  0
         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  0
         NodeSet links = getAllNodes().subset(Link.DOCUMENT_TYPE);
 348  
 
 349  
         // filter node set by access
 350  0
         if (checkAccess)
 351  
         {
 352  0
             links = checkAccess(links, JetspeedActions.VIEW);
 353  
         }
 354  0
         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  0
         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  0
         Link link = (Link) getAllNodes().subset(Link.DOCUMENT_TYPE).get(name);
 383  0
         if (link == null)
 384  
         {
 385  0
             throw new DocumentNotFoundException("Jetspeed PSML link not found: " + name);
 386  
         }
 387  
 
 388  
         // check access
 389  0
         if (checkAccess)
 390  
         {
 391  0
             link.checkAccess(JetspeedActions.VIEW);
 392  
         }
 393  0
         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  0
         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  0
         if (checkAccess)
 422  
         {
 423  0
             checkAccess(JetspeedActions.VIEW);
 424  
         }
 425  
 
 426  
         // get pageSecurity
 427  0
         PageSecurity pageSecurity = (PageSecurity) getAllNodes( false ).subset(PageSecurity.DOCUMENT_TYPE).get(PageSecurity.DOCUMENT_TYPE);
 428  0
         if (pageSecurity == null)
 429  
         {
 430  0
             throw new DocumentNotFoundException("Jetspeed PSML page security not found: " + PageSecurity.DOCUMENT_TYPE);
 431  
         }
 432  0
         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  0
         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  0
         NodeSet nodes = getAllNodes();
 456  0
         NodeSet filteredNodes = null;
 457  0
         Iterator checkAccessIter = nodes.iterator();
 458  0
         while (checkAccessIter.hasNext())
 459  
         {
 460  0
             Node node = (Node)checkAccessIter.next();
 461  
             try
 462  
             {
 463  0
                 ((AbstractNode) node).checkAccess(JetspeedActions.VIEW);
 464  0
                 if (filteredNodes != null)
 465  
                 {
 466  0
                     filteredNodes.add(node);
 467  
                 }
 468  
             }
 469  0
             catch (SecurityException se)
 470  
             {
 471  0
                 if (filteredNodes == null)
 472  
                 {
 473  0
                     filteredNodes = new NodeSetImpl(getPath(), ((NodeSetImpl) nodes).getComparator());
 474  0
                     Iterator copyIter = nodes.iterator();
 475  0
                     while (copyIter.hasNext())
 476  
                     {
 477  0
                         Node copyNode = (Node)copyIter.next();
 478  0
                         if (copyNode != node)
 479  
                         {
 480  0
                             filteredNodes.add(copyNode);
 481  
                         }
 482  
                         else
 483  
                         {
 484  
                             break;
 485  
                         }
 486  0
                     }
 487  
                 }
 488  0
             }
 489  0
         }
 490  0
         if (filteredNodes != null)
 491  
         {
 492  0
             return filteredNodes;
 493  
         }
 494  0
         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  0
     	return getAllNodes( true );
 508  
     }
 509  
     
 510  
     protected synchronized NodeSet getAllNodes( boolean folderExistenceRequired ) throws DocumentException
 511  
     {
 512  0
         if((allNodes == null) && (folderHandler != class="keyword">null))
 513  
         {            
 514  0
             if(metadata.getDocumentOrder() != null)
 515  
             {
 516  0
                 if (getPath().endsWith(PATH_SEPARATOR))
 517  
                 {
 518  0
                     allNodes = new NodeSetImpl(getPath(), class="keyword">new NodeOrderCompartaor(metadata.getDocumentOrder(), getPath()));
 519  
                 }
 520  
                 else
 521  
                 {
 522  0
                     allNodes = new NodeSetImpl(getPath(), class="keyword">new NodeOrderCompartaor(metadata.getDocumentOrder(), getPath() + PATH_SEPARATOR));
 523  
                 }
 524  
             }
 525  
             else
 526  
             {
 527  0
                 allNodes = new NodeSetImpl(getPath());
 528  
             }
 529  
 
 530  
             try
 531  
             {
 532  0
                 String[] nodeNames = folderHandler.listAll(getPath());
 533  0
                 for (int i = 0; i < nodeNames.length; i++)
 534  
                 {
 535  0
                     if (!nodeNames[i].equals(FolderMetaDataImpl.DOCUMENT_TYPE))
 536  
                     {
 537  0
                         Node node = null;
 538  
                         try
 539  
                         {
 540  0
                             if (getPath().endsWith(PATH_SEPARATOR))
 541  
                             {
 542  0
                                 String full = PageManagerUtils.concatenatePaths(getPath(), nodeNames[i]); 
 543  0
                                 if (!folderHandler.isFolder(full))
 544  
                                 {
 545  0
                                     node = getHandlerFactory().getDocumentHandlerForPath(nodeNames[i]).getDocument(getPath() + nodeNames[i]);
 546  
                                 }
 547  
                                 else
 548  
                                 {
 549  0
                                     node = folderHandler.getFolder(getPath() + nodeNames[i]);
 550  
                                 }
 551  0
                             }
 552  
                             else
 553  
                             {
 554  0
                                 String full = PageManagerUtils.concatenatePaths(getPath(), nodeNames[i]); 
 555  0
                                 if (!folderHandler.isFolder(full))                                
 556  
                                 //if(nodeNames[i].indexOf(".") > -1)
 557  
                                 {
 558  0
                                     node = getHandlerFactory().getDocumentHandlerForPath(nodeNames[i]).getDocument(getPath() + PATH_SEPARATOR + nodeNames[i]);
 559  
                                 }
 560  
                                 else
 561  
                                 {
 562  0
                                     node = folderHandler.getFolder(getPath() + PATH_SEPARATOR + nodeNames[i]);
 563  
                                 }
 564  
                             }
 565  0
                             node.setParent(this);
 566  0
                             allNodes.add(node);
 567  
                         }               
 568  0
                         catch (UnsupportedDocumentTypeException e)
 569  
                         {
 570  
                             // Skip unsupported documents
 571  0
                             log.info("getAllNodes() Skipping unsupported document: "+nodeNames[i]);
 572  
                         }
 573  0
                         catch (Exception e)
 574  
                         {
 575  0
                             log.warn("getAllNodes() failed to create Node: "+nodeNames[i]+":"+e.toString(), e);
 576  0
                         }
 577  
                     }       
 578  
                 }
 579  
             }
 580  0
             catch (FolderNotFoundException fnfe)
 581  
             {
 582  0
             	if ( folderExistenceRequired )
 583  
             	{
 584  0
             		log.error( "getAllNodes() unexpected missing folder: " + getPath(), fnfe );
 585  
             	}
 586  0
             }
 587  
         }
 588  
         
 589  0
         return allNodes;
 590  
     }
 591  
     
 592  
     /**
 593  
      * <p>
 594  
      * getFolderMetaData
 595  
      * </p>
 596  
      *
 597  
      * @return implementation specific folder metadata
 598  
      */
 599  
     public FolderMetaDataImpl getFolderMetaData()
 600  
     {
 601  0
         return metadata;
 602  
     }
 603  
 
 604  
     /**
 605  
      * <p>
 606  
      * setFolderHandler
 607  
      * </p>
 608  
      *
 609  
      * @param handler folder handler
 610  
      */
 611  
     public void setFolderHandler(FolderHandler handler)
 612  
     {
 613  0
         this.folderHandler = handler;
 614  0
     }
 615  
 
 616  
     /**
 617  
      * <p>
 618  
      * getMetadata
 619  
      * </p>
 620  
      *
 621  
      * @see org.apache.jetspeed.page.document.AbstractNode#getMetadata()
 622  
      * @return metadata
 623  
      */
 624  
     public GenericMetadata getMetadata()
 625  
     {        
 626  0
         return metadata.getMetadata();
 627  
     }
 628  
 
 629  
     /**
 630  
      * <p>
 631  
      * getSecurityConstraints
 632  
      * </p>
 633  
      *
 634  
      * @see org.apache.jetspeed.om.common.SecureResource#getSecurityConstraints()
 635  
      * @return
 636  
      */
 637  
     public SecurityConstraints getSecurityConstraints()
 638  
     {
 639  0
         return metadata.getSecurityConstraints();
 640  
     }
 641  
     /**
 642  
      * <p>
 643  
      * setSecurityConstraints
 644  
      * </p>
 645  
      *
 646  
      * @see org.apache.jetspeed.om.common.SecureResource#setSecurityConstraints(org.apache.jetspeed.om.common.SecurityConstraints)
 647  
      * @param constraints
 648  
      */
 649  
     public void setSecurityConstraints(SecurityConstraints constraints)
 650  
     {
 651  0
         metadata.setSecurityConstraints(constraints);
 652  0
     }
 653  
 
 654  
     /**
 655  
      * getEffectivePageSecurity
 656  
      *
 657  
      * @see org.apache.jetspeed.om.page.psml.AbstractElementImpl#getEffectivePageSecurity()
 658  
      */
 659  
     public PageSecurity getEffectivePageSecurity()
 660  
     {
 661  
         // return single page security if available
 662  0
         PageSecurity pageSecurity = null;
 663  
         try
 664  
         {
 665  0
             pageSecurity = getPageSecurity(false);
 666  0
             if (pageSecurity != null)
 667  
             {
 668  0
                 return pageSecurity;
 669  
             }
 670  
         }
 671  0
         catch (NodeException ne)
 672  
         {
 673  
         }
 674  0
         catch (NodeNotFoundException nnfe)
 675  
         {
 676  0
         }
 677  
 
 678  
         // delegate to parent folder implementation
 679  0
         FolderImpl parentFolderImpl = (FolderImpl)getParent();
 680  0
         if (parentFolderImpl != null)
 681  
         {
 682  0
             return parentFolderImpl.getEffectivePageSecurity();
 683  
         }
 684  0
         return null;
 685  
     }
 686  
 
 687  
     /**
 688  
      * <p>
 689  
      * checkPermissions
 690  
      * </p>
 691  
      *
 692  
      * @param path
 693  
      * @param mask
 694  
      * @param checkNodeOnly
 695  
      * @param checkParentsOnly
 696  
      * @throws SecurityException
 697  
      */
 698  
     public void checkPermissions(String path, int mask, boolean checkNodeOnly, class="keyword">boolean checkParentsOnly) throws SecurityException
 699  
     {
 700  
         // check granted folder permissions unless the check is
 701  
         // to be skipped due to explicity granted access
 702  0
         if (!checkParentsOnly)
 703  
         {
 704  0
             FolderPermission permission = new FolderPermission(path, mask);
 705  0
             AccessController.checkPermission(permission);
 706  
         }
 707  
 
 708  
         // if not checking node only, recursively check
 709  
         // all parent permissions in hierarchy
 710  0
         if (!checkNodeOnly && (getParent() != null))
 711  
         {
 712  0
             ((AbstractNode)getParent()).checkPermissions(mask, false, false);
 713  
         }
 714  0
     }
 715  
 
 716  
     /**
 717  
      * <p>
 718  
      * getTitle
 719  
      * </p>
 720  
      *
 721  
      * @see org.apache.jetspeed.page.document.Node#getTitle(java.util.Locale)
 722  
      * @param locale
 723  
      * @return title in specified locale
 724  
      */
 725  
     public String getTitle( Locale locale )
 726  
     {
 727  0
         return metadata.getTitle(locale);
 728  
     }
 729  
     /**
 730  
      * <p>
 731  
      * getTitle
 732  
      * </p>
 733  
      *
 734  
      * @see org.apache.jetspeed.om.page.BaseElement#getTitle()
 735  
      * @return title
 736  
      */
 737  
     public String getTitle()
 738  
     {
 739  0
         return metadata.getTitle();
 740  
     }
 741  
     /**
 742  
      * <p>
 743  
      * setTitle
 744  
      * </p>
 745  
      *
 746  
      * @see org.apache.jetspeed.om.page.BaseElement#setTitle(java.lang.String)
 747  
      * @param title
 748  
      */
 749  
     public void setTitle( String title )
 750  
     {
 751  0
         metadata.setTitle(title);
 752  0
     }
 753  
     /**
 754  
      * <p>
 755  
      * getShortTitle
 756  
      * </p>
 757  
      *
 758  
      * @see org.apache.jetspeed.page.document.Node#getShortTitle(java.util.Locale)
 759  
      * @param locale
 760  
      * @return short title in supplied locate
 761  
      */
 762  
     public String getShortTitle( Locale locale )
 763  
     {
 764  0
         return metadata.getShortTitle(locale);
 765  
     }
 766  
     /**
 767  
      * <p>
 768  
      * getShortTitle
 769  
      * </p>
 770  
      *
 771  
      * @see org.apache.jetspeed.om.page.BaseElement#getShortTitle()
 772  
      * @return short title
 773  
      */
 774  
     public String getShortTitle()
 775  
     {
 776  0
         return metadata.getShortTitle();
 777  
     }
 778  
     /**
 779  
      * <p>
 780  
      * setShortTitle
 781  
      * </p>
 782  
      *
 783  
      * @see org.apache.jetspeed.om.page.BaseElement#setShortTitle(java.lang.String)
 784  
      * @param title
 785  
      */
 786  
     public void setShortTitle( String title )
 787  
     {
 788  0
         metadata.setShortTitle(title);
 789  0
     }
 790  
     /**
 791  
      * <p>
 792  
      * getType
 793  
      * </p>
 794  
      *
 795  
      * @see org.apache.jetspeed.page.document.Node#getType()
 796  
      * @return type string
 797  
      */
 798  
     public String getType()
 799  
     {
 800  0
         return FOLDER_TYPE;
 801  
     }
 802  
     /**
 803  
      * <p>
 804  
      * isHidden
 805  
      * </p>
 806  
      *
 807  
      * @see org.apache.jetspeed.page.document.Node#isHidden()
 808  
      * @return whether folder is hidden
 809  
      */
 810  
     public boolean isHidden()
 811  
     {
 812  0
         return metadata.isHidden();
 813  
     }
 814  
     /**
 815  
      * <p>
 816  
      * setHidden
 817  
      * </p>
 818  
      *
 819  
      * @see org.apache.jetspeed.page.document.AbstractNode#setHidden(boolean)
 820  
      * @param hidden
 821  
      */
 822  
     public void setHidden( boolean hidden )
 823  
     {        
 824  0
         ((AbstractNode)metadata).setHidden(hidden);
 825  0
     }
 826  
 
 827  
     /* (non-Javadoc)
 828  
      * @see org.apache.jetspeed.om.folder.Reset#reset()
 829  
      */
 830  
     public void reset()
 831  
     {
 832  0
         allNodes = null;
 833  
         
 834  0
     }
 835  
 
 836  
     /**
 837  
      * getMenuDefinitions - get list of menu definitions
 838  
      *
 839  
      * @return definition list
 840  
      */
 841  
     public List getMenuDefinitions()
 842  
     {
 843  0
         return metadata.getMenuDefinitions();
 844  
     }
 845  
 
 846  
     /**
 847  
      * newMenuDefinition - creates a new empty menu definition
 848  
      *
 849  
      * @return a newly created MenuDefinition object for use in Folder
 850  
      */
 851  
     public MenuDefinition newMenuDefinition()
 852  
     {
 853  0
         return new MenuDefinitionImpl();
 854  
     }
 855  
 
 856  
     /**
 857  
      * newMenuExcludeDefinition - creates a new empty menu exclude definition
 858  
      *
 859  
      * @return a newly created MenuExcludeDefinition object for use in Folder
 860  
      */
 861  
     public MenuExcludeDefinition newMenuExcludeDefinition()
 862  
     {
 863  0
         return new MenuExcludeDefinitionImpl();
 864  
     }
 865  
 
 866  
     /**
 867  
      * newMenuIncludeDefinition - creates a new empty menu include definition
 868  
      *
 869  
      * @return a newly created MenuIncludeDefinition object for use in Folder
 870  
      */
 871  
     public MenuIncludeDefinition newMenuIncludeDefinition()
 872  
     {
 873  0
         return new MenuIncludeDefinitionImpl();
 874  
     }
 875  
 
 876  
     /**
 877  
      * newMenuOptionsDefinition - creates a new empty menu options definition
 878  
      *
 879  
      * @return a newly created MenuOptionsDefinition object for use in Folder
 880  
      */
 881  
     public MenuOptionsDefinition newMenuOptionsDefinition()
 882  
     {
 883  0
         return new MenuOptionsDefinitionImpl();
 884  
     }
 885  
 
 886  
     /**
 887  
      * newMenuSeparatorDefinition - creates a new empty menu separator definition
 888  
      *
 889  
      * @return a newly created MenuSeparatorDefinition object for use in Folder
 890  
      */
 891  
     public MenuSeparatorDefinition newMenuSeparatorDefinition()
 892  
     {
 893  0
         return new MenuSeparatorDefinitionImpl();
 894  
     }
 895  
 
 896  
     /**
 897  
      * setMenuDefinitions - set list of menu definitions
 898  
      *
 899  
      * @param definitions definition list
 900  
      */
 901  
     public void setMenuDefinitions(List definitions)
 902  
     {
 903  0
         metadata.setMenuDefinitions(definitions);
 904  0
     }
 905  
 
 906  
     /**
 907  
      * unmarshalled - notification that this instance has been
 908  
      *                loaded from the persistent store
 909  
      */
 910  
     public void unmarshalled()
 911  
     {
 912  
         // notify super class implementation
 913  0
         super.unmarshalled();
 914  
 
 915  
         // default title of pages to name
 916  0
         if (getTitle() == null)
 917  
         {
 918  0
             setTitle(getTitleName());
 919  
         }
 920  0
     }
 921  
     
 922  
     public boolean isReserved()
 923  
     {
 924  0
         return (reservedType > RESERVED_FOLDER_NONE);
 925  
     }
 926  
     
 927  
     public int getReservedType()
 928  
     {
 929  0
         return reservedType;
 930  
     }
 931  
     
 932  
     private void setReservedType()
 933  
     {
 934  0
         String name = getName();
 935  0
         if (name != null)
 936  
         {
 937  0
             if (name.startsWith(RESERVED_SUBSITE_FOLDER_PREFIX))
 938  
             {
 939  0
                 reservedType = RESERVED_FOLDER_SUBSITES;
 940  
             }
 941  0
             else if (name.startsWith(RESERVED_FOLDER_PREFIX))            
 942  
             {
 943  0
                 if (name.equals(RESERVED_USER_FOLDER_NAME))
 944  0
                     reservedType = RESERVED_FOLDER_USERS;
 945  0
                 else if (name.equals(RESERVED_ROLE_FOLDER_NAME))
 946  0
                     reservedType = RESERVED_FOLDER_ROLES;
 947  0
                 else if (name.equals(RESERVED_GROUP_FOLDER_NAME))
 948  0
                     reservedType = RESERVED_FOLDER_GROUPS;
 949  0
                 else if (name.equals(RESERVED_MEDIATYPE_FOLDER_NAME))
 950  0
                     reservedType = RESERVED_FOLDER_MEDIATYPE;
 951  0
                 else if (name.equals(RESERVED_LANGUAGE_FOLDER_NAME))
 952  0
                     reservedType = RESERVED_FOLDER_LANGUAGE;
 953  0
                 else if (name.equals(RESERVED_COUNTRY_FOLDER_NAME))
 954  0
                     reservedType = RESERVED_FOLDER_COUNTRY;
 955  
                 else
 956  0
                     reservedType = RESERVED_FOLDER_OTHER;            
 957  
             }
 958  
         }
 959  0
     }
 960  
     
 961  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.