use of org.eclipse.che.commons.lang.Pair in project che by eclipse.
the class FileCleaner method clean.
private static void clean() {
Pair<File, Integer> pair;
final Set<Pair<File, Integer>> failToDelete = new HashSet<>();
while ((pair = files.poll()) != null) {
final File file = pair.first;
int deleteAttempts = pair.second;
if (file.exists()) {
if (!IoUtil.deleteRecursive(file)) {
failToDelete.add(Pair.of(file, ++deleteAttempts));
if (deleteAttempts > logAfterAttempts) {
LOG.error("Unable delete file '{}' after {} tries", file, deleteAttempts);
}
} else if (LOG.isDebugEnabled()) {
LOG.debug("Delete file '{}'", file);
}
}
}
if (!failToDelete.isEmpty()) {
files.addAll(failToDelete);
}
}
use of org.eclipse.che.commons.lang.Pair in project che by eclipse.
the class MemoryVirtualFileTest method countsMd5Sums.
@Test
public void countsMd5Sums() throws Exception {
VirtualFile root = getRoot();
VirtualFile folder = root.createFolder(generateFolderName());
VirtualFile file1 = folder.createFile(generateFileName(), DEFAULT_CONTENT);
VirtualFile file2 = folder.createFile(generateFileName(), "xxx");
root.createFolder(generateFolderName());
Set<Pair<String, String>> expected = newHashSet(Pair.of(countMd5Sum(file1), file1.getPath().subPath(folder.getPath()).toString()), Pair.of(countMd5Sum(file2), file2.getPath().subPath(folder.getPath()).toString()));
assertEquals(expected, newHashSet(folder.countMd5Sums()));
}
use of org.eclipse.che.commons.lang.Pair in project che by eclipse.
the class PostgreSqlTckModule method configure.
@Override
protected void configure() {
final String dbUrl = System.getProperty("jdbc.url");
final String dbUser = System.getProperty("jdbc.user");
final String dbPassword = System.getProperty("jdbc.password");
waitConnectionIsEstablished(dbUrl, dbUser, dbPassword);
// jpa
install(new PersistTestModuleBuilder().setDriver(Driver.class).setUrl(dbUrl).setUser(dbUser).setPassword(dbPassword).setExceptionHandler(PostgreSqlExceptionHandler.class).addEntityClasses(AccountImpl.class, UserImpl.class, ProfileImpl.class, PreferenceEntity.class, WorkspaceImpl.class, WorkspaceConfigImpl.class, ProjectConfigImpl.class, EnvironmentImpl.class, EnvironmentRecipeImpl.class, ExtendedMachineImpl.class, SourceStorageImpl.class, ServerConf2Impl.class, StackImpl.class, CommandImpl.class, SnapshotImpl.class, RecipeImpl.class, SshPairImpl.class).addEntityClass("org.eclipse.che.api.workspace.server.model.impl.ProjectConfigImpl$Attribute").build());
bind(TckResourcesCleaner.class).to(JpaCleaner.class);
// db initialization
bind(DBInitializer.class).asEagerSingleton();
final PGSimpleDataSource dataSource = new PGSimpleDataSource();
dataSource.setUser(dbUser);
dataSource.setPassword(dbPassword);
dataSource.setUrl(dbUrl);
bind(SchemaInitializer.class).toInstance(new FlywaySchemaInitializer(dataSource, "che-schema"));
// account
bind(AccountDao.class).to(JpaAccountDao.class);
bind(new TypeLiteral<TckRepository<AccountImpl>>() {
}).toInstance(new JpaTckRepository<>(AccountImpl.class));
// user
bind(UserDao.class).to(JpaUserDao.class);
bind(ProfileDao.class).to(JpaProfileDao.class);
bind(PreferenceDao.class).to(JpaPreferenceDao.class);
bind(new TypeLiteral<TckRepository<UserImpl>>() {
}).to(UserRepo.class);
bind(new TypeLiteral<TckRepository<Pair<String, Map<String, String>>>>() {
}).to(PreferencesRepo.class);
bind(new TypeLiteral<TckRepository<ProfileImpl>>() {
}).toInstance(new JpaTckRepository<>(ProfileImpl.class));
bind(PasswordEncryptor.class).to(SHA512PasswordEncryptor.class);
// machine
bind(RecipeDao.class).to(JpaRecipeDao.class);
bind(SnapshotDao.class).to(JpaSnapshotDao.class);
bind(new TypeLiteral<TckRepository<RecipeImpl>>() {
}).toInstance(new JpaTckRepository<>(RecipeImpl.class));
bind(new TypeLiteral<TckRepository<SnapshotImpl>>() {
}).toInstance(new JpaTckRepository<>(SnapshotImpl.class));
bind(new TypeLiteral<TckRepository<Workspace>>() {
}).toInstance(new WorkspaceRepoForSnapshots());
// ssh
bind(SshDao.class).to(JpaSshDao.class);
bind(new TypeLiteral<TckRepository<SshPairImpl>>() {
}).toInstance(new JpaTckRepository<>(SshPairImpl.class));
// workspace
bind(WorkspaceDao.class).to(JpaWorkspaceDao.class);
bind(StackDao.class).to(JpaStackDao.class);
bind(new TypeLiteral<TckRepository<WorkspaceImpl>>() {
}).toInstance(new WorkspaceRepository());
bind(new TypeLiteral<TckRepository<StackImpl>>() {
}).toInstance(new StackRepository());
}
Aggregations