use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class RequisitionImplementationTest method testForeignSourceWithSlash.
@Test
public void testForeignSourceWithSlash() {
runTest(fsr -> {
final ForeignSource fs = fsr.getForeignSource("foo/bar");
fs.setDefault(false);
fsr.save(fs);
fsr.flush();
final ForeignSource saved = fsr.getForeignSource("foo/bar");
assertNotNull(saved);
assertEquals(fs, saved);
}, ForeignSourceRepositoryException.class);
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class RequisitionImplementationTest method testForeignSourceWithSpace.
@Test
public void testForeignSourceWithSpace() {
runTest(fsr -> {
final ForeignSource fs = fsr.getForeignSource("foo bar");
fs.setDefault(false);
fsr.save(fs);
fsr.flush();
final ForeignSource saved = fsr.getForeignSource("foo bar");
assertNotNull(saved);
assertEquals(fs, saved);
}, null);
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class RequisitionImplementationTest method testCreateSimpleForeignSource.
@Test
public void testCreateSimpleForeignSource() {
runTest(fsr -> {
ForeignSource fs = fsr.getForeignSource("blah");
fs.setDefault(false);
fsr.save(fs);
fsr.flush();
fs = fsr.getForeignSource("blah");
assertNotNull(fs);
assertNotNull(fs.getScanInterval());
}, null);
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class FasterFilesystemForeignSourceRepository method getForeignSources.
/* (non-Javadoc)
* @see org.opennms.netmgt.provision.persist.FilesystemForeignSourceRepository#getForeignSources()
*/
@Override
public Set<ForeignSource> getForeignSources() throws ForeignSourceRepositoryException {
m_readLock.lock();
try {
final Set<ForeignSource> foreignSources = new TreeSet<ForeignSource>();
for (String baseName : getForeignSourcesDirectoryWatcher().getBaseNamesWithExtension(".xml")) {
try {
ForeignSource contents = getForeignSourcesDirectoryWatcher().getContents(baseName + ".xml");
foreignSources.add(contents);
} catch (FileNotFoundException e) {
LOG.info("Unable to load foreignSource {}: It must have been deleted by another thread", baseName, e);
}
}
return foreignSources;
} finally {
m_readLock.unlock();
}
}
use of org.opennms.netmgt.provision.persist.foreignsource.ForeignSource in project opennms by OpenNMS.
the class CachingForeignSourceRepository method getForeignSourceMap.
private Map<String, ForeignSource> getForeignSourceMap() {
readLock();
try {
if (m_foreignSources == null) {
writeLock();
try {
final Map<String, ForeignSource> fses = new TreeMap<String, ForeignSource>();
for (final ForeignSource fs : m_foreignSourceRepository.getForeignSources()) {
fses.put(fs.getName(), fs);
}
m_foreignSources = fses;
} finally {
readLock();
writeUnlock();
}
}
return m_foreignSources;
} finally {
readUnlock();
}
}
Aggregations