001/* 002 * (C) Copyright 2006-2007 Nuxeo SAS <http://nuxeo.com> and others 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the Eclipse Public License v1.0 006 * which accompanies this distribution, and is available at 007 * http://www.eclipse.org/legal/epl-v10.html 008 * 009 * Contributors: 010 * Jean-Marc Orliaguet, Chalmers 011 * 012 * $Id$ 013 */ 014 015package org.nuxeo.theme.jsf.negotiation.engine; 016 017import javax.faces.context.FacesContext; 018 019import org.nuxeo.theme.Manager; 020import org.nuxeo.theme.jsf.negotiation.CookieManager; 021import org.nuxeo.theme.negotiation.Scheme; 022import org.nuxeo.theme.types.TypeFamily; 023 024public class CookieValue implements Scheme { 025 026 public String getOutcome(final Object context) { 027 final String engineName = CookieManager.getCookie("nxthemes.engine", 028 ((FacesContext) context).getExternalContext()); 029 if (engineName == null) { 030 return null; 031 } 032 if (Manager.getTypeRegistry().lookup(TypeFamily.ENGINE, engineName) != null) { 033 return engineName; 034 } 035 return null; 036 } 037}