gt: 		Set<String> titles = new LinkedHashSet<String>();
context: package com.nixmash.blog.mvc.controller;
  
  import com.nixmash.blog.mvc.containers.Pager;
  import com.nixmash.blog.mvc.containers.ProductCategory;
  import com.nixmash.blog.mvc.containers.UserQuery;
  import com.nixmash.blog.solr.dto.ProductDTO;
  import com.nixmash.blog.solr.exceptions.GeoLocationException;
  import com.nixmash.blog.solr.model.Product;
  import com.nixmash.blog.solr.service.ProductService;
  import com.nixmash.blog.solr.utils.SolrUtils;
  import org.apache.commons.lang3.StringUtils;
  import org.slf4j.Logger;
  import org.slf4j.LoggerFactory;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.beans.support.PagedListHolder;
  import org.springframework.data.domain.Page;
  import org.springframework.data.domain.PageRequest;
  import org.springframework.data.solr.UncategorizedSolrException;
  import org.springframework.data.solr.core.query.result.FacetFieldEntry;
  import org.springframework.data.solr.core.query.result.FacetPage;
  import org.springframework.data.solr.core.query.result.HighlightPage;
  import org.springframework.stereotype.Controller;
  import org.springframework.ui.Model;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.annotation.*;
  import org.springframework.web.servlet.ModelAndView;
  
  import javax.servlet.http.HttpServletRequest;
  import java.text.MessageFormat;
  import java.util.*;
  
  import static java.lang.Math.toIntExact;
  import static org.springframework.web.bind.annotation.RequestMethod.GET;
  
  @Controller
  public class SolrController {
  
  	private final ProductService productService;
  
  	private static final Logger logger = LoggerFactory.getLogger(SolrController.class);
  
  	private static final String MODEL_ATTRIBUTE_PRODUCTS = "products";
  	private static final String MODEL_ATTRIBUTE_PRODUCT = "product";
  	private static final String MODEL_ATTRIBUTE_USERQUERY = "userQuery";
  	private static final String MODEL_ATTRIBUTE_PAGER = "pager";
  	private static final String MODEL_ATTRIBUTE_PRODUCT_CATEGORIES = "productCategories";
  	private static final String MODEL_ATTRIBUTE_CATEGORY = "category";
  
  	private static final int PRODUCT_LIST_PAGE_SIZE = 5;
  	private static final String PRODUCT_LIST_BASEURL = "/products/page/";
  
  	private static final String PRODUCT_LIST_VIEW = "products/list";
  	private static final String PRODUCT_SEARCH_VIEW = "products/search";
  	private static final String PRODUCT_CATEGORIES_VIEW = "products/categories";
  	private static final String PRODUCT_VIEW = "products/view";
  	private static final String PRODUCTS_BYCATEGORY_VIEW = "products/category";
  	private static final String PRODUCT_MAP_VIEW = "products/map";
  
  	private static final String SESSION_ATTRIBUTE_PRODUCTLIST = "productList";
  
  	private static final String LOCATION_ATTRIBUTE_NAME = "location";
  
  	private List<Product> locationProducts;
  
  	@Autowired
  	public SolrController(ProductService productService) {
  		this.productService = productService;
  	}
  
  	@RequestMapping(value = "/products/json", method = RequestMethod.GET)
  	public @ResponseBody List<Product> getProductsByLocation() {
  		return locationProducts;
  	}
  
  	@RequestMapping(value = "/products/map/bad", method = GET)
  	public ModelAndView badLocationMap(HttpServletRequest request) throws GeoLocationException {
  		return productMap(request, "35.453487-97.5184727");
  	}
  
  	@RequestMapping(value = "/products/map", method = GET)
  	public ModelAndView goodLocationMap(HttpServletRequest request) throws GeoLocationException {
  		return productMap(request, "35.453487,-97.5184727");
  	}
  
  	public ModelAndView productMap(HttpServletRequest request, String location) throws GeoLocationException {
  
  		request.setAttribute("location", location);
  		ModelAndView mav = new ModelAndView();
  		mav.addObject(LOCATION_ATTRIBUTE_NAME, location);
  
  		locationProducts = productService.getProductsByLocation(location);
  		logger.debug("Found {} products for location: {}", locationProducts.size(), location);
  
  		mav.setViewName(PRODUCT_MAP_VIEW);
  		return mav;
  	}
  
  	@RequestMapping(value = "/products")
  	public String productsRedirect(HttpServletRequest request) {
  		request.getSession().setAttribute(SESSION_ATTRIBUTE_PRODUCTLIST, null);
  		return "redirect:/products/page/1";
  	}
  
  	@SuppressWarnings("unchecked")
  	@RequestMapping(value = "/products/page/{pageNumber}", method = RequestMethod.GET)
  	public String pagedProductsPage(HttpServletRequest request, @PathVariable Integer pageNumber, Model uiModel) {
  
  		logger.debug("Showing paged products page # {}", pageNumber);
  		PagedListHolder<Product> pagedListHolder = (PagedListHolder<Product>) request.getSession()
  				.getAttribute(SESSION_ATTRIBUTE_PRODUCTLIST);
  
  		if (pagedListHolder == null) {
  			pagedListHolder = new PagedListHolder<Product>(productService.getProducts());
  			pagedListHolder.setPageSize(PRODUCT_LIST_PAGE_SIZE);
  
  		} else {
  
  			final int goToPage = pageNumber - 1;
  			if (goToPage <= pagedListHolder.getPageCount() && goToPage >= 0) {
  				pagedListHolder.setPage(goToPage);
  			}
  		}
  
  		request.getSession().setAttribute(SESSION_ATTRIBUTE_PRODUCTLIST, pagedListHolder);
  
  		uiModel.addAttribute(MODEL_ATTRIBUTE_PAGER, currentPage(pagedListHolder));
  		uiModel.addAttribute(MODEL_ATTRIBUTE_PRODUCTS, pagedListHolder);
  
  		return PRODUCT_LIST_VIEW;
  	}
  
  	@RequestMapping(value = "/products/search", method = GET)
  	public String productSearch(Model model) {
  		model.addAttribute(MODEL_ATTRIBUTE_USERQUERY, new UserQuery());
  		return PRODUCT_SEARCH_VIEW;
  	}
  
  	@RequestMapping(value = "/products/categories", method = RequestMethod.GET)
  	public String productCategories(Model model) {
  
  		FacetPage<Product> catfacetPage = productService.getFacetedProductsCategory();
  		Page<FacetFieldEntry> catPage = catfacetPage.getFacetResultPage(Product.CATEGORY_FIELD);
  
  		List<ProductCategory> results = new ArrayList<ProductCategory>();
  		for (FacetFieldEntry entry : catPage) {
  			results.add(new ProductCategory(entry.getValue(), toIntExact(entry.getValueCount())));
  		}
  
  		model.addAttribute(MODEL_ATTRIBUTE_PRODUCT_CATEGORIES, results);
  		return PRODUCT_CATEGORIES_VIEW;
  	}
  
  	@RequestMapping(value = "/products/categories/{category}", method = GET)
  	public String productByCategory(@PathVariable("category") String category, Model model) {
  		logger.debug("Showing product page for category: {}", category);
  
  		List<Product> found = productService.getProductsByCategory(category);
  		logger.debug("Found {} products for category: {}", found.size(), category);
  
  		model.addAttribute(MODEL_ATTRIBUTE_CATEGORY, StringUtils.capitalize(category));
  		model.addAttribute(MODEL_ATTRIBUTE_PRODUCTS, found);
  		return PRODUCTS_BYCATEGORY_VIEW;
  	}
  
  	@RequestMapping(value = "/products/list", method = RequestMethod.GET)
  	public String processFindForm(UserQuery userQuery, BindingResult result, Model model, HttpServletRequest request) {
  		List<Product> results = null;
  
  		Boolean isSimpleTermQuery = userQuery.getQuery().matches("[a-zA-Z_0-9 ]*");
  
  		if (StringUtils.isEmpty(userQuery.getQuery())) {
  			return "redirect:/products/search";
  		} else
  			try {
  				if (isSimpleTermQuery) {
  					HighlightPage<Product> highlightedResults = productService
  							.findByHighlightedNameCriteria(userQuery.getQuery());
  					results = SolrUtils.highlightPagesToList(highlightedResults);
  				} else {
  					results = productService.getProductsWithUserQuery(userQuery.getQuery());
  				}
  			} catch (UncategorizedSolrException ex) {
  				logger.info(MessageFormat.format("Bad Query: {0}", userQuery.getQuery()));
  				result.rejectValue("query", "product.search.error", new Object[] { userQuery.getQuery() }, "not found");
  				return PRODUCT_SEARCH_VIEW;
  			}
  
  		if (results.size() < 1) {
  			result.rejectValue("query", "product.search.noresults", new Object[] { userQuery.getQuery() }, "not found");
  			return PRODUCT_SEARCH_VIEW;
  		}
  
  		if (results.size() > 1) {
  			PagedListHolder<Product> pagedListHolder = new PagedListHolder<Product>(results);
  			pagedListHolder.setPageSize(PRODUCT_LIST_PAGE_SIZE);
  			request.getSession().setAttribute(SESSION_ATTRIBUTE_PRODUCTLIST, pagedListHolder);
  			return "redirect:/products/page/1";
  		} else {
  			Product product = results.iterator().next();
  			return "redirect:/products/" + product.getId();
  		}
  	}
  
  	@ResponseBody
  	@RequestMapping(value = "/products/autocomplete", produces = "application/json")
  	public Set<String> autoComplete(Model model, @RequestParam("term") String query) {
  		if (StringUtils.isBlank(query)) {
  			return Collections.emptySet();
  		}
  
  		PageRequest pageRequest = new PageRequest(0, 1);
  		FacetPage<Product> result = productService.autocompleteNameFragment(query, pageRequest);
  
  