001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2014 ForgeRock AS.
015 */
016
017package org.forgerock.openig.config;
018
019import java.io.File;
020
021/**
022 * Encapsulate logic to access configuration files and other directories of the OpenIG base directory.
023 * A typical structure may looks like the following:
024 * <pre>
025 *     config/config.json
026 *     scripts/groovy/**.groovy
027 *     tmp/
028 * </pre>
029 *
030 * This interface provides an abstraction over the directory layout to protect against changes of naming, ...
031 */
032public interface Environment {
033
034    /**
035     * Key to retrieve an {@link Environment} instance from the {@link org.forgerock.openig.heap.Heap}.
036     */
037    public static final String ENVIRONMENT_HEAP_KEY = "Environment";
038
039    /**
040     * Returns the base directory of the OpenIG file system.
041     * It can be used to access resources that are not part of the standard layout.
042     * @return the base directory of the OpenIG file system.
043     */
044    File getBaseDirectory();
045
046    /**
047     * Returns the temporary directory of OpenIG (where we have read+write permissions).
048     * It usually points to the {@literal tmp/} directory.
049     * @return the working directory.
050     */
051    File getTempDirectory();
052
053    /**
054     * Returns the directory that contains the files of the given type. It
055     * usually points to the {@literal scripts/<type>/} directory.
056     *
057     * @param type
058     *            script's type (could be {@literal groovy} or {@literal js})
059     * @return the scripting directory.
060     */
061    File getScriptDirectory(String type);
062
063    /**
064     * Returns the directory that contains the configuration files.
065     * It usually points to the {@literal config/} directory.
066     * @return the configuration directory.
067     */
068    File getConfigDirectory();
069
070}