From b4ff3771ba873c036fe9be69cd90921e6746ab6a Mon Sep 17 00:00:00 2001
From: Timm Fitschen <t.fitschen@indiscale.com>
Date: Tue, 29 Nov 2022 01:14:58 +0100
Subject: [PATCH] WIP: file storage refactoring

---
 .../server/database/BackendTransaction.java   |  13 +--
 .../caosdb/server/database/DatabaseUtils.java |   2 +-
 .../implementation/MySQL}/MySQLListFiles.java |   7 +-
 .../MySQL/MySQLRetrieveAllUncheckedFiles.java |   2 +-
 .../UnixFileSystem/DeleteFile.java            |  19 ----
 .../UnixFileSystem/FileSystemCheckHash.java   |  54 ----------
 .../UnixFileSystem/FileSystemCheckSize.java   |  57 ----------
 .../UnixFileSystem/FileSystemFileExists.java  |  52 ---------
 .../FileSystemFileWasModifiedAfter.java       |  54 ----------
 .../FileSystemGetFileIterator.java            | 101 ------------------
 .../UnixFileSystem/FileSystemTransaction.java |  50 ---------
 .../UnixFileSystem/ResolveFile.java           |  18 ----
 .../backend/interfaces/DeleteFileImpl.java    |  10 --
 .../backend/interfaces/FileCheckSize.java     |  30 ------
 .../backend/interfaces/FileExists.java        |  30 ------
 .../interfaces/FileWasModifiedAfter.java      |  30 ------
 .../interfaces/GetFileIteratorImpl.java       |  31 ------
 .../backend/interfaces/StoreFileImpl.java     |  10 --
 .../backend/transaction/DeleteFile.java       |   5 +-
 .../backend/transaction/GetFileIterator.java  |  11 +-
 .../backend/transaction/StoreFile.java        |   8 +-
 .../entity/container/WritableContainer.java   |   6 --
 .../filesystem/FileStorageInterface.java      |  36 +------
 .../server/filesystem/LocalFileStorage.java   |  91 +++++++++++-----
 .../caosdb/server/filesystem/StoreFile.java   |  20 ----
 .../consistency/AbstractConsistencyEvent.java |   5 -
 .../FileStorageConsistencyCheck.java          |   4 -
 27 files changed, 80 insertions(+), 676 deletions(-)
 rename src/main/java/org/caosdb/server/database/{ => backend/implementation/MySQL}/MySQLListFiles.java (92%)
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/DeleteFile.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckHash.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckSize.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileExists.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileWasModifiedAfter.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemGetFileIterator.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemTransaction.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/ResolveFile.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/interfaces/DeleteFileImpl.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/interfaces/FileCheckSize.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/interfaces/FileExists.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/interfaces/FileWasModifiedAfter.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/interfaces/GetFileIteratorImpl.java
 delete mode 100644 src/main/java/org/caosdb/server/database/backend/interfaces/StoreFileImpl.java
 delete mode 100644 src/main/java/org/caosdb/server/filesystem/StoreFile.java

diff --git a/src/main/java/org/caosdb/server/database/BackendTransaction.java b/src/main/java/org/caosdb/server/database/BackendTransaction.java
index a3093651..4f41f7a3 100644
--- a/src/main/java/org/caosdb/server/database/BackendTransaction.java
+++ b/src/main/java/org/caosdb/server/database/BackendTransaction.java
@@ -46,6 +46,7 @@ import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertRole;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertSparseEntity;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLInsertTransactionHistory;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLIsSubType;
+import org.caosdb.server.database.backend.implementation.MySQL.MySQLListFiles;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLListRoles;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLListUsers;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLLogUserVisit;
@@ -73,10 +74,8 @@ import org.caosdb.server.database.backend.implementation.MySQL.MySQLSyncStats;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLUpdateSparseEntity;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLUpdateUser;
 import org.caosdb.server.database.backend.implementation.MySQL.MySQLUpdateUserRoles;
-import org.caosdb.server.database.backend.implementation.UnixFileSystem.DeleteFile;
 import org.caosdb.server.database.backend.interfaces.BackendTransactionImpl;
 import org.caosdb.server.database.backend.interfaces.DeleteEntityPropertiesImpl;
-import org.caosdb.server.database.backend.interfaces.DeleteFileImpl;
 import org.caosdb.server.database.backend.interfaces.DeletePasswordImpl;
 import org.caosdb.server.database.backend.interfaces.DeleteRoleImpl;
 import org.caosdb.server.database.backend.interfaces.DeleteSparseEntityImpl;
@@ -123,7 +122,6 @@ import org.caosdb.server.database.backend.interfaces.SetFileChecksumImpl;
 import org.caosdb.server.database.backend.interfaces.SetPasswordImpl;
 import org.caosdb.server.database.backend.interfaces.SetPermissionRulesImpl;
 import org.caosdb.server.database.backend.interfaces.SetQueryTemplateDefinitionImpl;
-import org.caosdb.server.database.backend.interfaces.StoreFileImpl;
 import org.caosdb.server.database.backend.interfaces.SyncStatsImpl;
 import org.caosdb.server.database.backend.interfaces.UpdateSparseEntityImpl;
 import org.caosdb.server.database.backend.interfaces.UpdateUserImpl;
@@ -132,7 +130,6 @@ import org.caosdb.server.database.exceptions.TransactionException;
 import org.caosdb.server.database.misc.TransactionBenchmark;
 import org.caosdb.server.entity.EntityInterface;
 import org.caosdb.server.entity.RetrieveEntity;
