package com.pm.server.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.pm.server.datatype.Coordinate;
import com.pm.server.player.Ghost;
import com.pm.server.player.GhostRepository;

@RestController
@RequestMapping("/ghost")
public class GhostControllerImpl implements GhostController {

	@Autowired
	private GhostRepository ghostRepository;

	@Override
	@RequestMapping(
			value="/integer",
			method=RequestMethod.GET
	)
	public int getInteger() {
		return 0;
	}

	// Returns map of ghost id to location
	@Override
	@RequestMapping(
			value="/locations",
			method=RequestMethod.GET
	)
	public Map<Integer, Coordinate> getAllLocations() {

		List<Ghost> ghosts = ghostRepository.getAllGhosts();

		Map<Integer, Coordinate> ghostsLocations =
				new HashMap<Integer, Coordinate>();

		for(Ghost ghost : ghosts) {
			ghostsLocations.put(ghost.getId(), ghost.getLocation());
		}

		return ghostsLocations;
	}

}
@@ -870,32 +870,68 @@
 equestMethod.GET
+,%0A%09%09%09produces=%7B %22application/json%22 %7D
 %0A%09)%0A%09public Map%3C
@@ -1114,16 +1114,40 @@
 te%3E();%0A%0A
+%09%09if(ghosts != null) %7B%0A%09
 %09%09for(Gh
@@ -1168,16 +1168,17 @@
 osts) %7B%0A
+%09
 %09%09%09ghost
@@ -1229,16 +1229,21 @@
 ion());%0A
+%09%09%09%7D%0A
 %09%09%7D%0A%0A%09%09r

Fix null exception if no ghosts found