Options.java revision 8af80418ba1ec431c8027fa9668e5678658d3611
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Copyright (c) 2007 Sun Microsystems Inc. All Rights Reserved
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * The contents of this file are subject to the terms
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * of the Common Development and Distribution License
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * (the License). You may not use this file except in
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * compliance with the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * You can obtain a copy of the License at
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * https://opensso.dev.java.net/public/CDDLv1.0.html or
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * opensso/legal/CDDLv1.0.txt
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * See the License for the specific language governing
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * permission and limitations under the License.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * When distributing Covered Code, include this CDDL
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Header Notice in each file and include the License file
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * at opensso/legal/CDDLv1.0.txt.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * If applicable, add the following below the CDDL Header,
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * with the fields enclosed by brackets [] replaced by
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * your own identifying information:
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * "Portions Copyrighted [year] [name of copyright owner]"
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * $Id: Options.java,v 1.7 2009/01/05 23:17:09 veiming Exp $
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster *
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster/*
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * Portions Copyrighted 2011-2012 ForgeRock AS
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpackage com.sun.identity.config;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.config.util.TemplatedPage;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.AMSetupServlet;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport com.sun.identity.setup.EmbeddedOpenDS;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.apache.click.control.ActionLink;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterimport org.forgerock.openam.upgrade.UpgradeUtils;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Fosterpublic class Options extends TemplatedPage {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink createConfigLink = new ActionLink("upgradeLink", this, "upgrade" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink testUrlLink = new ActionLink("coexistLink", this, "coexist" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public ActionLink pushConfigLink = new ActionLink("olderUpgradeLink", this, "olderUpgrade" );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected boolean upgrade = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected boolean upgradeCompleted = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected boolean isOpenDS1x = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected boolean debugOn = false;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster private java.util.Locale configLocale = null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster protected String getTitle() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return isNewInstall() ? "configuration.options.title" : "upgrade.title";
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public void doInit() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster upgrade = !isNewInstall();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster upgradeCompleted = AMSetupServlet.isUpgradeCompleted();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("upgradeCompleted", Boolean.valueOf(upgradeCompleted));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel( "upgrade", Boolean.valueOf( upgrade ) );
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster isOpenDS1x = EmbeddedOpenDS.isOpenDSVer1Installed();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("isOpenDS1x", Boolean.valueOf(isOpenDS1x));
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (isOpenDS1x) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster addModel("odsdir", AMSetupServlet.getBaseDir());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster debugOn = getContext().getRequest().getParameter( "debug" ) != null;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (debugOn) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster AMSetupServlet.enableDebug();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster /**
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * @return If <tt>true</tt>, the options.htm page will be cusotmized for a new installation, otherwise it will be
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster * customized for an upgrade.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isNewInstall() {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster if (AMSetupServlet.isConfigured() && UpgradeUtils.isVersionNewer()) {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return !UpgradeUtils.canUpgrade();
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster } else {
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster return true;
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}