Coverage Report - org.openpermis.policy.bean.basic.BasicTargetAccessRuleCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
BasicTargetAccessRuleCollection
85%
12/14
100%
4/4
1.4
 
 1  
 /*
 2  
  * Copyright (c) 2009, Swiss Federal Department of Defence Civil Protection and Sport
 3  
  *                     (http://www.vbs.admin.ch)
 4  
  * Copyright (c) 2009, Ergon Informatik AG (http://www.ergon.ch)
 5  
  * All rights reserved.
 6  
  *
 7  
  * Licensed under the Open Permis License which accompanies this distribution,
 8  
  * and is available at http://www.openpermis.org/BSDlicenceKent.txt
 9  
  */
 10  
 package org.openpermis.policy.bean.basic;
 11  
 
 12  
 import java.net.URI;
 13  
 import java.util.ArrayList;
 14  
 import java.util.Collection;
 15  
 import java.util.List;
 16  
 
 17  
 import org.openpermis.policy.AuthorizedRoles;
 18  
 import org.openpermis.policy.TimeStamp;
 19  
 import org.openpermis.policy.bean.SerialNumber;
 20  
 import org.openpermis.policy.bean.TargetAccessRuleBean;
 21  
 import org.openpermis.policy.bean.TargetAccessRuleBeanCollection;
 22  
 
 23  
 
 24  
 /**
 25  
  * Basic implementation of {@link TargetAccessRuleBeanCollection}.
 26  
  * @since 0.3.0
 27  
  */
 28  0
 public class BasicTargetAccessRuleCollection 
 29  
         extends BasicAbstractCollection<TargetAccessRuleBean> 
 30  
         implements TargetAccessRuleBeanCollection 
 31  
 {
 32  
         
 33  
         //---- Static
 34  
         
 35  
         private static final long serialVersionUID = -956620427014379243L;
 36  
 
 37  
         //---- State
 38  
         
 39  
         //---- Constructors
 40  
         
 41  
         /**
 42  
          * Creates a basic target access rule collection.
 43  
          * @param serialNumber the serial number of this part.
 44  
          * @since 0.3.0
 45  
          */
 46  
         protected BasicTargetAccessRuleCollection (SerialNumber serialNumber) {
 47  266
                 super(serialNumber);
 48  266
         }
 49  
         
 50  
         /**
 51  
          * Creates a basic target access rule collection.
 52  
          * @param serialNumber the serial number of this part.
 53  
          * @param collection a collection of {@link TargetAccessRuleBean}'s.
 54  
          * @since 0.3.0
 55  
          */
 56  
         protected BasicTargetAccessRuleCollection (
 57  
                 SerialNumber serialNumber, 
 58  
                 Collection<TargetAccessRuleBean> collection
 59  
         ) {
 60  249
                 super(serialNumber, collection);
 61  248
         }
 62  
         
 63  
         //---- Methods
 64  
         
 65  
         //---- TargetAccessRuleCollection
 66  
         
 67  
         /**
 68  
          * @since 0.3.0
 69  
          */
 70  
         public List<AuthorizedRoles> findAuthorizedRoleSets (
 71  
                 URI resourceUri, 
 72  
                 String actionName, 
 73  
                 List<?> arguments, 
 74  
                 TimeStamp timeStamp
 75  
         ) {
 76  15
                 final List<AuthorizedRoles> result = 
 77  
                         new ArrayList<AuthorizedRoles>();
 78  15
                 for (TargetAccessRuleBean targetAccessRule : this) {
 79  52
                         final AuthorizedRoles pair =
 80  
                                 targetAccessRule.findAuthorizedRoleSet(
 81  
                                         resourceUri, actionName, arguments, timeStamp
 82  
                                 );
 83  52
                         if (pair != null) {
 84  13
                                 result.add(pair);
 85  
                         }
 86  52
                 }
 87  15
                 return result;
 88  
         }
 89  
         
 90  
         //---- BasicAbstractCollection
 91  
         
 92  
         /**
 93  
          * @since 0.3.0
 94  
          */
 95  
         protected boolean isCollectionType (BasicPart part) {
 96  935
                 return part instanceof TargetAccessRuleBeanCollection;
 97  
         }
 98  
         
 99  
         //---- BeanCollection
 100  
         
 101  
         /**
 102  
          * @since 0.3.0
 103  
          */
 104  
         public BasicTargetAccessRuleCollection create (List<TargetAccessRuleBean> list) {
 105  0
                 return new BasicTargetAccessRuleCollection(getSerialNumber().next(), list);
 106  
         }
 107  
         
 108  
 }