Question

I have created a rest service in a java application . I need to call this rest service on the click of a button in Alfresco Share page . How do i approacj it . Can i directly call the service with the url ?

Was it helpful?

Solution

You can add a custom endpoint to SURF & use the SURF Proxy-Servlet: Example Flickr Endpoint share-config-custom.xml:

<alfresco-config>
   <config evaluator="string-compare" condition="Remote">
      <remote>       
         <endpoint>
            <id>flickr</id>
            <name>flickr - unauthenticated access for oembed resolution</name>
            <description>Access flickr to resolve URLs to embed presentations.</description>
            <connector-id>http</connector-id>
            <endpoint-url>http://www.flickr.com/services</endpoint-url>
            <identity>none</identity>
         </endpoint>         
      </remote>
   </config>
</alfresco-config>

In Browser JS Code just use the flickr endpoint via PROXY, e.g. add a new va PROXY_FLICKR_API :

var PROXY_FLICKR_API = Alfresco.constants.PROXY_URI.replace("/alfresco/", "/flickr/");
Alfresco.util.Ajax.jsonRequest(
     {
        method: Alfresco.util.Ajax.GET,
        url: PROXY_FLICKR_API + "add your concrete URL",
        successCallback:
        {
           ...
        },
        failureCallback:
        {
           ...
        }
     });

You should add your var PROXY_FLICKR_API JS declaration via SURF Extension mechanism - your target markupid is (more details http://blogs.alfresco.com/wp/developer/2012/05/22/customizing-share-javascript-widget-instantiation-part-1/):

<@markup id="yourid" target="resources" action="after">
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top