Package de.dlr.proseo.ingestor.rest
Class ProductManager
java.lang.Object
de.dlr.proseo.ingestor.rest.ProductManager
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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioncountProducts(String mission, String[] productClass, String mode, String fileClass, String quality, String startTimeFrom, String startTimeTo, String genTimeFrom, String genTimeTo, Boolean onlyWithFile, Long jobStepId, Long id) Get the number of products available, possibly filtered by mission, product class, production mode, file class, quality and time rangescreateProduct(RestProduct product) Create a product from the given Json object (does NOT create associated product files!)voidDelete a product by IDdownloadProductById(Long id, Long fromByte, Long toByte) 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 FacilityfindEquivalentProduct(RestProduct product) Find any product equivalent to the given product (i. e. fulfilling the Product::equals() conditions).getDownloadTokenById(Long id, String encodedFileName) Get a JSON Web Token for creating a download link to a Storage ManagergetProductById(Long id) Find the product with the given IDgetProductByUuid(String uuid) Find the product with the given universally unique product identifiergetProducts(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) List of all products filtered by mission, product class, , production mode, file class, quality and time rangesmodifyProduct(Long id, RestProduct product) Update the product with the given ID with the attribute values of the given Json object.
-
Field Details
-
ingestorConfig
Ingestor configuration
-
-
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 databaseIllegalStateException- if the product to delete still as files at some Processing FacilitySecurityException- if a cross-mission data access was attemptedRuntimeException- 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 typesmode- the processing modefileClass- the file classquality- the qualitystartTimeFrom- earliest sensing start timestartTimeTo- latest sensing start timegenTimeFrom- earliest generation timegenTimeTo- latest generation timerecordFrom- first record of filtered and ordered result to returnrecordTo- last record of filtered and ordered result to returnonlyWithFile- if true, only returns products having at least one product file on any of the processing facilitiesjobStepId- get input products of job steporderBy- 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 foundSecurityException- 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 typesmode- the processing modefileClass- the file classquality- the qualitystartTimeFrom- earliest sensing start timestartTimeTo- latest sensing start timegenTimeFrom- earliest generation timegenTimeTo- latest generation timeonlyWithFile- if true, only counts products having at least one product file on any of the processing facilitiesjobStepId- 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 invalidSecurityException- if a cross-mission data access was attempted
-
findEquivalentProduct
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 givenjakarta.persistence.NoResultException- if no product with the given ID existsSecurityException- 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 updateproduct- 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 existsIllegalArgumentException- if any of the input data was invalidConcurrentModificationException- if the product has been modified since retrieval by the clientSecurityException- 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 givenjakarta.persistence.NoResultException- if no product with the given UUID existsSecurityException- 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 downloadfromByte- 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 givenjakarta.persistence.NoResultException- if no product with the given ID exists or if it does not have a data fileSecurityException- 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 downloadfileName- 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 givenjakarta.persistence.NoResultException- if no product with the given ID or no file with the given name existsSecurityException- if a cross-mission data access was attempted
-