PayloadAttachments.java [src/csip/api/server] Revision:   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.api.server;

import java.io.File;
import java.util.Collection;

/**
 * FormDataInput
 *
 * @author od
 */
public interface PayloadAttachments {

  /**
   * Get the attached files for this request. This includes the request.
   * @return The set of files.
   */
  Collection<File> getFiles();


  /**
   * Get the number of attachments. This includes the request.
   * @return the number of files attached.
   */
  int getFilesCount();


  /**
   * Check is a input file exists in the workspace.
   *
   * @param name the file name
   * @return true if the file exist, false otherwise
   * @throws ServiceException if there is a JSON error.
   */
  boolean hasFile(String name) throws ServiceException;


  /**
   * Check if a required file attachment exists in the workspace.
   *
   * @param name the file name
   * @return this object
   * @throws ServiceException if the parameter is not found.
   */
  PayloadAttachments require(String name) throws ServiceException;


  /**
   * Get a file object for a given file name.
   * @param name the file name (no path)
   * @return the file object with its absolute file path within the workspace.
   * It returns null if the file is not input or does not exist.
   * @throws csip.api.server.ServiceException if the file is missing
   */
  File getFile(String name) throws ServiceException;
}