/** * <p>getPaths</p> * * @return a {@link java.util.Map} object. * @throws java.io.IOException if any. */ public Map<String, Path> getPaths() throws IOException { update(); return Collections.unmodifiableMap(m_destinationPaths); }
/** * <p>replacePath</p> * * @param oldName a {@link java.lang.String} object. * @param newPath a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @throws java.io.IOException if any. */ public synchronized void replacePath(String oldName, Path newPath) throws IOException { if (m_destinationPaths.containsKey(oldName)) { m_destinationPaths.remove(oldName); } addPath(newPath); }
/** * Removes a Path form the xml file based on its name * * @param name * the name of the path to remove * @exception IOException * @throws java.io.IOException if any. */ public synchronized void removePath(String name) throws IOException { m_destinationPaths.remove(name); saveCurrent(); }
/** * <p>getTargetCommands</p> * * @param path a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @param index a int. * @param target a {@link java.lang.String} object. * @return a {@link java.util.Collection} object. * @throws java.io.IOException if any. */ public Collection<String> getTargetCommands(Path path, int index, String target) throws IOException { update(); Target[] targets = getTargetList(index, path); for (int i = 0; i < targets.length; i++) { if (targets[i].getName().equals(target)) return targets[i].getCommands(); } // default null value if target isn't found in Path return null; }
/** * <p>saveCurrent</p> * * @throws java.io.IOException if any. */ public synchronized void saveCurrent() throws IOException { allPaths.clearPaths(); for (Path path : m_destinationPaths.values()) { allPaths.addPath(path); } allPaths.setHeader(rebuildHeader()); // Marshal to a string first, then write the string to the file. This // way the original config // isn't lost if the XML from the marshal is hosed. StringWriter stringWriter = new StringWriter(); JaxbUtils.marshal(allPaths, stringWriter); String writerString = stringWriter.toString(); saveXML(writerString); /* * TODO: what do do about this? Should this be here? * Appears that everything is handled through the update * method when a member of field is requested. * * Delete after all Notifd tests are passing. */ //reload(); }
/** * <p>parseXML</p> * * @param stream a {@link java.io.InputStream} object. * @throws IOException */ protected void parseXML(final InputStream stream) throws IOException { try (final InputStreamReader isr = new InputStreamReader(stream)) { allPaths = JaxbUtils.unmarshal(DestinationPaths.class, isr); oldHeader = allPaths.getHeader(); initializeDestinationPaths(); } }
path = getDestinationPathManager().getPath(notification.getDestinationPath()); if (path == null) { LOG.warn("Unknown destination path {}. Please check the <destinationPath> tag for the notification {} in the notifications.xml file.", notification.getDestinationPath(), notification.getName());
/** * <p>getPath</p> * * @param pathName a {@link java.lang.String} object. * @return a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @throws java.io.IOException if any. */ public Path getPath(String pathName) throws IOException { update(); return m_destinationPaths.get(pathName); }
/** * <p>addPath</p> * * @param newPath a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @throws java.io.IOException if any. */ public synchronized void addPath(Path newPath) throws IOException { m_destinationPaths.put(newPath.getName(), newPath); saveCurrent(); }
/** * <p>pathHasTarget</p> * * @param path a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @param target a {@link java.lang.String} object. * @return a boolean. * @throws java.io.IOException if any. */ public boolean pathHasTarget(Path path, String target) throws IOException { update(); for (Target curTarget : path.getTargets()) { if (curTarget.getName().equals(target)) return true; } // default false value if target isn't found return false; }
/** * Removes a Path from the xml file. * * @param path * the path to remove * @exception IOException * @throws java.io.IOException if any. */ public synchronized void removePath(Path path) throws IOException { m_destinationPaths.remove(path.getName()); saveCurrent(); }
/** * <p>getTargetList</p> * * @param index a int. * @param path a {@link org.opennms.netmgt.config.destinationPaths.Path} object. * @return an array of {@link org.opennms.netmgt.config.destinationPaths.Target} objects. * @throws java.io.IOException if any. */ public Target[] getTargetList(int index, Path path) throws IOException { update(); Target[] targets = null; // index of -1 indicates the initial targets, any other index means to // get // the targets from the Escalate object at that index if (index == -1) { targets = path.getTargets().toArray(new Target[0]); } else { targets = path.getEscalates().get(index).getTargets().toArray(new Target[0]); } return targets; }
m_groupManager.update(); m_notificationManager.update(); m_destinationPathManager.update(); m_notificationCommandManager.update(); ebldr = new EventBuilder(EventConstants.RELOAD_DAEMON_CONFIG_SUCCESSFUL_UEI, getName());