/** * Do process all products in database that their ingestion is not finished. If provided parameter * is null, default processing consists in removing the data from database. Otherwise, the * provided processing is launched. * * @param proc the processing to execute. if null, remove processing will be performed. * @return the list of products reprocessed. */ @Transactional(readOnly = false, propagation = Propagation.REQUIRED) @CacheEvict( value = {"product_count", "product", "products"}, allEntries = true) public void processUnprocessed(boolean recover) { long start = new Date().getTime(); if (!recover) { Iterator<Product> products = getUnprocessedProducts(); while (products.hasNext()) { products.next(); products.remove(); } logger.debug( "Cleanup incomplete processed products in " + (new Date().getTime() - start) + "ms"); } else { Iterator<Product> products = getUnprocessedProducts(); while (products.hasNext()) { Product product = products.next(); // Do reporcess only already transfered products if (product.getPath().toString().equals(product.getOrigin())) { products.remove(); } else { try { String path = product.getPath().getPath(); logger.info("Recovering product from " + path); // Check if product is still present in repository if (!new File(path).exists()) { throw new DataStoreException("Product " + path + " not present locally."); } // Retrieve owner if any User owner = productDao.getOwnerOfProduct(product); // Retrieve collections List<Collection> collections = collectionDao.getCollectionsOfProduct(product.getId()); processProduct(product, owner, collections, null, null); } catch (Exception e) { logger.error("Error while processing: " + e.getMessage() + "- abort reprocessing."); products.remove(); } } } } }