main/src/main/java/org/onap/policy/pap/main/rest/depundep/PdpGroupDeployProvider.java
/**
     * Adds a policy to a subgroup, if it isn't there already.
     */
Adds a policy to a subgroup, if it isn't there already.
Adds a policy to a subgroup if it isn ' t there already .
@Override
    protected BiFunction<PdpGroup, PdpSubGroup, Boolean> makeUpdater(ToscaPolicy policy,
                    ToscaPolicyIdentifierOptVersion requestedIdent) {
        ToscaPolicyIdentifier desiredIdent = policy.getIdentifier();
        ToscaPolicyTypeIdentifier desiredType = policy.getTypeIdentifier();
        return (group, subgroup) -> {
            if (!subgroup.getSupportedPolicyTypes().contains(desiredType)) {
                return false;
            }
            if (containsPolicy(group, subgroup, desiredIdent)) {
                return false;
            }
            if (subgroup.getPdpInstances().isEmpty()) {
                throw new PfModelRuntimeException(Status.BAD_REQUEST, "group " + group.getName() + " subgroup "
                                + subgroup.getPdpType() + " has no active PDPs");
            }
            subgroup.getPolicies().add(desiredIdent);
            logger.info("add policy {} {} to subgroup {} {} count={}", desiredIdent.getName(),
                            desiredIdent.getVersion(), group.getName(), subgroup.getPdpType(),
                            subgroup.getPolicies().size());
            return true;
        };
    }
@ Override protected BiFunction < PdpGroup , PdpSubGroup , Boolean > makeUpdater ( ToscaPolicy policy , ToscaPolicyIdentifierOptVersion requestedIdent ) { ToscaPolicyIdentifier desiredIdent = policy . getIdentifier ( ) ; ToscaPolicyTypeIdentifier desiredType = policy . getTypeIdentifier ( ) ; return ( group , subgroup ) -> { if ( ! subgroup . getSupportedPolicyTypes ( ) . contains ( desiredType ) ) { return false ; } if ( containsPolicy ( group , subgroup , desiredIdent ) ) { return false ; } if ( subgroup . getPdpInstances ( ) . isEmpty ( ) ) { throw new PfModelRuntimeException ( Status . BAD_REQUEST , "group " + group . getName ( ) + " subgroup " + subgroup . getPdpType ( ) + " has no active PDPs" ) ; } subgroup . getPolicies ( ) . add ( desiredIdent ) ; logger . info ( "add policy {} {} to subgroup {} {} count={}" , desiredIdent . getName ( ) , desiredIdent . getVersion ( ) , group . getName ( ) , subgroup . getPdpType ( ) , subgroup . getPolicies ( ) . size ( ) ) ; return true ; } ; }
Adds a policy to a subgroup, if it isn't there already.
Adds a policy to a subgroup if it isn ' t there already .
// doesn't support the desired policy type // add the policy to the subgroup