private boolean writeModel(Metadata metadata, TVAMainType tva) { try { JAXBContext context = JAXBContext.newInstance("tva.metadata._2011"); Marshaller m = context.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); metadata.getSource().createNewFile(); m.marshal(tvaFactory.createTVAMain(tva), metadata.getSource()); } catch (JAXBException e) { logger.error(e, Messages.ERROR_EXPORTING_TVA); return false; } catch (IOException e) { logger.error(e, Messages.ERROR_EXPORTING_TVA); return false; } return true; }
@Override public boolean saveMetadata(Project project) { if (project == null || project.getMetadata() == null) return false; Metadata metadata = project.getMetadata(); TVAMainType tva = null; if (metadata.getContent() == null) { tva = tvaFactory.createTVAMainType(); } else { tva = (TVAMainType) metadata.getContent(); } if (tva.getProgramDescription() == null) tva.setProgramDescription(activaFactory.createExtendedProgramDescriptionType()); createProgramInformation(project, tva); createEntityInformation(project, tva); createSegmentInformation(project, tva); return writeModel(metadata, tva); }