Add common utils and uri obfuscator

This commit is contained in:
Andrea Cavalli 2020-09-25 21:22:34 +02:00
parent 91b33a2baa
commit 90277e1c51
6 changed files with 149 additions and 0 deletions

View File

@ -52,6 +52,11 @@
<version>RELEASE</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.warp</groupId>
<artifactId>common-utils</artifactId>
<version>1.0.7</version>
</dependency>
</dependencies>
<build>

View File

@ -1,5 +1,6 @@
module org.warp.filesponge {
exports org.warp.filesponge.api;
exports org.warp.filesponge.extra.api;
exports org.warp.filesponge.value;
requires lombok;
requires org.jetbrains.annotations;

View File

@ -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);
}
}

View File

@ -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();
}

View File

@ -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();
}

View 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;