Interface UnitaryImporter<O>
- Type Parameters:
O
- The type of object to import
public interface UnitaryImporter<O>
Unitary importer of an abstract object into Ametys.
-
Method Summary
Modifier and TypeMethodDescriptionCreates the object with the given id and XML properties file.getPropertiesXml
(Path zipEntryPath) Gets the properties XML file from its ZIP pathTheImportReport
The name for the object to import in error logsretrieveId
(Document propertiesXml) Retrieves the id of the object to import from the XML fileunitaryImport
(Path zipArchivePath, Path zipEntryPath, Merger merger, Logger logger) Does the unitary import.default void
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 Details
-
objectNameForLogs
The name for the object to import in error logs- Returns:
- The name for the object to import in error logs
-
getPropertiesXml
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
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
TheImportReport
- Returns:
- The
ImportReport
-
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, 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.
-