Interface UnitaryImporter<O>
-
- Type Parameters:
O
- The type of object to import
- All Known Implementing Classes:
ContentsArchiverHelper.Importer.UnitaryContentImporter
,ResourcesArchiverHelper.Importer.UnitaryCollectionImporter
,ResourcesArchiverHelper.Importer.UnitaryResourceImporter
,SiteImporter.UnitarySiteImporter
,SitemapImporter.UnitaryPageImporter
,SitemapImporter.UnitarySitemapImporter
public interface UnitaryImporter<O>
Unitary importer of an abstract object into Ametys.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description O
create(Path zipEntryPath, String id, Document propertiesXml)
Creates the object with the given id and XML properties file.Document
getPropertiesXml(Path zipEntryPath)
Gets the properties XML file from its ZIP pathImportReport
getReport()
TheImportReport
String
objectNameForLogs()
The name for the object to import in error logsString
retrieveId(Document propertiesXml)
Retrieves the id of the object to import from the XML filedefault Optional<O>
unitaryImport(Path zipArchivePath, Path zipEntryPath, Merger merger, org.slf4j.Logger logger)
Does the unitary import.default void
unitaryImportFinalize()
The optional process to do in a `finally` block inunitaryImport(java.nio.file.Path, java.nio.file.Path, org.ametys.plugins.contentio.archive.Merger, org.slf4j.Logger)
-
-
-
Method Detail
-
objectNameForLogs
String objectNameForLogs()
The name for the object to import in error logs- Returns:
- The name for the object to import in error logs
-
getPropertiesXml
Document getPropertiesXml(Path zipEntryPath) throws Exception
Gets the properties XML file from its ZIP path- Parameters:
zipEntryPath
- The ZIP entry path of the XML file- Returns:
- The properties XML file
- Throws:
Exception
- if an error occurs
-
retrieveId
String retrieveId(Document propertiesXml) throws Exception
Retrieves the id of the object to import from the XML file- Parameters:
propertiesXml
- The properties XML file- Returns:
- The id of the object to import
- Throws:
Exception
- if an error occurs
-
create
O create(Path zipEntryPath, String id, Document propertiesXml) throws Archivers.AmetysObjectNotImportedException, ImportGlobalFailException, Exception
Creates the object with the given id and XML properties file.
Note that the implementation must create the object with the given id, but it can also create sub-objects for this unitary object (for instance a Resource as an attachment for a Content, etc.).- Parameters:
zipEntryPath
- The ZIP entry path of the XML fileid
- The id of the object to importpropertiesXml
- The properties XML file- Returns:
- The created object
- Throws:
Archivers.AmetysObjectNotImportedException
- If the object was not imported due to an exception (for instance an attribute is missing in the XML file). Then the object is ignored and the import will continue to the next object.ImportGlobalFailException
- If the global import process must stop due to any fatal exception.Exception
- if another unexpected error occurs
-
getReport
ImportReport getReport()
TheImportReport
- Returns:
- The
ImportReport
-
unitaryImportFinalize
default void unitaryImportFinalize()
The optional process to do in a `finally` block inunitaryImport(java.nio.file.Path, java.nio.file.Path, org.ametys.plugins.contentio.archive.Merger, org.slf4j.Logger)
-
unitaryImport
default Optional<O> unitaryImport(Path zipArchivePath, Path zipEntryPath, Merger merger, org.slf4j.Logger logger) throws ImportGlobalFailException
Does the unitary import.
Do not override the default behavior.- Parameters:
zipArchivePath
- The ZIP filezipEntryPath
- The ZIP entry path of the XML filemerger
- TheMerger
logger
- The logger- Returns:
- The optionally created object
- Throws:
ImportGlobalFailException
- If the global import process must stop due to any fatal exception.
-
-