1 /**************************************************************************
2 Copyright 2005 Webstersmalley
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15 *************************************************************************/
16
17
18
19 package com.webstersmalley.picweb.online.web;
20
21 import java.io.IOException;
22 import java.util.HashMap;
23 import java.util.Map;
24
25 import javax.servlet.ServletException;
26 import javax.servlet.http.HttpServlet;
27 import javax.servlet.http.HttpServletRequest;
28 import javax.servlet.http.HttpServletResponse;
29
30 import org.apache.commons.logging.Log;
31 import org.apache.commons.logging.LogFactory;
32 import org.springframework.web.servlet.ModelAndView;
33 import org.springframework.web.servlet.mvc.Controller;
34
35 import com.webstersmalley.picweb.online.bus.Category;
36 import com.webstersmalley.picweb.online.bus.CategoryManager;
37
38 public class BrowserController implements Controller {
39 /*** Logger for this class and subclasses */
40 protected final Log logger = LogFactory.getLog(getClass());
41
42 private CategoryManager categoryManager;
43
44 public ModelAndView handleRequest(HttpServletRequest request,
45 HttpServletResponse response) throws ServletException, IOException {
46 Map model = new HashMap();
47
48 model.put("categories", categoryManager.getRootCategories());
49 logger.info("Forwarding to jsp now");
50 return new ModelAndView("ListCategories", "model", model);
51 }
52
53 /***
54 * @return Returns the catMan.
55 */
56 public CategoryManager getCategoryManager() {
57 return categoryManager;
58 }
59
60 /***
61 * @param catMan
62 * The catMan to set.
63 */
64 public void setCategoryManager(CategoryManager categoryManager) {
65 this.categoryManager = categoryManager;
66 }
67
68 }