/**
 * Copyright (c) 2006 Red Hat, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 * USA
 *
 * Component of: Red Hat Application Server
 * 
 * Initial Developers: Greg Lapouchnian
 *                     Patrick Smith
 *
 */

package olstore.controller;

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

import javax.servlet.http.HttpServletRequest;

import olstore.domain.logic.OlstoreFacade;


/**
 * A helper class for initalizing a new model map.
 */
public class ControllerHelper {
    
	/**
	 * Returns a default model map that sets all available types (for the left.jsp), 
	 * the username, and if the user is an admin (also for left.jsp).
	 * 
	 * @param request the HttpServletRequest object.
	 * @param olstore the olstore object.
	 */
	public static Map initModel(HttpServletRequest request, OlstoreFacade olstore) {
        Map model = new HashMap();
        model.put("isAdmin", new Boolean(request.isUserInRole("admin")));
        model.put("types", olstore.getTypes());
        model.put("userName", request.getRemoteUser());
        return model;
    }
}
