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
__GSON
private ArchiverExtensionPoint
_archiverEP
protected Context
_context
The context(package private) static String
MANIFEST_FILENAME
static String
METADATA_PREFIX
The prefix path for exporting metadata contentstatic String
ROLE
Avalon 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)
void
contextualize(Context context)
void
export(File output)
Exports withArchiverExtensionPoint
mechanism into the givenFile
File
getArchiveFile(String name)
Gets the archive fileStream<String>
getArchiveFiles()
Gets the archive filesPath
getArchiveFolder()
Gets the folder containing all the managed archivesStream<PartialImport>
getPartialImports(String archiveName)
Gets the partial imports of the given archiveImportReport
importAll(File input, Merger merger)
Imports all data from the given ZIP archiveImportReport
partialImport(File input, Collection<String> partialImports, Merger merger)
Imports partial data from the given ZIP archivevoid
service(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:
service
in interfaceServiceable
- Throws:
ServiceException
-
contextualize
public void contextualize(Context context) throws ContextException
- Specified by:
contextualize
in 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 withArchiverExtensionPoint
mechanism 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
-
-