private List < Policy > aggregateContractPolicies ( ContractBean contractBean , EntityInfo clientInfo ) throws StorageException { List < Policy > policies = new ArrayList <> ( ) ; PolicyType [ ] types = new PolicyType [ ] { PolicyType . Client , PolicyType . Plan , PolicyType . Api } ; for ( PolicyType policyType : types ) { String org , id , ver ; switch ( policyType ) { case Client : { org = clientInfo . organizationId ; id = clientInfo . id ; ver = clientInfo . version ; break ; } case Plan : { org = contractBean . getApi ( ) . getApi ( ) . getOrganization ( ) . getId ( ) ; id = contractBean . getPlan ( ) . getPlan ( ) . getId ( ) ; ver = contractBean . getPlan ( ) . getVersion ( ) ; break ; } case Api : { org = contractBean . getApi ( ) . getApi ( ) . getOrganization ( ) . getId ( ) ; id = contractBean . getApi ( ) . getApi ( ) . getId ( ) ; ver = contractBean . getApi ( ) . getVersion ( ) ; break ; } default : { throw new RuntimeException ( "Missing case for switch!" ) ; //$NON-NLS-1$ } } Iterator < PolicyBean > clientPolicies = storage . getAllPolicies ( org , id , ver , policyType ) ; while ( clientPolicies . hasNext ( ) ) { PolicyBean policyBean = clientPolicies . next ( ) ; Policy policy = new Policy ( ) ; policy . setPolicyJsonConfig ( policyBean . getConfiguration ( ) ) ; policy . setPolicyImpl ( policyBean . getDefinition ( ) . getPolicyImpl ( ) ) ; policies . add ( policy ) ; } } return policies ; }
Aggregates the api client and plan policies into a single ordered list .