use of com.google.common.io.PatternFilenameFilter in project EventHub by Codecademy.
the class ShardedEventIndexModule method getEventIndexFactory.
@Provides
public EventIndex.Factory getEventIndexFactory(@Named("eventhub.shardedeventindex.directory") final String shardedEventIndexDirectory, @Named("eventhub.eventindex.initialNumEventIdsPerDay") final int initialNumEventIdsPerDay, final DmaIdList.Factory dmaIdListFactory) {
dmaIdListFactory.setDefaultCapacity(initialNumEventIdsPerDay);
return new EventIndex.Factory() {
@Override
public EventIndex build(String eventType) {
String eventIndexDirectory = String.format("%s/%s/", shardedEventIndexDirectory, eventType);
List<String> dates = Lists.newArrayList();
File[] files = new File(eventIndexDirectory).listFiles(new PatternFilenameFilter("[0-9]{8}\\.ser"));
if (files != null) {
for (File file : files) {
dates.add(file.getName().substring(0, 8));
}
}
SortedMap<String, IdList> eventIdListMap = Maps.newTreeMap();
for (String date : dates) {
eventIdListMap.put(date, dmaIdListFactory.build(EventIndex.getEventIdListFilename(eventIndexDirectory, date)));
}
return new EventIndex(eventIndexDirectory, dmaIdListFactory, eventIdListMap);
}
};
}
use of com.google.common.io.PatternFilenameFilter in project rpki-validator-3 by RIPE-NCC.
the class PreconfiguredTrustAnchors method managePreconfiguredTrustAnchors.
@PostConstruct
public void managePreconfiguredTrustAnchors() {
new TransactionTemplate(transactionManager).execute((status) -> {
log.info("Automatically adding preconfigured trust anchors");
if (settings.isPreconfiguredTalsLoaded()) {
log.info("Preconfigured trust anchors are already loaded, skipping");
return null;
}
settings.markPreconfiguredTalsLoaded();
File[] tals = preconfiguredTrustAnchorDirectory.listFiles(new PatternFilenameFilter(Pattern.compile("^.*\\.tal$")));
if (ArrayUtils.isEmpty(tals)) {
log.warn("No preconfigured trust anchors found at {}, skipping", preconfiguredTrustAnchorDirectory);
return null;
}
for (File tal : tals) {
TrustAnchorLocator locator = TrustAnchorLocator.fromFile(tal);
if (trustAnchors.findBySubjectPublicKeyInfo(locator.getPublicKeyInfo()).isPresent()) {
log.info("Preconfigured trust anchor '{}' already installed, skipping", locator.getCaName());
continue;
}
TrustAnchor trustAnchor = new TrustAnchor(true);
trustAnchor.setName(locator.getCaName());
trustAnchor.setLocations(locator.getCertificateLocations().stream().map(URI::toASCIIString).collect(Collectors.toList()));
trustAnchor.setSubjectPublicKeyInfo(locator.getPublicKeyInfo());
trustAnchor.setRsyncPrefetchUri(locator.getPrefetchUris().stream().filter(uri -> "rsync".equalsIgnoreCase(uri.getScheme())).map(URI::toASCIIString).findFirst().orElse(null));
trustAnchorService.add(trustAnchor);
}
return null;
});
}
use of com.google.common.io.PatternFilenameFilter in project calcite by apache.
the class QuidemTest method data.
protected static Collection<Object[]> data(String first) {
// inUrl = "file:/home/fred/calcite/core/target/test-classes/sql/agg.iq"
final URL inUrl = JdbcTest.class.getResource("/" + first);
String x = inUrl.getFile();
assert x.endsWith(first);
final String base = File.separatorChar == '\\' ? x.substring(1, x.length() - first.length()).replace('/', File.separatorChar) : x.substring(0, x.length() - first.length());
final File firstFile = new File(x);
final File dir = firstFile.getParentFile();
final List<String> paths = new ArrayList<>();
final FilenameFilter filter = new PatternFilenameFilter(".*\\.iq$");
for (File f : Util.first(dir.listFiles(filter), new File[0])) {
assert f.getAbsolutePath().startsWith(base) : "f: " + f.getAbsolutePath() + "; base: " + base;
paths.add(f.getAbsolutePath().substring(base.length()));
}
return Lists.transform(paths, new Function<String, Object[]>() {
public Object[] apply(String path) {
return new Object[] { path };
}
});
}
use of com.google.common.io.PatternFilenameFilter in project intellij-community by JetBrains.
the class IdeaLicenseHelper method copyIDEALicense.
public static void copyIDEALicense(final String sandboxHome) {
File sandboxSystemPath = new File(sandboxHome, "system");
File systemPath = new File(PathManager.getSystemPath());
File[] runningIdeaLicenses = systemPath.listFiles(new PatternFilenameFilter("idea\\d+\\.key"));
if (runningIdeaLicenses != null) {
for (File license : runningIdeaLicenses) {
File devIdeaLicense = new File(sandboxSystemPath, license.getName());
if (!devIdeaLicense.exists()) {
try {
FileUtil.copy(license, devIdeaLicense);
} catch (IOException e) {
LOG.error(e);
}
}
}
}
}
use of com.google.common.io.PatternFilenameFilter in project Glowstone by GlowstoneMC.
the class GlowPluginTypeDetector method scan.
public void scan() {
GlowServer.logger.info("Scanning plugins...");
File[] files = directory.listFiles(new PatternFilenameFilter(".+\\.jar"));
if (files == null || files.length == 0) {
return;
}
for (File file : files) {
scanFile(file);
}
GlowServer.logger.info("PluginTypeDetector: found " + bukkitPlugins.size() + " Bukkit, " + spongePlugins.size() + " Sponge, " + (forgefPlugins.size() + forgenPlugins.size()) + " Forge, " + canaryPlugins.size() + " Canary, " + unrecognizedPlugins.size() + " unknown plugins (total " + files.length + ")");
if (!unrecognizedPlugins.isEmpty()) {
for (File file : unrecognizedPlugins) {
GlowServer.logger.warning("Unrecognized plugin: " + file.getPath());
}
}
}
Aggregations