private boolean contractAlreadyExists ( String organizationId , String clientId , String version , NewContractBean bean ) { try { List < ContractSummaryBean > contracts = query . getClientContracts ( organizationId , clientId , version ) ; for ( ContractSummaryBean contract : contracts ) { if ( contract . getApiOrganizationId ( ) . equals ( bean . getApiOrgId ( ) ) && contract . getApiId ( ) . equals ( bean . getApiId ( ) ) && contract . getApiVersion ( ) . equals ( bean . getApiVersion ( ) ) && contract . getPlanId ( ) . equals ( bean . getPlanId ( ) ) ) { return true ; } } return false ; } catch ( StorageException e ) { return false ; } }
Check to see if the contract already exists by getting a list of all the client s contracts and comparing with the one being created .