HWBOT
  1. HWBOT
  2. HWBOT-937

Add support for json callback to API

    Details

    • Type: Story Story
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: hwbot v5, hwbot v5.4.0
    • Labels:
      None

      Description

      I wanted to write a simple example on how to request a benchmark ranking and integrate it on a site using jquery. The problem is that do this, you need to provide a callback function (so designed to prevent XSS). Spring doesn't seem to provide anything for this, so I made something myself. in webmvc-config.xml I changed the default JacksonJsonView:
              <property name="defaultViews">
                  <list>
                      <bean class="org.hwbot.web.servlet.MappingJacksonJsonpView">
                       <property name="objectMapper" ref="jacksonObjectMapper" />
                      </bean>
                  </list>

      This class basically checks if there's a jsoncallback parameter and if so surrounds the JSON output with the callback function. Only thing is, it doesn't work.
      curl -i -H "Accept: application/json" "http://uat.hwbot.org/api/ranking?application=aquamark&limit=1&jsoncallback=callback" -> JSON not surrounded by the callback function
      However if the JSON output is an exception, it DOES work:
      curl -i -H "Accept: application/json" "http://uat.hwbot.org/api/ranking?application=fail&limit=1&jsoncallback=callback" -> callback({"exception":{...});

       

        Activity

        Hide
        Frederik Colardyn added a comment -
        I suggest you enable trace logging in log4j for ContentNegotiatingViewResolver to see why it doesn't choose your custom JacksonPView.
        Show
        Frederik Colardyn added a comment - I suggest you enable trace logging in log4j for ContentNegotiatingViewResolver to see why it doesn't choose your custom JacksonPView.
        Hide
        Build Server added a comment -
        Integrated in HWBOT v4 #2716 (See [http://dev.hwbot.org/job/HWBOT%20v4/2716/])
            HWBOT-937

        Add support for json callback to API

        dennis :
        Files :
        * /hwbot/trunk/src/main/java/org/hwbot/web/servlet/MappingJacksonJsonpView.java
        * /hwbot/trunk/src/main/resources/spring/webmvc-config.xml
        * /hwbot/trunk/src/main/java/org/hwbot/web/util/MappingJacksonJsonpHttpMessageConverter.java
        * /hwbot/trunk/src/main/java/org/hwbot/web/actions/GenericApiResponse.java
        * /hwbot/trunk/src/main/java/org/hwbot/web/actions/ApiController.java
        Show
        Build Server added a comment - Integrated in HWBOT v4 #2716 (See [ http://dev.hwbot.org/job/HWBOT%20v4/2716/ ])      HWBOT-937 Add support for json callback to API dennis : Files : * /hwbot/trunk/src/main/java/org/hwbot/web/servlet/MappingJacksonJsonpView.java * /hwbot/trunk/src/main/resources/spring/webmvc-config.xml * /hwbot/trunk/src/main/java/org/hwbot/web/util/MappingJacksonJsonpHttpMessageConverter.java * /hwbot/trunk/src/main/java/org/hwbot/web/actions/GenericApiResponse.java * /hwbot/trunk/src/main/java/org/hwbot/web/actions/ApiController.java
        Hide
        Build Server added a comment -
        Integrated in HWBOT v4 #2718 (See [http://dev.hwbot.org/job/HWBOT%20v4/2718/])
            HWBOT-937

        Add support for json callback to API

        dennis :
        Files :
        * /hwbot/trunk/src/main/resources/spring/webmvc-config.xml
        Show
        Build Server added a comment - Integrated in HWBOT v4 #2718 (See [ http://dev.hwbot.org/job/HWBOT%20v4/2718/ ])      HWBOT-937 Add support for json callback to API dennis : Files : * /hwbot/trunk/src/main/resources/spring/webmvc-config.xml
        Hide
        Build Server added a comment -
        Integrated in HWBOT v4 #2719 (See [http://dev.hwbot.org/job/HWBOT%20v4/2719/])
            HWBOT-937

        Add support for json callback to API

        dennis :
        Files :
        * /hwbot/trunk/src/main/java/org/hwbot/web/actions/ApiController.java
        Show
        Build Server added a comment - Integrated in HWBOT v4 #2719 (See [ http://dev.hwbot.org/job/HWBOT%20v4/2719/ ])      HWBOT-937 Add support for json callback to API dennis : Files : * /hwbot/trunk/src/main/java/org/hwbot/web/actions/ApiController.java
        Hide
        Dennis Devriendt added a comment -
        Functionality added and also added an example to the API docs on how to easily integrate a benchmark ranking on a website, using JQuery.
        Show
        Dennis Devriendt added a comment - Functionality added and also added an example to the API docs on how to easily integrate a benchmark ranking on a website, using JQuery.
        Hide
        Build Server added a comment -
        Integrated in HWBOT v4 #2720 (See [http://dev.hwbot.org/job/HWBOT%20v4/2720/])
            HWBOT-937

        Add support for json callback to API

        dennis :
        Files :
        * /hwbot/trunk/src/main/java/org/hwbot/model/dto/ApiSubmissionInfo.java
        * /hwbot/trunk/src/main/java/org/hwbot/model/dto/ApiMemberInfo.java
        * /hwbot/trunk/src/main/java/org/hwbot/model/dto/ApiRankingInfo.java
        Show
        Build Server added a comment - Integrated in HWBOT v4 #2720 (See [ http://dev.hwbot.org/job/HWBOT%20v4/2720/ ])      HWBOT-937 Add support for json callback to API dennis : Files : * /hwbot/trunk/src/main/java/org/hwbot/model/dto/ApiSubmissionInfo.java * /hwbot/trunk/src/main/java/org/hwbot/model/dto/ApiMemberInfo.java * /hwbot/trunk/src/main/java/org/hwbot/model/dto/ApiRankingInfo.java

          People

          • Assignee:
            Dennis Devriendt
            Reporter:
            Dennis Devriendt
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: