Class ProductManager

java.lang.Object
de.dlr.proseo.ingestor.rest.ProductManager

@Component public class ProductManager extends Object
Service methods required to create, modify and delete products in the prosEO database, and to query the database about such products
Author:
Dr. Thomas Bassler
  • Field Details

  • Constructor Details

    • ProductManager

      public ProductManager()
  • Method Details

    • deleteProductById

      @Transactional(isolation=REPEATABLE_READ) public void deleteProductById(Long id) throws jakarta.persistence.EntityNotFoundException, IllegalStateException, SecurityException, RuntimeException
      Delete a product by ID
      Parameters:
      id - the ID of the product to delete
      Throws:
      jakarta.persistence.EntityNotFoundException - if the product to delete does not exist in the database
      IllegalStateException - if the product to delete still as files at some Processing Facility
      SecurityException - if a cross-mission data access was attempted
      RuntimeException - if the deletion was not performed as expected
    • getProducts

      @Transactional(isolation=REPEATABLE_READ, readOnly=true) public List<RestProduct> getProducts(String mission, String[] productClass, String mode, String fileClass, String quality, String startTimeFrom, String startTimeTo, String genTimeFrom, String genTimeTo, Integer recordFrom, Integer recordTo, Boolean onlyWithFile, Long jobStepId, String[] orderBy) throws jakarta.persistence.NoResultException, SecurityException
      List of all products filtered by mission, product class, , production mode, file class, quality and time ranges
      Parameters:
      mission - the mission code (will be set to logged in mission, if not given; otherwise must match logged in mission)
      productClass - an array of product types
      mode - the processing mode
      fileClass - the file class
      quality - the quality
      startTimeFrom - earliest sensing start time
      startTimeTo - latest sensing start time
      genTimeFrom - earliest generation time
      genTimeTo - latest generation time
      recordFrom - first record of filtered and ordered result to return
      recordTo - last record of filtered and ordered result to return
      onlyWithFile - if true, only returns products having at least one product file on any of the processing facilities
      jobStepId - get input products of job step
      orderBy - an array of strings containing a column name and an optional sort direction (ASC/DESC), separated by white space
      Returns:
      a list of products
      Throws:
      jakarta.persistence.NoResultException - if no products matching the given search criteria could be found
      SecurityException - if a cross-mission data access was attempted
    • countProducts

      @Transactional(isolation=REPEATABLE_READ, readOnly=true) public String countProducts(String mission, String[] productClass, String mode, String fileClass, String quality, String startTimeFrom, String startTimeTo, String genTimeFrom, String genTimeTo, Boolean onlyWithFile, Long jobStepId, Long id) throws SecurityException
      Get the number of products available, possibly filtered by mission, product class, production mode, file class, quality and time ranges
      Parameters:
      mission - the mission code (will be set to logged in mission, if not given; otherwise must match logged in mission)
      productClass - an array of product types
      mode - the processing mode
      fileClass - the file class
      quality - the quality
      startTimeFrom - earliest sensing start time
      startTimeTo - latest sensing start time
      genTimeFrom - earliest generation time
      genTimeTo - latest generation time
      onlyWithFile - if true, only counts products having at least one product file on any of the processing facilities
      jobStepId - get input products of job step
      Returns:
      the number of products found as string
      Throws:
      SecurityException - if a cross-mission data access was attempted
    • createProduct

      @Transactional(isolation=REPEATABLE_READ) public RestProduct createProduct(RestProduct product) throws IllegalArgumentException, SecurityException
      Create a product from the given Json object (does NOT create associated product files!)
      Parameters:
      product - the Json object to create the product from
      Returns:
      a Json object corresponding to the product after persistence (with ID and version for all contained objects)
      Throws:
      IllegalArgumentException - if any of the input data was invalid
      SecurityException - if a cross-mission data access was attempted
    • findEquivalentProduct

      public Product findEquivalentProduct(RestProduct product)
      Find any product equivalent to the given product (i. e. fulfilling the Product::equals() conditions).
      Parameters:
      product - the product example to search for
      Returns:
      a product with the same characteristics or null, if no such product can be found
    • getProductById

      @Transactional(isolation=REPEATABLE_READ, readOnly=true) public RestProduct getProductById(Long id) throws IllegalArgumentException, jakarta.persistence.NoResultException, SecurityException
      Find the product with the given ID
      Parameters:
      id - the ID to look for
      Returns:
      a Json object corresponding to the product found
      Throws:
      IllegalArgumentException - if no product ID was given
      jakarta.persistence.NoResultException - if no product with the given ID exists
      SecurityException - if a cross-mission data access was attempted
    • modifyProduct

      @Transactional(isolation=REPEATABLE_READ) public RestProduct modifyProduct(Long id, RestProduct product) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, ConcurrentModificationException, SecurityException
      Update the product with the given ID with the attribute values of the given Json object. This method will NOT modify associated product files.
      Parameters:
      id - the ID of the product to update
      product - a Json object containing the modified (and unmodified) attributes
      Returns:
      a Json object corresponding to the product after modification (with ID and version for all contained objects)
      Throws:
      jakarta.persistence.EntityNotFoundException - if no product with the given ID exists
      IllegalArgumentException - if any of the input data was invalid
      ConcurrentModificationException - if the product has been modified since retrieval by the client
      SecurityException - if a cross-mission data access was attempted
    • getProductByUuid

      @Transactional(isolation=REPEATABLE_READ, readOnly=true) public RestProduct getProductByUuid(String uuid) throws IllegalArgumentException, jakarta.persistence.NoResultException, SecurityException
      Find the product with the given universally unique product identifier
      Parameters:
      uuid - the UUID to look for
      Returns:
      a Json object corresponding to the product found
      Throws:
      IllegalArgumentException - if no or an invalid product UUID was given
      jakarta.persistence.NoResultException - if no product with the given UUID exists
      SecurityException - if a cross-mission data access was attempted
    • downloadProductById

      @Transactional(isolation=REPEATABLE_READ, readOnly=true) public String downloadProductById(Long id, Long fromByte, Long toByte) throws IllegalArgumentException, jakarta.persistence.NoResultException, SecurityException
      Get the primary data file (or ZIP file, if available) for the product as data stream (optionally range-restricted), returns a redirection link to the Storage Manager of a random Processing Facility
      Parameters:
      id - the ID of the product to download
      fromByte - the first byte of the data stream to download (optional, default is file start, i.e. byte 0)
      toByte - the last byte of the data stream to download (optional, default is file end, i.e. file size - 1)
      Returns:
      a redirect URL for the HTTP Location header
      Throws:
      IllegalArgumentException - if no product ID was given
      jakarta.persistence.NoResultException - if no product with the given ID exists or if it does not have a data file
      SecurityException - if a cross-mission data access was attempted
    • getDownloadTokenById

      @Transactional(isolation=REPEATABLE_READ) public String getDownloadTokenById(Long id, String encodedFileName) throws IllegalArgumentException, jakarta.persistence.NoResultException, SecurityException
      Get a JSON Web Token for creating a download link to a Storage Manager
      Parameters:
      id - the ID of the product to download
      fileName - the name of the file to download (default primary data file or ZIP file, if available)
      Returns:
      the signed JSON Web Token (JWS) as per RFC 7515 and RFC 7519
      Throws:
      IllegalArgumentException - if no product ID was given
      jakarta.persistence.NoResultException - if no product with the given ID or no file with the given name exists
      SecurityException - if a cross-mission data access was attempted