Preserve Original Create and Modified Date?

cancel
Showing results for 
Search instead for 
Did you mean: 
Member II

Preserve Original Create and Modified Date?

Hi,

I am trying to preserve original document create/modify date and it is working for pdf and office document.

I want same behaviour for images also.

Content Model : 

<?xml version="1.0" encoding="UTF-8"?>
<model name="demo:custom-model"
	xmlns="http://www.alfresco.org/model/dictionary/1.0">
	<description>Sample model for original creation and modification dates
	</description>
	<author>Sanjay</author>
	<version>1.0</version>
	<imports>
		<import uri="http://www.alfresco.org/model/dictionary/1.0"
			prefix="d" />
	</imports>
	<namespaces>
		<namespace
			uri="http://www.alfresco.com/model/custom-model/1.0" prefix="demo" />
	</namespaces>
	<aspects>
		<aspect name="demo:testAuditMetadata">
			<title>Test Audit Metadata</title>
			<description>Test Audit Metadata</description>
			<properties>
				<property name="demo:originalCreatedDate">
					<title>Original Created Date</title>
					<description>Original Created Date</description>
					<type>d:text</type>
				</property>
				<property name="demo:originalModifiedDate">
					<title>Original Modified Date</title>
					<description>Original Modified Date</description>
					<type>d:text</type>
				</property>
			</properties>
		</aspect>
	</aspects>
</model>

Bean :

 

<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
          http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
	<bean id="extracter.TikaAuto"		class="org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter"  parent="baseMetadataExtracter">
		<constructor-arg>
			<ref bean="tikaConfig" />
		</constructor-arg>
		<property name="overwritePolicy">
			<value>EAGER</value>
		</property>
		<property name="mappingProperties">
			<bean 		class="org.springframework.beans.factory.config.PropertiesFactoryBean">
				<property name="location">	<value>classpath:alfresco/metadata/TikaAutoMetadataExtracter.properties
					</value>
				</property>
			</bean>
		</property>
	</bean>
	<bean id="extracter.PDFBox"
	class="org.alfresco.repo.content.metadata.PdfBoxMetadataExtracter"
		parent="baseMetadataExtracter">
		<property name="documentSelector"
			ref="pdfBoxEmbededDocumentSelector" />
		<property name="overwritePolicy">
			<value>EAGER</value>
		</property>
		<!-- Including custom properties -->
		<property name="mappingProperties">
			<bean				class="org.springframework.beans.factory.config.PropertiesFactoryBean">
				<property name="location">					<value>classpath:alfresco/metadata/PdfBoxMetadataExtracter.properties
					</value>
				</property>
			</bean>
		</property>
	</bean>
	<bean id="extracter.Poi"		class="org.alfresco.repo.content.metadata.PoiMetadataExtracter"
		parent="baseMetadataExtracter">
		<property name="poiFootnotesLimit"
			value="${content.transformer.Poi.poiFootnotesLimit}" />
		<property name="poiExtractPropertiesOnly"			value="${content.transformer.Poi.poiExtractPropertiesOnly}" />
		<property name="poiAllowableXslfRelationshipTypes">
			<list>
				<!-- These values are valid for Office 2007, 2010 and 2013 -->				<value>http://schemas.openxmlformats.org/officeDocument/2006/relationships/presProps
				</value>				<value>http://schemas.openxmlformats.org/officeDocument/2006/relationships/viewProps
				</value>
			</list>
		</property>
		<property name="overwritePolicy">
			<value>EAGER</value>
		</property>
		<!-- Including custom properties -->
		<property name="mappingProperties">
			<bean				class="org.springframework.beans.factory.config.PropertiesFactoryBean">
				<property name="location">					<value>classpath:alfresco/metadata/PoiMetadataExtracter.properties
					</value>
				</property>
			</bean>
		</property>
	</bean>
</beans>

PdfBoxMetadataExtracter.properties and PoiMetadataExtracter.properties

# Namespaces
namespace.prefix.cm=http://www.alfresco.org/model/content/1.0
#Custom model namespace
namespace.prefix.demo=http://www.alfresco.com/model/custom-model/1.0

# OOTB Default Mappings
author=cm:author
title=cm:title
description=cm:description

# Custom Properties to be mapped
created=demo:originalCreatedDate
modified=demo:originalModifiedDate

TikaAutoMetadataExtracter.properties

 

# Namespaces
namespace.prefix.cm=http://www.alfresco.org/model/content/1.0
namespace.prefix.exif=http://www.alfresco.org/model/exif/1.0
namespace.prefix.audio=http://www.alfresco.org/model/audio/1.0
#Custom model namespace
namespace.prefix.demo=http://www.alfresco.com/model/custom-model/1.0

# OOTB Default Mappings
author=cm:author
title=cm:title
description=cm:description
created=cm:created

# Custom Properties to be mapped
created=demo:originalCreatedDate
modified=demo:originalModifiedDate

