871b417a57cab3336793a845810383ceae4233cbMark de Reeper * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * Copyright (c) 2008 Sun Microsystems, Inc. All Rights Reserved.
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * The contents of this file are subject to the terms
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * of the Common Development and Distribution License
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * (the License). You may not use this file except in
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * compliance with the License.
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * You can obtain a copy of the License at
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * https://opensso.dev.java.net/public/CDDLv1.0.html or
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * See the License for the specific language governing
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * permission and limitations under the License.
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * When distributing Covered Code, include this CDDL
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * Header Notice in each file and include the License file
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * If applicable, add the following below the CDDL Header,
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * with the fields enclosed by brackets [] replaced by
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * your own identifying information:
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * "Portions Copyrighted [year] [name of copyright owner]"
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * $Id: HomeDirLocator.java,v 1.1 2009/01/21 18:43:54 kanduls Exp $
5c39d8f041417518a02ce2c941d96c2d33b2a364Mark de Reeper * Portions Copyrighted 2013 ForgeRock AS.
871b417a57cab3336793a845810383ceae4233cbMark de Reeperpackage com.sun.identity.agents.tools.jetty.v7;
871b417a57cab3336793a845810383ceae4233cbMark de Reeperimport com.sun.identity.install.tools.configurator.IServerHomeDirLocator;
871b417a57cab3336793a845810383ceae4233cbMark de Reeperimport com.sun.identity.install.tools.configurator.IStateAccess;
871b417a57cab3336793a845810383ceae4233cbMark de Reeperimport com.sun.identity.install.tools.configurator.InstallException;
871b417a57cab3336793a845810383ceae4233cbMark de Reeperimport com.sun.identity.install.tools.util.Debug;
871b417a57cab3336793a845810383ceae4233cbMark de Reeperimport com.sun.identity.install.tools.util.FileUtils;
871b417a57cab3336793a845810383ceae4233cbMark de Reeperimport com.sun.identity.install.tools.util.LocalizedMessage;
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * Home directory locator for Jetty agent
871b417a57cab3336793a845810383ceae4233cbMark de Reeperpublic class HomeDirLocator implements IServerHomeDirLocator, IConstants, IConfigKeys {
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * Computes the jetty home directory from the config directory
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * @param state State object where are the
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * @return Home directory.
871b417a57cab3336793a845810383ceae4233cbMark de Reeper * @throws InstallException
871b417a57cab3336793a845810383ceae4233cbMark de Reeper public String getServerDirectory(IStateAccess state) throws InstallException {
871b417a57cab3336793a845810383ceae4233cbMark de Reeper Debug.log("HomeDirLocator: Finding home directory from config dir.");
871b417a57cab3336793a845810383ceae4233cbMark de Reeper jettyConfigDir = (String) state.get(STR_KEY_JETTY_SERVER_CONFIG_DIR);
871b417a57cab3336793a845810383ceae4233cbMark de Reeper if ((jettyConfigDir != null) && (jettyConfigDir.length() > 0)) {
871b417a57cab3336793a845810383ceae4233cbMark de Reeper jettyHomeDir = (new File(jettyConfigDir)).getParent();
871b417a57cab3336793a845810383ceae4233cbMark de Reeper Debug.log("HomeDirLocator: The Jetty home directory " + jettyHomeDir + " specified is invalid:");
871b417a57cab3336793a845810383ceae4233cbMark de Reeper throw new InstallException(LocalizedMessage.get(JETTY_ERR_IN_VALID_HOME_DIR, STR_JETTY_GROUP));
871b417a57cab3336793a845810383ceae4233cbMark de Reeper Debug.log("HomeDirLocator : Jetty server home " + "directory = " + jettyHomeDir);