package org.dukecon.server.core;

import org.dukecon.server.conference.ConferenceDataProvider;
import org.springframework.stereotype.Component;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;

/**
 * @author Niko Köbler, http://www.n-k.de, @dasniko
 */
@Component
@Path("meta")
public class MetaService {
    @Inject
    List<ConferenceDataProvider> talkProviders;

    @GET
    @Produces(MediaType.APPLICATION_JSON)
    public Response getMeta() {
        String id = "499959"; //hardcoded to Javaland for now
        Optional<ConferenceDataProvider> provider = talkProviders.stream().filter( p -> p.getConference().getId().equals(id)).findFirst();
        return Response.ok().entity(provider.get().getConference().getMetaData()).build();
    }

    @GET
    @Path("ping")
    public Response ping() {
        Map<String, String> m = new HashMap<>(1);
        m.put("last_updated", "2015-05-19T16:20:11");
        return Response.ok().entity(m).build();
    }
}

@@ -215,16 +215,46 @@
 s.Path;%0A
+import javax.ws.rs.PathParam;%0A
 import j
@@ -562,209 +562,304 @@
     
-@Inject%0A    List%3CConferenceDataProvider%3E talkProviders;%0A%0A    @GET%0A    @Produces(MediaType.APPLICATION_JSON)%0A    public Response getMeta() %7B%0A        String id = %22499959%22; //hardcoded to Javaland for now
+List%3CConferenceDataProvider%3E talkProviders;%0A%0A    @Inject%0A    MetaService(List%3CConferenceDataProvider%3E talkProviders) %7B%0A        this.talkProviders = talkProviders;%0A    %7D%0A%0A    @GET%0A    @Path(%22%7Bid%7D%22)%0A    @Produces(MediaType.APPLICATION_JSON)%0A    public Response getMeta(@PathParam(%22id%22) String id) %7B
 %0A   
@@ -937,17 +937,16 @@
 .filter(
- 
 p -%3E p.g
@@ -989,24 +989,64 @@
 indFirst();%0A
+        if (provider.isPresent()) %7B%0A    
         retu
@@ -1120,24 +1120,294 @@
 )).build();%0A
+        %7D%0A        return Response.status(Response.Status.NOT_FOUND).build();%0A    %7D%0A%0A    @Deprecated%0A    @GET%0A    @Produces(MediaType.APPLICATION_JSON)%0A    public Response getMeta() %7B%0A        String id = %22499959%22; //hardcoded to Javaland 2016%0A        return getMeta(id);%0A
     %7D%0A%0A    @

Make MetaService work for other conferences as well