In Alfresco 4.0 there is a new Content Publish action that uses an extendable framework to allow users to set up channels that content can be published to. This has been introduced to be used with Alfresco's social content solutions and they have created channels that tie into the Spring Social APIs to allow users to create publishing channels that can output to different types of social media.Although these publishing channels are primarily set up for Spring Social targets it is possible to do other types of publishing though this framework. For example, we can hook into the Alfresco Content Publishing framework to allow us to send content to a MarkLogic server in the same way that content can now be published out to social platforms.

Setup New Content Publishing Channel

To setup a new Content Publishing Channel you can use the new Channel Manager section in the share Admin Console:

http://localhost:8080/share/page/console/admin-console/channel-admin#

Channels can be defined and then new instances of channel type can be created with their own set of properties and username/password.

You must have a type with a parent of DeliveryChannel that will be picked up automatically by the Share Publish Channel screen. Any additional properties added to this type will automatically appear on the screen so you can have configuration such as URL, Port, Path etc.


<types>
      <type name="marklogic:DeliveryChannel">
         <title>Marklogic Delivery Channel </title>
         <description>Node type used to represent marklogic delivery channels </description>
         <parent>pub:DeliveryChannel</parent>
         <mandatory-aspects>
            <aspect>marklogic:DeliveryChannelAspect</aspect>
            <aspect>ippcm:tree-root</aspect>
         </mandatory-aspects>
      </type>
   </types>

   <aspects>
      <aspect name="marklogic:DeliveryChannelAspect">
         <title>Marklogic Delivery Channel Aspect</title>
         <description>Applied to a node that represents a marklogic delivery channel</description>
          <properties>
                <property name="marklogic:enabled">
                    <title>is it enabled</title>
                    <type>d:boolean</type>
                    <multiple>false</multiple>
                </property>
                    <property name="marklogic:host">
                           <title>The marklogic host name</title>
                    <type>d:text</type>
                    <multiple>false</multiple>
                </property>
                    <property name="marklogic:port">
                           <title>The marklogic port</title>
                    <type>d:int</type>
                    <multiple>false</multiple>
                </property>
            </properties>
      </aspect>
   </aspects>


By default it will pop up a screen asking you for your username and password but you must then click on the new icon to set other properties such as host name and port as well as being able to rename it to something more descriptive.

Add Publication Code

Once the channel has been created in the content model we need to add the baseChannelType that will link this DeliveryChannel to the actual publish actions.


<bean id="marklogicDeliveryChannelType" class="com.ixxus.alfresco.publishing.marklogic.MarklogicChannelType" parent="baseChannelType">

This ChannelType defines if it can publish, un-publish, and update status. It is linked to the type created in the content model by the getChannelNodeType method. You also need to overwrite the methods to perform the publishing/status update.


public class MarklogicChannelTypeextendsAbstractChannelType{
…
       @Override
       publicQNamegetChannelNodeType() {
             returnMarklogicChannelContentModel.DeliveryChannelAspectType.TYPE;
       }
…
       @Override
       publicbooleancanPublish() {
             returntrue;
       }
…
    @Override
    public void publish(NodeRefnodeToPublish, MapchannelProperties)

Cautions

One thing to be wary of is that by default the password and username are stored against the publishable channel node as encrypted content so you need to inject the encryptor and call decrypt against the content.

Another thing to note is that content to be published is copied to the Data Dictionary under a node in Publishing Root which will have a child folder with the same name as your Channel Type so if you are doing any path or relationship processing in your publish action you may need to get the child of association pub:source.

Next to your channel type you need the images at various sizes, these are picked up via a webscript that share calls and simply need to be the same name as your ChannelType but with the size and “.png” appended to the end (MarklogicChannelType32.png for example).

Publish Content

Once the channel has been created we can use the new “Publish” action within the share UI to select the correct publication location

This will then asynchronously line up the content to be published using our custom code and channel properties

We can then view the publishing history of a document using the document details screen within Alfresco Share

TO DOs

This is all you need to do to create a new publication location to Alfresco 4.0 but it can then be extended and tailored to your particular needs.

For example in the Marklogic example we might want to only publish content with a particular Mimetype by editing the getSupportedMimeTypes method. We might also want to update a status message stored within an XML section of MarkLogic that could be used for an RSS feed or to automatically notify users of new content.

All of these things and many more are possible with the new Publication Channel Framework within Alfresco 4.0 and although by default these channels are all using Spring Social, it is worth knowing that this does not have to be the case.