How can i modify the author of a document
Hi I upload a lot of file in Nuxeo and i appear to be the author of these documents. But i'm not. is it possible to change the author ?
Regards
By default we consider in Nuxeo DM that the author of the Nuxeo Document is the user that creates the document. I insist on the fact that we talk about the Nuxeo Document not the attached File to the Nuxeo Document. By default in Nuxeo DM we don't expose a field to specify the author of the content attach to the document (the Photographer, the cameraman, …).
If you need to add this field you can through Nuxeo Studio override the File Document Type.
I let you watch this.
Or if you really want to set the author of the Nuxeo document to the author of the binary you are uploading then you can write a custom listener, extract the name of the author from your upload, and use that name to set the author field.
Perhaps anyone could help me ?
In fact, I try to position a default value to a custom field ("emetteur") for a custom Type ("docSUAIO") but it doesn't work. I don't need to extract it from upload, just to use the user connected to set the default value for my custom field when the document is being created. I use a custom listener on event "emptyDocumentModelCreated" and then use this class :
public class StoredocSuaioEventListener implements EventListener {
@Override
public void handleEvent(Event event) throws ClientException {
EventContext ctx = event.getContext();
if (!(ctx instanceof DocumentEventContext)) {
return;
}
DocumentModel doc = ((DocumentEventContext) ctx).getSourceDocument();
if (doc == null) {
return;
}
if (doc.getType().equals("docSUAIO")){
process(doc,ctx.getPrincipal().toString());
}
}
public void process(DocumentModel doc, String emet) throws ClientException {
doc.setPropertyValue("docSUAIO:emetteur", emet );
/* doc.setPropertyValue("creator", emet); perhap to position, i'm not enough sure */
}
}
But unfortunately, when I keep the user login, it is almost ok (except the tab VIEW show only the first name) but when I enter another user, it is almost ok EXCEPT that the login user disappears after document is created ! So, the Nuxeo DM is strongly strange : no more user connected…