@Override public Map<String, AbstractPolicy> getPolicies(EvaluationCtx eval, PolicyFinder policyFinder) throws PolicyIndexException { // no indexing, return everything // return a copy, otherwise the map could change during evaluation if policies are added, deleted etc readLock.lock(); try { Map<String, AbstractPolicy> result = new ConcurrentHashMap<String, AbstractPolicy>(); for(String id:policies.keySet()){ AbstractPolicy policy = handleDocument(m_policyReader.readPolicy(policies.get(id)),policyFinder); result.put(id, policy); } return result; } catch (ParsingException pe) { throw new PolicyIndexException(pe.getMessage(),pe); }finally { readLock.unlock(); } }
@Override public AbstractPolicy getPolicy(String name, PolicyFinder policyFinder) throws PolicyIndexException { readLock.lock(); try { logger.debug("Getting policy named: " + name); if (policies.containsKey(name)) { return handleDocument(m_policyReader.readPolicy(policies.get(name)), policyFinder); } else { throw new PolicyIndexException("Attempting to get non-existent policy " + name); } } catch (ParsingException pe) { throw new PolicyIndexException(pe.getMessage(),pe); } finally { readLock.unlock(); } }
@Override public AbstractPolicy getPolicy(String name, PolicyFinder policyFinder) throws PolicyIndexException { try { readLock.lock(); XMLResource resource = (XMLResource) m_collection.getResource(nameToId(name)); if (resource == null) { log.error("Attempting to get non-existant resource " + name); throw new PolicyIndexException("Attempting to get non-existant resource " + name); } Document policyDoc = m_policyReader.readPolicy(((String)resource.getContent()).getBytes("UTF-8")); return handleDocument(policyDoc, policyFinder); } catch (UnsupportedEncodingException e) { // Should never happen throw new RuntimeException("Unsupported encoding " + e.getMessage(), e); } catch (XMLDBException e) { log.error("Error getting policy " + name + " " + e.getMessage(), e); throw new PolicyIndexException("Error getting policy " + name + " " + e.getMessage(), e); } catch (ParsingException e) { log.error("Error getting policy " + name + " " + e.getMessage(), e); throw new PolicyIndexException("Error getting policy " + name + " " + e.getMessage(), e); } finally { readLock.unlock(); } }
Status status = new Status(code, pe.getMessage());
@Override public AbstractPolicy getPolicy(String name, PolicyFinder policyFinder) throws PolicyIndexException { log.debug("Getting document: " + name); XmlDocument doc = null; DbXmlManager.readLock.lock(); try { doc = m_dbXmlManager.container.getDocument(name); return handleDocument(m_policyReader.readPolicy(doc.getContent()), policyFinder); } catch (XmlException xe) { throw new PolicyIndexException("Error getting Policy: " + name + xe.getMessage() + " - " + xe.getDatabaseException().getMessage(), xe); } catch (ParsingException pe) { throw new PolicyIndexException("Error getting Policy: " + name + pe.getMessage(), pe); } finally { DbXmlManager.readLock.unlock(); } }
return createProcessingError(pe.getMessage()); } catch (UnknownIdentifierException uie) { return createProcessingError("unknown attribute type: " + type);
throw new PolicyIndexException("Error retrieving query results " + e.getMessage(), e); } catch (ParsingException e) { log.error("Error retrieving query results " + e.getMessage(), e); throw new PolicyIndexException("Error retrieving query results " + e.getMessage(), e); } catch (UnsupportedEncodingException e) {
throw new PolicyIndexException("Error getting query results." + xe.getMessage(), xe); } catch (ParsingException pe) { log.error("Error getting query results." + pe.getMessage()); throw new PolicyIndexException("Error getting query results." + pe.getMessage(), pe); } finally { DbXmlManager.readLock.unlock();