/** * Gets the requisition directory. * * @return the requisition directory */ private File getRequisitionDir() { if (requisitionDir == null) { requisitionDir = new File(ConfigFileConstants.getFilePathString() + "imports"); } return requisitionDir; }
/** * Instantiates a new upgrade status. * * @throws OnmsUpgradeException the OpenNMS upgrade exception */ public UpgradeStatus() throws OnmsUpgradeException { this(new File(ConfigFileConstants.getFilePathString() + STATUS_FILE)); }
/** * <p>resetDefaultForeignSource</p> * * @throws org.opennms.netmgt.provision.persist.ForeignSourceRepositoryException if any. */ @Override public void resetDefaultForeignSource() throws ForeignSourceRepositoryException { final File deleteFile = new File(ConfigFileConstants.getFilePathString() + "default-foreign-source.xml"); if (!deleteFile.exists()) { return; } if (!deleteFile.delete()) { LOG.warn("unable to remove {}", deleteFile.getPath()); } }
@Override protected Requisition getExistingRequisition(String foreignSource) { // This is not elegant but it is necessary to avoid booting Spring File req = new File(ConfigFileConstants.getFilePathString(), "imports" + File.separator + foreignSource + ".xml"); if (req.exists()) { return JaxbUtils.unmarshal(Requisition.class, req); } return null; } };
@Override protected Requisition getExistingRequisition(String foreignSource) { // This is not elegant but it is necessary to avoid booting Spring File req = new File(ConfigFileConstants.getFilePathString(), "imports" + File.separator + foreignSource + ".xml"); if (req.exists()) { return JaxbUtils.unmarshal(Requisition.class, req); } return null; } };
/** * Gets the 3GPP resource format. * * @param resourceType the resource type * @return the 3gpp format */ public static String get3gppFormat(String resourceType) { if (m_pmGroups.isEmpty()) { try { File configFile = new File(ConfigFileConstants.getFilePathString(), PM_GROUPS_FILENAME); if (configFile.exists()) { LOG.info("Using 3GPP PM Groups format from {}", configFile); m_pmGroups.load(new FileInputStream(configFile)); } else { LOG.info("Using default 3GPP PM Groups format."); m_pmGroups.load(Sftp3gppUtils.class.getResourceAsStream("/" + PM_GROUPS_FILENAME)); } } catch (Exception e) { LOG.warn("Can't load 3GPP PM Groups format because {}", e.getMessage()); } } return m_pmGroups.getProperty(resourceType); }
private void checkDirectoryForUnKnownFiles(String name) { Path directory = Paths.get(ConfigFileConstants.getFilePathString(), name); try (DirectoryStream<Path> stream = Files.newDirectoryStream(directory, "*.{properties,xml}")) { for (Path entry : stream) { checkFileForSyntax(entry); } } catch (IOException e) { throw new ConfigCheckValidationException(e); } }
/** * Gets the 3GPP resource format. * * @param resourceType the resource type * @return the 3gpp format */ public static String get3gppFormat(String resourceType) { if (m_pmGroups.isEmpty()) { try { File configFile = new File(ConfigFileConstants.getFilePathString(), PM_GROUPS_FILENAME); if (configFile.exists()) { LOG.info("Using 3GPP PM Groups format from {}", configFile); m_pmGroups.load(new FileInputStream(configFile)); } else { LOG.info("Using default 3GPP PM Groups format."); m_pmGroups.load(Sftp3gppUtils.class.getResourceAsStream("/" + PM_GROUPS_FILENAME)); } } catch (Exception e) { LOG.warn("Can't load 3GPP PM Groups format because {}", e.getMessage()); } } return m_pmGroups.getProperty(resourceType); }
@Override public void rollback() throws OnmsUpgradeException { try { for (File jmxResourceDir : getJmxResourceDirectories()) { File zip = new File(jmxResourceDir.getAbsolutePath() + ZIP_EXT); FileUtils.deleteDirectory(jmxResourceDir); if(!jmxResourceDir.mkdirs()) { LOG.warn("Could not make directory: {}", jmxResourceDir.getPath()); } unzipFile(zip, jmxResourceDir); if(!zip.delete()) { LOG.warn("Could not delete file: {}", zip.getPath()); } } File configDir = new File(ConfigFileConstants.getFilePathString()); for (File backupFile : backupFiles) { unzipFile(backupFile, configDir); } } catch (IOException e) { throw new OnmsUpgradeException("Can't restore the backup files because " + e.getMessage()); } }
/** {@inheritDoc} */ @Override public void putDefaultForeignSource(ForeignSource foreignSource) throws ForeignSourceRepositoryException { if (foreignSource == null) { throw new ForeignSourceRepositoryException("foreign source was null"); } foreignSource.setName("default"); final File outputFile = new File(ConfigFileConstants.getFilePathString() + "default-foreign-source.xml"); Writer writer = null; OutputStream outputStream = null; try { outputStream = new FileOutputStream(outputFile); writer = new OutputStreamWriter(outputStream, StandardCharsets.UTF_8); JaxbUtils.marshal(foreignSource, writer); } catch (final Throwable e) { throw new ForeignSourceRepositoryException("unable to write requisition to " + outputFile.getPath(), e); } finally { IOUtils.closeQuietly(writer); IOUtils.closeQuietly(outputStream); } }
/** * The main method. * * @param args the arguments */ public static void main(String[] args) { if (args.length > 1 && new File(args[0]).exists()) { System.setProperty("opennms.home", args[0]); } initializeSingleInstanceDatabase(); BeanUtils.getBeanFactory("jasperReportContext"); // To trigger Spring Initialization File reportsDirectory = new File(ConfigFileConstants.getFilePathString(), "report-templates"); System.out.printf("Analyzing jasper reports located at %s\n", reportsDirectory); for (File report : FileUtils.listFiles(reportsDirectory, new String[] { "jrxml" }, true)) { System.out.printf("Compiling report template %s\n", report.getAbsolutePath()); try { JasperCompileManager.compileReportToFile(report.getAbsolutePath()); } catch (JRException e) { System.err.println("Error: cannot compile report because: " + e.getMessage()); e.printStackTrace(); } } }
/** * The main method. * * @param args the arguments */ public static void main(String[] args) { if (args.length > 1 && new File(args[0]).exists()) { System.setProperty("opennms.home", args[0]); } initializeSingleInstanceDatabase(); BeanUtils.getBeanFactory("jasperReportContext"); // To trigger Spring Initialization File reportsDirectory = new File(ConfigFileConstants.getFilePathString(), "report-templates"); System.out.printf("Analyzing jasper reports located at %s\n", reportsDirectory); for (File report : FileUtils.listFiles(reportsDirectory, new String[] { "jrxml" }, true)) { System.out.printf("Compiling report template %s\n", report.getAbsolutePath()); try { JasperCompileManager.compileReportToFile(report.getAbsolutePath()); } catch (JRException e) { System.err.println("Error: cannot compile report because: " + e.getMessage()); e.printStackTrace(); } } }
File cfg = new File(ConfigFileConstants.getFilePathString(), "vmware-config.xml"); if (cfg.exists()) { String username = null;
+ "/share/reports/AVAIL-SVG-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_SVG_XSL); } else if (format.equals("PDF")) { + "/share/reports/AVAIL-PDF-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_PDF_XSL); } else if (format.equals("HTML")) { + "/share/reports/AVAIL-HTML-" + catFileName + fmt.format(new java.util.Date()) + ".html"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_HTML_XSL); } else {
File cfg = new File(ConfigFileConstants.getFilePathString(), "vmware-config.xml"); if (cfg.exists()) { String username = null;
+ "/share/reports/AVAIL-SVG-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_SVG_XSL); } else if (format.equals("PDF")) { + "/share/reports/AVAIL-PDF-" + catFileName + fmt.format(new java.util.Date()) + ".pdf"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_PDF_XSL); } else if (format.equals("HTML")) { + "/share/reports/AVAIL-HTML-" + catFileName + fmt.format(new java.util.Date()) + ".html"; xslFileName = ConfigFileConstants.getFilePathString() + ConfigFileConstants.getFileName(ConfigFileConstants.REPORT_HTML_XSL); } else {
@Override public void execute() throws OnmsUpgradeException { try { // Fixing JRB/RRD files final boolean isRrdtool = isRrdToolEnabled(); final boolean storeByGroup = isStoreByGroupEnabled(); for (File jmxResourceDir : getJmxResourceDirectories()) { if (storeByGroup) { processGroupFiles(jmxResourceDir, isRrdtool); } else { processSingleFiles(jmxResourceDir, isRrdtool); } } // Fixing JMX Configuration File File jmxConfigFile = null; try { jmxConfigFile = ConfigFileConstants.getFile(ConfigFileConstants.JMX_DATA_COLLECTION_CONF_FILE_NAME); } catch (IOException e) { throw new OnmsUpgradeException("Can't find JMX Configuration file (ignoring processing)"); } fixJmxConfigurationFile(jmxConfigFile); // List Bad Metrics: log("Found %s Bad Metrics: %s\n", badMetrics.size(), badMetrics); // Fixing Graph Templates File jmxGraphsFile = new File(ConfigFileConstants.getFilePathString(), "snmp-graph.properties"); fixJmxGraphTemplateFile(jmxGraphsFile); } catch (Exception e) { throw new OnmsUpgradeException("Can't upgrade the JRBs because " + e.getMessage(), e); } }
toolbar.setComponentAlignment(comboLabel, Alignment.MIDDLE_LEFT); final File eventsDir = new File(ConfigFileConstants.getFilePathString(), "events"); final XmlFileContainer container = new XmlFileContainer(eventsDir, true); container.addExcludeFile("default.events.xml"); // This is a protected file, should not be updated.
toolbar.setComponentAlignment(comboLabel, Alignment.MIDDLE_LEFT); final File datacollectionDir = new File(ConfigFileConstants.getFilePathString(), "datacollection"); final ComboBox dcGroupSource = new ComboBox(); toolbar.addComponent(dcGroupSource);
toolbar.setComponentAlignment(comboLabel, Alignment.MIDDLE_LEFT); final File datacollectionDir = new File(ConfigFileConstants.getFilePathString(), "datacollection"); final ComboBox dcGroupSource = new ComboBox(); toolbar.addComponent(dcGroupSource);