/** * Loads the rule dictionary from the specified dictionaryPath * * @param dictionaryLocation The full path to the .rules file. * @return A rule dictionary object * @see readDictionary http://docs.oracle.com/cd/E23943_01/apirefs.1111/e10663/toc.htm */ public static RuleDictionary loadRuleDictionary(String dictionaryLocation) throws Exception { RuleDictionary dict = null; Reader reader = null; Writer writer = null; try { reader = new FileReader(new File(dictionaryLocation)); dict = RuleDictionary.readDictionary(reader, new DecisionPointDictionaryFinder(null)); List<SDKWarning> warnings = new ArrayList<SDKWarning>(); dict.update(warnings); if (warnings.size() > 0) { System.err.println("Validation warnings: " + warnings); } } finally { if (reader != null) { try { reader.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } if (writer != null) { try { writer.close(); } catch (IOException ioe) { ioe.printStackTrace(); } } } return dict; }
/** * Update the rule dictionary from the specified dictionaryPath * * @param A rule dictionary object * @return boolean true if the update was successful otherwise false. * @see See writeDictionary http://docs.oracle.com/cd/E23943_01/apirefs.1111/e10663/toc.htm */ public static boolean updateRuleDictionary(RuleDictionary dictionary) throws Exception { UndoableEdit undo = null; List<SDKWarning> warnings = new ArrayList<SDKWarning>(); boolean rc = false; try { undo = dictionary.update(warnings); rc = true; } catch (ConcurrentUpdateException e) { dictionary.rollback(); } catch (SDKException e) { dictionary.rollback(); } return rc; }