Reputation: 2080
I know I may get down-voted for this trivial question...
In Javascript it is easy (even magical): remote.call("/api/...")
How do I get this in Java?
I read a lots of posts like this one, where the Alfresco (repository) URL is either hard coded http://localhost:8080/alfresco
, either undefined (exemple : REPO_WEB_SERVICE_URL
).
Is there a helper that could give me the URL of the repository? Is there a class that do the same as the remote
Javascript root object?
I’m sorry if the answer is obvious, I just can’t see it, I’m searching for hours already and I'm starting going crazy about it as it should be a no-brainer...
Upvotes: 2
Views: 2093
Reputation: 2080
Partial answer, in order to get the Alfresco Repository base path.
Inject the connectorService
into the bean:
<bean id="MyEvaluator" class="org.me.MyEvaluator">
<property name="connectorService" ref="connector.service" />
</bean>
Then in the class, retrieve the Alfresco endpoint:
String alfrescoEndPoint = connectorService.getConnector("alfresco").getEndpoint();
alfrescoEndPoint
will be something like http://host:port/alfresco/s
according to what was set in alfresco-global.properties
.
Upvotes: 1
Reputation: 1657
In order to make the remote available in your Share script you need to inject the remote using Spring.
Set a context file to set your remote variable:
<bean id="MyEvaluator" class="org.me.MyEvaluator">
<property name="remote" ref="webframework.webscripts.scriptremote" />
</bean>
Then you need to create the variable in your Java class. Given that you can use it as you like:
public class MyEvaluator extends BaseEvaluator {
private ScriptRemote remote;
public void setRemote(ScriptRemote remote) {
this.remote = remote;
}
public void doScriptCall() {
Response response = remote.call("/api/...");
}
}
Upvotes: 5