Class XmlPropertiesFileMetadataLoader
- java.lang.Object
-
- org.alfresco.repo.bulkimport.metadataloaders.XmlPropertiesFileMetadataLoader
-
- All Implemented Interfaces:
MetadataLoader
public final class XmlPropertiesFileMetadataLoader extends java.lang.ObjectMetadataLoader that loads metadata from an (optional) "shadow" properties file in XML format. This shadow properties file must have exactly the same name and extension as the file for whom it is storing metadata, but with the suffix ".metadata.properties.xml". So for example, if there is a file called "IMG_1967.jpg", the "shadow" metadata file for it would be called "IMG_1967.jpg.metadata.properties.xml". The metadata file itself follows the usual rules for Java properties XML files, with a property with the key "type" containing the qualified name of the content type to use for the file, a property with the key "aspects" containing a comma-delimited list of qualified names of the aspects to attach to the file, and then one Java property per metadata property, with the key being the Alfresco property QName and the value being the value of that property. For example (note escaping rules for namespace separator!):Notes:Metadata for IMG_1967.jpg cm:content cm:versionable, custom:myAspect This is the value of the cm:title field. This is the value of the cm:description field. workspace://SpacesStore/3da6c395-3a4b-4a57-836d-8e5 This is the value of the custom:myProperty field. 2001-01-01T12:00:00.000+01:00 - Java XML properties files fully support Unicode characters (unlike the
original properties file format), so use of this class is strongly
recommended over and
PropertiesFileMetadataLoader. - the metadata must conform to the type and aspect definitions configured in Alfresco (including mandatory fields, constraints and data types). Any violations will terminate the bulk import process.
- associations are not yet supported
- dates, times and date times must be stored in ISO8601 format (although note that Alfresco ignores timezone modifiers)
- Since:
- 4.0
- See Also:
MetadataLoader
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.alfresco.repo.bulkimport.MetadataLoader
MetadataLoader.Metadata
-
-
Field Summary
Fields Modifier and Type Field Description protected org.alfresco.service.cmr.dictionary.DictionaryServicedictionaryServiceprotected java.lang.StringmetadataFileExtensionprotected java.lang.StringmultiValuedSeparatorprotected org.alfresco.service.namespace.NamespaceServicenamespaceService-
Fields inherited from interface org.alfresco.repo.bulkimport.MetadataLoader
METADATA_SUFFIX
-
-
Constructor Summary
Constructors Constructor Description XmlPropertiesFileMetadataLoader(ServiceRegistry serviceRegistry)XmlPropertiesFileMetadataLoader(ServiceRegistry serviceRegistry, java.lang.String multiValuedSeparator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringgetMetadataFileExtension()voidloadMetadata(ImportableItem.ContentAndMetadata contentAndMetadata, MetadataLoader.Metadata metadata)Method that populates the type, aspects and properties to attach to a given file or space.protected java.util.Map<java.lang.String,java.io.Serializable>loadMetadataFromFile(java.nio.file.Path metadataFile)Method that actually loads the properties from the file.voidsetProtectedProperties(java.util.List<java.lang.String> protectedProperties)
-
-
-
Field Detail
-
namespaceService
protected final org.alfresco.service.namespace.NamespaceService namespaceService
-
dictionaryService
protected final org.alfresco.service.cmr.dictionary.DictionaryService dictionaryService
-
multiValuedSeparator
protected final java.lang.String multiValuedSeparator
-
metadataFileExtension
protected final java.lang.String metadataFileExtension
-
-
Constructor Detail
-
XmlPropertiesFileMetadataLoader
public XmlPropertiesFileMetadataLoader(ServiceRegistry serviceRegistry)
-
XmlPropertiesFileMetadataLoader
public XmlPropertiesFileMetadataLoader(ServiceRegistry serviceRegistry, java.lang.String multiValuedSeparator)
-
-
Method Detail
-
setProtectedProperties
public void setProtectedProperties(java.util.List<java.lang.String> protectedProperties)
-
loadMetadataFromFile
protected java.util.Map<java.lang.String,java.io.Serializable> loadMetadataFromFile(java.nio.file.Path metadataFile)
Method that actually loads the properties from the file.- Parameters:
metadataFile- The file to load the properties from (must not be null).- Returns:
- A new
Propertiesobject loaded from that file. - See Also:
AbstractMapBasedMetadataLoader#loadMetadataFromFile(java.io.File)
-
getMetadataFileExtension
public final java.lang.String getMetadataFileExtension()
- Specified by:
getMetadataFileExtensionin interfaceMetadataLoader- Returns:
- The extension for files used to store this metadata, minus the stop character (.) e.g. "properties", "xml", "json", etc.
- See Also:
MetadataLoader.getMetadataFileExtension()
-
loadMetadata
public final void loadMetadata(ImportableItem.ContentAndMetadata contentAndMetadata, MetadataLoader.Metadata metadata)
Description copied from interface:MetadataLoaderMethod that populates the type, aspects and properties to attach to a given file or space.- Specified by:
loadMetadatain interfaceMetadataLoader- Parameters:
contentAndMetadata- The contentAndMetadata from which to obtain the metadata (will not be null).metadata- The metadata object to populate (will not be null, and may already be partially populated).
-
-