/** * This file is part of Faktotum. * * * Faktotum 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 3 of * the License, or (at your option) any later version. * * Faktotum 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 Faktotum. * * If not, see <http://www.gnu.org/licenses/>. */ package de.romankreisel.faktotum.beans; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.Date; import java.util.logging.Level; import javax.ejb.EJB; import javax.ejb.Stateless; import de.romankreisel.faktotum.FaktotumContextListener; /** * This class contains business code related to the Faktotum product * * @author Roman Kreisel <mail@romankreisel.de> * */ @Stateless public class FaktotumProductBean extends FaktotumBean { @EJB private SettingBean settingBean; public Date getBuildDate() { return FaktotumContextListener.getBuildTime(); } /** * Returns the text from a license contained in the WAR * * @param licenseName * @return the license text or null, if the license doesn't exist or * couldn't be read */ private String getLicense(String licenseName) { try (InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream("/resources/license/" + licenseName + ".txt");) { BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); StringBuffer stringBuffer = new StringBuffer(); String nextLine; while ((nextLine = reader.readLine()) != null) { stringBuffer.append(nextLine); } return stringBuffer.toString(); } catch (IOException e) { this.getLogger().log(Level.WARNING, "Error reading license " + licenseName, e); return null; } } public String getLicenseApache2() { return this.getLicense("apache-2.0"); } public String getLicenseLGPL3() { return this.getLicense("apache-2.0"); } /** * Gets the configureable product name of Faktotum. * * @return the configured product name */ public String getProductName() { return this.settingBean.getStringSettingValue(SettingBean.SETTING_STRING_PRODUCT_NAME); } public Date getStartTime() { return FaktotumContextListener.getStartTime(); } /** * The version of Faktotum * * @return the version number */ public String getVersion() { return FaktotumContextListener.getVersion(); } }