Class PropertiesFileMetadataLoader

java.lang.Object
org.alfresco.repo.bulkimport.metadataloaders.PropertiesFileMetadataLoader
All Implemented Interfaces:
MetadataLoader

public final class PropertiesFileMetadataLoader extends Object
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 XmlPropertiesFileMetadataLoader instead.
  • 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:
  • Field Details

    • namespaceService

      protected final NamespaceService namespaceService
    • dictionaryService

      protected final DictionaryService dictionaryService
    • multiValuedSeparator

      protected final String multiValuedSeparator
    • metadataFileExtension

      protected final String metadataFileExtension
  • Constructor Details

    • PropertiesFileMetadataLoader

      public PropertiesFileMetadataLoader(ServiceRegistry serviceRegistry)
    • PropertiesFileMetadataLoader

      public PropertiesFileMetadataLoader(ServiceRegistry serviceRegistry, String multiValuedSeparator)
  • Method Details

    • loadMetadataFromFile

      protected Map<String,Serializable> loadMetadataFromFile(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 Properties object loaded from that file.
      See Also:
      • org.alfresco.repo.bulkimport.metadataloaders.AbstractMapBasedMetadataLoader#loadMetadataFromFile(java.io.File)
    • getMetadataFileExtension

      public final String getMetadataFileExtension()
      Specified by:
      getMetadataFileExtension in interface MetadataLoader
      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: MetadataLoader
      Method that populates the type, aspects and properties to attach to a given file or space.
      Specified by:
      loadMetadata in interface MetadataLoader
      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).