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

0 votes

2 answers

2196 views

ANSWER



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.

1 votes



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.

0 votes



We strongly not recommend that, because this field is not for that point. Create your own field and Hide the Nuxeo default one is a better solution.
11/09/2011

I strongly disagree, in most cases my customers want to preserve metadata - dates and authors from the pre-existing system. This is especially important for search and ordering. Having to create new fields would require significant effort and is imo unnecessary. Makes more sense to create a field to create actual Nuxeo document creation - if only for audit purpose.
11/11/2011

Hello, Please Bruce, could you tell me how 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…

03/28/2012

Hi Brigitte, the setting of the author of a document is embedded in a dublincore listener. By design, Nuxeo provides no mechanism to override this. What this means is that setting the author property in your own listener, prior to actual document creation will/can never work. So I suspect that Nuxeo has not provided any mechanism to perform this override in the Studio environment. The only real way to modify this behavious is to modify the Nuxeo listener that sets the author value. This (effectively) requires downloading the sources, making the change required and then recompiling the effected package. The downside to this is obvious - you then have to maintain this customization from hotfix to hotfix and release to release. But I have found this necessary in the past - at least as a temporary measure during mass import of content. Hope this helps.
03/28/2012

Ok Bruce thanks for this response. I understand for the document's author (called "creator" in my example) but for a custom field separate from the nuxeo standard fields, why it doesn't work ? I don't understand why when I set the value of the property "emetteur", specific to my document type, it break the nuxeo login, unless Nuxeo use this term somewhere else : "emetteur" ?
03/28/2012

Ok, I undestand where my problem was : I modified the single_user_suggestion_widget_template.xhtml (value="#{userSession.currentUser.name}" in inputText of h:panelGroup suggestiongroup) and it was a very bad idea… Now it's ok for me and I think that I don't modify the author of document, I'll give the function with the custom field.
03/28/2012