/** * {@inheritDoc} */ @Override public ProfileInstance loadProfile(final InputStream in) { try { final Unmarshaller unmarshaller = context.createUnmarshaller(); final ProfileInstance profile = (ProfileInstance) unmarshaller.unmarshal(in); return profile; } catch (final JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e.getMessage(), e); } }
/** * {@inheritDoc} */ @Override public synchronized void save() { try { Marshaller marshaller = context.createMarshaller(); marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); marshaller.marshal(queue, Paths.get(targetFileName).toFile()); } catch (JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e.getMessage(), e); } }
/** * {@inheritDoc} */ @Override public ReportSpec readReportSpec(final Path file) { try (final Reader reader = Files.newBufferedReader(file, UTF_8)) { Unmarshaller unmarshaller = context.createUnmarshaller(); return (ReportSpec) unmarshaller.unmarshal(reader); } catch (final JAXBException e) { log.error(e.getErrorCode(), e); return null; } catch (final IOException e) { log.error(e.getMessage(), e); throw new RuntimeException(e); } }
/** * {@inheritDoc} */ @Override public SubmissionQueueData list() { Path in = Paths.get(targetFileName); if (Files.exists(in)) { try { Unmarshaller unmarshaller = context.createUnmarshaller(); return (SubmissionQueueData) unmarshaller.unmarshal(in.toFile()); } catch (JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e.getMessage(), e); } } return null; }
/** * {@inheritDoc} */ @Override public FilterImpl loadFilter(InputStream in) { try { Unmarshaller unmarshaller = context.createUnmarshaller(); FilterSpec spec = (FilterSpec) unmarshaller.unmarshal(in); return spec.getFilter(); } catch (JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e.getMessage(), e); } }
/** * Loads a walkState from persistent XML. * @return walk state */ public ProfileWalkState load() { final Path xml = profileHomeDir.resolve(FILE_WALKER_XML); if (Files.exists(xml)) { try { Unmarshaller unmarshaller = context.createUnmarshaller(); ProfileWalkState walkState = (ProfileWalkState) unmarshaller.unmarshal(xml.toFile()); return walkState; } catch (JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e.getMessage(), e); } } return new ProfileWalkState(); }
/** * Saves a file walker to XML. * @param walkState the file walker to save */ public void save(ProfileWalkState walkState) { final Path xml = profileHomeDir.resolve(FILE_WALKER_XML); try { Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(walkState, xml.toFile()); } catch (PropertyException e) { log.error(e.getMessage(), e); throw new RuntimeException(e); } catch (JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e); } }
/** * {@inheritDoc} */ @Override public void saveFilter(FilterImpl filter, OutputStream output) { OutputStream out = null; try { Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); out = new BufferedOutputStream(output); FilterSpec spec = new FilterSpec(filter); m.marshal(spec, out); } catch (PropertyException e) { log.error(e.getMessage(), e); throw new RuntimeException(e); } catch (JAXBException e) { log.error(e.getErrorCode(), e); throw new RuntimeException(e); } finally { closeOutputStream(out); } }
LogHelper.warn(logger, "Exception Details-> Code:'%s', Message:'%s'", jaxbe.getErrorCode(), jaxbe.getMessage()); throw jaxbe;
LogHelper.warn(logger, "Exception Details-> Code:'%s', Message:'%s'", jaxbe.getErrorCode(), jaxbe.getMessage()); throw jaxbe;