package io.pivotal.pso.client;

import io.pivotal.pso.client.domain.KeyValue;
import io.pivotal.pso.client.service.MapService;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class MapController {
	
	@Autowired
	MapService mapService;
	
	Logger logger = LoggerFactory.getLogger(MapController.class);
	
	@RequestMapping(value = "/map", method=RequestMethod.GET)
	public String getKey(Model model){
		model.addAttribute("keyValue", new KeyValue());
		model.addAttribute("keyValues", mapService.getKeyValues());
		return "map";
	}
	
	@RequestMapping(value = "/map", method=RequestMethod.POST)
	public String putKeyValue(@ModelAttribute("keyValue") KeyValue keyValue){
		mapService.putKeyValue(keyValue);
		return "redirect:map";
	}
	
	@RequestMapping(value = "/getKey/{key}", method=RequestMethod.POST)
	public @ResponseBody String putKeyValue(@PathVariable String key){
		return mapService.getValue(key);
	}
	
	
}

@@ -121,16 +121,39 @@
 rvice;%0A%0A
+import java.util.Map;%0A%0A
 import o
@@ -1229,32 +1229,176 @@
 rect:map%22;%0A%09%7D%0A%09%0A
+%09@RequestMapping(value = %22/env%22, method=RequestMethod.GET)%0A%09@ResponseBody%0A%09public Map%3CString, String%3E getEnv()%7B%0A%09%09return System.getenv();%0A%09%7D%09%0A%09%0A
 %09@RequestMapping

add the environment variables on the ur