001/*
002 * #%L
003 * Netarchivesuite - common
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023package dk.netarkivet.common.distribute.arcrepository;
024
025/**
026 * This class encapsulates the different upload states, while storing a file in the archive of a replica . Used by the
027 * classes ArcRepository, AdminData, and ArcRepositoryEntry.
028 * <p>
029 * TODO Needs localisation.
030 *
031 * @see dk.netarkivet.archive.arcrepository.ArcRepository
032 * @see dk.netarkivet.archive.arcrepositoryadmin.AdminData
033 * @see dk.netarkivet.archive.arcrepositoryadmin.ArcRepositoryEntry
034 */
035public enum ReplicaStoreState {
036
037    /** Upload to a replica archive has started. */
038    UPLOAD_STARTED,
039    /** Data has been successfully uploaded to a replica archive. */
040    DATA_UPLOADED,
041    /**
042     * Upload to replica archive completed, which means that it has been verified by a checksumJob.
043     */
044    UPLOAD_COMPLETED,
045    /** Upload to the replica archive has failed. */
046    UPLOAD_FAILED,
047    /**
048     * If it is unknown whether a file has been successfully uploaded to a replica or not. Used in the database.
049     */
050    UNKNOWN_UPLOAD_STATE;
051
052    public static ReplicaStoreState fromOrdinal(int ordinal) {
053        switch (ordinal) {
054        case 0:
055            return UPLOAD_STARTED;
056        case 1:
057            return DATA_UPLOADED;
058        case 2:
059            return UPLOAD_COMPLETED;
060        case 3:
061            return UPLOAD_FAILED;
062        default:
063            // anything else is unknown.
064            return UNKNOWN_UPLOAD_STATE;
065        }
066    }
067
068}