cancel
Showing results for 
Search instead for 
Did you mean: 

How to import data into Nuxeo and keep original dc:creator, dc:created, dc:modified, dc:lastContributor from former application

Eduardo_Rodrigu
Champ on-the-rise
Champ on-the-rise

I am migrating content from an existing application into Nuxeo. We are replacing our existing workflow solution by Nuxeo.

I need to keep the dc:creator, dc:created, dc:modified, dc:lastContributor fields with the former application values. I know they are internal fields maintained from DublinCore.

I saw another thread where the suggestion was using a custom field, but that doesn't seem a great idea moving forward. I'd need to maintain those fields manually. I want to rely on Nuxeo core to keep the fields up-to-date for every new created/updated document.

Even though dc:creator, dc:created are dc fields I managed to change their values with an update call after the document has been created.

What are the alternatives to update dc:modified, dc:lastContributor ?

How can I use an Admin user to act on behalf of another user?

The import script will run only once so I don't mind about a few hacks.

3 REPLIES 3

Eduardo_Rodrigu
Champ on-the-rise
Champ on-the-rise

Half way there.

With Michael Gena help I managed to get in a good point

It's possible to disable DublinCore using Nuxeo Studio adding this extension

<extension point="listener" target="org.nuxeo.ecm.core.event.EventServiceComponent">  
	<listener enabled="false" async="false" class="org.nuxeo.ecm.platform.dublincore.listener.DublinCoreListener" name="dclistener" postCommit="false" priority="120">  
		<event>documentCreated</event>  
		<event>beforeDocumentModification</event>  
		<event>documentPublished</event>  
		<event>lifecycle_transition_event</event>  
		<event>documentCreatedByCopy</event>  
	</listener>  
</extension>

Note enabled="false"

The problem with this solution is that it requires an additional deploy to enable DC again.

I wonder if there is a API call that we can use in order to disable and enable DC .

sokolov
Employee
Employee

Try 

if (doc.getProperty(key).isSecured()) {
try (NuxeoLoginContext ignored = Framework.loginUser("Administrator")) {
log.debug("Is secured " + key);
doc.setPropertyValue(key, (Serializable) fieldValue);
}
} else {
doc.setPropertyValue(key, (Serializable) fieldValue);
}
session.importDocuments(Collections.singletonList(docToCreate));

dhaglund
Champ on-the-rise
Champ on-the-rise

You don't have to disable Dublin Core listeners for the whole application using a contribution. You can temporarily disable the listeners when processing one specific document in backend code if that is what you want. Then save your document. Like this:

doc.putContextData(DISABLE_DUBLINCORE_LISTENER, Boolean.TRUE);

Search Nuxeos source code for DISABLE_DUBLINCORE_LISTENER if you want examples.

Getting started

Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.