如何从Alfresco脚本启动FTR复制作业 [英] How to start an FTR Replication Job from Alfresco Script

查看:112
本文介绍了如何从Alfresco脚本启动FTR复制作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

与本主题一样,我已经配置了文件传输复制作业,可以手动运行。

As in the subject, I have an already configured File Transfer Replication Job, which I am able to run manually.

现在,我想从以下位置启动它脚本(不是Web脚本或Java)的结尾。但是,我找不到有关如何实现此目的的文档或示例。我在官方文档中发现了一个Transfer对象,但是我找不到更多API详细信息。

Now, I would like to start it at the end of a Script (not a Web Script or Java). However I cannot find documentation or example on how to achieve this. I have spot a Transfer object in the official documentation, but I have not been able to found any more API details.

我的Alfresco版本是4.2。

My Alfresco version is 4.2.

推荐答案

花了我一段时间才弄清楚,但最终我找到了两个解决方案。

It took me a while to figure it out, but eventually I found two solutions.

第一个解决方案

有关根对象部分,其中有一个 replicationService 映射到 org .alfresco.repo.replication.script.ScriptReplicationService ,但实际上并没有说太多。

At the official documentation regarding the Root Objects part there is a replicationService which maps to org.alfresco.repo.replication.script.ScriptReplicationService but it really doesn't say much.

如果您熟悉Alfresco,则可以通过进入Alfresco文件夹来找到impl类,然后打开 WEB-INF / classes / alfresco / replication-services-context.xml 。我已经猜到了文件名,但是您可以使用replicationService作为键来搜索所有xml文件。这是相关的部分:

If you are familiar with Alfresco, you can track down to the impl class by going into Alfresco folder and open WEB-INF/classes/alfresco/replication-services-context.xml. I have guessed the file name, but you can do a search of all xml files with replicationService as key. Here is the relevant part:

   <bean id="replicationService" class="org.alfresco.repo.replication.ReplicationServiceImpl" >
      <property name="actionService" ref="ActionService"/>
      <property name="scheduledPersistedActionService" ref="scheduledPersistedActionService" />
      <property name="replicationDefinitionPersister" ref="replicationDefinitionPersister" />
   </bean>

如果打开源代码或API,则可以发现相关方法: loadReplicationDefinitions(String target)其中target是在复制作业中配置的目标的名称,而 replicate(ReplicationDefinitionplicationDefinition)可以从中调用一个脚本。

If you open the source code or the API you can spot the relevant methods: loadReplicationDefinitions(String target) where target is the name of the target configured in the Replication Job and replicate(ReplicationDefinition replicationDefinition) which can be invoked from a Script.

最后是调用您的复制作业的片段。

In the end this is the fragment that invoke your replication job.

var jobs = replicationService.loadReplicationDefinitions('MyTargetName');
var job = jobs[0]; // I only have one target with that name, it safe to get 0
replicationService.replicate(job);

就是这样,您的内容已转移。

That's it, your content is transferred.

第二个解决方案

另一个不太容易的选择是调用转移根对象(复制服务所依赖的对象)也可以工作,但是您必须手动构建要传输的ScriptNode数组。

One other not so easy option is to invoke the transfer root object, which is the object the replication service rely on, it works too but then you have to manually build your array of ScriptNodes to be transferred.

var nodes = // your array of ScriptNodes
transfer.transfer('MyTargetName', nodes);

如果走得更远,您还可以异步调用并进行回调,但是我没有做任何尝试还没。

If you go further you can also invoke asynchronously and have your callback, but I didn't experiment on it yet.

这篇关于如何从Alfresco脚本启动FTR复制作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