/** * Helper static class that does the work to write a policy set to an output stream. * * @author pameladragosh * */ public static void writePolicyFile(OutputStream os, PolicyType policy) { JAXBElement<PolicyType> policySetElement = new ObjectFactory().createPolicy(policy); try { JAXBContext context = JAXBContext.newInstance(PolicyType.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, PolicyType policy) { JAXBElement<PolicyType> policySetElement = new ObjectFactory().createPolicy(policy); try { JAXBContext context = JAXBContext.newInstance(PolicyType.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 to a file on disk. * * @author pameladragosh * */ public static Path writePolicyFile(Path filename, PolicyType policy) { JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy); try { JAXBContext context = JAXBContext.newInstance(PolicyType.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(policyElement, 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 to a file on disk. * * @author pameladragosh * */ public static Path writePolicyFile(Path filename, PolicyType policy) { JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy); try { JAXBContext context = JAXBContext.newInstance(PolicyType.class); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); m.marshal(policyElement, 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; } } /**