a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington/*
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 *
a4544a5a0e622ef69e38641f87ab1b5685e05911Phill Cunnington * Portions Copyrighted 2011-2015 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;
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Joosteimport org.forgerock.openam.upgrade.VersionUtils;
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
17896349593859825d7867feb831f31376a36e01Julian Kigwana if (upgrade) {
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Jooste addModel("currentVersion", VersionUtils.getCurrentVersion());
17896349593859825d7867feb831f31376a36e01Julian Kigwana }
17896349593859825d7867feb831f31376a36e01Julian Kigwana
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 /**
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Jooste * @return boolean If <tt>true</tt>, the options.htm page will be customized for a new installation,
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Jooste * otherwise it will be customized for an upgrade.
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Jooste *
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Jooste * Automatic upgrades from 9.5 onwards are supported.
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster */
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster public boolean isNewInstall() {
a482d94cc9392203bc183f592f9accd23d6ded01Jaco Jooste return !(AMSetupServlet.isConfigured() && VersionUtils.isVersionNewer());
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster }
17896349593859825d7867feb831f31376a36e01Julian Kigwana
8af80418ba1ec431c8027fa9668e5678658d3611Allan Foster}