Class ResourcesArchiverHelper
- java.lang.Object
-
- org.ametys.runtime.plugin.component.AbstractLogEnabled
-
- org.ametys.plugins.contentio.archive.ResourcesArchiverHelper
-
- All Implemented Interfaces:
LogEnabled
,Component
,Contextualizable
,Serviceable
public class ResourcesArchiverHelper extends AbstractLogEnabled implements Component, Serviceable, Contextualizable
Export a resources collection as individual files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private class
ResourcesArchiverHelper.Importer
private static interface
ResourcesArchiverHelper.ResourceMetadataSaxer
-
Field Summary
-
Constructor Summary
Constructors Constructor Description ResourcesArchiverHelper()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
_checkoutImported(List<JCRResource> importedResources)
private void
_exportChild(AmetysObject child, ZipOutputStream zos, String prefix)
private void
_exportCollectionMetadataEntry(ResourceCollection collection, ZipOutputStream zos, String prefix)
private void
_exportResourceMetadataEntry(Resource resource, ZipOutputStream zos, String prefix, String metadataFileNameSuffix, ResourcesArchiverHelper.ResourceMetadataSaxer metadataSaxer, String debugName)
private void
_saveImported(Node parentOfRoot)
private void
_saxDublinCoreMetadata(DublinCoreAwareAmetysObject dcObject, ContentHandler contentHandler)
private void
_saxIfNotNull(String name, String[] values, ContentHandler contentHandler)
private void
_saxIfNotNull(String name, String value, ContentHandler contentHandler)
private void
_saxIfNotNull(String name, UserIdentity value, ContentHandler contentHandler)
private void
_saxLocalDateIfNotNull(String name, Date value, ContentHandler contentHandler)
private void
_saxSystemMetadata(ResourceCollection collection, ContentHandler contentHandler)
private void
_saxSystemMetadata(Resource resource, ContentHandler contentHandler)
private void
_saxZonedDateTimeIfNotNull(String name, Date value, ContentHandler contentHandler)
void
contextualize(Context context)
void
exportCollection(ResourceCollection collection, ZipOutputStream zos, String prefix)
Exports aResourceCollection
as folders and files inside the ZIP archive.void
exportResource(Resource resource, ZipOutputStream zos, String prefix)
Exports aResource
as file inside the ZIP archive.ImportReport
importCollection(String commonPrefix, Node parentOfRootResources, Path zipPath, Merger merger)
Imports folders and files from the given ZIP archive and path, under the givenResourceCollection
void
service(ServiceManager manager)
-
Methods inherited from class org.ametys.runtime.plugin.component.AbstractLogEnabled
getLogger, setLogger
-
-
-
-
Field Detail
-
__PROPERTIES_METADATA_XML_FILE_NAME_SUFFIX
private static final String __PROPERTIES_METADATA_XML_FILE_NAME_SUFFIX
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_FILE_NAME_SUFFIX
private static final String __DC_METADATA_XML_FILE_NAME_SUFFIX
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_ROOT
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_ROOT
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_TITLE
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_TITLE
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_CREATOR
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_CREATOR
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_SUBJECT
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_SUBJECT
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_DESCRIPTION
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_DESCRIPTION
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_PUBLISHER
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_PUBLISHER
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_CONTRIBUTOR
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_CONTRIBUTOR
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_DATE
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_DATE
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_TYPE
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_TYPE
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_FORMAT
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_FORMAT
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_IDENTIFIER
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_IDENTIFIER
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_SOURCE
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_SOURCE
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_LANGUAGE
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_LANGUAGE
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_RELATION
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_RELATION
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_COVERAGE
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_COVERAGE
- See Also:
- Constant Field Values
-
__DC_METADATA_XML_EXPORT_TAG_NAME_RIGHTS
private static final String __DC_METADATA_XML_EXPORT_TAG_NAME_RIGHTS
- See Also:
- Constant Field Values
-
_jcrResourcesCollectionFactory
private JCRResourcesCollectionFactory _jcrResourcesCollectionFactory
-
_jcrResourceFactory
private JCRResourceFactory _jcrResourceFactory
-
_cocoonContext
private Context _cocoonContext
-
-
Constructor Detail
-
ResourcesArchiverHelper
public ResourcesArchiverHelper()
-
-
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
-
exportCollection
public void exportCollection(ResourceCollection collection, ZipOutputStream zos, String prefix) throws IOException
Exports aResourceCollection
as folders and files inside the ZIP archive.- Parameters:
collection
- the rootResourceCollection
zos
- the ZIP OutputStream.prefix
- the prefix for the ZIP archive.- Throws:
IOException
- if an error occurs while archiving
-
_exportCollectionMetadataEntry
private void _exportCollectionMetadataEntry(ResourceCollection collection, ZipOutputStream zos, String prefix) throws IOException
- Throws:
IOException
-
_exportChild
private void _exportChild(AmetysObject child, ZipOutputStream zos, String prefix) throws IOException
- Throws:
IOException
-
exportResource
public void exportResource(Resource resource, ZipOutputStream zos, String prefix) throws IOException
Exports aResource
as file inside the ZIP archive.- Parameters:
resource
- theResource
.zos
- the ZIP OutputStream.prefix
- the prefix for the ZIP archive.- Throws:
IOException
- if an error occurs while archiving
-
_exportResourceMetadataEntry
private void _exportResourceMetadataEntry(Resource resource, ZipOutputStream zos, String prefix, String metadataFileNameSuffix, ResourcesArchiverHelper.ResourceMetadataSaxer metadataSaxer, String debugName) throws IOException
- Throws:
IOException
-
_saxDublinCoreMetadata
private void _saxDublinCoreMetadata(DublinCoreAwareAmetysObject dcObject, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxSystemMetadata
private void _saxSystemMetadata(Resource resource, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxSystemMetadata
private void _saxSystemMetadata(ResourceCollection collection, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxIfNotNull
private void _saxIfNotNull(String name, String value, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxIfNotNull
private void _saxIfNotNull(String name, UserIdentity value, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxIfNotNull
private void _saxIfNotNull(String name, String[] values, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxLocalDateIfNotNull
private void _saxLocalDateIfNotNull(String name, Date value, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
_saxZonedDateTimeIfNotNull
private void _saxZonedDateTimeIfNotNull(String name, Date value, ContentHandler contentHandler) throws SAXException
- Throws:
SAXException
-
importCollection
public ImportReport importCollection(String commonPrefix, Node parentOfRootResources, Path zipPath, Merger merger) throws IOException
Imports folders and files from the given ZIP archive and path, under the givenResourceCollection
- Parameters:
commonPrefix
- The common prefix in the ZIP archiveparentOfRootResources
- the parent of the rootResourceCollection
(the root will also be created)zipPath
- the input zip pathmerger
- TheMerger
- Returns:
- The
ImportReport
- Throws:
IOException
- if an error occurs while importing archive
-
_saveImported
private void _saveImported(Node parentOfRoot)
-
_checkoutImported
private void _checkoutImported(List<JCRResource> importedResources)
-
-