@Override public void logOut(TestInstance id, LogMapDTO log, File logDir) throws XdsException { logger.debug("Writing logs " + log.getKeys() + " to " + logFile(id, logDir)); FileOutputStream fos; ObjectOutputStream out = null; try { fos = new FileOutputStream(logFile(id, logDir)); out = new ObjectOutputStream(fos); out.writeObject(log); } catch (IOException e) { throw new XdsInternalException("Cannot write transaction log file", e); } finally { try { out.close(); } catch (IOException e) { // throw new XdsInternalException("Cannot write transaction log file", e); } } }
public LogMapDTO logIn(TestInstance id) throws Exception { FileInputStream fis = null; ObjectInputStream in = null; try { fis = new FileInputStream(logFile(id)); in = new ObjectInputStream(fis); LogMapDTO map = (LogMapDTO) in.readObject(); getLogger().debug("restoring log " + map.getKeys() + " from " + logDir); return map; } catch (ClassNotFoundException e) { getLogger().debug("attempting to restore log " + "from " + logDir); throw new XdsInternalException("Cannot create model of type LogMapDTO - class not found",e); } finally { in.close(); } }
public void logOut(TestInstance id, LogMapDTO log) throws XdsException { getLogger().debug("Writing log " + log.getKeys() + " to " + logDir); FileOutputStream fos = null; ObjectOutputStream out = null; try { fos = new FileOutputStream(logFile(id)); out = new ObjectOutputStream(fos); out.writeObject(log); } catch (IOException e) { throw new XdsInternalException("Cannot write transaction log file", e); } finally { try { out.close(); } catch (IOException e) { throw new XdsInternalException("Cannot write transaction log file", e); } } }
@Override public LogMapDTO logIn(TestInstance id, File logDir) throws Exception { logger.debug("Reading log from " + logFile(id, logDir)); FileInputStream fis = null; ObjectInputStream in = null; try { fis = new FileInputStream(logFile(id, logDir)); in = new ObjectInputStream(fis); LogMapDTO map = (LogMapDTO) in.readObject(); logger.debug("restoring log " + map.getKeys() + " from " + logFile(id, logDir)); return map; } catch (ClassNotFoundException e) { logger.debug("attempting to restore log " + "from " + logFile(id, logDir)); throw new XdsInternalException("Cannot create model of type LogMapDTO - class not found", e); } catch (Exception e) { logger.error(ExceptionUtil.here("Cannot load " + logFile(id, logDir))); throw e; } finally { if (in != null) in.close(); } }