001/*
002 * (C) Copyright 2006-2009 Nuxeo SAS (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 *     Nuxeo - initial API and implementation
016 *
017 * $Id$
018 */
019
020package org.nuxeo.ecm.webapp.helpers;
021
022import static org.jboss.seam.annotations.Install.FRAMEWORK;
023
024import java.io.Serializable;
025
026import org.jboss.seam.ScopeType;
027import org.jboss.seam.annotations.Factory;
028import org.jboss.seam.annotations.Install;
029import org.jboss.seam.annotations.Name;
030import org.jboss.seam.annotations.Scope;
031import org.joda.time.DateTime;
032import org.nuxeo.runtime.api.Framework;
033
034@Name("appNameFactory")
035@Scope(ScopeType.STATELESS)
036@Install(precedence = FRAMEWORK)
037public class NuxeoProductNameFactory implements Serializable {
038
039    public static String PNAME_KEY = "org.nuxeo.ecm.product.name";
040
041    public static String PVERSION_KEY = "org.nuxeo.ecm.product.version";
042
043    private static final long serialVersionUID = 1L;
044
045    @Factory(value = "nuxeoApplicationName", scope = ScopeType.APPLICATION)
046    public String getNuxeoProductName() {
047        return Framework.getProperty(PNAME_KEY);
048    }
049
050    @Factory(value = "nuxeoApplicationVersion", scope = ScopeType.APPLICATION)
051    public String getNuxeoProductVersion() {
052        return Framework.getProperty(PVERSION_KEY);
053    }
054
055    /**
056     * Gives current year used in copyright (in case this needs to be extracted from a configuration in the future).
057     *
058     * @since 5.9.2
059     */
060    @Factory(value = "copyrightCurrentYear", scope = ScopeType.APPLICATION)
061    public String getCurrentYearAsString() {
062        return new DateTime().toString("Y");
063    }
064
065}