I modified the DublinCoreListener to achieve this same effect when importing 
documents into Nuxeo. I inserted code that checks for the DOCUMENT_CREATED 
event and I use the dublincore field source to then determine if this is an 
import. If it's an import then I simply bail and do not override create/mod 
date while I have already set.

extract from DublinCoreListener.java
...
        DocumentModel doc = docCtx.getSourceDocument();
        if (doc.isVersion()) {
            log.debug("No DublinCore update on versions");
            return;
        }
        
        // DBG: 2010.06.01: if Source is set to import and this is a create 
event 
        //                  then bypass setting of create and last modified 
dates
        if (DOCUMENT_CREATED.equals(eventId)) {
            String source;
            try {
                source = doc.getProperty("dublincore", "source").toString();
            } catch (Exception e) {
                source = "";
            }

            if ("import".equals(source)) {
                log.debug("Do not set created date, modified date, and 
contributor on import");
                return;
            }
        }
                
        Date eventDate = new Date(event.getTime());
        Calendar cEventDate = Calendar.getInstance();
        cEventDate.setTime(eventDate);
...
--
Posted by "bgrant" at Nuxeo Discussions <http://nuxeo.org/discussions>
View the complete thread: 
<http://www.nuxeo.org/discussions/thread.jspa?threadID=3792#11764>
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm

Reply via email to