public void addPolicy(Policy policy) throws PolicyException {
// Add BlueprintPolicy
if (policy instanceof BlueprintPolicy) {
if (erectors.get(policy.getTarget()) == null) {
throw new PolicyException("Blueprint does not exist for BlueprintPolicy target: " + policy.getTarget());
}
List<BlueprintPolicy> policies = blueprintPolicies.get(policy.getTarget());
if (policies == null) {
policies = new ArrayList<BlueprintPolicy>();
}
policies.add((BlueprintPolicy) policy);
logger.info("Setting BlueprintPolicy {} for {}", policy, policy.getTarget());
blueprintPolicies.put(policy.getTarget(), policies);
// Add FieldPolicy
} else if (policy instanceof FieldPolicy) {
// XXX: force FieldPolicy's to be mapped to a blueprint? Limits their scope, but enables validation
if (erectors.get(policy.getTarget()) == null) {
throw new PolicyException("Blueprint does not exist for FieldPolicy target: " + policy.getTarget());
}
List<FieldPolicy> policies = fieldPolicies.get(policy.getTarget());
if (policies == null) {
policies = new ArrayList<FieldPolicy>();