Coverage report

  %line %branch
org.apache.jetspeed.om.page.impl.PageSecurityImpl
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.page.impl;
 18  
 
 19  
 import java.util.HashMap;
 20  
 import java.util.Iterator;
 21  
 import java.util.List;
 22  
 import java.util.Map;
 23  
 
 24  
 import org.apache.jetspeed.om.common.SecurityConstraint;
 25  
 import org.apache.jetspeed.om.page.PageSecurity;
 26  
 import org.apache.jetspeed.om.page.SecurityConstraintsDef;
 27  
 import org.apache.jetspeed.page.document.impl.DocumentImpl;
 28  
 import org.apache.jetspeed.page.impl.DatabasePageManagerUtils;
 29  
 
 30  
 /**
 31  
  * PageSecurityImpl
 32  
  *
 33  
  * @author <a href="mailto:rwatler@apache.org">Randy Watler</a>
 34  
  * @version $Id$
 35  
  */
 36  
 public class PageSecurityImpl extends DocumentImpl implements PageSecurity
 37  
 {
 38  
     private List constraintsDefs;
 39  
     private List globalConstraintsRefs;
 40  
 
 41  
     private PageSecurityConstraintsDefList securityConstraintsDefs;
 42  
     private Map securityConstraintsDefsMap;
 43  
     private PageSecurityConstraintsRefList globalSecurityConstraintsRefs;
 44  
 
 45  
     public PageSecurityImpl()
 46  
     {
 47  0
         super(null);
 48  0
     }
 49  
 
 50  
     /**
 51  
      * accessConstraintsDefs
 52  
      *
 53  
      * Access mutable persistent collection member for List wrappers.
 54  
      *
 55  
      * @return persistent collection
 56  
      */
 57  
     List accessConstraintsDefs()
 58  
     {
 59  
         // create initial collection if necessary
 60  0
         if (constraintsDefs == null)
 61  
         {
 62  0
             constraintsDefs = DatabasePageManagerUtils.createList();
 63  
         }
 64  0
         return constraintsDefs;
 65  
     }
 66  
 
 67  
     /**
 68  
      * accessGlobalConstraintsRefs
 69  
      *
 70  
      * Access mutable persistent collection member for List wrappers.
 71  
      *
 72  
      * @return persistent collection
 73  
      */
 74  
     List accessGlobalConstraintsRefs()
 75  
     {
 76  
         // create initial collection if necessary
 77  0
         if (globalConstraintsRefs == null)
 78  
         {
 79  0
             globalConstraintsRefs = DatabasePageManagerUtils.createList();
 80  
         }
 81  0
         return globalConstraintsRefs;
 82  
     }
 83  
 
 84  
     /**
 85  
      * clearSecurityConstraintsDefsMap
 86  
      *
 87  
      * Clear previously cached security constraints definitions map.
 88  
      */
 89  
     synchronized void clearSecurityConstraintsDefsMap()
 90  
     {
 91  0
         securityConstraintsDefsMap = null;
 92  0
     }
 93  
 
 94  
     /* (non-Javadoc)
 95  
      * @see org.apache.jetspeed.om.common.SecuredResource#newSecurityConstraint()
 96  
      */
 97  
     public SecurityConstraint newSecurityConstraint()
 98  
     {
 99  
         // return specific security constraint definition instance
 100  0
         return new PageSecuritySecurityConstraintImpl();
 101  
     }
 102  
 
 103  
     /* (non-Javadoc)
 104  
      * @see org.apache.jetspeed.om.page.PageSecurity#getSecurityConstraintsDefs()
 105  
      */
 106  
     public List getSecurityConstraintsDefs()
 107  
     {
 108  
         // return mutable constraints defs list
 109  
         // by using list wrapper to manage
 110  
         // element uniqueness
 111  0
         if (securityConstraintsDefs == null)
 112  
         {
 113  0
             securityConstraintsDefs = new PageSecurityConstraintsDefList(this);
 114  
         }
 115  0
         return securityConstraintsDefs;
 116  
     }
 117  
     
 118  
     /* (non-Javadoc)
 119  
      * @see org.apache.jetspeed.om.common.SecuredResource#newSecurityConstraintsDef()
 120  
      */
 121  
     public SecurityConstraintsDef newSecurityConstraintsDef()
 122  
     {
 123  
         // return specific security constraints definition instance
 124  0
         return new SecurityConstraintsDefImpl();
 125  
     }
 126  
 
 127  
     /* (non-Javadoc)
 128  
      * @see org.apache.jetspeed.om.page.PageSecurity#setSecurityConstraintsDefs(java.util.List)
 129  
      */
 130  
     public void setSecurityConstraintsDefs(List definitions)
 131  
     {
 132  
         // set constraints defs by replacing existing
 133  
         // entries with new elements if new collection
 134  
         // is specified
 135  0
         List securityConstraintsDefs = getSecurityConstraintsDefs();
 136  0
         if (definitions != securityConstraintsDefs)
 137  
         {
 138  
             // replace all constraints definitions
 139  0
             securityConstraintsDefs.clear();
 140  0
             if (definitions != null)
 141  
             {
 142  0
                 securityConstraintsDefs.addAll(definitions);
 143  
             }
 144  
         }
 145  
         // clear cached security constraints definition map
 146  0
         clearSecurityConstraintsDefsMap();
 147  0
     }
 148  
 
 149  
     /* (non-Javadoc)
 150  
      * @see org.apache.jetspeed.om.page.PageSecurity#getSecurityConstraintsDef(java.lang.String)
 151  
      */
 152  
     public synchronized SecurityConstraintsDef getSecurityConstraintsDef(String name)
 153  
     {
 154  
         // build and cache security constraints definitions
 155  
         // map if necessary upon realization or after modification
 156  0
         if ((getSecurityConstraintsDefs() != null) && (securityConstraintsDefsMap == class="keyword">null))
 157  
         {
 158  0
             securityConstraintsDefsMap = new HashMap((getSecurityConstraintsDefs().size() * 2) + 1);
 159  0
             Iterator definitionsIter = getSecurityConstraintsDefs().iterator();
 160  0
             while (definitionsIter.hasNext())
 161  
             {
 162  0
                 SecurityConstraintsDef definition = (SecurityConstraintsDef)definitionsIter.next();
 163  0
                 String definitionName = definition.getName();
 164  0
                 if (!securityConstraintsDefsMap.containsKey(definitionName))
 165  
                 {
 166  0
                     securityConstraintsDefsMap.put(definitionName, definition);
 167  
                 }
 168  0
             }
 169  
         }
 170  
         // lookup constraints definition using cached map 
 171  0
         if (securityConstraintsDefsMap != null)
 172  
         {
 173  0
             return (SecurityConstraintsDef)securityConstraintsDefsMap.get(name);
 174  
         }
 175  0
         return null;
 176  
     }
 177  
 
 178  
     /* (non-Javadoc)
 179  
      * @see org.apache.jetspeed.om.page.PageSecurity#getGlobalSecurityConstraintsRefs()
 180  
      */
 181  
     public List getGlobalSecurityConstraintsRefs()
 182  
     {
 183  
         // return mutable constraints refs list
 184  
         // by using list wrapper to manage apply
 185  
         // order and element uniqueness
 186  0
         if (globalSecurityConstraintsRefs == null)
 187  
         {
 188  0
             globalSecurityConstraintsRefs = new PageSecurityConstraintsRefList(this);
 189  
         }
 190  0
         return globalSecurityConstraintsRefs;
 191  
     }
 192  
     
 193  
     /* (non-Javadoc)
 194  
      * @see org.apache.jetspeed.om.page.PageSecurity#setGlobalSecurityConstraintsRefs(java.util.List)
 195  
      */
 196  
     public void setGlobalSecurityConstraintsRefs(List constraintsRefs)
 197  
     {
 198  
         // set constraints refs using ordered ref
 199  
         // names by replacing existing entries with
 200  
         // new elements if new collection is specified
 201  0
         List globalSecurityConstraintsRefs = getGlobalSecurityConstraintsRefs();
 202  0
         if (constraintsRefs != globalSecurityConstraintsRefs)
 203  
         {
 204  
             // replace all constraints ref names
 205  0
             globalSecurityConstraintsRefs.clear();
 206  0
             if (constraintsRefs != null)
 207  
             {
 208  0
                 globalSecurityConstraintsRefs.addAll(constraintsRefs);
 209  
             }
 210  
         }
 211  0
     }
 212  
 
 213  
     /* (non-Javadoc)
 214  
      * @see org.apache.jetspeed.page.document.Node#getType()
 215  
      */
 216  
     public String getType()
 217  
     {
 218  0
         return DOCUMENT_TYPE;
 219  
     }
 220  
 }

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