@Test public void testDefaultForeignSource() throws Exception { createRequisition(); List<String> detectorList = Arrays.asList(new String[]{ "DNS", "FTP", "HTTP", "HTTPS", "ICMP", "IMAP", "LDAP", "NRPE", "POP3", "SMTP", "SNMP", "SSH" }); String uuid = UUID.randomUUID().toString(); ForeignSource defaultForeignSource = m_foreignSourceRepository.getForeignSource(uuid); assertEquals("name must match requested foreign source repository name", uuid, defaultForeignSource.getName()); assertEquals("scan-interval must be 1 day", 86400000, defaultForeignSource.getScanInterval().getMillis()); assertEquals("foreign source must have no default policies", 0, defaultForeignSource.getPolicies().size()); List<String> fsNames = new ArrayList<String>(); for (PluginConfig config : defaultForeignSource.getDetectors()) { fsNames.add(config.getName()); } assertEquals("detector list must match expected defaults", detectorList, fsNames); assertTrue("foreign source must be tagged as default", defaultForeignSource.isDefault()); }
public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException { if (foreignSourceName == null) { throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!"); } m_readLock.lock(); try { final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName); if (inputFile != null && inputFile.exists()) { return RequisitionFileUtils.getForeignSourceFromFile(inputFile); } else { final ForeignSource fs = getDefaultForeignSource(); fs.setName(foreignSourceName); return fs; } } finally { m_readLock.unlock(); } }
FilesystemForeignSourceRepository extends AbstractForeignSourceRepository implements InitializingBean { public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException { if (foreignSourceName == null) { throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!"); } m_readLock.lock(); try { final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName); if (inputFile != null && inputFile.exists()) { return RequisitionFileUtils.getForeignSourceFromFile(inputFile); } else { final ForeignSource fs = getDefaultForeignSource(); fs.setName(foreignSourceName); return fs; } } finally { m_readLock.unlock(); } } }
FilesystemForeignSourceRepository extends AbstractForeignSourceRepository implements InitializingBean { public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException { if (foreignSourceName == null) { throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!"); } m_readLock.lock(); try { final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName); if (inputFile != null && inputFile.exists()) { return RequisitionFileUtils.getForeignSourceFromFile(inputFile); } else { final ForeignSource fs = getDefaultForeignSource(); fs.setName(foreignSourceName); return fs; } } finally { m_readLock.unlock(); } } FilesystemForeignSourceRepository(); }
FilesystemForeignSourceRepository extends AbstractForeignSourceRepository implements InitializingBean { public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException { if (foreignSourceName == null) { throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!"); } m_readLock.lock(); try { final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName); if (inputFile != null && inputFile.exists()) { return RequisitionFileUtils.getForeignSourceFromFile(inputFile); } else { final ForeignSource fs = getDefaultForeignSource(); fs.setName(foreignSourceName); return fs; } } finally { m_readLock.unlock(); } } FilesystemForeignSourceRepository(); @Override void afterPropertiesSet(); Set<String> getActiveForeignSourceNames(); int getForeignSourceCount(); Set<ForeignSource> getForeignSources(); ForeignSource getForeignSource(final String foreignSourceName); void save(final ForeignSource foreignSource); void delete(final ForeignSource foreignSource); Set<Requisition> getRequisitions(); Requisition getRequisition(final String foreignSourceName); Requisition getRequisition(final ForeignSource foreignSource); void save(final Requisition requisition); void delete(final Requisition requisition); void setRequisitionPath(final String path); void setForeignSourcePath(final String path); @Override Date getRequisitionDate(final String foreignSource); URL getRequisitionURL(final String foreignSource); @Override void flush(); }
FilesystemForeignSourceRepository extends AbstractForeignSourceRepository implements InitializingBean { public ForeignSource getForeignSource(final String foreignSourceName) throws ForeignSourceRepositoryException { if (foreignSourceName == null) { throw new ForeignSourceRepositoryException("can't get a foreign source with a null name!"); } m_readLock.lock(); try { final File inputFile = RequisitionFileUtils.encodeFileName(m_foreignSourcePath, foreignSourceName); if (inputFile != null && inputFile.exists()) { return RequisitionFileUtils.getForeignSourceFromFile(inputFile); } else { final ForeignSource fs = getDefaultForeignSource(); fs.setName(foreignSourceName); return fs; } } finally { m_readLock.unlock(); } } FilesystemForeignSourceRepository(); @Override void afterPropertiesSet(); Set<String> getActiveForeignSourceNames(); int getForeignSourceCount(); Set<ForeignSource> getForeignSources(); ForeignSource getForeignSource(final String foreignSourceName); void save(final ForeignSource foreignSource); void delete(final ForeignSource foreignSource); Set<Requisition> getRequisitions(); Requisition getRequisition(final String foreignSourceName); Requisition getRequisition(final ForeignSource foreignSource); void save(final Requisition requisition); void delete(final Requisition requisition); void setRequisitionPath(final String path); void setForeignSourcePath(final String path); @Override Date getRequisitionDate(final String foreignSource); URL getRequisitionURL(final String foreignSource); @Override void flush();  }