ArchiveStore.java [src/csip] Revision: 71821307bfe742c00c6dc582c171224a9ac59935  Date: Fri Apr 21 11:46:19 MDT 2017
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API and application suite.
 *
 * 2012-2017, Olaf David and others, OMSLab, Colorado State University.
 *
 * OMSLab licenses this file to you under the MIT license.
 * See the LICENSE file in the project root for more information.
 */
package csip;

import java.io.File;
import java.util.HashSet;
import java.util.Set;

/**
 * Archive Store
 */
interface ArchiveStore {

    static String ARCHIVE_TOO_BIG = "the archive was too big to store.";


    void archiveSession(String sid, ModelArchive ma, File f) throws Exception;


    ModelArchive getArchive(String suid) throws Exception;


    boolean hasArchive(String suid) throws Exception;


    void removeArchive(String suid);


    byte[] getFile(String suid, String filename) throws Exception;


    void shutdown() throws Exception;


    /**
     * Get the number of elements.
     * @return the number of elements
     */
    long getCount();


    Set<String> keys(int skip, int limit, String sortby, boolean sortAsc);

    /**
     *
     */
    ArchiveStore NONE = new ArchiveStore() {
        Set<String> keys = new HashSet<>();


        @Override
        public void archiveSession(String sid, ModelArchive ma, File f) throws Exception {
        }


        @Override
        public ModelArchive getArchive(String suid) throws Exception {
            return null;
        }


        @Override
        public void removeArchive(String suid) {
        }


        @Override
        public byte[] getFile(String suid, String filename) throws Exception {
            return null;
        }


        @Override
        public void shutdown() throws Exception {
        }


        @Override
        public Set<String> keys(int skip, int limit, String sortby, boolean sortAsc) {
            return keys;
        }


        @Override
        public long getCount() {
            return keys.size();
        }


        @Override
        public boolean hasArchive(String suid) throws Exception {
            return false;
        }
    };

}