geo\:lat=cm:latitude
geo\:long=cm:longitude
tiff\:ImageWidth=exif:pixelXDimension
tiff\:ImageLength=exif:pixelYDimension
tiff\:Make=exif:manufacturer
tiff\:Model=exif:model
tiff\:Software=exif:software
tiff\:Orientation=exif:orientation
tiff\:XResolution=exif:xResolution
tiff\:YResolution=exif:yResolution
tiff\:ResolutionUnit=exif:resolutionUnit
exif\:Flash=exif:flash
exif\:ExposureTime=exif:exposureTime
exif\:FNumber=exif:fNumber
exif\:FocalLength=exif:focalLength
exif\:IsoSpeedRatings=exif:isoSpeedRatings
exif\:DateTimeOriginal=exif:dateTimeOriginal
xmpDM\:album=audio:album
xmpDM\:artist=audio:artist
xmpDM\:composer=audio:composer
xmpDM\:engineer=audio:engineer
xmpDM\:genre=audio:genre
xmpDM\:trackNumber=audio:trackNumber
xmpDM\:releaseDate=audio:releaseDate
#xmpDM:logComment
xmpDM\:audioSampleRate=audio:sampleRate
xmpDM\:audioSampleType=audio:sampleType
xmpDM\:audioChannelType=audio:channelType
xmpDM\:audioCompressor=audio:compressor

Let me know what I am missign for image metadata extractor.

Thanks & Regards,
1 Reply
Moderator
Moderator

Re: Preserve Original Create and Modified Date?

Have a look at this full thread as well, as there are some debugging steps in case you are not seeing metadata extracted:

https://hub.alfresco.com/t5/alfresco-content-services-forum/preserve-original-create-and-modified-da...

https://hub.alfresco.com/t5/alfresco-content-services-forum/how-to-preserve-original-document-create...

Try enabling the debug logs:

#Metadata extractor 
log4j.logger.org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter=DEBUG
log4j.logger.org.alfresco.repo.content.metadata.MetadataExtracterRegistry=DEBUG

Look for logs carefully and see what metadata is extracted, mapped and changed, e.g.:

Image Extraction:
Mapped and Accepted: {{http://www.alfresco.org/model/exif/1.0}focalLength=4.5, {http://www.alfresco.org/model/exif/1.0}model=TG-5, {http://www.alfresco.org/model/content/1.0}title=null, {http://www.alfresco.org/model/exif/1.0}flash=false, {http://www.alfresco.org/model/exif/1.0}fNumber=8.0, {http://www.alfresco.org/model/exif/1.0}isoSpeedRatings=100, {http://www.alfresco.org/model/content/1.0}description={en_US=OLYMPUS DIGITAL CAMERA}, {http://www.alfresco.org/model/exif/1.0}dateTimeOriginal=Sun May 07 13:23:51 EDT 2017, {http://www.alfresco.org/model/exif/1.0}manufacturer=OLYMPUS CORPORATION, {http://www.github.com/abhinavmishra14/model/demo/1.0}originCreatedDate=2017-05-07T13:23:51, {http://www.alfresco.org/model/exif/1.0}pixelXDimension=590, {http://www.alfresco.org/model/exif/1.0}pixelYDimension=442, {http://www.alfresco.org/model/content/1.0}author=null, {http://www.alfresco.org/model/exif/1.0}exposureTime=0.005}
2020-05-22 09:58:00,041 DEBUG [org.alfresco.repo.content.metadata.AbstractMappingMetadataExtracter] [http-bio-8080-exec-14] Completed metadata extraction: 
reader:    ContentAccessor[ contentUrl=store://2020/5/22/9/57/db13881d-4caf-4a72-a481-054bb9246b63.bin, mimetype=image/jpeg, size=94399, encoding=UTF-8, locale=en_US]
extracter: org.alfresco.repo.content.metadata.TikaAutoMetadataExtracter@126bd574
changed:   {{http://www.github.com/abhinavmishra14/model/demo/1.0}originCreatedDate=2017-05-07T13:23:51,{http://www.alfresco.org/model/exif/1.0}focalLength=4.5, {http://www.alfresco.org/model/exif/1.0}model=TG-5, {http://www.alfresco.org/model/content/1.0}title=null, {http://www.alfresco.org/model/exif/1.0}flash=false, {http://www.alfresco.org/model/exif/1.0}fNumber=8.0, {http://www.alfresco.org/model/exif/1.0}isoSpeedRatings=100, {http://www.alfresco.org/model/content/1.0}description={en_US=OLYMPUS DIGITAL CAMERA}, {http://www.alfresco.org/model/exif/1.0}dateTimeOriginal=Sun May 07 13:23:51 EDT 2017, {http://www.alfresco.org/model/exif/1.0}manufacturer=OLYMPUS CORPORATION, {http://www.alfresco.org/model/exif/1.0}pixelXDimension=590, {http://www.alfresco.org/model/exif/1.0}pixelYDimension=442, {http://www.alfresco.org/model/content/1.0}author=null, {http://www.alfresco.org/model/exif/1.0}exposureTime=0.005}

There is a sample project available here for ACS 5.2.x: https://github.com/abhinavmishra14/alfresco-metadataextraction-demo/tree/master/metadata-extractor-d...

Look at this context file and compare your changes: https://github.com/abhinavmishra14/alfresco-metadataextraction-demo/blob/master/metadata-extractor-d...

Compare your config changes: https://github.com/abhinavmishra14/alfresco-metadataextraction-demo/tree/master/metadata-extractor-d...

 

 

~Abhinav
(ACSCE, AWS SAA-C02, GAIQ)