onNewFile(@NotNull FURI fileURI, @NotNull FTYPE fileType);
-
- /**
- * Called when the mirror notifies you details about a file.
- *
- * {@link FileSource#onNewFile(FURI, FTYPE)} must have been already called
- */
- Mono onFile(@NotNull FURI fileURI, @NotNull FileSourceAvailability fileAvailability, long totalSize);
-
- /**
- * Called when the mirror notifies you the bytes of a part of a file.
- *
- * {@link FileSource#onNewFile(FURI, FTYPE)} and {@link FileSource#onFile(FURI, FileSourceAvailability, long)} must
- * have been already called
- */
- Mono onFilePiece(@NotNull FURI fileURI, long offset, long size, @NotNull ByteBuffer piece);
-}
diff --git a/src/main/lombok/org/warp/filesponge/api/FileStorage.java b/src/main/lombok/org/warp/filesponge/api/FileStorage.java
deleted file mode 100644
index 799dd94..0000000
--- a/src/main/lombok/org/warp/filesponge/api/FileStorage.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.api;
-
-import java.nio.ByteBuffer;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-import org.warp.filesponge.value.FileType;
-import org.warp.filesponge.value.FileURI;
-import org.warp.filesponge.value.MirrorURI;
-import reactor.core.publisher.Mono;
-
-public interface FileStorage {
-
- Mono newFile(@NotNull FURI fileURI, @NotNull FTYPE fileType);
-
- /**
- * Read file data.
- * Fails if not all the file data is available.
- * @param fileURI File URI
- * @return read-only file data
- * @throws java.util.NoSuchElementException if file is not existing, or some requested data is missing
- */
- Mono readFileData(@NotNull FURI fileURI);
-
- /**
- * Read a part of file data.
- * Fails if not all the requested file data is available.
- * @param fileURI File URI
- * @param offset offset of the current data segment
- * @param size current data segment size
- * @return read-only file data part
- * @throws java.util.NoSuchElementException if file is not existing, or some requested data is missing
- * @throws org.warp.commonutils.error.IndexOutOfBoundsException if requested offset or size is not valid
- */
- Mono readFileDataPart(@NotNull FURI fileURI, long offset, long size);
-
- /**
- * Set a part of file data.
- * If file size is 0, the file will be deleted.
- * @param fileURI File URI
- * @param offset offset of the current data segment
- * @param size current data segment size
- * @param bytes data segment, can be null if totalSize is 0
- * @param totalSize total file size
- * @return nothing
- */
- Mono setFileData(@NotNull FURI fileURI, long offset, long size, @Nullable ByteBuffer bytes, long totalSize);
-
- Mono hasAllData(@NotNull FURI fileURI);
-
- /**
- * Delete a file
- * @param fileURI File URI
- * @return nothing
- */
- default Mono deleteFile(@NotNull FURI fileURI) {
- return setFileData(fileURI, 0, 0, null, 0);
- }
-}
diff --git a/src/main/lombok/org/warp/filesponge/extra/api/FileURITranslator.java b/src/main/lombok/org/warp/filesponge/extra/api/FileURITranslator.java
deleted file mode 100644
index 932a7f5..0000000
--- a/src/main/lombok/org/warp/filesponge/extra/api/FileURITranslator.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.extra.api;
-
-import java.util.Optional;
-import org.warp.filesponge.value.AlreadyAssignedException;
-import org.warp.filesponge.value.FileURI;
-
-/**
- * Translate File URIs to "fileId" and back
- */
-public interface FileURITranslator {
-
- Optional getURI(FID fileId);
-
- Optional getFileId(FURI fileURI);
-
- /**
- * @throws AlreadyAssignedException Throw if the uri has another fileId assigned
- */
- void setFileId(FURI fileURI, FID fileId) throws AlreadyAssignedException;
-
- Optional delete(FID fileId);
-
- Optional delete(FURI fileURI);
-
- void clear();
-}
diff --git a/src/main/lombok/org/warp/filesponge/extra/api/URIObfuscator.java b/src/main/lombok/org/warp/filesponge/extra/api/URIObfuscator.java
deleted file mode 100644
index e7d80a2..0000000
--- a/src/main/lombok/org/warp/filesponge/extra/api/URIObfuscator.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.extra.api;
-
-import org.warp.filesponge.value.FileURI;
-
-/**
- * Create an unique "fileId" for each File URI
- */
-public interface URIObfuscator {
-
- FURI deobfuscateFileId(FID fileId);
-
- void getFileId(FURI fileURI);
-
- void setURIValue(FURI fileURI, FID fileId);
-
- FURI delete(FID fileId);
-
- FID delete(FURI fileURI);
-
- void clear();
-}
diff --git a/src/main/lombok/org/warp/filesponge/extra/package-info.java b/src/main/lombok/org/warp/filesponge/extra/package-info.java
deleted file mode 100644
index 5769ec9..0000000
--- a/src/main/lombok/org/warp/filesponge/extra/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-/**
- * Extra functionalities and utilities for FileSponge
- */
-package org.warp.filesponge.extra;
\ No newline at end of file
diff --git a/src/main/lombok/org/warp/filesponge/reactor/AsyncSet.java b/src/main/lombok/org/warp/filesponge/reactor/AsyncSet.java
deleted file mode 100644
index ab9415c..0000000
--- a/src/main/lombok/org/warp/filesponge/reactor/AsyncSet.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2021 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.reactor;
-
-import java.util.Set;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-/**
- * Asynchronous set
- * @param value type
- */
-public interface AsyncSet {
-
- /**
- * Clear the set
- *
- * @return void
- */
- Mono clear();
-
- /**
- * Add element to the set
- *
- * @param value value to add
- * @return true if added, false if it's already present. Can't be empty.
- */
- Mono add(T value);
-
- /**
- * Remove element from the set
- *
- * @param value value to remove
- * @return true if removed, false if it's not present. Can't be empty.
- */
- Mono remove(T value);
-
- /**
- * Find if element is present in the set
- *
- * @param value value to find
- * @return true if found, false if not. Can't be empty.
- */
- Mono contains(T value);
-
- /**
- * Get the set size
- *
- * @return set size, from 0 to {@value Integer#MAX_VALUE}. Can't be empty.
- */
- Mono size();
-
- /**
- * Get all values
- * @return values, in a flux. Can be empty.
- */
- Flux toFlux();
-
- /**
- * Get all values
- * @return values, in a set. Can't be empty.
- */
- Mono> toSet();
-}
diff --git a/src/main/lombok/org/warp/filesponge/reactor/ConcurrentAsyncSet.java b/src/main/lombok/org/warp/filesponge/reactor/ConcurrentAsyncSet.java
deleted file mode 100644
index 2273916..0000000
--- a/src/main/lombok/org/warp/filesponge/reactor/ConcurrentAsyncSet.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2021 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.reactor;
-
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentHashMap.KeySetView;
-import lombok.EqualsAndHashCode;
-import org.warp.commonutils.concurrency.atomicity.Atomic;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-@Atomic
-@EqualsAndHashCode
-public class ConcurrentAsyncSet implements AsyncSet {
-
- private final KeySetView set;
-
- public ConcurrentAsyncSet() {
- this.set = ConcurrentHashMap.newKeySet();
- }
-
- @Override
- public Mono clear() {
- return Mono.fromCallable(() -> {
- set.clear();
- return null;
- });
- }
-
- @Override
- public Mono add(T value) {
- return Mono.fromCallable(() -> set.add(value));
- }
-
- @Override
- public Mono remove(T value) {
- return Mono.fromCallable(() -> set.remove(value));
- }
-
- @Override
- public Mono contains(T value) {
- return Mono.fromCallable(() -> set.contains(value));
- }
-
- @Override
- public Mono size() {
- return Mono.fromCallable(set::size);
- }
-
- @Override
- public Flux toFlux() {
- return Flux.fromStream(set::stream);
- }
-
- @Override
- public Mono> toSet() {
- return Mono.fromCallable(() -> Set.copyOf(set));
- }
-
- @Override
- public String toString() {
- return set.toString();
- }
-}
diff --git a/src/main/lombok/org/warp/filesponge/reactor/HashAsyncSet.java b/src/main/lombok/org/warp/filesponge/reactor/HashAsyncSet.java
deleted file mode 100644
index f228456..0000000
--- a/src/main/lombok/org/warp/filesponge/reactor/HashAsyncSet.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2021 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.reactor;
-
-import java.util.HashSet;
-import java.util.Set;
-import lombok.EqualsAndHashCode;
-import org.warp.commonutils.concurrency.atomicity.NotAtomic;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-
-@NotAtomic
-@EqualsAndHashCode
-public class HashAsyncSet implements AsyncSet {
-
- private final HashSet set;
-
- public HashAsyncSet() {
- this.set = new HashSet<>();
- }
-
- public HashAsyncSet(HashSet set) {
- this.set = set;
- }
-
- @Override
- public Mono clear() {
- return Mono.fromCallable(() -> {
- set.clear();
- return null;
- });
- }
-
- @Override
- public Mono add(T value) {
- return Mono.fromCallable(() -> set.add(value));
- }
-
- @Override
- public Mono remove(T value) {
- return Mono.fromCallable(() -> set.remove(value));
- }
-
- @Override
- public Mono contains(T value) {
- return Mono.fromCallable(() -> set.contains(value));
- }
-
- @Override
- public Mono size() {
- return Mono.fromCallable(set::size);
- }
-
- @Override
- public Flux toFlux() {
- return Flux.fromStream(set::stream);
- }
-
- @Override
- public Mono> toSet() {
- return Mono.fromCallable(() -> Set.copyOf(set));
- }
-
- @Override
- public String toString() {
- return set.toString();
- }
-
- public SynchronizedHashAsyncSet synchronize() {
- return new SynchronizedHashAsyncSet<>(this);
- }
-}
diff --git a/src/main/lombok/org/warp/filesponge/reactor/SynchronizedHashAsyncSet.java b/src/main/lombok/org/warp/filesponge/reactor/SynchronizedHashAsyncSet.java
deleted file mode 100644
index 7eb44af..0000000
--- a/src/main/lombok/org/warp/filesponge/reactor/SynchronizedHashAsyncSet.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2021 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.reactor;
-
-import java.util.Set;
-import lombok.EqualsAndHashCode;
-import org.warp.commonutils.concurrency.atomicity.NotAtomic;
-import reactor.core.publisher.Flux;
-import reactor.core.publisher.Mono;
-import reactor.core.scheduler.Scheduler;
-import reactor.core.scheduler.Schedulers;
-
-@EqualsAndHashCode
-@NotAtomic
-public class SynchronizedHashAsyncSet implements AsyncSet {
-
- private transient final Scheduler scheduler = Schedulers.single();
- private final HashAsyncSet set;
-
- public SynchronizedHashAsyncSet() {
- this.set = new HashAsyncSet<>();
- }
-
- public SynchronizedHashAsyncSet(HashAsyncSet set) {
- this.set = set;
- }
-
- @Override
- public Mono clear() {
- return set.clear().subscribeOn(scheduler);
- }
-
- @Override
- public Mono add(T value) {
- return set.add(value).subscribeOn(scheduler);
- }
-
- @Override
- public Mono remove(T value) {
- return set.remove(value).subscribeOn(scheduler);
- }
-
- @Override
- public Mono contains(T value) {
- return set.contains(value).subscribeOn(scheduler);
- }
-
- @Override
- public Mono size() {
- return set.size().subscribeOn(scheduler);
- }
-
- @Override
- public Flux toFlux() {
- return set.toFlux().subscribeOn(scheduler);
- }
-
- @Override
- public Mono> toSet() {
- return set.toSet().subscribeOn(scheduler);
- }
-
- @Override
- public String toString() {
- return set.toString();
- }
-}
diff --git a/src/main/lombok/org/warp/filesponge/value/FileStatus.java b/src/main/lombok/org/warp/filesponge/value/FileStatus.java
deleted file mode 100644
index 28027ef..0000000
--- a/src/main/lombok/org/warp/filesponge/value/FileStatus.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.value;
-
-import java.util.Optional;
-import lombok.Value;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
-
-@Value
-public class FileStatus {
- @NotNull FileAvailability availability;
- @NotNull FileDataAvailability dataAvailability;
- @Nullable Integer totalSize;
- @Nullable Integer downloadedSize;
-
- public Optional getTotalSize() {
- return Optional.ofNullable(totalSize);
- }
-
- public Optional getDownloadedSize() {
- return Optional.ofNullable(downloadedSize);
- }
-}
diff --git a/src/main/lombok/org/warp/filesponge/value/FileURI.java b/src/main/lombok/org/warp/filesponge/value/FileURI.java
deleted file mode 100644
index 80ebb50..0000000
--- a/src/main/lombok/org/warp/filesponge/value/FileURI.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.value;
-
-public interface FileURI {}
diff --git a/src/main/lombok/org/warp/filesponge/value/MirrorURI.java b/src/main/lombok/org/warp/filesponge/value/MirrorURI.java
deleted file mode 100644
index 288ee5c..0000000
--- a/src/main/lombok/org/warp/filesponge/value/MirrorURI.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
- * FileSponge
- * Copyright (C) 2020 Andrea Cavalli
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU 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 General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program. If not, see .
- */
-
-package org.warp.filesponge.value;
-
-public interface MirrorURI {}