main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java
/**
     * Determines if a subgroup already contains the desired policy.
     *
     * @param group group that contains the subgroup
     * @param subgroup subgroup of interest
     * @param desiredIdent identifier of the desired policy
     * @return {@code true} if the subgroup contains the desired policy, {@code false}
     *         otherwise
     * @throws PfModelRuntimeException if the subgroup contains a different version of the
     *         desired policy
     */
Determines if a subgroup already contains the desired policy.
Determines if a subgroup already contains the desired policy .
private boolean containsPolicy(PdpGroup group, PdpSubGroup subgroup, ToscaPolicyIdentifier desiredIdent) {
        String desnm = desiredIdent.getName();
        String desvers = desiredIdent.getVersion();
        for (ToscaPolicyIdentifier actualIdent : subgroup.getPolicies()) {
            if (!actualIdent.getName().equals(desnm)) {
                continue;
            }
            if (!actualIdent.getVersion().equals(desvers)) {
                throw new PfModelRuntimeException(Status.BAD_REQUEST,
                                "group " + group.getName() + " subgroup " + subgroup.getPdpType() + " policy " + desnm
                                                + " " + desvers + " different version already deployed: "
                                                + actualIdent.getVersion());
            }
            logger.info("subgroup {} {} already contains policy {} {}", group.getName(), subgroup.getPdpType(), desnm,
                            desvers);
            return true;
        }
        return false;
    }
private boolean containsPolicy ( PdpGroup group , PdpSubGroup subgroup , ToscaPolicyIdentifier desiredIdent ) { String desnm = desiredIdent . getName ( ) ; String desvers = desiredIdent . getVersion ( ) ; for ( ToscaPolicyIdentifier actualIdent : subgroup . getPolicies ( ) ) { if ( ! actualIdent . getName ( ) . equals ( desnm ) ) { continue ; } if ( ! actualIdent . getVersion ( ) . equals ( desvers ) ) { throw new PfModelRuntimeException ( Status . BAD_REQUEST , "group " + group . getName ( ) + " subgroup " + subgroup . getPdpType ( ) + " policy " + desnm + " " + desvers + " different version already deployed: " + actualIdent . getVersion ( ) ) ; } logger . info ( "subgroup {} {} already contains policy {} {}" , group . getName ( ) , subgroup . getPdpType ( ) , desnm , desvers ) ; return true ; } return false ; }
Determines if a subgroup already contains the desired policy.
Determines if a subgroup already contains the desired policy .
// found the policy - ensure the version matches // already has the desired policy & version