Platform Explorer / Nuxeo Platform LTS 2015 7.10

Service org.nuxeo.ecm.platform.publisher.api.PublisherService

Documentation

  • 5.3.1
  • 5.3.2
  • 5.4.0

Overview

Since Nuxeo 5.3GA, you can now publish a document in 3 different ways:

  • On local sections
  • On remote sections (on a remote Nuxeo server)
  • On the file system

When using the PublisherService, you only need to care about 3 interfaces:

  • PublishedDocument: represents the published document: could be created from a DocumentModel, a proxy, a file on the file system.
  • PublicationNode: represents a Node where you can publish a DocumentModel: could be another DocumentModel (mainly Folder / Section), a directory on the file system.
  • PublicationTree: the tree which is used to publish / unpublish documents, to approve / reject publication, list the already published documents in a PublicationNode, … See the javadoc of the PublicationTree.

The PublisherService mainly works with 3 concepts:

  • factory: the classe which is used to actually create the published document. It also manages the approval / rejection workflow on published documents.
  • tree: a PublicationTree instance asociated to a name: for instance, we have a SectionPublicationTree which will publish in Sections, a LocalFSTree to publish on the file system, …
  • tree instance: an actual publication tree where we define the factory to use, the underlying tree to use, its name / title, and some parameters we will see later.

Next, we will see how to configure the different ways to publish in your Nuxeo server.

Local sections

That was the only way to publish on version < 5.3GA, and so this is the default way to publish.

Here is the default contribution you can find in Nuxeo (publisher-jbpm-contrib.xml in nuxeo-platform-publisher-jbpm. This contribution override the one in publisher-contrib.xml located in the nuxeo-platform-publisher-core project):

<extension target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
      point="treeInstance">

    <publicationTreeConfig name="DefaultSectionsTree" tree="RootSectionsCoreTree"
                           factory="CoreProxyWithWorkflow" localSectionTree="true"
                           title="label.publication.tree.local.sections">
      <parameters>
        <!-- <parameter name="RootPath">/default-domain/sections</parameter> -->
        <parameter name="RelativeRootPath">/sections</parameter>
        <parameter name="enableSnapshot">true</parameter>
        <parameter name="iconExpanded">/icons/folder_open.gif</parameter>
        <parameter name="iconCollapsed">/icons/folder.gif</parameter>
      </parameters>
    </publicationTreeConfig>

  </extension>

We define an instance using the RootSectionsTree tree and the CoreProxyWithWorkflow factory. We give it a name, a title and configure it to be a localSectionTree (which means we will publish on Sections on the same Nuxeo as the documents to be published are).

The parameters:

  • RootPath: it’s used when you want to define the root publication node of your PublicationTree. You can’t use RootPath AND RelativeRoothPath parameter.
  • RelativeRootPath: used when you just want to define a relative path (without specifying the domain path). A PublicationTree instance will be created automatically for each Domain, appending the RelativeroothPath value to each Domain.

For instance, assuming we have 2 Domains: domain-1 and domain-2, and the RelativeRootPath is set to "/sections", 2 PublicationTree instances will be created: the first one with a RootPath set to /domain-1/sections, the second one with a RootPath set to /domain-2/sections.

In the UI, when publishing, you can chose the PublicationTree you want. The list of trees will be automatically updated when creating and deleting Domain§.

  • iconExpanded and iconCollapsed: specify which icons to use when displaying the PublicationTree on the interface.

Remote sections

To make the remote publication work, both the Nuxeo server and client need to be configured.

Server configuration

You should create a new config file, publisher-server-config.xml for instance, in the nuxeo.ear/config folder of your Nuxeo acting as a server.

Here is a sample configuration:

<?xml version="1.0"?>
  <component name="org.nuxeo.ecm.platform.publisher.contrib.server">

    <extension target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
      point="treeInstance">

      <publicationTreeConfig name="ServerRemoteTree" tree="CoreTreeWithExternalDocs" factory="RemoteDocModel" >
        <parameters>
          <parameter name="RootPath">/default-domain/sections</parameter>
        </parameters>
      </publicationTreeConfig>

    </extension>

  </component>

Parameters: RootPath: its value must be the path to the document which is the root of your PublicationTree. Here, it will be the document /default-domain/sections, the default Sections Root in Nuxeo.

This parameter can be modified to suit your needs. Don’t forget to put the whole path to the document

Client configuration

You should create a new config file, publisher-client-config.xml for instance, in the nuxeo.ear/config folder of your Nuxeo acting as a client.

Here is a sample configuration

<?xml version="1.0"?>
  <component name="org.nuxeo.ecm.platform.publisher.contrib.client">

    <extension
        target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
        point="treeInstance">

      <publicationTreeConfig name="ClientRemoteTree" tree="ClientForRemoteTree"
                             factory="ClientProxyFactory">
        <parameters>
          <parameter name="title">label.publication.tree.remote.sections</parameter>
          <parameter name="userName">Administrator</parameter>
          <parameter name="password">Administrator</parameter>
          <parameter name="baseURL">
            http://myserver:8080/nuxeo/site/remotepublisher/
          </parameter>
          <parameter name="targetTree">ServerRemoteTree</parameter>
          <parameter name="originalServer">localserver</parameter>
          <parameter name="enableSnapshot">true</parameter>
        </parameters>
      </publicationTreeConfig>

    </extension>

  </component>

