Package de.dlr.proseo.ingestor.rest
Class ProductIngestor
java.lang.Object
de.dlr.proseo.ingestor.rest.ProductIngestor
Services required to ingest products from pickup points into the prosEO
database, and to create, read, updated and delete product file metadata
- Author:
- Dr. Thomas Bassler
-
Field Summary
FieldsModifier and TypeFieldDescription(package private) IngestorConfigurationIngestor configuration(package private) ProductManagerProduct Manager(package private) org.springframework.boot.web.client.RestTemplateBuilderREST template builder -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddeleteProductFile(Long productId, ProcessingFacility facility, Boolean eraseFiles) Delete a product file for a product from a given processing facility (metadata and actual data file(s))voidDelete all product (files) with eviction time older than t.getFacilityByName(String facilityName) /** Find a processing facility by name (transaction wrapper for repository method)getProductFile(Long productId, ProcessingFacility facility) Get the product file metadata for a product at a given processing facilityingestProductFile(Long productId, ProcessingFacility facility, RestProductFile productFile, String user, String password) Create the metadata of a new product file for a product at a given processing facility (it is assumed that the files themselves are already pushed to the Storage Manager)ingestProducts(ProcessingFacility facility, boolean copyFiles, List<IngestorProduct> ingestorProducts, String user, String password) Ingest all given products into the storage manager of the given processing facility.modifyProductFile(Long productId, ProcessingFacility facility, RestProductFile productFile) Update the product file metadata for a product at a given processing facility
-
Field Details
-
rtb
@Autowired org.springframework.boot.web.client.RestTemplateBuilder rtbREST template builder -
ingestorConfig
Ingestor configuration -
productManager
Product Manager
-
-
Constructor Details
-
ProductIngestor
public ProductIngestor()
-
-
Method Details
-
getFacilityByName
@Transactional(isolation=REPEATABLE_READ, readOnly=true) public ProcessingFacility getFacilityByName(String facilityName) /** Find a processing facility by name (transaction wrapper for repository method)- Parameters:
facilityName- the name of the facility to retrieve- Returns:
- the processing facility found or null, if no such processing facility exists
-
ingestProducts
public List<RestProduct> ingestProducts(ProcessingFacility facility, boolean copyFiles, List<IngestorProduct> ingestorProducts, String user, String password) throws IllegalArgumentException, javax.ws.rs.ProcessingException, SecurityException Ingest all given products into the storage manager of the given processing facility. If the ID of a product to ingest is null or 0 (zero), then the product will be created, otherwise a matching product will be looked up and updated NOTE: Datatabase transactions are programmatically, therefore no '@Transactional' annotation here.- Parameters:
facility- the processing facility to ingest products tocopyFiles- indicates, whether to copy the files to a different storage area (default "true"; only applicable if source and target storage type are the same)ingestorProducts- a list of product descriptions with product file locationsuser- the username to pass on to the Production Plannerpassword- the password to pass on to the Production Planner- Returns:
- a Json representation of the product updated and/or created including their product files
- Throws:
IllegalArgumentException- if the product ingestion failed (typically due to an error in the Json input)javax.ws.rs.ProcessingException- if the communication with the Storage Manager failsSecurityException- if a cross-mission data access was attempted
-
getProductFile
@Transactional(isolation=REPEATABLE_READ, readOnly=true) public RestProductFile getProductFile(Long productId, ProcessingFacility facility) throws jakarta.persistence.NoResultException, SecurityException Get the product file metadata for a product at a given processing facility- Parameters:
productId- the ID of the product to retrievefacility- the processing facility to retrieve the product file metadata for- Returns:
- the Json representation of the product file metadata
- Throws:
jakarta.persistence.NoResultException- if no product file for the given product ID exists at the given processing facilitySecurityException- if a cross-mission data access was attempted
-
ingestProductFile
@Transactional(isolation=REPEATABLE_READ) public RestProductFile ingestProductFile(Long productId, ProcessingFacility facility, RestProductFile productFile, String user, String password) throws IllegalArgumentException, SecurityException Create the metadata of a new product file for a product at a given processing facility (it is assumed that the files themselves are already pushed to the Storage Manager)- Parameters:
productId- the ID of the product to retrievefacility- the processing facility, in which the files have been storedproductFile- the REST product file to storeuser- the username to pass on to the Production Plannerpassword- the password to pass on to the Production Planner- Returns:
- the updated REST product file (with ID and version)
- Throws:
IllegalArgumentException- if the product cannot be found, or if the data for the product file is invalid (also, if a product file for the given processing facility already exists)SecurityException- if a cross-mission data access was attempted
-
deleteProductFile
@Transactional(isolation=REPEATABLE_READ) public void deleteProductFile(Long productId, ProcessingFacility facility, Boolean eraseFiles) throws jakarta.persistence.EntityNotFoundException, RuntimeException, javax.ws.rs.ProcessingException, IllegalArgumentException, SecurityException Delete a product file for a product from a given processing facility (metadata and actual data file(s))- Parameters:
productId- the ID of the product to retrievefacility- the processing facility, from which the files shall be deletederaseFiles- erase the data file(s) from the storage area (default "true")- Throws:
jakarta.persistence.EntityNotFoundException- if the product or the product file could not be foundRuntimeException- if the deletion failedjavax.ws.rs.ProcessingException- if the communication with the Storage Manager failsIllegalArgumentException- if the product currently satisfies a product query for the given processing facilitySecurityException- if a cross-mission data access was attempted
-
deleteProductFilesOlderThan
Delete all product (files) with eviction time older than t.- Parameters:
t- The Instant for eviction time
-
modifyProductFile
@Transactional(isolation=REPEATABLE_READ) public RestProductFile modifyProductFile(Long productId, ProcessingFacility facility, RestProductFile productFile) throws jakarta.persistence.EntityNotFoundException, IllegalArgumentException, ConcurrentModificationException, SecurityException Update the product file metadata for a product at a given processing facility- Parameters:
productId- the ID of the product to retrievefacility- the processing facility, in which the files have been storedproductFile- the REST product file to store- Returns:
- the updated REST product file (with ID and version)
- Throws:
IllegalArgumentException- if the product cannot be found, or if the data for the product file is invalid (also, if a product file for the given processing facility already exists)ConcurrentModificationException- if the product file was modified since its retrieval by the clientSecurityException- if a cross-mission data access was attemptedjakarta.persistence.EntityNotFoundException
-