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.compat.negotiators; 016 017import org.jboss.seam.Component; 018import org.nuxeo.ecm.core.api.DocumentModel; 019import org.nuxeo.runtime.api.Framework; 020import org.nuxeo.theme.localconfiguration.LocalThemeConfig; 021import org.nuxeo.theme.localconfiguration.LocalThemeHelper; 022import org.nuxeo.theme.negotiation.Scheme; 023import org.nuxeo.theme.perspectives.PerspectiveManager; 024import org.nuxeo.theme.perspectives.PerspectiveType; 025 026/** 027 * Negotiation scheme for obtaining the local perspective from the current document. 028 * 029 * @author <a href="mailto:jmo@chalmers.se">Jean-Marc Orliaguet</a> 030 * @deprecated since 5.5: use local theme flavour instead 031 */ 032@Deprecated 033public class LocalPerspective implements Scheme { 034 035 /** 036 * Called by the theme negotiation module. 037 * 038 * @return the local theme associated to the current space (workspace, section, ...) as a 'theme/page' string. 039 * Return null otherwise. 040 */ 041 public String getOutcome(Object context) { 042 Boolean useOldThemeConf = Boolean.valueOf(Framework.getProperty(LocalThemeConfig.OLD_THEME_CONFIGURATION_PROPERTY)); 043 if (Boolean.FALSE.equals(useOldThemeConf)) { 044 return null; 045 } 046 047 DocumentModel currentSuperSpace = (DocumentModel) Component.getInstance("currentSuperSpace"); 048 if (currentSuperSpace == null) { 049 return null; 050 } 051 052 // Get the placeful local theme configuration for the current 053 // workspace. 054 LocalThemeConfig localThemeConfig = LocalThemeHelper.getLocalThemeConfig(currentSuperSpace); 055 if (localThemeConfig == null) { 056 return null; 057 } 058 059 // Extract the perspective 060 String perspectiveName = localThemeConfig.getPerspective(); 061 if (perspectiveName == null) { 062 return null; 063 } 064 065 // Look up the perspective 066 PerspectiveType perspective = PerspectiveManager.getPerspectiveByName(perspectiveName); 067 if (perspective != null) { 068 return perspectiveName; 069 } 070 return null; 071 } 072 073}