List of usage examples for org.jdom2 Element addContent
@Override public Element addContent(final Collection<? extends Content> newContent)
From source file:com.webfront.model.Config.java
public void setConfig() { FileWriter writer = null;//from www . j av a 2 s. com File defaultStartupFile = new File(home + fileSep + defaultConfigFileName); try (FileWriter defaultWriter = new FileWriter(defaultStartupFile)) { defaultWriter.write(installDir); } catch (IOException ex) { Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex); } try { xmlDoc = new Document(); Element rootElement = new Element(root); Element systemNode = new Element("system"); systemNode.addContent(new Element("installDir").addContent(getInstallDir())); // systemNode.addContent(new Element("tmpDir").addContent(tmpDir)); String tmp = tmpDir; tmp.replaceAll("/", "\\/"); systemNode.addContent(new Element("tmpDir").addContent(tmp)); rootElement.addContent(systemNode); xmlDoc.setRootElement(rootElement); writer = new FileWriter(getInstallDir() + getFileSep() + configFileName); XMLOutputter xml = new XMLOutputter(); xml.setFormat(Format.getPrettyFormat()); writer.write(xml.outputString(xmlDoc)); } catch (IOException ex) { Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex); } finally { try { if (writer != null) { writer.close(); } } catch (IOException ex) { Logger.getLogger(Config.class.getName()).log(Level.SEVERE, null, ex); } } }
From source file:com.xebialabs.overcast.support.libvirt.DomainWrapper.java
License:Apache License
private void updateFilesystemMappings(Document cloneXmlDocument, List<Filesystem> mappings) { Element devices = cloneXmlDocument.getRootElement().getChild("devices"); Map<String, Filesystem> currentFilesystems = getFilesystems(domainXml); for (Filesystem fs : mappings) { if (currentFilesystems.containsKey(fs.target)) { removeFilesystemsWithTarget(cloneXmlDocument, fs.target); }/*from ww w . ja va 2s . c o m*/ devices.addContent(toFileSystemXml(fs)); } }
From source file:com.xebialabs.overcast.support.libvirt.jdom.DiskXml.java
License:Apache License
public static String cloneVolumeXml(Disk backingDisk, String clonedDiskName) throws IOException { Element volume = new Element("volume"); volume.addContent(new Element("name").setText(clonedDiskName)); volume.addContent(new Element("allocation").setText("0")); volume.addContent(new Element("capacity").setText("" + backingDisk.getInfo().capacity)); Element target = new Element("target"); volume.addContent(target);//from w w w .j av a 2 s .c o m target.addContent(new Element("format").setAttribute("type", backingDisk.format)); target.addContent(new Element("compat").setText("1.1")); Element backingStore = new Element("backingStore"); volume.addContent(backingStore); backingStore.addContent(new Element("path").setText(backingDisk.file)); backingStore.addContent(new Element("format").setAttribute("type", backingDisk.format)); return JDomUtil.elementToString(volume); }
From source file:com.xebialabs.overcast.support.libvirt.jdom.FilesystemXml.java
License:Apache License
public static Element toFileSystemXml(Filesystem fs) { Element filesystem = new Element("filesystem").setAttribute("type", "mount").setAttribute("accessmode", fs.accessMode.name().toLowerCase()); filesystem.addContent(new Element("source").setAttribute("dir", fs.source)); filesystem.addContent(new Element("target").setAttribute("dir", fs.target)); if (fs.readOnly) { filesystem.addContent(new Element("readonly")); }/*from w w w. j a v a2 s .co m*/ return filesystem; }
From source file:com.xebialabs.overcast.support.libvirt.Metadata.java
License:Apache License
private static Element createProvisioningMetadata(String parentDomain, String provisionedWith, String provisionedChecksum, Date provisionedAt) { SimpleDateFormat sdf = new SimpleDateFormat(XML_DATE_FORMAT); sdf.setTimeZone(METADATA_TIMEZONE);//from w w w . j a v a2 s. c o m Element metadata = new Element(METADATA); Element ocmetadata = new Element(OVERCAST_METADATA, METADATA_NS_V1); metadata.addContent(ocmetadata); ocmetadata.addContent(new Element(PARENT_DOMAIN, METADATA_NS_V1).setText(parentDomain)); ocmetadata.addContent(new Element(PROVISIONED_WITH, METADATA_NS_V1).setText(provisionedWith)); ocmetadata.addContent(new Element(PROVISIONED_CHECKSUM, METADATA_NS_V1).setText(provisionedChecksum)); ocmetadata.addContent(new Element(CREATION_TIME, METADATA_NS_V1).setText(sdf.format(provisionedAt))); return metadata; }
From source file:com.xebialabs.overcast.support.libvirt.Metadata.java
License:Apache License
private static Element createCloningMetadata(String parentDomain, Date creationTime) { SimpleDateFormat sdf = new SimpleDateFormat(XML_DATE_FORMAT); sdf.setTimeZone(METADATA_TIMEZONE);/* w w w. ja v a 2s .c o m*/ Element metadata = new Element(METADATA); Element ocmetadata = new Element(OVERCAST_METADATA, METADATA_NS_V1); metadata.addContent(ocmetadata); ocmetadata.addContent(new Element(PARENT_DOMAIN, METADATA_NS_V1).setText(parentDomain)); ocmetadata.addContent(new Element(CREATION_TIME, METADATA_NS_V1).setText(sdf.format(creationTime))); return metadata; }
From source file:compile.util.Tomcat.java
public void checkIfInContextFile(Project proj) { LogService.tomcatAddingContext(//from w w w.j av a 2 s . c om PropertiesFile.getInstance().getPropertiesUtil().getParam("workingDirContext")); Element racine = _serverXml.getRacine(); Element service = racine.getChild("Service", null); Element engine = service.getChild("Engine", null); Element host = engine.getChild("Host", null); List<Element> listContext = host.getChildren("Context", null); boolean notInContext = true; for (Element context : listContext) { if (context.getAttributeValue("docBase") .equals(proj.getPathProject() + SEP + "target" + SEP + proj.getWebappName())) { notInContext = false; } } if (notInContext) { host.addContent(new Element("Context") .setAttribute("docBase", proj.getPathProject() + SEP + "target" + SEP + proj.getWebappName()) .setAttribute("path", PropertiesFile.getInstance().getPropertiesUtil().getParam("workingDirContext")) .setAttribute("reloadable", "true")); _serverXml.save(); } }
From source file:Contabilidad.javaToXML.java
/** * Genera el Nodo de Notificacion del XML y lo agrega a el nodo root * @param identif Informacin de Itenfificacion contenida en la clase TFactDocMX *///w w w . j av a2 s.c o m public void generaIdentificacion(Identificacion identif) { Element identificacion = new Element("Identificacion", PREFIX, PREFIX_URI); identificacion.addContent( new Element("CdgPaisEmisor", PREFIX, PREFIX_URI).setText(identif.getCdgPaisEmisor().value())); identificacion.addContent(new Element("TipoDeComprobante", PREFIX, PREFIX_URI) .setText(identif.getTipoDeComprobante().value())); identificacion.addContent(new Element("RFCEmisor", PREFIX, PREFIX_URI).setText(identif.getRFCEmisor())); identificacion.addContent( new Element("RazonSocialEmisor", PREFIX, PREFIX_URI).setText(identif.getRazonSocialEmisor())); identificacion.addContent(new Element("Usuario", PREFIX, PREFIX_URI).setText(identif.getUsuario())); if (identif.getNumeroInterno() != null) identificacion.addContent( new Element("NumeroInterno", PREFIX, PREFIX_URI).setText(identif.getNumeroInterno())); if (identif.getAsignacionSolicitada() != null) { Element AsignacionSolicitada = new Element("AsignacionSolicitada", PREFIX, PREFIX_URI); if (identif.getAsignacionSolicitada().getSerie().compareTo("") != 0) AsignacionSolicitada.addContent(new Element("Serie", PREFIX, PREFIX_URI) .setText(identif.getAsignacionSolicitada().getSerie())); if (identif.getAsignacionSolicitada().getFolio().compareTo("") != 0) AsignacionSolicitada.addContent(new Element("Folio", PREFIX, PREFIX_URI) .setText(identif.getAsignacionSolicitada().getFolio())); if (identif.getAsignacionSolicitada().getTiempoDeEmision() != null) AsignacionSolicitada .addContent(new Element("TiempoDeEmision", PREFIX, PREFIX_URI).setText(sdf.format(identif .getAsignacionSolicitada().getTiempoDeEmision().toGregorianCalendar().getTime()))); identificacion.addContent(AsignacionSolicitada); } identificacion.addContent( new Element("LugarExpedicion", PREFIX, PREFIX_URI).setText(identif.getLugarExpedicion())); if (identif.getNumCtaPago() != null) identificacion.addContent( new Element("NumCtaPago", PREFIX, PREFIX_URI).setText(identif.getLugarExpedicion())); if (identif.getTotalDeParcialidades() != null) { if (identif.getTotalDeParcialidades().getFolioFiscalOrigUuid() != null) identificacion.addContent(new Element("FolioFiscalOrigUuid", PREFIX, PREFIX_URI) .setText(identif.getTotalDeParcialidades().getFolioFiscalOrigUuid())); else identificacion.addContent(new Element("FolioFiscalOrigNum", PREFIX, PREFIX_URI) .setText(identif.getTotalDeParcialidades().getFolioFiscalOrigNum().toString())); if (identif.getTotalDeParcialidades().getSerieFolioFiscalOrig() != null) identificacion.addContent(new Element("SerieFolioFiscalOrig", PREFIX, PREFIX_URI) .setText(identif.getTotalDeParcialidades().getFolioFiscalOrigNum().toString())); identificacion.addContent( new Element("FechaFolioFiscalOrig", PREFIX, PREFIX_URI).setText(this.sdf.format(identif .getTotalDeParcialidades().getFechaFolioFiscalOrig().toGregorianCalendar().getTime()))); identificacion.addContent(new Element("MontoFolioFiscalOrig", PREFIX, PREFIX_URI) .setText(identif.getTotalDeParcialidades().getMontoFolioFiscalOrig().getValue().toString())); } //CadenaOriginal root.addContent(identificacion); }
From source file:Contabilidad.javaToXML.java
/** * Genera el Nodo de Cancelaciones del XML y lo agrega a el nodo root * @param cancel Informacin de Cancelacioens contenida en la clase TFactDocMX *///from ww w .ja v a 2 s.co m public void generarCancelaciones(Cancelaciones cancel) { if (cancel != null) { Element cancelaciones = new Element("Cancelaciones", PREFIX, PREFIX_URI); for (int x = 0; x < cancel.getCancelaYSustituye().size(); x++) { Element CancelaHijos = new Element("CancelaYSustituye", PREFIX, PREFIX_URI); CancelaHijos.addContent(new Element("Numero", PREFIX, PREFIX_URI) .setText(cancel.getCancelaYSustituye().get(x).getNumero())); if (cancel.getCancelaYSustituye().get(x).getFecha() != null) CancelaHijos.addContent(new Element("Fecha", PREFIX, PREFIX_URI).setText(this.sdf.format( cancel.getCancelaYSustituye().get(x).getFecha().toGregorianCalendar().getTime()))); if (cancel.getCancelaYSustituye().get(x).getTipoCancelacion() != null) CancelaHijos.addContent(new Element("TipoCancelacion", PREFIX, PREFIX_URI) .setText(cancel.getCancelaYSustituye().get(x).getTipoCancelacion())); if (cancel.getCancelaYSustituye().get(x).getConceptoCancelacion() != null) CancelaHijos.addContent(new Element("ConceptoCancelacion", PREFIX, PREFIX_URI) .setText(cancel.getCancelaYSustituye().get(x).getConceptoCancelacion())); cancelaciones.addContent(CancelaHijos); } root.addContent(cancelaciones); } }
From source file:Contabilidad.javaToXML.java
/** * Genera el Nodo de Origen del XML y lo agrega a el nodo root * @param ori Informacin de Origen contenida en la clase TFactDocMX */// w ww . j av a2s . c om public void generarOrigen(Origen ori) { if (ori != null) { Element origen = new Element("Origen", PREFIX, PREFIX_URI); if (ori.getArea() != null) origen.addContent(new Element("Area", PREFIX, PREFIX_URI).setText(ori.getArea())); if (ori.getModulo() != null) origen.addContent(new Element("Modulo", PREFIX, PREFIX_URI).setText(ori.getModulo())); root.addContent(origen); } }