Esempio n. 1
0
 void load() {
   try {
     if (new File(_queriesFileName).exists()) {
       XMLObjectCache cache = new XMLObjectCache();
       cache.load(_queriesFileName, getClass().getClassLoader());
       Iterator it = cache.getAllForClass(Folder.class);
       if (it.hasNext()) {
         _rootFolder = (Folder) it.next();
       }
     }
   } catch (FileNotFoundException ignore) { // first time user has run pgm.
   } catch (XMLException ex) {
     final Logger log = _app.getLogger();
     log.showMessage(Logger.ILogTypes.ERROR, "Error loading queries file: " + _queriesFileName);
     log.showMessage(Logger.ILogTypes.ERROR, ex);
   } catch (DuplicateObjectException ex) {
     final Logger log = _app.getLogger();
     log.showMessage(Logger.ILogTypes.ERROR, "Error loading queries file: " + _queriesFileName);
     log.showMessage(Logger.ILogTypes.ERROR, ex);
   }
 }
Esempio n. 2
0
 /** Save cached objects. */
 void save() {
   try {
     XMLObjectCache cache = new XMLObjectCache();
     try {
       if (_rootFolder != null) {
         cache.add(_rootFolder);
       }
     } catch (DuplicateObjectException ignore) {
     }
     cache.save(_queriesFileName);
   } catch (IOException ex) {
     final Logger logger = _app.getLogger();
     logger.showMessage(
         Logger.ILogTypes.ERROR, "Error occured saving queries to " + _queriesFileName);
     logger.showMessage(Logger.ILogTypes.ERROR, ex);
   } catch (XMLException ex) {
     final Logger logger = _app.getLogger();
     logger.showMessage(
         Logger.ILogTypes.ERROR, "Error occured saving queries to " + _queriesFileName);
     logger.showMessage(Logger.ILogTypes.ERROR, ex);
   }
 }