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 2008 Sun Microsystems, Inc.
015 */
016package org.opends.guitools.controlpanel.datamodel;
017
018import java.io.File;
019import java.util.Date;
020
021import org.opends.server.types.BackupInfo;
022
023/** Class used to describe a backup. */
024public class BackupDescriptor
025{
026  /** The different types of backups. */
027  public enum Type
028  {
029    /** Full backup. */
030    FULL,
031    /** Incremental backup. */
032    INCREMENTAL
033  }
034
035  private Type type;
036  private Date creationDate;
037  private File path;
038  private String id;
039  private BackupInfo info;
040
041  /**
042   * The BackupDescriptor constructor.
043   * @param path the directory where the backup is located.
044   * @param creationDate the date of creation of the backup.
045   * @param type the type of backup.
046   * @param id the backup id.
047   */
048  public BackupDescriptor(File path, Date creationDate, Type type, String id)
049  {
050   this.path = path;
051   this.creationDate = creationDate;
052   this.type = type;
053   this.id = id;
054  }
055
056  /**
057   * The BackupDescriptor generated using a BackupInfo object.
058   * @param info the BackupInfo object that contains all the information about
059   * the backup.
060   */
061  public BackupDescriptor(BackupInfo info)
062  {
063   this.path = new File(info.getBackupDirectory().getPath());
064   this.creationDate = info.getBackupDate();
065   this.type = info.isIncremental() ? Type.INCREMENTAL : Type.FULL;
066   this.id = info.getBackupID();
067   this.info = info;
068  }
069
070  /**
071   * Returns the creation date of the backup.
072   * @return the creation date of the backup.
073   */
074  public Date getCreationDate()
075  {
076    return creationDate;
077  }
078
079  /**
080   * Returns the directory where the backup is located.
081   * @return the directory where the backup is located.
082   */
083  public File getPath()
084  {
085    return path;
086  }
087
088  /**
089   * Returns the type of the backup.
090   * @return the type of the backup.
091   */
092  public Type getType()
093  {
094    return type;
095  }
096
097  /**
098   * Returns the backup ID.
099   * @return the backup ID.
100   */
101  public String getID()
102  {
103    return id;
104  }
105
106  /**
107   * Returns the BackupInfo object associated with this backup.  It might be
108   * <CODE>null</CODE>.
109   * @return the BackupInfo object associated with this backup.
110   */
111  public BackupInfo getBackupInfo()
112  {
113    return info;
114  }
115}