Class Archivers
java.lang.Object
org.ametys.plugins.contentio.archive.Archivers
Convenient methods for
Archiver API implementations-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classException indicating an Ametys Object cannot be imported -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidexportAcl(javax.jcr.Node node, ZipOutputStream zos, String path) Export ACL sub-nodestatic voidexportBinaries(ModelAwareDataHolder dataHolder, ZipOutputStream zos, String path) Export the given data holder's binariesstatic voidexportFiles(ModelAwareDataHolder dataHolder, ZipOutputStream zos, String path) Export the given data holder's filesstatic voidexportRichTexts(ModelAwareDataHolder dataHolder, ZipOutputStream zos, String path) Export the attachments of the given data holder's rich textsstatic StringgetFolderPathFromDataPath(String dataPath) Retrieves a folder path from a data path.static StringgetHashedPath(String name) Computes a hashed path from an object name.static SAXTransformerFactoryGets aSAXTransformerFactorystatic voidImport ACL sub-nodestatic TransformerHandlerGet a TransformerHandler object that can process SAXContentHandler events into a Resultstatic javax.jcr.NodereplaceNodeWithDesiredUuid(javax.jcr.Node srcNode, String uuid) Replace the given JCR Node by a copy of it with the given UUID.static voidsetStandardOutputProperties(TransformerHandler transformerHandler) Sets standard output properties to the transformer of the given handler, such as encoding and indentation.static voidunitarySave(javax.jcr.Node ametysObjectNode, Logger logger) Save the pending changes brought to this node associated to anAmetysObject
If the save failed, it is logged in ERROR level and the changes are discarded.static StringxpathEvalNonEmpty(String xPath, Node domNode) Evaluates a non-empty XPath query.
-
Field Details
-
WARN_MESSAGE_ROOT_HAS_PENDING_CHANGES
The warning message for a root ofArchiverwhich stil has pending change while we do a unitary save on every imported object.- See Also:
-
-
Method Details
-
getSaxTransformerFactory
Gets aSAXTransformerFactory- Returns:
- a
SAXTransformerFactory
-
newTransformerHandler
Get a TransformerHandler object that can process SAXContentHandler events into a Result- Returns:
- A non-null reference to a TransformerHandler, that maybe used as a ContentHandler for SAX parse events.
- Throws:
TransformerConfigurationException- If for some reason theTransformerHandler cannot be created.
-
setStandardOutputProperties
Sets standard output properties to the transformer of the given handler, such as encoding and indentation.- Parameters:
transformerHandler- The transformer handler
-
getHashedPath
Computes a hashed path from an object name.- Parameters:
name- the object name.- Returns:
- a hashed path.
-
exportAcl
public static void exportAcl(javax.jcr.Node node, ZipOutputStream zos, String path) throws javax.jcr.RepositoryException, IOException Export ACL sub-node- Parameters:
node- The JCR nodezos- the ZIP OutputStream.path- the zip entry path- Throws:
javax.jcr.RepositoryException- if an error occursIOException- if an I/O error occurs
-
importAcl
public static void importAcl(javax.jcr.Node node, Path zipPath, Merger merger, String zipEntryPath, Logger logger) throws javax.jcr.RepositoryException, IOException Import ACL sub-node- Parameters:
node- The JCR nodezipPath- the input zip pathmerger- TheMergerzipEntryPath- the zip entry pathlogger- The logger- Throws:
javax.jcr.RepositoryException- if an error occursIOException- if an I/O error occurs
-
xpathEvalNonEmpty
public static String xpathEvalNonEmpty(String xPath, Node domNode) throws Archivers.AmetysObjectNotImportedException, TransformerException Evaluates a non-empty XPath query. If the result is empty, anArchivers.AmetysObjectNotImportedExceptionis thrown.- Parameters:
xPath- The XPath querydomNode- The DOM node- Returns:
- The evaluation as String
- Throws:
Archivers.AmetysObjectNotImportedException- If the result is emptyTransformerException- if an evaluation error occured
-
replaceNodeWithDesiredUuid
public static javax.jcr.Node replaceNodeWithDesiredUuid(javax.jcr.Node srcNode, String uuid) throws javax.jcr.RepositoryException Replace the given JCR Node by a copy of it with the given UUID. The source JCR Node is removed.- Parameters:
srcNode- The source JCR Nodeuuid- The desired UUID- Returns:
- The JCR Node with the desired UUID
- Throws:
javax.jcr.RepositoryException- if an error occurs
-
unitarySave
public static void unitarySave(javax.jcr.Node ametysObjectNode, Logger logger) throws Archivers.AmetysObjectNotImportedException, ImportGlobalFailException Save the pending changes brought to this node associated to anAmetysObject
If the save failed, it is logged in ERROR level and the changes are discarded.- Parameters:
ametysObjectNode- The nodelogger- The logger- Throws:
Archivers.AmetysObjectNotImportedException- If the save failedImportGlobalFailException- If a severe error occured and the global import process must be stopped
-
exportRichTexts
public static void exportRichTexts(ModelAwareDataHolder dataHolder, ZipOutputStream zos, String path) throws IOException Export the attachments of the given data holder's rich texts- Parameters:
dataHolder- The data holderzos- TheZipOutputStreamwhere to export the attachmentspath- The path of the folder used to export the attachments- Throws:
IOException- if an error occurs while exporting the attachments
-
exportBinaries
public static void exportBinaries(ModelAwareDataHolder dataHolder, ZipOutputStream zos, String path) throws IOException Export the given data holder's binaries- Parameters:
dataHolder- The data holderzos- TheZipOutputStreamwhere to export the binariespath- The path of the folder used to export the binaries- Throws:
IOException- if an error occurs while exporting the binaries
-
exportFiles
public static void exportFiles(ModelAwareDataHolder dataHolder, ZipOutputStream zos, String path) throws IOException Export the given data holder's files- Parameters:
dataHolder- The data holderzos- TheZipOutputStreamwhere to export the filespath- The path of the folder used to export the files- Throws:
IOException- if an error occurs while exporting the files
-
getFolderPathFromDataPath
Retrieves a folder path from a data path. Replaces all repeater entries like '[x]', to a folder with the position ('/x')- Parameters:
dataPath- the data path- Returns:
- the folder path
-