001/* 002 * Copyright 2015 Anyware Services 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.ametys.runtime.util; 017 018import java.io.File; 019 020import org.ametys.runtime.servlet.RuntimeConfig; 021 022/** 023 * Helper for Ametys home locations 024 * 025 */ 026public final class AmetysHomeHelper 027{ 028 /** The path to the Ametys home data directory */ 029 public static final String AMETYS_HOME_DATA_DIR = "data"; 030 /** The path to the Ametys home config directory */ 031 public static final String AMETYS_HOME_CONFIG_DIR = "config"; 032 /** The path to the Ametys home temporary directory */ 033 public static final String AMETYS_HOME_TMP_DIR = "tmp"; 034 035 private AmetysHomeHelper() 036 { 037 // Helper class, never to be instantiated. 038 } 039 040 /** 041 * Returns the Ametys home directory. Cannot be null. 042 * @return The Ametys home directory. 043 */ 044 public static File getAmetysHome() 045 { 046 return RuntimeConfig.getInstance().getAmetysHome(); 047 } 048 049 /** 050 * Returns the Ametys home data directory. Cannot be null. 051 * @return The Ametys home data directory. 052 */ 053 public static File getAmetysHomeData() 054 { 055 return new File(RuntimeConfig.getInstance().getAmetysHome(), AMETYS_HOME_DATA_DIR); 056 } 057 058 /** 059 * Returns the Ametys home config directory. Cannot be null. 060 * @return The Ametys home config directory. 061 */ 062 public static File getAmetysHomeConfig() 063 { 064 return new File(RuntimeConfig.getInstance().getAmetysHome(), AMETYS_HOME_CONFIG_DIR); 065 } 066 067 /** 068 * Returns the Ametys temporary directory. Cannot be null. 069 * @return The Ametys temporary directory. 070 */ 071 public static File getAmetysHomeTmp() 072 { 073 return new File(RuntimeConfig.getInstance().getAmetysHome(), AMETYS_HOME_TMP_DIR); 074 } 075 076}