private Input retrieveInput(String key) { validate(); // Because scripted input names are not 1:1 with the original name // (they are the absolute path on the Splunk instance followed by // the original name), we will iterate over the entities in the list, // and if we find one that matches, return it. Set<Entry<String, LinkedList<Input>>> set = items.entrySet(); for (Entry<String, LinkedList<Input>> entry: set) { String entryKey = entry.getKey(); LinkedList<Input> entryValue = entry.getValue(); InputKind kind = entryValue.get(0).getKind(); if (InputCollection.matchesInputName(kind, key, entryKey)) { if (entryValue.size() > 1) { throw new SplunkException(SplunkException.AMBIGUOUS, "Multiple inputs matched " + key + "; specify a namespace to disambiguate."); } else { return entryValue.get(0); } } } return null; }
private Input retrieveInput(String key, Args namespace) { Util.ensureNamespaceIsExact(namespace); validate(); // Because scripted input names are not 1:1 with the original name // (they are the absolute path on the Splunk instance followed by // the original name), we will iterate over the entities in the list, // and if we find one that matches, return it. String pathMatcher = service.fullpath("", namespace); Set<Entry<String, LinkedList<Input>>> set = items.entrySet(); for (Entry<String, LinkedList<Input>> entry: set) { String entryKey = entry.getKey(); LinkedList<Input> entryValue = entry.getValue(); InputKind kind = entryValue.get(0).getKind(); if (InputCollection.matchesInputName(kind, key, entryKey)) { for (Input entity: entryValue) { if (entity.path.startsWith(pathMatcher)) { return entity; } } } } return null; } }