如何从Share in Java中调用Alfresco(存储库)webscript

bou*_*mbh 2 java web-services alfresco alfresco-share

我知道我可能会因为这个微不足道的问题而被投票......

在Javascript中它很容易(甚至是神奇的): remote.call("/api/...")

我如何用Java获得这个?

我阅读了很多像这样的帖子,其中Alfresco(存储库)URL是硬编码的http://localhost:8080/alfresco,或者是未定义的(例如:) REPO_WEB_SERVICE_URL.

是否有帮助器可以提供存储库的URL?是否有一个类与remoteJavascript根对象相同?

我很抱歉,如果答案很明显,我就是看不到它,我已经找了好几个小时了,我开始疯狂了,因为它应该是一个不用脑子的...

Mar*_*doz 5

为了使您的Share脚本中的远程可用,您需要使用Spring注入远程.

设置上下文文件以设置远程变量:

<bean id="MyEvaluator" class="org.me.MyEvaluator">
    <property name="remote" ref="webframework.webscripts.scriptremote" />
</bean>
Run Code Online (Sandbox Code Playgroud)

然后,您需要在Java类中创建变量.鉴于您可以随意使用它:

public class MyEvaluator extends BaseEvaluator {

    private ScriptRemote remote;

    public void setRemote(ScriptRemote remote) {
        this.remote = remote;
    }

    public void doScriptCall() {
        Response response = remote.call("/api/...");
    }

}
Run Code Online (Sandbox Code Playgroud)