Parameters:

  • targetTree : this parameter corresponds to the name of the tree defined on the server, here ServerRemoteTree. username, password: the account defined by those parameters will be the one used to connect to the remote Nuxeo and so to create documents in the PublicationTree. This account MUST exist on the server.
  • baseURL: URL used by the publisher service on the client side to communicate with the server.
  • originalServer: identify the Nuxeo server used as client.

File system

To publish on the file system, you just need to define a new tree instance using the LocalFSTree and the RootPath of your tree. Here is a sample configuration:

<extension
    target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
    point="treeInstance">

    <publicationTreeConfig name="FSTree" tree="LocalFSTree"
                         factory="LocalFile" localSectionTree="false"
                         title="label.publication.tree.fileSystem">
      <parameters>
        <parameter name="RootPath">/opt/publishing-folder</parameter>
        <parameter name="enableSnapshot">true</parameter>
        <parameter name="iconExpanded">/icons/folder_open.gif</parameter>
        <parameter name="iconCollapsed">/icons/folder.gif</parameter>
      </parameters>
    </publicationTreeConfig>

  </extension>
  • RootPath: the root folder on the file system to be used as the root of the publication tree.

Implementation

org.nuxeo.ecm.platform.publisher.api.PublisherService

Click for full Javadoc

Additional documentation

Code Sample  
Publisher Service
  • 5.3.1
  • 5.3.2
  • 5.4.0

Overview

Since Nuxeo 5.3GA, you can now publish a document in 3 different ways:

  • On local sections
  • On remote sections (on a remote Nuxeo server)
  • On the file system

When using the PublisherService, you only need to care about 3 interfaces:

  • PublishedDocument: represents the published document: could be created from a DocumentModel, a proxy, a file on the file system.
  • PublicationNode: represents a Node where you can publish a DocumentModel: could be another DocumentModel (mainly Folder / Section), a directory on the file system.
  • PublicationTree: the tree which is used to publish / unpublish documents, to approve / reject publication, list the already published documents in a PublicationNode, … See the javadoc of the PublicationTree.

The PublisherService mainly works with 3 concepts:

  • factory: the classe which is used to actually create the published document. It also manages the approval / rejection workflow on published documents.
  • tree: a PublicationTree instance asociated to a name: for instance, we have a SectionPublicationTree which will publish in Sections, a LocalFSTree to publish on the file system, …
  • tree instance: an actual publication tree where we define the factory to use, the underlying tree to use, its name / title, and some parameters we will see later.

Next, we will see how to configure the different ways to publish in your Nuxeo server.

Local sections

That was the only way to publish on version < 5.3GA, and so this is the default way to publish.

Here is the default contribution you can find in Nuxeo (publisher-jbpm-contrib.xml in nuxeo-platform-publisher-jbpm. This contribution override the one in publisher-contrib.xml located in the nuxeo-platform-publisher-core project):

<extension target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
      point="treeInstance">

    <publicationTreeConfig name="DefaultSectionsTree" tree="RootSectionsCoreTree"
                           factory="CoreProxyWithWorkflow" localSectionTree="true"
                           title="label.publication.tree.local.sections">
      <parameters>
        <!-- <parameter name="RootPath">/default-domain/sections</parameter> -->
        <parameter name="RelativeRootPath">/sections</parameter>
        <parameter name="enableSnapshot">true</parameter>
        <parameter name="iconExpanded">/icons/folder_open.gif</parameter>
        <parameter name="iconCollapsed">/icons/folder.gif</parameter>
      </parameters>
    </publicationTreeConfig>

  </extension>

We define an instance using the RootSectionsTree tree and the CoreProxyWithWorkflow factory. We give it a name, a title and configure it to be a localSectionTree (which means we will publish on Sections on the same Nuxeo as the documents to be published are).

The parameters:

  • RootPath: it’s used when you want to define the root publication node of your PublicationTree. You can’t use RootPath AND RelativeRoothPath parameter.
  • RelativeRootPath: used when you just want to define a relative path (without specifying the domain path). A PublicationTree instance will be created automatically for each Domain, appending the RelativeroothPath value to each Domain.

For instance, assuming we have 2 Domains: domain-1 and domain-2, and the RelativeRootPath is set to "/sections", 2 PublicationTree instances will be created: the first one with a RootPath set to /domain-1/sections, the second one with a RootPath set to /domain-2/sections.

In the UI, when publishing, you can chose the PublicationTree you want. The list of trees will be automatically updated when creating and deleting Domain§.

  • iconExpanded and iconCollapsed: specify which icons to use when displaying the PublicationTree on the interface.

Remote sections

To make the remote publication work, both the Nuxeo server and client need to be configured.

Server configuration

You should create a new config file, publisher-server-config.xml for instance, in the nuxeo.ear/config folder of your Nuxeo acting as a server.

Here is a sample configuration:

