How to get back to source file from published document?

In the summary view of a published document it seems there should be a way to go to the source document in the interface. I don't see anyway to see where the published document came from. If this is not currently there, that would be a simple and great feature to add.

0 votes

1 answers

2090 views

ANSWER

I think that the folks from Nuxeo would say that this runs contrary to the publishing paradigm - that is, a published version is a poit-in-time snapshot of a workspace document and most consumers of published works should never see or be able to link to a work-in-progress version. From a practical perspective though, with proper security in place, I can absolutely see the value of a link back to the source (if it still exists).
03/03/2012

Even linking back to the precise version if it exists and if one has permission would be a nice feature.
03/03/2012



Yes,

I understand this is a interesting feature for you, but not for Nuxeo DM, as said Bruce. Our target is to answers to 80% of the need of our customer and you see that the document type are weakly typed (File, Note, …) and note (Contract, CV, …).

But hopefully for you Nuxeo DM is based on a platform and gives you tools to implement things you need.

Ok I stop my sales argument :D

You just have to create an operation with Nuxeo IDE that fetch the source document.

@Context
protected CoreSession session;

@OperationMethod(collector = DocumentModelCollector.class)
public DocumentModel run(DocumentModel input) throws Exception {
    return session.getSourceDocument(input.getRef());
}

You create a Seam component that tells if the user have right to navigate to the source document. You will have to use unrestrictedSession to get the document, and then check if the user have rights:

@Name("yourComponent")
public class NavigationContextBean implements NavigationContext, Serializable {


    @In(create = true, required = false)
    protected transient CoreSession documentManager;

    public boolean hasRightOnSourceDocument() {
        YourRunner runner = new YourRunner(documentManager);


        try {
            runner.runUnrestricted();
        } catch (ClientException e) {
            throw new ClientRuntimeException(e);
        }
        DocumentRef publishedDocumentRef = runner.sourceDocumentRef;
        return documentManager.hasPermission(publishedDocumentRef, "READ");

    }

    class YourRunner extends UnrestrictedSessionRunner {

        public DocumentRef sourceDocumentRef;

        protected YourRunner(CoreSession session) {
            super(session);
        }

        @Override
        public void run() throws ClientException {
            sourceDocumentRef = session.getSourceDocument(input.getRef()).getRef();
        }
    }
}

So you can do what you want with Studio. You create a button and you use the Seam component to let the button appears for the user or not.

And you attach the following operation chain to your button:

  • Fetch > Context Document(s)
  • your operation
  • User Interface > Navigate to Document

Your demand is a bit specific and we must take care of the right on the source document that why we need to do this. If you are interested to this kind of feature, you can follow our free webinar on Nuxeo Studio and Nuxeo IDE.

And you are welcome to create a marketplace package with this feature and publish to our marketplace.

1 votes



Did you make it work ?
03/19/2012