Addons

Nuxeo File System Exporter

Updated: November 15, 2024

Nuxeo FS Exporter with Nuxeo Web UI
The default button to perform an export to a File System is exposed in Nuxeo JSF UI. You can perfectly use it in Nuxeo Web UI too, by creating a button in Nuxeo Studio Modeler, using the operation Services > ExportStructureToFS.

Functional Overview

The File System Exporter package is an addon for the Nuxeo platform to enable users exporting one chosen root structure of documents from their Nuxeo Platform to a specified File System directory.

The installation of the plugin will add a new operation in "Services" called "ExportStructureToFS". This operation must be added to the registries in Studio and then can be used in an automation chain.

In the user interface, users will now see a new action button that allows them to export the structure with the following parameters defined in Studio:

  • Root Path = /default-domain/
  • File System target = /tmp

After clicking on the export action, a connected user has now access to the entire structure directly on his tmp folder.

The following rules are implemented by default:

  • All the documents are exported 
  • When an exported document already exists in your File System directory, it will be prefixed with a timestamp. In this way, no document will be deleted 
  • The attached files to a document are exported in the same directory than the document. They are prefixed with the name of the document parent.

Installation

This addon requires no specific installation steps. It can be installed like any other package with nuxeoctl command line or from the Marketplace.

Technical Overview

Enabling the New Operation

In Studio go to Settings > Registries, to create a new Automation Operations with the following JSON path:   

{
  "operations": [
    {
  "id" : "ExportStructureToFS",
  "label" : "ExportStructureToFS",
  "category" : "Services",
  "requires" : null,
  "description" : "This operation enables to export the structure contained in the Root name path to the File System Target path. You can declare your own query to choose the document being exported.",
  "url" : "ExportStructureToFS",
  "signature" : [ "void", "void" ],
  "params" : [ {
    "name" : "File System Target",
    "description" : "",
    "type" : "string",
    "required" : true,
    "widget" : null,
    "order" : 0,
    "values" : [ ]
  }, {
    "name" : "Root Path",
    "description" : "",
    "type" : "string",
    "required" : true,
    "widget" : null,
    "order" : 0,
    "values" : [ ]
  }, {
    "name" : "Query",
    "description" : "",
    "type" : "string",
    "required" : false,
    "widget" : null,
    "order" : 0,
    "values" : [ ]
  } ]
}
]
}

If you don't know how to add an external operation, you will find all the information that you need on the page Referencing an Externally Defined Operation.

Creating the Automation Chain

This operation can be called in an automation chain called “ExportFS” in our example, and linked to a user action.

This operation has the following parameters:

  • File System Target: where the export will be done on the File System
  • Root  Path: the path of the top document in the hierarchy to be exported.
  • Query: optional parameter. By default the query called by the exporter is:

    SELECT * FROM Document ecm:mixinType !='HiddenInNavigation' AND ecm:isVersion = 0 AND ecm:isTrashed = 0
    

    You can define your own query and put it the in the Query parameter.

For example if you want to export all the documents even the ones in “deleted” state you can define this query in the field of the Query parameter.

SELECT * FROM Document WHERE ecm:mixinType !='HiddenInNavigation' AND ecm:isVersion = 0

Customization

If you want to go further you can decide to contribute to the extension point “exportLogic” with a custom class to have a new way of export:

  • Export only documents of type “File”
  • Override existing documents (not using the timestamp prefix anymore)
  • Create an XML export of each document (done as an example) 

The following contribution has already been written: CustomExporterPlugin. It launches the default export (export all the documents under root path) and in addition, for each exported document, creates the XML version.

You can use it with the following XML extension in Studio :  

<extension
target="org.nuxeo.io.fsexporter.FSExporter"
point="exportLogic">

        <exportLogic
class="org.nuxeo.io.fsexporter.CustomExporterPlugin" />

</extension>