cancel
Showing results for 
Search instead for 
Did you mean: 

TransferServicePolicies

jainkumar11
Champ in-the-making
Champ in-the-making
Hi All,
I have tried implementing following policies in below sample code.
I have registered the bean in XML file and copied in alfresco\tomcat\webapps\share\WEB-INF\classes\alfresco\extension folder
public class SampleTargetService implements TransferServicePolicies.OnStartInboundTransferPolicy, TransferServicePolicies.OnEndInboundTransferPolicy
{
   @Override
   public void onStartInboundTransfer(String arg0) {
      System.out.println("onStartInboundTransfer");
   }
   @Override
   public void onEndInboundTransfer(String arg0, Set<NodeRef> arg1,
         Set<NodeRef> arg2, Set<NodeRef> arg3) {
      System.out.println("End Inbound");
   }
   @Override
   public void processEvent(TransferEvent arg0) {
      System.out.println("Process event method.");
   }
}

After doing this, Events are not getting called even when my replication job gets completed. Any idea what I am doing wrong!!!!!
Can someone suggest when will these policies actually gets fired.

Thanks KJ
2 REPLIES 2

mrogers
Star Contributor
Star Contributor
You have put your file in the wrong place.   (Never touch anything below WEB-INF)

And your code is missing binding your methods to the class policy   policyComponent.bindClassBehaviour.  

Study RepoTransferReceiverImplTest if you need an example.

jainkumar11
Champ in-the-making
Champ in-the-making
I tried doing following.

/**
*
*/
package com.test.behavior;

import java.util.Set;

import org.alfresco.repo.policy.Behaviour.NotificationFrequency;
import org.alfresco.repo.policy.ClassPolicyDelegate;
import org.alfresco.repo.policy.JavaBehaviour;
import org.alfresco.repo.policy.PolicyComponent;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.transfer.TransferCallback;
import org.alfresco.service.cmr.transfer.TransferEvent;
import org.alfresco.service.cmr.transfer.TransferServicePolicies;
import org.alfresco.service.cmr.transfer.TransferServicePolicies.BeforeStartInboundTransferPolicy;
import org.alfresco.service.cmr.transfer.TransferServicePolicies.OnEndInboundTransferPolicy;
import org.alfresco.service.cmr.transfer.TransferServicePolicies.OnStartInboundTransferPolicy;
import org.alfresco.service.namespace.NamespaceService;
import org.alfresco.service.namespace.QName;

/**
* @author test
*
*/
public class SampleTargetService implements
   TransferServicePolicies.OnStartInboundTransferPolicy,
   TransferServicePolicies.OnEndInboundTransferPolicy, TransferCallback
{
   private PolicyComponent policyComponent;
   private NodeService nodeService;
   private JavaBehaviour onStartInboundTransfer;

    public void init() throws Exception{
           System.out.println("Inside init()…..I am in……………………………………");
           // Create behaviours
           this.onStartInboundTransfer = new JavaBehaviour(this, "onStartInboundTransfer", NotificationFrequency.EVERY_EVENT);
                 System.out.println("NamespaceService.ALFRESCO_URI="+NamespaceService.ALFRESCO_URI);
           // Bind behaviours to node policies
          this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onStartInboundTransfer"), this, this.onStartInboundTransfer);   
   }   
   
   @Override
   public void onStartInboundTransfer(String arg0) {
      System.out.println("onStartInboundTransfer");      
   }

   @Override
   public void onEndInboundTransfer(String arg0, Set<NodeRef> arg1,
         Set<NodeRef> arg2, Set<NodeRef> arg3) {
      System.out.println("End Inbound");
   }

   @Override
   public void processEvent(TransferEvent arg0) {
      System.out.println("Process event method.");
   }
    public NodeService getNodeService() {
           return nodeService;
       }
       public void setNodeService(NodeService nodeService) {
           this.nodeService = nodeService;
       }
       public PolicyComponent getPolicyComponent() {
           return policyComponent;
       }
       public void setPolicyComponent(PolicyComponent policyComponent) {
           this.policyComponent = policyComponent;
       }
}

My init method logges gets printed but when I run my replication job other methods are not called.
Getting started

Tags


Find what you came for

We want to make your experience in Hyland Connect as valuable as possible, so we put together some helpful links.