001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2008 Sun Microsystems, Inc.
025 */
026package org.opends.guitools.controlpanel.datamodel;
027
028import java.io.File;
029import java.util.Date;
030
031import org.opends.server.types.BackupInfo;
032
033/** Class used to describe a backup. */
034public class BackupDescriptor
035{
036  /** The different types of backups. */
037  public enum Type
038  {
039    /** Full backup. */
040    FULL,
041    /** Incremental backup. */
042    INCREMENTAL
043  }
044
045  private Type type;
046  private Date creationDate;
047  private File path;
048  private String id;
049  private BackupInfo info;
050
051  /**
052   * The BackupDescriptor constructor.
053   * @param path the directory where the backup is located.
054   * @param creationDate the date of creation of the backup.
055   * @param type the type of backup.
056   * @param id the backup id.
057   */
058  public BackupDescriptor(File path, Date creationDate, Type type, String id)
059  {
060   this.path = path;
061   this.creationDate = creationDate;
062   this.type = type;
063   this.id = id;
064  }
065
066  /**
067   * The BackupDescriptor generated using a BackupInfo object.
068   * @param info the BackupInfo object that contains all the information about
069   * the backup.
070   */
071  public BackupDescriptor(BackupInfo info)
072  {
073   this.path = new File(info.getBackupDirectory().getPath());
074   this.creationDate = info.getBackupDate();
075   this.type = info.isIncremental() ? Type.INCREMENTAL : Type.FULL;
076   this.id = info.getBackupID();
077   this.info = info;
078  }
079
080  /**
081   * Returns the creation date of the backup.
082   * @return the creation date of the backup.
083   */
084  public Date getCreationDate()
085  {
086    return creationDate;
087  }
088
089  /**
090   * Returns the directory where the backup is located.
091   * @return the directory where the backup is located.
092   */
093  public File getPath()
094  {
095    return path;
096  }
097
098  /**
099   * Returns the type of the backup.
100   * @return the type of the backup.
101   */
102  public Type getType()
103  {
104    return type;
105  }
106
107  /**
108   * Returns the backup ID.
109   * @return the backup ID.
110   */
111  public String getID()
112  {
113    return id;
114  }
115
116  /**
117   * Returns the BackupInfo object associated with this backup.  It might be
118   * <CODE>null</CODE>.
119   * @return the BackupInfo object associated with this backup.
120   */
121  public BackupInfo getBackupInfo()
122  {
123    return info;
124  }
125}