/** * Returns the id of this policy. If the policy is invalid or can't be * retrieved, then a runtime exception is thrown. * * @return the policy id * * @throws ProcessingException if the referenced policy can't be retrieved */ public URI getId() { return resolvePolicy().getId(); }
/** * Adds a new policy to the collection, and uses the policy's identifier * as the reference identifier. If this identifier already exists in the * collection, and this policy does not represent a new version of the * policy, then the policy is not added. * * @param policy the policy to add * * @return true if the policy was added, false otherwise */ public boolean addPolicy(AbstractPolicy policy) { return addPolicy(policy, policy.getId().toString()); }
@Override public Map<String, AbstractPolicy> loadPolicies(PolicyParser policyParser, boolean validate, File dir) throws IOException, ValidationException { Map<String,AbstractPolicy> policies = new HashMap<String,AbstractPolicy>(); File defaultDir = new File(dir,"default"); if (defaultDir.exists()){ policies.putAll(loadPolicies(policyParser, validate,defaultDir)); } for (File file: dir.listFiles()) { if (!file.getName().equals("default")){ if (file.isDirectory()) { policies.putAll(loadPolicies(policyParser, validate, file)); } else { if (file.getName().endsWith(".xml")) { logger.info("Loading policy: {}", file.getPath()); InputStream policyStream = new FileInputStream(file); AbstractPolicy policy = policyParser.parse(policyStream, validate); logger.info("Loaded policy ID: {}", policy.getId()); String key = null; if (m_override == Strategy.FILENAME) { key = file.getName(); } else key = policy.getId().toString(); policies.put(key, policy); } } } } return policies; }
@Override public Map<String, AbstractPolicy> loadPolicies(PolicyParser policyParser, boolean validate, File dir) throws IOException, ValidationException { Map<String,AbstractPolicy> policies = new HashMap<String,AbstractPolicy>(); File defaultDir = new File(dir,"default"); if (defaultDir.exists()){ policies.putAll(loadPolicies(policyParser, validate,defaultDir)); } for (File file: dir.listFiles()) { if (!file.getName().equals("default")){ if (file.isDirectory()) { policies.putAll(loadPolicies(policyParser, validate, file)); } else { if (file.getName().endsWith(".xml")) { logger.info("Loading policy: {}", file.getPath()); InputStream policyStream = new FileInputStream(file); AbstractPolicy policy = policyParser.parse(policyStream, validate); logger.info("Loaded policy ID: {}", policy.getId()); String key = null; if (m_override == Strategy.FILENAME) { key = file.getName(); } else key = policy.getId().toString(); policies.put(key, policy); } } } } return policies; }