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 */ 025public final class AmetysHomeHelper 026{ 027 /** The path to the Ametys home administrator directory */ 028 public static final String AMETYS_HOME_ADMINISTRATOR_DIR = "administrator"; 029 /** The path to the Ametys home data directory */ 030 public static final String AMETYS_HOME_DATA_DIR = "data"; 031 /** The path to the Ametys home config directory */ 032 public static final String AMETYS_HOME_CONFIG_DIR = "config"; 033 /** The path to the Ametys home temporary directory */ 034 public static final String AMETYS_HOME_TMP_DIR = "tmp"; 035 036 private AmetysHomeHelper() 037 { 038 // Helper class, never to be instantiated. 039 } 040 041 /** 042 * Returns the Ametys home directory. Cannot be null. 043 * @return The Ametys home directory. 044 */ 045 public static File getAmetysHome() 046 { 047 return RuntimeConfig.getInstance().getAmetysHome(); 048 } 049 050 /** 051 * Returns the Ametys home data directory. Cannot be null. 052 * @return The Ametys home data directory. 053 */ 054 public static File getAmetysHomeData() 055 { 056 return new File(RuntimeConfig.getInstance().getAmetysHome(), AMETYS_HOME_DATA_DIR); 057 } 058 059 /** 060 * Returns the Ametys home config directory. Cannot be null. 061 * @return The Ametys home config directory. 062 */ 063 public static File getAmetysHomeConfig() 064 { 065 return new File(RuntimeConfig.getInstance().getAmetysHome(), AMETYS_HOME_CONFIG_DIR); 066 } 067 068 /** 069 * Returns the Ametys temporary directory. Cannot be null. 070 * @return The Ametys temporary directory. 071 */ 072 public static File getAmetysHomeTmp() 073 { 074 return new File(RuntimeConfig.getInstance().getAmetysHome(), AMETYS_HOME_TMP_DIR); 075 } 076}