Class PropertiesFileMetadataLoader
java.lang.Object
org.alfresco.repo.bulkimport.metadataloaders.PropertiesFileMetadataLoader
- All Implemented Interfaces:
MetadataLoader
MetadataLoader that loads metadata from an (optional) "shadow" properties file. 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". So for example, if there is a file called "IMG_1967.jpg", the "shadow" properties metadata file for it would be called "IMG_1967.jpg.metadata.properties".
The metadata file itself follows the usual rules for Java properties 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!):
type=cm:content
aspects=cm:versionable, custom:myAspect
cm\:title=This is the value of the cm:title field.
cm\:description=This is the value of the cm:description field.
cm\:taggable=workspace://SpacesStore/3da6c395-3a4b-4a57-836d-8e5
custom\:myProperty=This is the value of the custom:myProperty field.
custom\:aDateProperty=2001-01-01T12:00:00.000+01:00
Notes:
- Java properties files do not support Unicode characters - all values are loaded assuming an ISO-8859-1 character set. For Unicode metadata, you should use
XmlPropertiesFileMetadataLoaderinstead. - 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:
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.alfresco.repo.bulkimport.MetadataLoader
MetadataLoader.Metadata -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final DictionaryServiceprotected final Stringprotected final Stringprotected final NamespaceServiceFields inherited from interface org.alfresco.repo.bulkimport.MetadataLoader
METADATA_SUFFIX -
Constructor Summary
ConstructorsConstructorDescriptionPropertiesFileMetadataLoader(ServiceRegistry serviceRegistry) PropertiesFileMetadataLoader(ServiceRegistry serviceRegistry, String multiValuedSeparator) -
Method Summary
Modifier and TypeMethodDescriptionfinal Stringfinal voidloadMetadata(ImportableItem.ContentAndMetadata contentAndMetadata, MetadataLoader.Metadata metadata) Method that populates the type, aspects and properties to attach to a given file or space.protected Map<String,Serializable> loadMetadataFromFile(Path metadataFile) Method that actually loads the properties from the file.
-
Field Details
-
namespaceService
-
dictionaryService
-
multiValuedSeparator
-
metadataFileExtension
-
-
Constructor Details
-
PropertiesFileMetadataLoader
-
PropertiesFileMetadataLoader
-
-
Method Details
-
loadMetadataFromFile
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:
-
org.alfresco.repo.bulkimport.metadataloaders.AbstractMapBasedMetadataLoader#loadMetadataFromFile(java.io.File)
-
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:
-
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).
-