private List < Policy > aggregateContractPolicies ( ContractSummaryBean contractBean ) { try { 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 = contractBean . getClientOrganizationId ( ) ; id = contractBean . getClientId ( ) ; ver = contractBean . getClientVersion ( ) ; break ; } case Plan : { org = contractBean . getApiOrganizationId ( ) ; id = contractBean . getPlanId ( ) ; ver = contractBean . getPlanVersion ( ) ; break ; } case Api : { org = contractBean . getApiOrganizationId ( ) ; id = contractBean . getApiId ( ) ; ver = contractBean . getApiVersion ( ) ; break ; } default : { throw new RuntimeException ( "Missing case for switch!" ) ; //$NON-NLS-1$ } } List < PolicySummaryBean > clientPolicies = query . getPolicies ( org , id , ver , policyType ) ; try { storage . beginTx ( ) ; for ( PolicySummaryBean policySummaryBean : clientPolicies ) { PolicyBean policyBean = storage . getPolicy ( policyType , org , id , ver , policySummaryBean . getId ( ) ) ; Policy policy = new Policy ( ) ; policy . setPolicyJsonConfig ( policyBean . getConfiguration ( ) ) ; policy . setPolicyImpl ( policyBean . getDefinition ( ) . getPolicyImpl ( ) ) ; policies . add ( policy ) ; } } finally { storage . rollbackTx ( ) ; } } return policies ; } catch ( Exception e ) { throw ExceptionFactory . actionException ( Messages . i18n . format ( "ErrorAggregatingPolicies" , contractBean . getClientId ( ) + "->" + contractBean . getApiDescription ( ) ) , e ) ; //$NON-NLS-1$ //$NON-NLS-2$ } }
Aggregates the API client and plan policies into a single ordered list .