001/* 002 * (C) Copyright 2011 Nuxeo SA (http://nuxeo.com/) and contributors. 003 * 004 * All rights reserved. This program and the accompanying materials 005 * are made available under the terms of the GNU Lesser General Public License 006 * (LGPL) version 2.1 which accompanies this distribution, and is available at 007 * http://www.gnu.org/licenses/lgpl.html 008 * 009 * This library is distributed in the hope that it will be useful, 010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 012 * Lesser General Public License for more details. 013 * 014 * Contributors: 015 * Anahide Tchertchian 016 */ 017package org.nuxeo.ecm.webapp.helpers; 018 019import static org.jboss.seam.annotations.Install.FRAMEWORK; 020 021import org.jboss.seam.ScopeType; 022import org.jboss.seam.annotations.In; 023import org.jboss.seam.annotations.Install; 024import org.jboss.seam.annotations.Name; 025import org.jboss.seam.annotations.Scope; 026import org.nuxeo.runtime.api.Framework; 027import org.nuxeo.runtime.services.config.ConfigurationService; 028 029/** 030 * Seam component that exposes getters for properties managed by the {@link ConfigurationService} or the runtime 031 * {@link Framework}. 032 * 033 * @since 5.5 034 */ 035@Name("frameworkPropertyActions") 036@Scope(ScopeType.STATELESS) 037@Install(precedence = FRAMEWORK) 038public class FrameworkPropertyActions { 039 040 @In(create = true) 041 protected transient ConfigurationService configurationService; 042 043 /** 044 * Returns the given property value from the {@link ConfigurationService} if any, otherwise null. 045 */ 046 public String getProperty(String propertyName) { 047 return configurationService.getProperty(propertyName); 048 } 049 050 /** 051 * Returns the given property value from the {@link ConfigurationService} if any, otherwise the given default value. 052 */ 053 public String getProperty(String propertyName, String defaultValue) { 054 return configurationService.getProperty(propertyName, defaultValue); 055 } 056 057 /** 058 * Returns true if given property has been setup to true (defaults to false if not set). 059 * 060 * @since 5.8 061 * @see {@link ConfigurationService#isBooleanPropertyTrue(String)} 062 */ 063 public boolean isBooleanPropertyTrue(String propertyName) { 064 return configurationService.isBooleanPropertyTrue(propertyName); 065 } 066 067 /** 068 * Returns the given property value from the {@link Framework} if any, otherwise null. 069 * 070 * @since 7.4 071 */ 072 public String getFrameworkProperty(String key) { 073 return Framework.getProperty(key); 074 } 075 076 /** 077 * Returns the given property value from the {@link Framework} if any, otherwise the given default value. 078 * 079 * @since 7.4 080 */ 081 public String getFrameworkProperty(String key, String defValue) { 082 return Framework.getProperty(key, defValue); 083 } 084 085}