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

import csip.annotations.Resource;
import java.io.File;
import java.io.IOException;
import java.sql.Connection;

/**
 * ServiceResources access.
 *
 * @author od
 */
public interface ServiceResources {

  /**
   * Get the raw resource definitions without assuming anything.
   *
   * @param id the resource id
   * @return the resource object
   */
  Resource get(String id);


  /**
   * Get a service resource file. Resources are defined as service annotations.
   *
   * @param id the id of the resource.
   * @return the extracted file within the local file system.
   * @throws ServiceException if file cannot be found or unpacked
   * @see csip.annotations.Resource
   */
  File getFile(String id) throws ServiceException;


  /**
   * Get an executable from a resource definition. Resources are defined as
   * service annotations.
   *
   * @param id the id of the resource
   * @return the ProcessExecution for that executable
   * @throws ServiceException if there is no EXE
   * @see csip.annotations.Resource
   */
  Executable getExe(String id) throws ServiceException;


  /**
   * Copy a FILE Resource to the Workspace.
   *
   * @param id The FILE resource ID.
   * @throws ServiceException if id does not exist
   * @throws IOException if copy fails
   */
  void copyFileToWorkspace(String id) throws ServiceException, IOException;


  /**
   * Get a JDBC connection from a resource definition.
   *
   * @param id the id of the resource
   * @return the JDBC connection.
   * @throws ServiceException if connection fails
   * @see csip.annotations.Resource
   */
  Connection getJDBC(String id) throws ServiceException;
}