ArchiveStore.java [src/csip] Revision: default  Date:
/*
 * $Id$
 *
 * This file is part of the Cloud Services Integration Platform (CSIP),
 * a Model-as-a-Service framework, API and application suite.
 *
 * 2012-2022, 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 extends AutoCloseable {

  static final String ARCHIVE_TOO_BIG = "the archive too big.";
  static final String ARCHIVE_PREFIX = "archive-";


  boolean isAvailable();


  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) 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) throws Exception {
      return null;
    }


    @Override
    public void close() 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;
    }


    @Override
    public boolean isAvailable() {
      return false;
    }

  };

}