/** * @return An XML DOM {@link Document} representation of the internal PGEConfigurationFile. * @throws Exception If any error occurs. */ public Document getConfigFileXml() throws Exception { DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); factory.setNamespaceAware(true); Document document; try { DocumentBuilder builder = factory.newDocumentBuilder(); document = builder.newDocument(); Element root = (Element) document.createElement(PGE_INPUT_TAG_NAME); root.setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.setAttribute( "xsi:noNamespaceSchemaLocation", (schemaLocation == null || (schemaLocation.equals("")) ? "input.xsd" : schemaLocation)); document.appendChild(root); if (configFile != null) { // write the PGE Name group if (configFile.getPgeName() != null) { PGEGroup pgeNameGroup = new PGEGroup(PGE_NAME_GROUP); pgeNameGroup.addScalar(configFile.getPgeName()); root.appendChild(getGroupElement(pgeNameGroup, document)); } // write the input product files root.appendChild(getGroupElement(configFile.getInputProductFiles(), document)); // write the static file identification files root.appendChild(getGroupElement(configFile.getStaticFileIdentificationFiles(), document)); // write the dynamic auxilliary files root.appendChild(getGroupElement(configFile.getDynamicAuxiliaryInputFiles(), document)); // write the recorded auxilliary files root.appendChild(getGroupElement(configFile.getRecordedAuxiliaryInputFiles(), document)); // write the product path group if (configFile.getProductPath() != null) { PGEGroup productPathGroup = new PGEGroup(PRODUCT_PATH_GROUP); productPathGroup.addScalar(configFile.getProductPath()); root.appendChild(getGroupElement(productPathGroup, document)); } // write the monitor level group root.appendChild(getGroupElement(configFile.getMonitorLevelGroup(), document)); // write the monitor group if (configFile.getMonitorFilenameFormat() != null && configFile.getMonitorPath() != null) { PGEGroup monitorGroup = new PGEGroup(MONITOR_GROUP); monitorGroup.addScalar(configFile.getMonitorPath()); monitorGroup.addScalar(configFile.getMonitorFilenameFormat()); root.appendChild(getGroupElement(monitorGroup, document)); } // write the pge specific groups for (String pgeSpecificGroupName : configFile.getPgeSpecificGroups().keySet()) { PGEGroup pgeSpecificGroup = (PGEGroup) configFile.getPgeSpecificGroups().get(pgeSpecificGroupName); root.appendChild(getGroupElement(pgeSpecificGroup, document)); } } return document; } catch (ParserConfigurationException pce) { LOG.log(Level.WARNING, "Error generating pge configuration file!: " + pce.getMessage()); throw new Exception("Error generating pge configuration file!: " + pce.getMessage()); } catch (Exception e) { LOG.log(Level.SEVERE, e.getMessage()); throw e; } }