Class ArchiveHandler
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.archive.ArchiveHandler
-
- All Implemented Interfaces:
LogEnabled,Component,Contextualizable,Serviceable
public class ArchiveHandler extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Archive data on disk.
-
-
Field Summary
Fields Modifier and Type Field Description private static com.google.gson.Gson__GSONprivate ArchiverExtensionPoint_archiverEPprotected Context_contextThe context(package private) static StringMANIFEST_FILENAMEstatic StringMETADATA_PREFIXThe prefix path for exporting metadata contentstatic StringROLEAvalon role.
-
Constructor Summary
Constructors Constructor Description ArchiveHandler()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void_exportActualData(ZipOutputStream zos)private void_exportManifest(ZipOutputStream zos)private ImportReport_partialImport(String archiverId, Path zipPath, Collection<String> partialImports, Merger merger)private Stream<PartialImport>_partialImports(Path archive)private Stream<PartialImport>_partialImportsFromJson(Map<String,Object> manifestJson)private Stream<PartialImport>_partialImportsFromJsonAndArchiver(Map<String,Object> manifestJson, String archiverId)voidcontextualize(Context context)voidexport(File output)Exports withArchiverExtensionPointmechanism into the givenFileFilegetArchiveFile(String name)Gets the archive fileStream<String>getArchiveFiles()Gets the archive filesPathgetArchiveFolder()Gets the folder containing all the managed archivesStream<PartialImport>getPartialImports(String archiveName)Gets the partial imports of the given archiveImportReportimportAll(File input, Merger merger)Imports all data from the given ZIP archiveImportReportpartialImport(File input, Collection<String> partialImports, Merger merger)Imports partial data from the given ZIP archivevoidservice(ServiceManager manager)-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
METADATA_PREFIX
public static final String METADATA_PREFIX
The prefix path for exporting metadata content- See Also:
- Constant Field Values
-
MANIFEST_FILENAME
static final String MANIFEST_FILENAME
- See Also:
- Constant Field Values
-
__GSON
private static final com.google.gson.Gson __GSON
-
_archiverEP
private ArchiverExtensionPoint _archiverEP
-
-
Constructor Detail
-
ArchiveHandler
public ArchiveHandler()
-
-
Method Detail
-
service
public void service(ServiceManager manager) throws ServiceException
- Specified by:
servicein interfaceServiceable- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualizein interfaceContextualizable- Throws:
ContextException
-
getArchiveFolder
public Path getArchiveFolder()
Gets the folder containing all the managed archives- Returns:
- the folder containing all the managed archives
-
getArchiveFiles
public Stream<String> getArchiveFiles()
Gets the archive files- Returns:
- the archive files
-
getArchiveFile
public File getArchiveFile(String name)
Gets the archive file- Parameters:
name- The archive name- Returns:
- the archive file
-
getPartialImports
public Stream<PartialImport> getPartialImports(String archiveName) throws IOException
Gets the partial imports of the given archive- Parameters:
archiveName- The archive name- Returns:
- the partial imports
- Throws:
IOException- if an I/O error occured
-
_partialImports
private Stream<PartialImport> _partialImports(Path archive) throws IOException
- Throws:
IOException
-
_partialImportsFromJson
private Stream<PartialImport> _partialImportsFromJson(Map<String,Object> manifestJson)
-
_partialImportsFromJsonAndArchiver
private Stream<PartialImport> _partialImportsFromJsonAndArchiver(Map<String,Object> manifestJson, String archiverId)
-
export
public void export(File output) throws IOException
Exports withArchiverExtensionPointmechanism into the givenFile- Parameters:
output- The output ZIP file- Throws:
IOException- if an IO exception occured
-
_exportManifest
private void _exportManifest(ZipOutputStream zos) throws IOException
- Throws:
IOException
-
_exportActualData
private void _exportActualData(ZipOutputStream zos) throws IOException
- Throws:
IOException
-
_partialImport
private ImportReport _partialImport(String archiverId, Path zipPath, Collection<String> partialImports, Merger merger) throws IOException
- Throws:
IOException
-
importAll
public ImportReport importAll(File input, Merger merger) throws IOException
Imports all data from the given ZIP archive- Parameters:
input- the ZIP archivemerger- theMerger- Returns:
- The
ImportReport - Throws:
IOException- if an I/O error occurs
-
partialImport
public ImportReport partialImport(File input, Collection<String> partialImports, Merger merger) throws IOException
Imports partial data from the given ZIP archive- Parameters:
input- the ZIP archivepartialImports- the partial importsmerger- theMerger- Returns:
- The
ImportReport - Throws:
IOException- if an I/O error occurs
-
-