package solysombra.api.resource;
import javax.ws.rs.NotFoundException;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import org.restlet.resource.Get;
import solysombra.domain.PlaceList;
import solysombra.repository.MapPlaceListRepository;
import solysombra.repository.PlaceListRepository;
@Path("/places/{user}")
public class PlaceListResource {
private final static @PathParam("user")String user = "Default";
//singleton
private static PlaceListResource _instance=null;
PlaceListRepository repository;
private PlaceListResource(){
repository = new MapPlaceListRepository();
initialize();
}
public static PlaceListResource getInstance(){
if(_instance==null) _instance = new PlaceListResource();
return _instance;
}
//a�adimos datos para el test en el repositorio
private void initialize(){
//TODO METODO INITIALIZE
PlaceList favoritos = new PlaceList();
favoritos.setName("Favoritos");
favoritos.setDescription("Lista de favoritos");
}
//TODO A�adir anotaciones
// @GET
// @Produces("application/json")
// public Collection<PlaceList> getAll(){
// return repository.getAll();
// }
@Get
@Produces("application/json")
public PlaceList getPlaceListFav(){
String name = "Favoritos";
PlaceList list = repository.get(name);
if(list==null){
throw new NotFoundException("La lista "+name+" no ha sido encontrada");
}
return list;
}
}