-import org.caosdb.server.filesystem.StoreFile;
 import org.caosdb.server.utils.UndoHandler;
 import org.caosdb.server.utils.Undoable;
 
@@ -186,10 +183,6 @@ public abstract class BackendTransaction implements Undoable {
       setImpl(RetrievePropertiesImpl.class, MySQLRetrieveProperties.class);
       setImpl(RetrieveSparseEntityImpl.class, MySQLRetrieveSparseEntity.class);
       setImpl(SyncStatsImpl.class, MySQLSyncStats.class);
-      //      setImpl(FileExists.class, FileSystemFileExists.class);
-      //      setImpl(FileWasModifiedAfter.class, FileSystemFileWasModifiedAfter.class);
-      //      setImpl(FileCheckHash.class, FileSystemCheckHash.class);
-      //      setImpl(GetFileIteratorImpl.class, FileSystemGetFileIterator.class);
       setImpl(SetFileCheckedTimestampImpl.class, MySQLSetFileCheckedTimestamp.class);
       setImpl(RetrieveAllUncheckedFilesImpl.class, MySQLRetrieveAllUncheckedFiles.class);
       setImpl(UpdateUserImpl.class, MySQLUpdateUser.class);
@@ -198,7 +191,6 @@ public abstract class BackendTransaction implements Undoable {
       setImpl(RetrievePasswordValidatorImpl.class, MySQLRetrievePasswordValidator.class);
       setImpl(DeletePasswordImpl.class, MySQLDeletePassword.class);
       setImpl(GetUpdateableChecksumsImpl.class, MySQLGetUpdateableChecksums.class);
-      //      setImpl(FileCheckSize.class, FileSystemCheckSize.class);
       setImpl(InsertRoleImpl.class, MySQLInsertRole.class);
       setImpl(RetrieveRoleImpl.class, MySQLRetrieveRole.class);
       setImpl(ListRolesImpl.class, MySQLListRoles.class);
@@ -212,9 +204,6 @@ public abstract class BackendTransaction implements Undoable {
       setImpl(
           RetrieveQueryTemplateDefinitionImpl.class, MySQLRetrieveQueryTemplateDefinition.class);
       setImpl(InsertEntityDatatypeImpl.class, MySQLInsertEntityDatatype.class);
-      setImpl(StoreFileImpl.class, StoreFile.class);
-      setImpl(DeleteFileImpl.class, DeleteFile.class);
-      //      setImpl(ResolveFileImpl.class, ResolveFile.class);
       setImpl(RetrieveVersionHistoryImpl.class, MySQLRetrieveVersionHistory.class);
       setImpl(SetFileChecksumImpl.class, MySQLSetFileChecksum.class);
       setImpl(GetFilesInDirectoryImpl.class, MySQLGetFilesInDirectory.class);
diff --git a/src/main/java/org/caosdb/server/database/DatabaseUtils.java b/src/main/java/org/caosdb/server/database/DatabaseUtils.java
index 1ce5d930..ad881041 100644
--- a/src/main/java/org/caosdb/server/database/DatabaseUtils.java
+++ b/src/main/java/org/caosdb/server/database/DatabaseUtils.java
@@ -235,7 +235,7 @@ public class DatabaseUtils {
               bytes2UTF8(rs.getBytes("FileHash")),
               rs.getLong("FileHashChecked"),
               bytes2UTF8(rs.getBytes("FileHashAlgo")));
-      final String mimetype = bytes2UTF8(rs.getBytes("FileMimetype"));
+      final String mimetype = bytes2UTF8(rs.getBytes("FileMimeType"));
       ret.fileType =
           java.util.Objects.equals("inode/directory", mimetype)
               ? ObjectType.DIRECTORY
diff --git a/src/main/java/org/caosdb/server/database/MySQLListFiles.java b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLListFiles.java
similarity index 92%
rename from src/main/java/org/caosdb/server/database/MySQLListFiles.java
rename to src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLListFiles.java
index c5b1774f..dfeed05b 100644
--- a/src/main/java/org/caosdb/server/database/MySQLListFiles.java
+++ b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLListFiles.java
@@ -1,13 +1,12 @@
-package org.caosdb.server.database;
+package org.caosdb.server.database.backend.implementation.MySQL;
 
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
 import java.sql.SQLException;
 import java.util.LinkedList;
 import java.util.List;
+import org.caosdb.server.database.DatabaseUtils;
 import org.caosdb.server.database.access.Access;
-import org.caosdb.server.database.backend.implementation.MySQL.ConnectionException;
-import org.caosdb.server.database.backend.implementation.MySQL.MySQLTransaction;
 import org.caosdb.server.database.backend.interfaces.ListFilesImpl;
 import org.caosdb.server.database.exceptions.TransactionException;
 import org.caosdb.server.database.proto.SparseEntity;
@@ -21,7 +20,7 @@ public class MySQLListFiles extends MySQLTransaction implements ListFilesImpl {
   }
 
   public static final String LIST_FILES_STMT =
-      "SELECT 'SHA-512' AS FileHashAlgo, file_id AS FileId, parent_directory AS FileParentID, path AS FilePath, size AS FileSize, hex(hash) AS FileHash, checked_timestamp AS FileHashChecked, mimetype AS FileMimetype, file_storage_id AS FileStorageID, file_key AS FileKey FROM files";
+      "SELECT 'SHA-512' AS FileHashAlgo, file_id AS FileId, parent_directory AS FileParentID, path AS FilePath, size AS FileSize, hex(hash) AS FileHash, checked_timestamp AS FileHashChecked, mimetype AS FileMimeType, file_storage_id AS FileStorageID, file_key AS FileKey FROM files";
   public static final String FILE_STORAGE_CLAUSE = " file_storage_id = ?";
   public static final String PATH_LIKE_CLAUSE = " path LIKE ?";
   public static final String LAST_CHECKED_BEFORE_CLAUSE = " checked_timestamp < ?";
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveAllUncheckedFiles.java b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveAllUncheckedFiles.java
index a1c547bd..9fc50c82 100644
--- a/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveAllUncheckedFiles.java
+++ b/src/main/java/org/caosdb/server/database/backend/implementation/MySQL/MySQLRetrieveAllUncheckedFiles.java
@@ -42,7 +42,7 @@ public class MySQLRetrieveAllUncheckedFiles extends MySQLTransaction
 
   private static final String STMT_RETRIEVE_ALL =
       "SELECT hash_algorithm AS FileHashAlgo, file_id AS FileId, " /*parent_directory AS FileParentId,*/
-          + "path AS FilePath, size AS FileSize, hex(hash) AS FileHash, checked_timestamp AS FileHashChecked, mimetype AS FileMimetype, file_storage_id AS FileStorageId, file_key AS FileKey FROM files WHERE checked_timestamp<? AND path LIKE ? AND (mimetype IS NULL OR mimetype != 'inode/directory')";
+          + "path AS FilePath, size AS FileSize, hex(hash) AS FileHash, checked_timestamp AS FileHashChecked, mimetype AS FileMimeType, file_storage_id AS FileStorageId, file_key AS FileKey FROM files WHERE checked_timestamp<? AND path LIKE ? AND (mimetype IS NULL OR mimetype != 'inode/directory')";
 
   public MySQLRetrieveAllUncheckedFiles(final Access access) {
     super(access);
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/DeleteFile.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/DeleteFile.java
deleted file mode 100644
index 212239d5..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/DeleteFile.java
+++ /dev/null
@@ -1,19 +0,0 @@
-package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-
-import org.caosdb.server.database.access.Access;
-import org.caosdb.server.database.backend.interfaces.DeleteFileImpl;
-import org.caosdb.server.entity.Message;
-import org.caosdb.server.filesystem.FSODescriptorInterface;
-import org.caosdb.server.utils.Undoable;
-
-public class DeleteFile extends FileSystemTransaction implements DeleteFileImpl {
-
-  public DeleteFile(Access access) {
-    super(access);
-  }
-
-  @Override
-  public Undoable delete(FSODescriptorInterface fileDescriptor) throws Message {
-    return getFileSystem().delete(fileDescriptor);
-  }
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckHash.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckHash.java
deleted file mode 100644
index 2ad90410..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckHash.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-//
-// import java.io.IOException;
-// import java.io.InputStream;
-// import org.caosdb.server.database.access.Access;
-// import org.caosdb.server.database.backend.interfaces.FileCheckHash;
-// import org.caosdb.server.database.exceptions.TransactionException;
-// import org.caosdb.server.filesystem.Hash;
-// import org.caosdb.server.filesystem.Hasher;
-//
-/// **
-// * TODO refactor. remove this class and let the file system back-end calculate the hash.
-// *
-// * @author Timm Fitschen (t.fitschen@indiscale.com)
-// */
-// public class FileSystemCheckHash extends FileSystemTransaction implements FileCheckHash {
-//
-//  public FileSystemCheckHash(final Access access) {
-//    super(access);
-//  }
-//
-//  @Override
-//  public boolean execute(final InputStream stream, final Hash hash) throws TransactionException {
-//    try {
-//      Hasher hasher = Hasher.create(hash.getAlgorithm());
-//      final Hash normativeHash = hasher.hash(stream);
-//      return hash.equals(normativeHash);
-//    } catch (final IOException e) {
-//      throw new TransactionException(e);
-//    }
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckSize.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckSize.java
deleted file mode 100644
index 768ebbd1..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemCheckSize.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-//
-// import com.google.common.base.Objects;
-// import org.caosdb.server.database.access.Access;
-// import org.caosdb.server.database.backend.interfaces.FileCheckSize;
-// import org.caosdb.server.database.exceptions.TransactionException;
-// import org.caosdb.server.entity.Message;
-// import org.caosdb.server.filesystem.FSODescriptorInterface;
-//
-/// **
-// * TODO refactor. remove this class and let the file system back-end return the file size.
-// *
-// * @author Timm Fitschen (t.fitschen@indiscale.com)
-// */
-// public class FileSystemCheckSize extends FileSystemTransaction implements FileCheckSize {
-//
-//  public FileSystemCheckSize(final Access access) {
-//    super(access);
-//  }
-//
-//  @Override
-//  public boolean execute(final String storage, final String path, final Long size)
-//      throws TransactionException {
-//    if (size == null) {
-//      return true;
-//    }
-//    try {
-//      final FSODescriptorInterface file = getFile(storage, path);
-//      boolean result = Objects.equal(size, file.getFile().length());
-//      return result;
-//    } catch (final Message e) {
-//      throw new TransactionException(e);
-//    }
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileExists.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileExists.java
deleted file mode 100644
index ac477650..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileExists.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-//
-// import java.io.File;
-// import org.caosdb.server.database.access.Access;
-// import org.caosdb.server.database.backend.interfaces.FileExists;
-// import org.caosdb.server.database.exceptions.TransactionException;
-// import org.caosdb.server.entity.Message;
-//
-/// **
-// * TODO refactor. remove this class and let the file system back-end decide if the file exists.
-// *
-// * @author Timm Fitschen (t.fitschen@indiscale.com)
-// */
-// public class FileSystemFileExists extends FileSystemTransaction implements FileExists {
-//
-//  public FileSystemFileExists(final Access access) {
-//    super(access);
-//  }
-//
-//  @Override
-//  public boolean execute(final String storage, final String path) throws TransactionException {
-//    try {
-//      final File f = getFile(storage, path).getFile();
-//      final boolean ret = f.exists();
-//      return ret;
-//    } catch (final Message e) {
-//      throw new TransactionException(e);
-//    }
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileWasModifiedAfter.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileWasModifiedAfter.java
deleted file mode 100644
index f692f5cd..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemFileWasModifiedAfter.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-//
-// import java.io.File;
-// import org.caosdb.server.database.access.Access;
-// import org.caosdb.server.database.backend.interfaces.FileWasModifiedAfter;
-// import org.caosdb.server.database.exceptions.TransactionException;
-// import org.caosdb.server.entity.Message;
-//
-/// **
-// * TODO refactor. remove this class and let the file system back-end return the last-modified
-// date.
-// *
-// * @author Timm Fitschen (t.fitschen@indiscale.com)
-// */
-// public class FileSystemFileWasModifiedAfter extends FileSystemTransaction
-//    implements FileWasModifiedAfter {
-//
-//  public FileSystemFileWasModifiedAfter(final Access access) {
-//    super(access);
-//  }
-//
-//  @Override
-//  public boolean execute(final String storage, final String path, final Long timestamp)
-//      throws TransactionException {
-//    try {
-//      final File f = getFile(storage, path).getFile();
-//      return f.lastModified() > timestamp;
-//    } catch (final Message e) {
-//      throw new TransactionException(e);
-//    }
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemGetFileIterator.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemGetFileIterator.java
deleted file mode 100644
index 12cf752f..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemGetFileIterator.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/// *
-// * ** header v3.0
-// * This file is a part of the CaosDB Project.
-// *
-// * Copyright (C) 2018 Research Group Biomedical Physics,
-// * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
-// *
-// * This program is free software: you can redistribute it and/or modify
-// * it under the terms of the GNU Affero General Public License as
-// * published by the Free Software Foundation, either version 3 of the
-// * License, or (at your option) any later version.
-// *
-// * This program is distributed in the hope that it will be useful,
-// * but WITHOUT ANY WARRANTY; without even the implied warranty of
-// * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-// * GNU Affero General Public License for more details.
-// *
-// * You should have received a copy of the GNU Affero General Public License
-// * along with this program. If not, see <https://www.gnu.org/licenses/>.
-// *
-// * ** end header
-// */
-// package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-//
-// import java.io.File;
-// import java.util.Arrays;
-// import java.util.Iterator;
-// import org.caosdb.server.database.access.Access;
-// import org.caosdb.server.database.backend.interfaces.GetFileIteratorImpl;
-// import org.caosdb.server.database.exceptions.TransactionException;
-// import org.caosdb.server.entity.Message;
-//
-// public class FileSystemGetFileIterator extends FileSystemTransaction
-//    implements GetFileIteratorImpl {
-//
-//  public FileSystemGetFileIterator(final Access access) {
-//    super(access);
-//  }
-//
-//  @Override
-//  public Iterator<String> execute(final String storage, final String location)
-//      throws TransactionException {
-//    File base;
-//    try {
-//      // TODO: move everything to GetFileIterator and refactor. Needs a listFiles
-//      // Transaction
-//      base = getFile(storage, location).getFile();
-//    } catch (final Message e) {
-//      throw new TransactionException(e);
-//    }
-//    return new FileNameIterator(base, location);
-//  }
-//
-//  public static class FileNameIterator implements Iterator<String> {
-//
-//    private final File base;
-//    private File[] files = null;
-//    private FileNameIterator subfiles = null;
-//    private int i = 0;
-//    private final String rootPath;
-//
-//    public FileNameIterator(final File base, final String rootPath) {
-//      this.rootPath = rootPath.length() == 0 || rootPath.endsWith("/") ? rootPath : rootPath +
-// "/";
-//      this.base = base;
-//      this.files = this.base.listFiles();
-//      Arrays.sort(this.files);
-//    }
-//
-//    @Override
-//    public boolean hasNext() {
-//      return this.files.length > this.i;
-//    }
-//
-//    @Override
-//    public String next() {
-//      if (this.subfiles != null) {
-//        if (this.subfiles.hasNext()) {
-//          return this.subfiles.next();
-//        } else {
-//          this.subfiles = null;
-//        }
-//      }
-//      final File ret = this.files[this.i++];
-//      if (ret.isDirectory()) {
-//        this.subfiles = new FileNameIterator(ret, this.rootPath + ret.getName() + "/");
-//        if (this.subfiles.hasNext()) {
-//          return next();
-//        } else {
-//          return this.rootPath + ret.getName() + "/";
-//        }
-//      }
-//      return this.rootPath + ret.getName();
-//    }
-//
-//    @Override
-//    public void remove() {
-//      throw new UnsupportedOperationException();
-//    }
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemTransaction.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemTransaction.java
deleted file mode 100644
index 1f6766a7..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/FileSystemTransaction.java
+++ /dev/null
@@ -1,50 +0,0 @@
-package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-
-import org.caosdb.server.database.access.Access;
-import org.caosdb.server.database.backend.interfaces.BackendTransactionImpl;
-import org.caosdb.server.database.misc.TransactionBenchmark;
-import org.caosdb.server.entity.Message;
-import org.caosdb.server.filesystem.FSODescriptorInterface;
-import org.caosdb.server.filesystem.FileSystem;
-import org.caosdb.server.filesystem.FileSystemInterface;
-
-/**
- * Encapsulates the FileSystem access an brings the access to the file system into a form which is
- * consistent with any other interaction with the storage back-ends.
- *
- * <p>This class is also responsible for measuring the file-system access performance.
- *
- * @author Timm Fitschen (t.fitschen@indiscale.com)
- */
-public abstract class FileSystemTransaction implements BackendTransactionImpl {
-
-  private Access access;
-  private TransactionBenchmark transactionBenchmark;
-  private FileSystemInterface fileSystem = FileSystem.getInstance();
-
-  public FileSystemTransaction(Access access) {
-    this.access = access;
-  }
-
-  public Access getAccess() {
-    return access;
-  }
-
-  @Override
-  public void setTransactionBenchmark(TransactionBenchmark b) {
-    this.transactionBenchmark = b;
-  }
-
-  @Override
-  public TransactionBenchmark getBenchmark() {
-    return transactionBenchmark;
-  }
-
-  public FileSystemInterface getFileSystem() {
-    return fileSystem;
-  }
-
-  public FSODescriptorInterface getFile(String storage, String path) throws Message {
-    return fileSystem.resolve(storage, path);
-  }
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/ResolveFile.java b/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/ResolveFile.java
deleted file mode 100644
index 28b27de6..00000000
--- a/src/main/java/org/caosdb/server/database/backend/implementation/UnixFileSystem/ResolveFile.java
+++ /dev/null
@@ -1,18 +0,0 @@
-// package org.caosdb.server.database.backend.implementation.UnixFileSystem;
-//
-// import org.caosdb.server.database.access.Access;
-// import org.caosdb.server.database.backend.interfaces.ResolveFileImpl;
-// import org.caosdb.server.entity.Message;
-// import org.caosdb.server.filesystem.FSODescriptorInterface;
-//
-// public class ResolveFile extends FileSystemTransaction implements ResolveFileImpl {
-//
-//  public ResolveFile(Access access) {
-//    super(access);
-//  }
-//
-//  @Override
-//  public FSODescriptorInterface resolveFile(String fileStorageId, String fileKey) throws Message {
-//    return getFileSystem().resolve(fileStorageId, fileKey);
-//  }
-// }
diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/DeleteFileImpl.java b/src/main/java/org/caosdb/server/database/backend/interfaces/DeleteFileImpl.java
deleted file mode 100644
index 40cd48f1..00000000
--- a/src/main/java/org/caosdb/server/database/backend/interfaces/DeleteFileImpl.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.caosdb.server.database.backend.interfaces;
-
-import org.caosdb.server.entity.Message;
-import org.caosdb.server.filesystem.FSODescriptorInterface;
-import org.caosdb.server.utils.Undoable;
-
-public interface DeleteFileImpl extends BackendTransactionImpl {
-
-  Undoable delete(FSODescriptorInterface fileDescriptor) throws Message;
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/FileCheckSize.java b/src/main/java/org/caosdb/server/database/backend/interfaces/FileCheckSize.java
deleted file mode 100644
index b9644d17..00000000
--- a/src/main/java/org/caosdb/server/database/backend/interfaces/FileCheckSize.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * ** header v3.0
- * This file is a part of the CaosDB Project.
- *
- * Copyright (C) 2018 Research Group Biomedical Physics,
- * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * ** end header
- */
-package org.caosdb.server.database.backend.interfaces;
-
-import org.caosdb.server.database.exceptions.TransactionException;
-
-public interface FileCheckSize extends BackendTransactionImpl {
-
-  public boolean execute(String storage, String path, Long size) throws TransactionException;
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/FileExists.java b/src/main/java/org/caosdb/server/database/backend/interfaces/FileExists.java
deleted file mode 100644
index 36cf762c..00000000
--- a/src/main/java/org/caosdb/server/database/backend/interfaces/FileExists.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * ** header v3.0
- * This file is a part of the CaosDB Project.
- *
- * Copyright (C) 2018 Research Group Biomedical Physics,
- * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * ** end header
- */
-package org.caosdb.server.database.backend.interfaces;
-
-import org.caosdb.server.database.exceptions.TransactionException;
-
-public interface FileExists extends BackendTransactionImpl {
-
-  public boolean execute(String storage, String path) throws TransactionException;
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/FileWasModifiedAfter.java b/src/main/java/org/caosdb/server/database/backend/interfaces/FileWasModifiedAfter.java
deleted file mode 100644
index 143797ff..00000000
--- a/src/main/java/org/caosdb/server/database/backend/interfaces/FileWasModifiedAfter.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * ** header v3.0
- * This file is a part of the CaosDB Project.
- *
- * Copyright (C) 2018 Research Group Biomedical Physics,
- * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * ** end header
- */
-package org.caosdb.server.database.backend.interfaces;
-
-import org.caosdb.server.database.exceptions.TransactionException;
-
-public interface FileWasModifiedAfter extends BackendTransactionImpl {
-
-  public boolean execute(String storage, String path, Long timestamp) throws TransactionException;
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/GetFileIteratorImpl.java b/src/main/java/org/caosdb/server/database/backend/interfaces/GetFileIteratorImpl.java
deleted file mode 100644
index cb6609a9..00000000
--- a/src/main/java/org/caosdb/server/database/backend/interfaces/GetFileIteratorImpl.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ** header v3.0
- * This file is a part of the CaosDB Project.
- *
- * Copyright (C) 2018 Research Group Biomedical Physics,
- * Max-Planck-Institute for Dynamics and Self-Organization Göttingen
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see <https://www.gnu.org/licenses/>.
- *
- * ** end header
- */
-package org.caosdb.server.database.backend.interfaces;
-
-import java.util.Iterator;
-import org.caosdb.server.database.exceptions.TransactionException;
-
-public interface GetFileIteratorImpl extends BackendTransactionImpl {
-
-  public Iterator<String> execute(String storage, String location) throws TransactionException;
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/interfaces/StoreFileImpl.java b/src/main/java/org/caosdb/server/database/backend/interfaces/StoreFileImpl.java
deleted file mode 100644
index a6e3da0e..00000000
--- a/src/main/java/org/caosdb/server/database/backend/interfaces/StoreFileImpl.java
+++ /dev/null
@@ -1,10 +0,0 @@
-package org.caosdb.server.database.backend.interfaces;
-
-import org.caosdb.server.entity.Message;
-import org.caosdb.server.filesystem.VirtualFSODescriptorInterface;
-import org.caosdb.server.utils.Undoable;
-
-public interface StoreFileImpl extends BackendTransactionImpl {
-
-  public Undoable store(VirtualFSODescriptorInterface file) throws Message;
-}
diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/DeleteFile.java b/src/main/java/org/caosdb/server/database/backend/transaction/DeleteFile.java
index c48ef84b..e387171b 100644
--- a/src/main/java/org/caosdb/server/database/backend/transaction/DeleteFile.java
+++ b/src/main/java/org/caosdb/server/database/backend/transaction/DeleteFile.java
@@ -23,10 +23,10 @@
 package org.caosdb.server.database.backend.transaction;
 
 import org.caosdb.server.database.BackendTransaction;
-import org.caosdb.server.database.backend.interfaces.DeleteFileImpl;
 import org.caosdb.server.database.exceptions.TransactionException;
 import org.caosdb.server.entity.EntityInterface;
 import org.caosdb.server.entity.Message;
+import org.caosdb.server.filesystem.FileSystem;
 
 public class DeleteFile extends BackendTransaction {
 
@@ -39,8 +39,7 @@ public class DeleteFile extends BackendTransaction {
   @Override
   public void execute() throws TransactionException {
     try {
-      DeleteFileImpl t = getImplementation(DeleteFileImpl.class);
-      getUndoHandler().append(t.delete(this.entity.getFSODescriptor()));
+      getUndoHandler().append(FileSystem.getInstance().delete(this.entity.getFSODescriptor()));
     } catch (final Message m) {
       this.entity.addError(m);
       throw new TransactionException(m);
diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/GetFileIterator.java b/src/main/java/org/caosdb/server/database/backend/transaction/GetFileIterator.java
index 3fe8f2fc..4a150c42 100644
--- a/src/main/java/org/caosdb/server/database/backend/transaction/GetFileIterator.java
+++ b/src/main/java/org/caosdb/server/database/backend/transaction/GetFileIterator.java
@@ -24,7 +24,6 @@ package org.caosdb.server.database.backend.transaction;
 
 import java.util.Iterator;
 import org.caosdb.server.database.BackendTransaction;
-import org.caosdb.server.database.backend.interfaces.GetFileIteratorImpl;
 import org.caosdb.server.database.exceptions.TransactionException;
 
 /**
@@ -35,18 +34,12 @@ import org.caosdb.server.database.exceptions.TransactionException;
 public class GetFileIterator extends BackendTransaction {
 
   private Iterator<String> iterator;
-  private final String location;
-  private String storage;
 
-  public GetFileIterator(final String fileStorageId, final String directory) {
-    this.location = directory;
-    this.storage = fileStorageId;
-  }
+  public GetFileIterator(final String fileStorageId, final String directory) {}
 
   @Override
   protected void execute() throws TransactionException {
-    final GetFileIteratorImpl t = getImplementation(GetFileIteratorImpl.class);
-    this.iterator = t.execute(this.storage, this.location);
+    // TODO
   }
 
   public Iterator<String> getIterator() {
diff --git a/src/main/java/org/caosdb/server/database/backend/transaction/StoreFile.java b/src/main/java/org/caosdb/server/database/backend/transaction/StoreFile.java
index 102d6eb8..ed796d32 100644
--- a/src/main/java/org/caosdb/server/database/backend/transaction/StoreFile.java
+++ b/src/main/java/org/caosdb/server/database/backend/transaction/StoreFile.java
@@ -23,10 +23,11 @@
 package org.caosdb.server.database.backend.transaction;
 
 import org.caosdb.server.database.BackendTransaction;
-import org.caosdb.server.database.backend.interfaces.StoreFileImpl;
 import org.caosdb.server.database.exceptions.TransactionException;
 import org.caosdb.server.entity.EntityInterface;
 import org.caosdb.server.entity.Message;
+import org.caosdb.server.filesystem.FileSystem;
+import org.caosdb.server.filesystem.RealFSODescriptorInterface;
 import org.caosdb.server.utils.EntityStatus;
 
 public class StoreFile extends BackendTransaction {
@@ -40,11 +41,10 @@ public class StoreFile extends BackendTransaction {
   @Override
   public void execute() {
     if (this.entity.getEntityStatus() == EntityStatus.QUALIFIED) {
-
+      RealFSODescriptorInterface twin = entity.getFSODescriptor().getTwin();
       try {
-        StoreFileImpl t = getImplementation(StoreFileImpl.class);
+        getUndoHandler().append(FileSystem.getInstance().move(twin, entity.getFSODescriptor()));
 
-        getUndoHandler().append(t.store(this.entity.getFSODescriptor()));
       } catch (final Message m) {
         this.entity.addMessage(m);
         throw new TransactionException(m);
diff --git a/src/main/java/org/caosdb/server/entity/container/WritableContainer.java b/src/main/java/org/caosdb/server/entity/container/WritableContainer.java
index 33f43394..dc88de57 100644
--- a/src/main/java/org/caosdb/server/entity/container/WritableContainer.java
+++ b/src/main/java/org/caosdb/server/entity/container/WritableContainer.java
@@ -24,7 +24,6 @@ package org.caosdb.server.entity.container;
 import java.util.HashMap;
 import org.apache.shiro.SecurityUtils;
 import org.apache.shiro.subject.Subject;
-import org.caosdb.server.filesystem.RealFSODescriptorInterface;
 
 public class WritableContainer extends TransactionContainer {
   private static final long serialVersionUID = -4097777313518959519L;
@@ -40,9 +39,4 @@ public class WritableContainer extends TransactionContainer {
   public WritableContainer() {
     this(SecurityUtils.getSubject(), System.currentTimeMillis(), null, null);
   }
-
-  @Override
-  public void addFile(final String uploadId, final RealFSODescriptorInterface fileProperties) {
-    super.addFile(uploadId, fileProperties);
-  }
 }
diff --git a/src/main/java/org/caosdb/server/filesystem/FileStorageInterface.java b/src/main/java/org/caosdb/server/filesystem/FileStorageInterface.java
index 5e41e7c3..f0b8be54 100644
--- a/src/main/java/org/caosdb/server/filesystem/FileStorageInterface.java
+++ b/src/main/java/org/caosdb/server/filesystem/FileStorageInterface.java
@@ -47,40 +47,10 @@ public interface FileStorageInterface {
 
   public abstract Hash getHash(FSODescriptorInterface fso, String algorithm);
 
-  //  /**
-  //   * If key identifies a link in this file storage, return a descriptor for that file.
-  //   *
-  //   * <p>Otherwise, return null.
-  //   *
-  //   * <p>The returned descriptor has the following properties:
-  //   *
-  //   * <p>If the descriptor has a file the link is intact. Otherwise the link is broken and the
-  // target
-  //   * does not exist.
-  //   *
-  //   * <p>If the target is indeed stored in this file storage, the fileStorageId and the key of
-  // the
-  //   * descriptor are non-null. A null fileStorageId or key indicates that the target lies outside
-  // of
-  //   * this file storage.
-  //   *
-  //   * @param key
-  //   * @return A descriptor of the target.
-  //   */
-  //  public abstract FSODescriptorInterface resolveLinkTarget(String key);
-
-  //  /**
-  //   * Try and resolve the key for the given descriptor.
-  //   *
-  //   * <p>There is no guarantee that it works.
-  //   *
-  //   * @param fso
-  //   * @return true if the resolution did indeed work.
-  //   */
-  //  public abstract boolean resolveKey(FSODescriptorInterface fso);
-
   /** Return true iff an object with this key exists. */
   public abstract boolean exists(String key);
 
-  //  public abstract boolean resolve(FSODescriptorInterface fso);
+  /*
+   * fileIterator(String keyPrefix, Long lastModifiedAfter,
+   */
 }
diff --git a/src/main/java/org/caosdb/server/filesystem/LocalFileStorage.java b/src/main/java/org/caosdb/server/filesystem/LocalFileStorage.java
index 03b96d2f..b2666d26 100644
--- a/src/main/java/org/caosdb/server/filesystem/LocalFileStorage.java
+++ b/src/main/java/org/caosdb/server/filesystem/LocalFileStorage.java
@@ -629,34 +629,6 @@ public abstract class LocalFileStorage implements FileStorageInterface {
     }
     return null;
   }
-  //
-  //  @Override
-  //  public RealFSODescriptorInterface resolveLinkTarget(String key) {
-  //    File file = getFile(key);
-  //    if (isSymlink(file)) {
-  //      try {
-  //        FSODescriptor result = new LocalFSODescriptor(kkkk);
-  //        return result;
-  //      } catch (IOException e) {
-  //        throw new FileSystemException(
-  //            "Could not resolve the link target: " + file.getAbsolutePath());
-  //      }
-  //    } else {
-  //      throw new FileSystemException("Not a symlink: " + id + ":" + key);
-  //    }
-  //  }
-
-  //  @Override
-  //  public boolean resolveKey(FSODescriptorInterface fso) {
-  //    Path absolute = fso.getFile().toPath().toAbsolutePath();
-  //    if (absolute.startsWith(getRoot())) {
-  //      String key = getRoot().relativize(absolute).toString();
-  //      fso.setKey(key);
-  //      fso.setFileStorageId(id);
-  //      return true;
-  //    }
-  //    return false;
-  //  }
 
   @Override
   public boolean exists(String key) {
@@ -702,4 +674,67 @@ public abstract class LocalFileStorage implements FileStorageInterface {
       throw new RuntimeException(e);
     }
   }
+
+  //  @Override
+  //  public Iterator<String> execute(final String storage, final String location)
+  //      throws TransactionException {
+  //    File base;
+  //    try {
+  //      // TODO: move everything to GetFileIterator and refactor. Needs a listFiles
+  //      // Transaction
+  //      base = getFile(storage, location).getFile();
+  //    } catch (final Message e) {
+  //      throw new TransactionException(e);
+  //    }
+  //    return new FileNameIterator(base, location);
+  //  }
+  //
+  //  public static class FileNameIterator implements Iterator<String> {
+  //
+  //    private final File base;
+  //    private File[] files = null;
+  //    private FileNameIterator subfiles = null;
+  //    private int i = 0;
+  //    private final String rootPath;
+  //
+  //    public FileNameIterator(final File base, final String rootPath) {
+  //      this.rootPath = rootPath.length() == 0 || rootPath.endsWith("/") ? rootPath : rootPath +
+  // "/";
+  //      this.base = base;
+  //      this.files = this.base.listFiles();
+  //      Arrays.sort(this.files);
+  //    }
+  //
+  //    @Override
+  //    public boolean hasNext() {
+  //      return this.files.length > this.i;
+  //    }
+  //
+  //    @Override
+  //    public String next() {
+  //      if (this.subfiles != null) {
+  //        if (this.subfiles.hasNext()) {
+  //          return this.subfiles.next();
+  //        } else {
+  //          this.subfiles = null;
+  //        }
+  //      }
+  //      final File ret = this.files[this.i++];
+  //      if (ret.isDirectory()) {
+  //        this.subfiles = new FileNameIterator(ret, this.rootPath + ret.getName() + "/");
+  //        if (this.subfiles.hasNext()) {
+  //          return next();
+  //        } else {
+  //          return this.rootPath + ret.getName() + "/";
+  //        }
+  //      }
+  //      return this.rootPath + ret.getName();
+  //    }
+  //
+  //    @Override
+  //    public void remove() {
+  //      throw new UnsupportedOperationException();
+  //    }
+  //  }
+  // }
 }
diff --git a/src/main/java/org/caosdb/server/filesystem/StoreFile.java b/src/main/java/org/caosdb/server/filesystem/StoreFile.java
deleted file mode 100644
index b538c2e5..00000000
--- a/src/main/java/org/caosdb/server/filesystem/StoreFile.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package org.caosdb.server.filesystem;
-
-import org.caosdb.server.database.access.Access;
-import org.caosdb.server.database.backend.implementation.UnixFileSystem.FileSystemTransaction;
-import org.caosdb.server.database.backend.interfaces.StoreFileImpl;
-import org.caosdb.server.entity.Message;
-import org.caosdb.server.utils.Undoable;
-
-public class StoreFile extends FileSystemTransaction implements StoreFileImpl {
-
-  public StoreFile(Access access) {
-    super(access);
-  }
-
-  @Override
-  public Undoable store(VirtualFSODescriptorInterface file) throws Message {
-    RealFSODescriptorInterface twin = file.getTwin();
-    return FileSystem.getInstance().move(twin, file);
-  }
-}
diff --git a/src/main/java/org/caosdb/server/filesystem/consistency/AbstractConsistencyEvent.java b/src/main/java/org/caosdb/server/filesystem/consistency/AbstractConsistencyEvent.java
index 05b2bea6..fabedaf7 100644
--- a/src/main/java/org/caosdb/server/filesystem/consistency/AbstractConsistencyEvent.java
+++ b/src/main/java/org/caosdb/server/filesystem/consistency/AbstractConsistencyEvent.java
@@ -10,7 +10,6 @@ public class AbstractConsistencyEvent implements ConsistencyEvent {
   private String fileStorageId;
   private String key;
   private String type;
-  //  private ConsistencyEvent parent;
   private String uuid = null;
   private Long timestamp;
 
@@ -21,10 +20,6 @@ public class AbstractConsistencyEvent implements ConsistencyEvent {
     this.fileStorageId = fileStorageId;
     this.key = key;
   }
-  //
-  //  AbstractConsistencyEvent(String name, String fileStorageId, String key) {
-  //    this(name, null, fileStorageId, key);
-  //  }
 
   @Override
   public String getFileStorageId() {
diff --git a/src/main/java/org/caosdb/server/transaction/FileStorageConsistencyCheck.java b/src/main/java/org/caosdb/server/transaction/FileStorageConsistencyCheck.java
index 473dc8c8..df876fdc 100644
--- a/src/main/java/org/caosdb/server/transaction/FileStorageConsistencyCheck.java
+++ b/src/main/java/org/caosdb/server/transaction/FileStorageConsistencyCheck.java
@@ -80,10 +80,6 @@ public class FileStorageConsistencyCheck extends Thread
         this.ts = System.currentTimeMillis();
         while (iterator != null && iterator.hasNext()) {
           final String path = iterator.next();
-          // this prevents all thumbnails  from being checked.
-          if (path.contains(".thumbnails/")) {
-            continue;
-          }
 
           if (DatabaseAccessManager.whoHasReservedWriteAccess() != null) {
             // there is a thread waiting to write. pause this one and
-- 
GitLab