Preparing Source Content & cm:created

160 views
Skip to first unread message

Zhihai Liu

unread,
Oct 14, 2016, 3:38:54 PM10/14/16
to Alfresco Bulk Import Tool
Metadata Example

Here's a fully worked example for IMG_1967.jpg.metadata.properties.xml:

<entry key="cm:created">1901-01-01T12:34:56.789+10:00</entry>

Question: will this cm:created value be preserved when bulk import tool loads the document? In the past I found Alfresco considers cm:created, cm:modified etc as "audit" properties and it sets the values as the system time when the import occurs. Thank you.

Peter Monks

unread,
Oct 14, 2016, 5:40:09 PM10/14/16
to alfresco-bulk-f...@googlegroups.com
G'day Zhihai,

tl;dr - yes creation and modification timestamps are preserved (written to the repository) by the tool.

Long answer - the tool temporarily disables Alfresco's so-called "auditable" aspect, which (amongst other things) controls whether these timestamps are writeable or not. The specific line of code is here: https://github.com/pmonks/alfresco-bulk-import/blob/master/amp/src/main/java/org/alfresco/extension/bulkimport/impl/BatchImporterImpl.java#L159

Cheers,
Peter 

Apologes for speling & gramar erorrs - sent from mobil deivce
--
You received this message because you are subscribed to the Google Groups "Alfresco Bulk Import Tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesys...@googlegroups.com.
To post to this group, send email to alfresco-bulk-f...@googlegroups.com.
Visit this group at https://groups.google.com/group/alfresco-bulk-filesystem-import.
For more options, visit https://groups.google.com/d/optout.

Zhihai Liu

unread,
Oct 14, 2016, 8:45:02 PM10/14/16
to Alfresco Bulk Import Tool
This is awesome. Thank you Peter!


On Friday, October 14, 2016 at 5:40:09 PM UTC-4, Peter Monks wrote:
G'day Zhihai,

tl;dr - yes creation and modification timestamps are preserved (written to the repository) by the tool.

Long answer - the tool temporarily disables Alfresco's so-called "auditable" aspect, which (amongst other things) controls whether these timestamps are writeable or not. The specific line of code is here: https://github.com/pmonks/alfresco-bulk-import/blob/master/amp/src/main/java/org/alfresco/extension/bulkimport/impl/BatchImporterImpl.java#L159

Cheers,
Peter 

Apologes for speling & gramar erorrs - sent from mobil deivce

On Oct 14, 2016, at 12:38 PM, Zhihai Liu <zhiha...@gmail.com> wrote:

Metadata Example

Here's a fully worked example for IMG_1967.jpg.metadata.properties.xml:

<entry key="cm:created">1901-01-01T12:34:56.789+10:00</entry>

Question: will this cm:created value be preserved when bulk import tool loads the document? In the past I found Alfresco considers cm:created, cm:modified etc as "audit" properties and it sets the values as the system time when the import occurs. Thank you.

--
You received this message because you are subscribed to the Google Groups "Alfresco Bulk Import Tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesystem-import+unsubscribe@googlegroups.com.
To post to this group, send email to alfresco-bulk-filesystem-imp...@googlegroups.com.

Zhihai Liu

unread,
Nov 10, 2016, 4:44:20 PM11/10/16
to Alfresco Bulk Import Tool
Hi Peter,

"cm:created" worked perfectly fine since your responded last time. However, I noticed something fairly strange today. Here is a sample metadata.properties.xml file.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
<properties>
<entry key="cm:name">Design Submissions.pdf</entry>
<entry key="namespace">http://www.alfresco.org/model/content/1.0</entry>
<entry key="cm:modifier">abc</entry>
<entry key="separator">,</entry>
<entry key="cm:creator">abc</entry>
<entry key="type">cm:content</entry>
<entry key="cm:created">2016-03-29T09:07:15-04:00</entry>
<entry key="parentAssociation">cm:contains</entry>
<entry key="cm:modified">2016-05-31T14:46:07-04:00</entry>
</properties>

After importing, Alfresco showed the following information in Document Details. As you can see, the Modified Date is correctly preserved. However, the Created Date is completely off - it is neither the date in the property file, nor system date (which would be today 11/10/2016). 

Created Date: Tue 3 Nov 2015 13:28:47
Modified Date: Tue 31 May 2016 14:46:07

Here is the display from Node Browser.
cm:created
d:datetime
03 Nov 2015 13:28:47 GMT-0500 (EST)
m:modified
d:datetime
31 May 2016 14:46:07 GMT-0400 (EDT)

I am based in US East (EST), where just went through daylight saving change last Sunday. I swear cm:created worked correctly last week. Does it have anything to do with that? I am scratching my head... Thank you for your help.





On Friday, October 14, 2016 at 5:40:09 PM UTC-4, Peter Monks wrote:
G'day Zhihai,

tl;dr - yes creation and modification timestamps are preserved (written to the repository) by the tool.

Long answer - the tool temporarily disables Alfresco's so-called "auditable" aspect, which (amongst other things) controls whether these timestamps are writeable or not. The specific line of code is here: https://github.com/pmonks/alfresco-bulk-import/blob/master/amp/src/main/java/org/alfresco/extension/bulkimport/impl/BatchImporterImpl.java#L159

Cheers,
Peter 

Apologes for speling & gramar erorrs - sent from mobil deivce

On Oct 14, 2016, at 12:38 PM, Zhihai Liu <zhiha...@gmail.com> wrote:

Metadata Example

Here's a fully worked example for IMG_1967.jpg.metadata.properties.xml:

<entry key="cm:created">1901-01-01T12:34:56.789+10:00</entry>

Question: will this cm:created value be preserved when bulk import tool loads the document? In the past I found Alfresco considers cm:created, cm:modified etc as "audit" properties and it sets the values as the system time when the import occurs. Thank you.

--
You received this message because you are subscribed to the Google Groups "Alfresco Bulk Import Tool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to alfresco-bulk-filesystem-import+unsubscribe@googlegroups.com.
To post to this group, send email to alfresco-bulk-filesystem-imp...@googlegroups.com.

Zhihai Liu

unread,
Nov 11, 2016, 3:23:59 PM11/11/16
to Alfresco Bulk Import Tool
I debugged and traced it to FilesystemBulkImportItemVersion.java line 259 - cachedMetadata.getProperties().containsKey(ContentModel.PROP_CREATED.toPrefixString())

cachedMetadata has been loaded with key "cm:created" from the metadata file. It seems that here we are checking and skipping if the matching key is found. However, ContentModel.PROP_CREATED.toPrefixString() resolves to "created" instead of "cm:created". Thus, assuming no such key exists, it goes ahead and executes the section "// If not set in the metadata file, set the creation timestamp to what's on disk". Later in BatchImporterImpl.importVersionMetadata(), this value replaces/overrides the value from metadata file.

Maybe we should call toPrefixString() with a NamespacePrefixResolver to resolve the prefix "cm" instead of null? Thanks.
Reply all
Reply to author
Forward
0 new messages