<?xml version="1.0"?>
  <component name="org.nuxeo.ecm.platform.publisher.contrib.server">

    <extension target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
      point="treeInstance">

      <publicationTreeConfig name="ServerRemoteTree" tree="CoreTreeWithExternalDocs" factory="RemoteDocModel" >
        <parameters>
          <parameter name="RootPath">/default-domain/sections</parameter>
        </parameters>
      </publicationTreeConfig>

    </extension>

  </component>

Parameters: RootPath: its value must be the path to the document which is the root of your PublicationTree. Here, it will be the document /default-domain/sections, the default Sections Root in Nuxeo.

This parameter can be modified to suit your needs. Don’t forget to put the whole path to the document

Client configuration

You should create a new config file, publisher-client-config.xml for instance, in the nuxeo.ear/config folder of your Nuxeo acting as a client.

Here is a sample configuration

<?xml version="1.0"?>
  <component name="org.nuxeo.ecm.platform.publisher.contrib.client">

    <extension
        target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
        point="treeInstance">

      <publicationTreeConfig name="ClientRemoteTree" tree="ClientForRemoteTree"
                             factory="ClientProxyFactory">
        <parameters>
          <parameter name="title">label.publication.tree.remote.sections</parameter>
          <parameter name="userName">Administrator</parameter>
          <parameter name="password">Administrator</parameter>
          <parameter name="baseURL">
            http://myserver:8080/nuxeo/site/remotepublisher/
          </parameter>
          <parameter name="targetTree">ServerRemoteTree</parameter>
          <parameter name="originalServer">localserver</parameter>
          <parameter name="enableSnapshot">true</parameter>
        </parameters>
      </publicationTreeConfig>

    </extension>

  </component>

Parameters:

  • targetTree : this parameter corresponds to the name of the tree defined on the server, here ServerRemoteTree. username, password: the account defined by those parameters will be the one used to connect to the remote Nuxeo and so to create documents in the PublicationTree. This account MUST exist on the server.
  • baseURL: URL used by the publisher service on the client side to communicate with the server.
  • originalServer: identify the Nuxeo server used as client.

File system

To publish on the file system, you just need to define a new tree instance using the LocalFSTree and the RootPath of your tree. Here is a sample configuration:

<extension
    target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
    point="treeInstance">

    <publicationTreeConfig name="FSTree" tree="LocalFSTree"
                         factory="LocalFile" localSectionTree="false"
                         title="label.publication.tree.fileSystem">
      <parameters>
        <parameter name="RootPath">/opt/publishing-folder</parameter>
        <parameter name="enableSnapshot">true</parameter>
        <parameter name="iconExpanded">/icons/folder_open.gif</parameter>
        <parameter name="iconCollapsed">/icons/folder.gif</parameter>
      </parameters>
    </publicationTreeConfig>

  </extension>
  • RootPath: the root folder on the file system to be used as the root of the publication tree.
Remote Publication - Server configuration
  • 5.3.1
  • 5.3.2
  • 5.4.0
<?xml version="1.0"?>
  <component name="org.nuxeo.ecm.platform.publisher.contrib.server">

    <extension target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
      point="treeInstance">

      <publicationTreeConfig name="ServerRemoteTree" tree="CoreTreeWithExternalDocs" factory="RemoteDocModel" >
        <parameters>
          <parameter name="RootPath">/default-domain/sections</parameter>
        </parameters>
      </publicationTreeConfig>

    </extension>

  </component>
File System Publication - Sample configuration
  • 5.3.1
  • 5.3.2
  • 5.4.0
<extension
    target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
    point="treeInstance">

    <publicationTreeConfig name="FSTree" tree="LocalFSTree"
                         factory="LocalFile" localSectionTree="false"
                         title="label.publication.tree.fileSystem">
      <parameters>
        <parameter name="RootPath">/opt/publishing-folder</parameter>
        <parameter name="enableSnapshot">true</parameter>
        <parameter name="iconExpanded">/icons/folder_open.gif</parameter>
        <parameter name="iconCollapsed">/icons/folder.gif</parameter>
      </parameters>
    </publicationTreeConfig>

  </extension>
Remote Publication - Client configuration
  • 5.3.1
  • 5.3.2
  • 5.4.0
<?xml version="1.0"?>
  <component name="org.nuxeo.ecm.platform.publisher.contrib.client">

    <extension
        target="org.nuxeo.ecm.platform.publisher.impl.service.PublisherServiceImpl"
        point="treeInstance">

      <publicationTreeConfig name="ClientRemoteTree" tree="ClientForRemoteTree"
                             factory="ClientProxyFactory">
        <parameters>
          <parameter name="title">label.publication.tree.remote.sections</parameter>
          <parameter name="userName">Administrator</parameter>
          <parameter name="password">Administrator</parameter>
          <parameter name="baseURL">
            http://myserver:8080/nuxeo/site/remotepublisher/
          </parameter>
          <parameter name="targetTree">ServerRemoteTree</parameter>
          <parameter name="originalServer">localserver</parameter>
          <parameter name="enableSnapshot">true</parameter>
        </parameters>
      </publicationTreeConfig>

    </extension>

  </component>