com.crabshue.commons.archive.ArchiveService Maven / Gradle / Ivy
package com.crabshue.commons.archive;
import java.io.File;
import java.io.InputStream;
import java.util.Collection;
import com.crabshue.commons.exceptions.ApplicationException;
/**
* Generic archive service for archivable entities.
*
* @param an {@link Archivable} archivable
*/
public interface ArchiveService {
/**
* Provide the root of the archive.
*
* @return the root of the archive.
*/
String getArchiveRootPath();
/**
* Compute the path for the archive folder associated with an archivable.
*
* @param archivable the archivable.
* @return the path to the archive folder.
*/
String getArchiveFolderPath(T archivable);
/**
* List files (recursively) in the archive folder of an archivable.
*
* @param archivable the archivable
* @return the list of files in the archive folder of the archivable.
*/
Collection listFilesInArchive(T archivable);
/**
* Retrieve a file with a given name in the archive folder for an archivable.
*
* @param archivable the archivable
* @param filename the filename
* @return the retrieved file
* @throws ApplicationException if number of files retrieved with the name is different of 1
*/
File retrieveUniqueFileInArchive(T archivable, String filename);
/**
* Delete the archive folder for an archivable.
*
* @param archivable the archivable
*/
void deleteArchiveFolder(T archivable);
/**
* Delete the content of an archive folder.
*
* @param archivable the archivable.
*/
void cleanArchiveFolder(T archivable);
/**
* Delete the content of an archive root.
*/
void cleanArchiveRoot();
/**
* Store a file in archive for an archivable.
*
* @param archivable the archivable
* @param file file the file
*/
void storeInArchive(T archivable, File file);
/**
* Store an input stream for an archivable.
*
* @param archivable the archivable.
* @param filename the file name in the archive.
* @param inputStream the input stream.
*/
void storeInArchive(T archivable, String filename, InputStream inputStream);
/**
* Store the content of a folder for an archivable.
*
* @param archivable the archivable.
* @param folder the folder to store.
*/
void storeFolderContentInArchive(T archivable, File folder);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy