package com.itkweb.bbtv.channels.services.sample;

import com.itkweb.bbtv.channels.apis.Channel;
import com.itkweb.bbtv.channels.apis.ChannelMeta;
import org.apache.felix.ipojo.annotations.Component;
import org.apache.felix.ipojo.annotations.Instantiate;
import org.apache.felix.ipojo.annotations.Provides;
import org.wisdom.api.DefaultController;
import org.wisdom.api.annotations.View;
import org.wisdom.api.http.Result;
import org.wisdom.api.templates.Template;

/**
 * Created by rmaneschi on 06/03/15.
 */
@Component
@Provides(specifications = Channel.class)
@Instantiate
public class JugChannel extends DefaultController implements Channel {

    private ChannelMeta meta = new ChannelMeta(JugChannel.class.getName(), "/assets/images/logo-jug.png", "JUG");

    @View("jug-channel")
    Template jugChannel;

    @Override
    public Result result() {
        return ok(render(jugChannel));
    }

    @Override
    public ChannelMeta getMeta() {
        return meta;
    }

}

@@ -44,16 +44,110 @@
 ample;%0A%0A
+import com.fasterxml.jackson.core.JsonParser;%0Aimport com.fasterxml.jackson.databind.JsonNode;%0A
 import c
@@ -184,16 +184,16 @@
 hannel;%0A
-
 import c
@@ -394,16 +394,68 @@
 ovides;%0A
+import org.apache.felix.ipojo.annotations.Requires;%0A
 import o
@@ -527,16 +527,52 @@
 s.View;%0A
+import org.wisdom.api.content.Json;%0A
 import o
@@ -641,16 +641,201 @@
 plate;%0A%0A
+import java.io.BufferedReader;%0Aimport java.io.IOException;%0Aimport java.io.InputStreamReader;%0Aimport java.net.MalformedURLException;%0Aimport java.net.URL;%0Aimport java.net.URLConnection;%0A%0A
 /**%0A * C
@@ -1124,16 +1124,46 @@
 JUG%22);%0A%0A
+    @Requires%0A    Json json;%0A%0A
     @Vie
@@ -1244,24 +1244,566 @@
  result() %7B%0A
+        URL yahoo = null;%0A        try %7B%0A            yahoo = new URL(%22http://jug-montpellier.org/api/events.json%22);%0A            URLConnection yc = yahoo.openConnection();%0A            BufferedReader in = new BufferedReader(new InputStreamReader(yc.getInputStream()));%0A            String inputLine;%0A            StringBuilder sb = new StringBuilder();%0A            while ((inputLine = in.readLine()) != null) %7B%0A                sb.append(inputLine);%0A            %7D%0A            in.close();%0A            JsonNode node = json.parse(sb.toString());%0A%0A    
         retu
@@ -1808,16 +1808,24 @@
 turn ok(
+node);//
 render(j
@@ -1833,24 +1833,215 @@
 gChannel));%0A
+        %7D catch (MalformedURLException e) %7B%0A            e.printStackTrace();%0A        %7D catch (IOException e) %7B%0A            e.printStackTrace();%0A        %7D%0A%0A        return badRequest(%22Error%22);%0A
     %7D%0A%0A    @

call json in channel