/** * Helper static class that does the work to write a policy set to an output stream. * * @author pameladragosh * */ public static void writePolicyFile(OutputStream os, PolicySetType policySet) { JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet); try { JAXBContext context = JAXBContext.newInstance(PolicySetType.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(policySetElement, os); } catch (JAXBException e) { logger.error("writePolicyFile failed: " + e.getLocalizedMessage()); } }
/** * Helper static class that does the work to write a policy set to an output stream. * * @author pameladragosh * */ public static void writePolicyFile(OutputStream os, PolicySetType policySet) { JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet); try { JAXBContext context = JAXBContext.newInstance(PolicySetType.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(policySetElement, os); } catch (JAXBException e) { logger.error("writePolicyFile failed: " + e.getLocalizedMessage()); } }
/** * Helper static class that does the work to write a policy set to a file on disk. * * @author pameladragosh * */ public static Path writePolicyFile(Path filename, PolicySetType policySet) { JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet); try { JAXBContext context = JAXBContext.newInstance(PolicySetType.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(policySetElement, filename.toFile()); if (Files.exists(filename)) { return filename; } else { logger.error("File does not exist after marshalling."); return null; } } catch (JAXBException e) { logger.error("writePolicyFile failed: " + e.getLocalizedMessage()); return null; } }
/** * Helper static class that does the work to write a policy set to a file on disk. * * @author pameladragosh * */ public static Path writePolicyFile(Path filename, PolicySetType policySet) { JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet); try { JAXBContext context = JAXBContext.newInstance(PolicySetType.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(policySetElement, filename.toFile()); if (Files.exists(filename)) { return filename; } else { logger.error("File does not exist after marshalling."); return null; } } catch (JAXBException e) { logger.error("writePolicyFile failed: " + e.getLocalizedMessage()); return null; } }