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 2006-2008 Sun Microsystems, Inc.
015 * Portions Copyright 2015-2016 ForgeRock AS.
016 */
017package org.opends.quicksetup.installer;
018
019import org.opends.quicksetup.ProgressStep;
020
021/** Enumeration of installation steps. */
022public enum InstallProgressStep implements ProgressStep {
023
024  /** Install not started. */
025  NOT_STARTED,
026  /** Configuring server. */
027  CONFIGURING_SERVER(5),
028  /** Creating base entry for the suffix. */
029  CREATING_BASE_ENTRY(10),
030  /** Importing the contents of an LDIF file into the suffix. */
031  IMPORTING_LDIF(20),
032  /** Importing generated data into the suffix. */
033  IMPORTING_AUTOMATICALLY_GENERATED(20),
034  /** Configuring replication. */
035  CONFIGURING_REPLICATION(10),
036  /** Starting Open DS server. */
037  STARTING_SERVER(10),
038  /** Stopping Open DS server. */
039  STOPPING_SERVER(5),
040  /** Initialize Replicated Suffixes. */
041  INITIALIZE_REPLICATED_SUFFIXES(25),
042  /** Configuring ADS. */
043  CONFIGURING_ADS(5),
044  /** Enabling Windows service. */
045  ENABLING_WINDOWS_SERVICE,
046  /** User is waiting for current task to finish so that the operation can be canceled. */
047  WAITING_TO_CANCEL,
048  /** Canceling install. */
049  CANCELING,
050  /** Installation finished successfully. */
051  FINISHED_SUCCESSFULLY,
052  /** User canceled installation. */
053  FINISHED_CANCELED,
054  /** Installation finished with an error. */
055  FINISHED_WITH_ERROR;
056
057  /**
058   * Contains the relative time that takes for the task to be accomplished.
059   * <p>
060   * For instance if downloading takes twice the time of extracting,
061   * the value for downloading will be the double of the value for extracting.
062   */
063  private final int relativeDuration;
064
065  InstallProgressStep() {
066    this(0);
067  }
068
069  InstallProgressStep(final int relativeDuration) {
070    this.relativeDuration = relativeDuration;
071  }
072
073  int getRelativeDuration()
074  {
075    return relativeDuration;
076  }
077
078  @Override
079  public boolean isLast() {
080    switch (this)
081    {
082    case FINISHED_CANCELED:
083    case FINISHED_SUCCESSFULLY:
084    case FINISHED_WITH_ERROR:
085      return true;
086    default:
087      return false;
088    }
089  }
090
091  @Override
092  public boolean isError() {
093    return FINISHED_WITH_ERROR.equals(this);
094  }
095}