93 lines
2.3 KiB
Java
93 lines
2.3 KiB
Java
package de.nbscloud.files.api;
|
|
|
|
import de.nbscloud.webcontainer.registry.App;
|
|
|
|
import java.nio.file.Path;
|
|
import java.time.LocalDateTime;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
|
|
public interface FilesService {
|
|
record ContentContainer(boolean directory, Path path, String name, long size,
|
|
LocalDateTime lastModified) {
|
|
}
|
|
|
|
class ContentTree {
|
|
private String name;
|
|
private boolean directory;
|
|
private String path;
|
|
private List<ContentTree> subTree = new ArrayList<>();
|
|
private ContentTree parent;
|
|
|
|
public String getName() {
|
|
return name;
|
|
}
|
|
|
|
public void setName(String name) {
|
|
this.name = name;
|
|
}
|
|
|
|
public boolean isDirectory() {
|
|
return directory;
|
|
}
|
|
|
|
public void setDirectory(boolean directory) {
|
|
this.directory = directory;
|
|
}
|
|
|
|
public String getPath() {
|
|
return path;
|
|
}
|
|
|
|
public void setPath(String path) {
|
|
this.path = path;
|
|
}
|
|
|
|
public List<ContentTree> getSubTree() {
|
|
return subTree;
|
|
}
|
|
|
|
public void setSubTree(List<ContentTree> subTree) {
|
|
this.subTree = subTree;
|
|
}
|
|
|
|
public boolean getHasSubTree() {
|
|
return !this.subTree.isEmpty();
|
|
}
|
|
|
|
public ContentTree getParent() {
|
|
return parent;
|
|
}
|
|
|
|
public void setParent(ContentTree parent) {
|
|
this.parent = parent;
|
|
}
|
|
}
|
|
|
|
void createAppDirectory(App app);
|
|
|
|
void createDirectory(App app, Path path);
|
|
|
|
void createFile(App app, Path path, byte[] content);
|
|
|
|
void overwriteFile(App app, Path path, byte[] content);
|
|
|
|
void delete(App app, Path path);
|
|
|
|
byte[] get(App app, Path path);
|
|
|
|
/**
|
|
* Paths in return list are always relative to the appDir. Non-recursive list.
|
|
*
|
|
* @param app to list the files for
|
|
* @param path in case of {@link Optional#EMPTY} the appDir is used as start dir. If not empty, path has to be relative
|
|
* to the appDir
|
|
*/
|
|
List<ContentContainer> list(App app, Optional<Path> path);
|
|
|
|
ContentTree getTree(App app, Optional<Path> path);
|
|
|
|
List<String> collectDirs(App app, Optional<Path> path);
|
|
}
|