Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2013 04:13 AM
I need to fetch external data in the repository, that is call http://example.com/fetch/some/json.
I need this both for a webscript (trigger manually) and a scheduled action.
In Share this is easy for webscripts via declaring remote endpoints. But how do I in the best way fetch external data repository side? I would prefere a way to do this with javascript.
There seem to be an older "left over" script here
http://localhost:8080/alfresco/service/sample/cmis/repo?service=servername
It uses var conn = remote.connect("alfresco"); but throws an error org.mozilla.javascript.EcmaError - ReferenceError: "remote" is not defined.
So I guess remote object is not available, can it be enabled? If so, can it be made available to a scheduled action as well?
I need this both for a webscript (trigger manually) and a scheduled action.
In Share this is easy for webscripts via declaring remote endpoints. But how do I in the best way fetch external data repository side? I would prefere a way to do this with javascript.
There seem to be an older "left over" script here
http://localhost:8080/alfresco/service/sample/cmis/repo?service=servername
It uses var conn = remote.connect("alfresco"); but throws an error org.mozilla.javascript.EcmaError - ReferenceError: "remote" is not defined.
So I guess remote object is not available, can it be enabled? If so, can it be made available to a scheduled action as well?
Labels:
- Labels:
-
Archive
1 ACCEPTED ANSWER
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2013 08:19 AM
Hello,
I think enhancing the webscripts.container bean should do the trick, e.g.
<blockcode>
<bean id="webscripts.container" class="org.alfresco.repo.web.scripts.RepositoryContainer" parent="webscripts.abstractcontainer">
<property name="name"><value>Repository</value></property>
<property name="scriptObjects">
<map merge="true">
<entry key="paging">
<ref bean="webscripts.js.paging"/>
</entry>
<entry key="remote">
<ref bean="webscripts.script.remote" />
</entry>
<entry key="cmis">
<ref bean="webscripts.js.cmis.client" />
</entry>
</map>
</property>
<!– more boring properties –>
</bean>
</blockcode>
I don't know about scheduled actions though, as the ScriptRemote class is not a valid processor extension and can not be added as a root object to the internal Rhino script processor.
Regards
Axel
I think enhancing the webscripts.container bean should do the trick, e.g.
<blockcode>
<bean id="webscripts.container" class="org.alfresco.repo.web.scripts.RepositoryContainer" parent="webscripts.abstractcontainer">
<property name="name"><value>Repository</value></property>
<property name="scriptObjects">
<map merge="true">
<entry key="paging">
<ref bean="webscripts.js.paging"/>
</entry>
<entry key="remote">
<ref bean="webscripts.script.remote" />
</entry>
<entry key="cmis">
<ref bean="webscripts.js.cmis.client" />
</entry>
</map>
</property>
<!– more boring properties –>
</bean>
</blockcode>
I don't know about scheduled actions though, as the ScriptRemote class is not a valid processor extension and can not be added as a root object to the internal Rhino script processor.
Regards
Axel
2 REPLIES 2
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-26-2013 08:19 AM
Hello,
I think enhancing the webscripts.container bean should do the trick, e.g.
<blockcode>
<bean id="webscripts.container" class="org.alfresco.repo.web.scripts.RepositoryContainer" parent="webscripts.abstractcontainer">
<property name="name"><value>Repository</value></property>
<property name="scriptObjects">
<map merge="true">
<entry key="paging">
<ref bean="webscripts.js.paging"/>
</entry>
<entry key="remote">
<ref bean="webscripts.script.remote" />
</entry>
<entry key="cmis">
<ref bean="webscripts.js.cmis.client" />
</entry>
</map>
</property>
<!– more boring properties –>
</bean>
</blockcode>
I don't know about scheduled actions though, as the ScriptRemote class is not a valid processor extension and can not be added as a root object to the internal Rhino script processor.
Regards
Axel
I think enhancing the webscripts.container bean should do the trick, e.g.
<blockcode>
<bean id="webscripts.container" class="org.alfresco.repo.web.scripts.RepositoryContainer" parent="webscripts.abstractcontainer">
<property name="name"><value>Repository</value></property>
<property name="scriptObjects">
<map merge="true">
<entry key="paging">
<ref bean="webscripts.js.paging"/>
</entry>
<entry key="remote">
<ref bean="webscripts.script.remote" />
</entry>
<entry key="cmis">
<ref bean="webscripts.js.cmis.client" />
</entry>
</map>
</property>
<!– more boring properties –>
</bean>
</blockcode>
I don't know about scheduled actions though, as the ScriptRemote class is not a valid processor extension and can not be added as a root object to the internal Rhino script processor.
Regards
Axel
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-27-2013 02:46 AM
Thanks, that makes the remote object available.
Since I'm developing a module I added this to my project
<code lang="xml">
<bean id="customSurfClientConfig" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
<property name="configService" ref="web.config" />
<property name="configs">
<list>
<value>classpath:alfresco/module/mymodule/context/surf-config.xml</value>
</list>
</property>
</bean>
</code>
and then in surf-config.xml
<code lang="xml">
<alfresco-config>
<config evaluator="string-compare" condition="Remote">
<remote>
<!– Define the endpoint for Presss –>
<endpoint>
<id>myservice</id>
<name>Myservice service</name>
<description>External service webb to retrieve data from</description>
<connector-id>http</connector-id>
<endpoint-url>http://www.examplecom</endpoint-url>
<identity>none</identity>
</endpoint>
</remote>
</config>
</alfresco-config>
</code>
and then i can use [font=Courier]var conn = remote.connect("myservice");[/font]
As for scheduling, I can probably use cron and curl to call the webscript.
Since I'm developing a module I added this to my project
<code lang="xml">
<bean id="customSurfClientConfig" class="org.springframework.extensions.config.ConfigBootstrap" init-method="register">
<property name="configService" ref="web.config" />
<property name="configs">
<list>
<value>classpath:alfresco/module/mymodule/context/surf-config.xml</value>
</list>
</property>
</bean>
</code>
and then in surf-config.xml
<code lang="xml">
<alfresco-config>
<config evaluator="string-compare" condition="Remote">
<remote>
<!– Define the endpoint for Presss –>
<endpoint>
<id>myservice</id>
<name>Myservice service</name>
<description>External service webb to retrieve data from</description>
<connector-id>http</connector-id>
<endpoint-url>http://www.examplecom</endpoint-url>
<identity>none</identity>
</endpoint>
</remote>
</config>
</alfresco-config>
</code>
and then i can use [font=Courier]var conn = remote.connect("myservice");[/font]
As for scheduling, I can probably use cron and curl to call the webscript.
