01: /**
02: * Copyright (c) 2006 Red Hat, Inc. All rights reserved.
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or any later version.
08: *
09: * This library is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public
15: * License along with this library; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
17: * USA
18: *
19: * Component of: Red Hat Application Server
20: *
21: * Initial Developers: Greg Lapouchnian
22: * Patrick Smith
23: *
24: */package olstore.controller;
25:
26: import java.util.HashMap;
27: import java.util.Map;
28:
29: import javax.servlet.http.HttpServletRequest;
30:
31: import olstore.domain.logic.OlstoreFacade;
32:
33: /**
34: * A helper class for initalizing a new model map.
35: */
36: public class ControllerHelper {
37:
38: /**
39: * Returns a default model map that sets all available types (for the left.jsp),
40: * the username, and if the user is an admin (also for left.jsp).
41: *
42: * @param request the HttpServletRequest object.
43: * @param olstore the olstore object.
44: */
45: public static Map initModel(HttpServletRequest request,
46: OlstoreFacade olstore) {
47: Map model = new HashMap();
48: model
49: .put("isAdmin", new Boolean(request
50: .isUserInRole("admin")));
51: model.put("types", olstore.getTypes());
52: model.put("userName", request.getRemoteUser());
53: return model;
54: }
55: }
|