Add common utils and uri obfuscator
This commit is contained in:
parent
91b33a2baa
commit
90277e1c51
5
pom.xml
5
pom.xml
@ -52,6 +52,11 @@
|
|||||||
<version>RELEASE</version>
|
<version>RELEASE</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.warp</groupId>
|
||||||
|
<artifactId>common-utils</artifactId>
|
||||||
|
<version>1.0.7</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
module org.warp.filesponge {
|
module org.warp.filesponge {
|
||||||
exports org.warp.filesponge.api;
|
exports org.warp.filesponge.api;
|
||||||
|
exports org.warp.filesponge.extra.api;
|
||||||
exports org.warp.filesponge.value;
|
exports org.warp.filesponge.value;
|
||||||
requires lombok;
|
requires lombok;
|
||||||
requires org.jetbrains.annotations;
|
requires org.jetbrains.annotations;
|
||||||
|
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.warp.filesponge.extra.api;
|
||||||
|
|
||||||
|
public class AlreadyAssignedException extends Exception {
|
||||||
|
|
||||||
|
public AlreadyAssignedException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlreadyAssignedException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlreadyAssignedException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AlreadyAssignedException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.warp.filesponge.extra.api;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.OptionalLong;
|
||||||
|
import org.warp.filesponge.value.FileURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Translate File URIs to "fileId" and back
|
||||||
|
*/
|
||||||
|
public interface FileURITranslator {
|
||||||
|
|
||||||
|
Optional<FileURI> getURI(long fileId);
|
||||||
|
|
||||||
|
OptionalLong getFileId(FileURI fileURI);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws AlreadyAssignedException Throw if the uri has another fileId assigned
|
||||||
|
*/
|
||||||
|
void setFileId(FileURI fileURI, long fileId) throws AlreadyAssignedException;
|
||||||
|
|
||||||
|
Optional<FileURI> delete(long fileId);
|
||||||
|
|
||||||
|
OptionalLong delete(FileURI fileURI);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.warp.filesponge.extra.api;
|
||||||
|
|
||||||
|
import org.warp.filesponge.value.FileURI;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create an unique "fileId" for each File URI
|
||||||
|
*/
|
||||||
|
public interface URIObfuscator {
|
||||||
|
|
||||||
|
FileURI deobfuscateFileId(long fileId);
|
||||||
|
|
||||||
|
void getFileId(FileURI fileURI);
|
||||||
|
|
||||||
|
void setURIValue(FileURI fileURI, long fileId);
|
||||||
|
|
||||||
|
FileURI delete(long fileId);
|
||||||
|
|
||||||
|
long delete(FileURI fileURI);
|
||||||
|
|
||||||
|
void clear();
|
||||||
|
}
|
22
src/main/lombok/org/warp/filesponge/extra/package-info.java
Normal file
22
src/main/lombok/org/warp/filesponge/extra/package-info.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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 <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra functionalities and utilities for FileSponge
|
||||||
|
*/
|
||||||
|
package org.warp.filesponge.extra;
|
Loading…
Reference in New Issue
Block a user