use of org.jaffa.applications.jaffa.modules.admin.components.checkpolicy.ui.exceptions.CheckPolicyException in project jaffa-framework by jaffa-projects.
the class CheckPolicyComponent method readFunctions.
/**
* This reads the bussiness-functions from the bussiness-functions.xml file
* @throws ApplicationExceptions if any error occurs.
*/
private List readFunctions() throws ApplicationExceptions {
ApplicationExceptions appExps = new ApplicationExceptions();
ArrayList bflist = new ArrayList();
InputStream stream = null;
try {
stream = URLHelper.newExtendedURL("resources/business-functions.xml").openStream();
// create a JAXBContext capable of handling classes generated into the package
JAXBContext jc = JAXBContext.newInstance("org.jaffa.security.businessfunctionsdomain");
// create an Unmarshaller
Unmarshaller u = jc.createUnmarshaller();
// enable validation
u.setSchema(JAXBHelper.createSchema(SCHEMA));
// unmarshal a document into a tree of Java content objects composed of classes from the package.
BusinessFunctions businessFunctions = (BusinessFunctions) u.unmarshal(XmlHelper.stripDoctypeDeclaration(stream));
for (Iterator i = businessFunctions.getBusinessFunction().iterator(); i.hasNext(); ) {
bflist.add(((BusinessFunction) i.next()).getName());
}
} catch (Exception e) {
appExps.add(new CheckPolicyException(CheckPolicyException.PROP_FILEREAD_ERROR, StringHelper.convertToHTML(e.getMessage())));
throw appExps;
} finally {
try {
if (stream != null) {
stream.close();
}
} catch (IOException e) {
// do nothing
}
}
return bflist;
}
Aggregations