cancel
Showing results for 
Search instead for 
Did you mean: 

Publishing in multi-server environment

lemmy
Champ in-the-making
Champ in-the-making
Hi,

I've set up Alfresco 3.4.d locally, publishing works fine. Now I'd like to use am environment with two servers:
1. Local server for editing (Quick Start Editorial), Windows 7, localhost
2. Live-server (Quick Start Live), Linux, http://www.mysite.com

After making changes to the local site I want to publish it to the live-server. My question is regarding the setup of this environment. What prerequisite do I have to fulfill?
-Setup of parameters for live-server (hostname, hostport)
-Creation of the wcmqs site on live server?
-Database content?
…

Thanks,
Lemmy
5 REPLIES 5

bremmington
Champ on-the-rise
Champ on-the-rise
There are a few steps needed. At the moment it does require some code to achieve it.

Pushing the content to your live environment will make use of the transfer service, and two things need to be done initially to set this up:
  1. Create a new transfer target. This is done by creating a new folder below Data Dictionary/Transfers/Transfer Target Groups/Default Group. When you have created the folder, edit its metadata and you will see a number of fields to fill in that identify the location of your target Alfresco server and the credentials for it. Make a note of the name of this new transfer target - you'll need it later

  2. In your target repository, create a Share site with the same name as the one in the editorial repository
After having done those two bits of setup, the next task is to write the code that's going to actually push the content to your new transfer target. This code will be triggered when the internal publish has occurred, so will hook into one of the new policies in the transfer service: "OnEndInboundTransferPolicy". I wrote a blog post about this a while ago.

I imagine the code will look something along the lines of this, but please be aware that this is just an outline that I just wrote for the purposes of this response - it is not tested, and is missing at least a couple of setters and error handling:


public class RemotePublisher
{
    private PolicyComponent policyComponent;
    private TransferService2 transferService;

    public void init()
    {
        policyComponent.bindClassBehaviour(
                TransferServicePolicies.OnEndInboundTransferPolicy.QNAME,
                TransferModel.TYPE_TRANSFER_RECORD,
                new JavaBehaviour(this, "onEndInboundTransferCommit", NotificationFrequency.TRANSACTION_COMMIT));
    }

    public void onEndInboundTransferCommit(String transferId, Set<NodeRef> createdNodes,
            Set<NodeRef> updatedNodes, Set<NodeRef> deletedNodes)
    {
        Set<NodeRef> nodesToTransfer = new HashSet<NodeRef>(359);
        nodesToTransfer.addAll(createdNodes);
        nodesToTransfer.addAll(updatedNodes);
        nodesToTransfer.addAll(deletedNodes);
       
        TransferDefinition transferDef = new TransferDefinition();
        transferDef.setNodes(nodesToTransfer);
        transferService.transferAsync("My Remote Target", transferDef);
    }
}
‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

The last line, where the transfer service is called, needs to have the name of your new transfer target as the first parameter (in place of "My Remote Target").

Hope that's useful.

lemmy
Champ in-the-making
Champ in-the-making
Thanks, Brain. This looks like a good solution. After reading your blog about the transfer service and the wiki about policies http://wiki.alfresco.com/wiki/Policy_Component one peace keeps unclear for me. I've understood that the transfer service calls OnEndInboundTransferPolicy for all registered policies. You want to hook there to use the transfer service to push the local repository to the remote.

The question is how and even more where to register this new policy.

Thanks,
Lemmy

bremmington
Champ on-the-rise
Champ on-the-rise
The "init" method of the outline class I posted earlier does the necessary binding to the policy. The line:

        policyComponent.bindClassBehaviour(
                TransferServicePolicies.OnEndInboundTransferPolicy.QNAME,
                TransferModel.TYPE_TRANSFER_RECORD,
                new JavaBehaviour(this, "onEndInboundTransferCommit", NotificationFrequency.TRANSACTION_COMMIT));
‍‍‍‍‍‍

will cause the policy framework to call the "onEndInboundTransferCommit" method on the RemotePublisher object when the transfer commits. When you wire this into the Spring application context as a bean, specify an "init-method". Something along the lines of:

   <bean id="myRemotePublisher" class="com.example.RemotePublisher" init-method="init">
      <property name="policyComponent" ref="policyComponent" />
      <property name="transferService" ref="transferService2" />
   </bean>
‍‍‍‍‍‍

This will cause Spring to invoke the "init" method once it has created the object.

aussen2
Champ in-the-making
Champ in-the-making
When working in a multi-server environment there is also the issue of synchronizing tags and categories across repositories. From my experience so far the Transfer Service is only handling content below Company Home. At least there is no option in the UI to set up a replication job that includes the categories associated with content. Even if the same categories (same in regard to name and path but not UUID) exist in the target repository the category assignments seem to get lost when synching.

Is there any way to synchronize the categories between two repositories in a way so they can be assigned on the editorial server and would still be assigned on the live server?

bremmington
Champ on-the-rise
Champ on-the-rise
Missed this last post - sorry.

In WQS we actually flatten tag values directly on to the web assets themselves so that, when published, the tag values remain. However, that aside, there's no reason why the transfer service can't transfer category / tag nodes - it can transfer any kind of node. It's not something I've tried, but if you write a new NodeFinder that traverses category properties and then alter the configuration of the publishing NodeCrawler to include it then that should work.

The WQS PublishService accepts an object that implements an interface named "NodeCrawlerConfigurer". There is currently one implementation of this interface: "WqsNodeCrawlerConfigurerImpl" that pulls together a selection of NodeFinder and NodeFilter objects that provide the default WQS behaviour. To add you new NodeFinder then you would define your own NodeCrawlerConfigurer class (probably derived from the WQS one) and replace the default configurer bean with an instance of your new configurer. The bean id that's relevant is "wqsmodule_publishingCrawlerConfigurer". The default definition for that bean is simply:


    <bean id="wqsmodule_publishingCrawlerConfigurer"
            class="org.alfresco.module.org_alfresco_module_wcmquickstart.publish.WqsNodeCrawlerConfigurerImpl" />
‍‍‍‍

However, as I said initially, tag values should be published without doing this. Hope that helps.