@Test (groups={"non-regression"}) public void testChecksumUpdate () throws MalformedURLException { Product product = new Product (); product.setPath (new URL ("file:/product/path")); Download download = new Product.Download (); download.setPath ("/no/path/file"); download.setSize (0L); download.setType ("application/octet-stream"); download.setChecksums ( Maps.newHashMap (ImmutableMap.of( "MD5", "54ABCDEF98765", "SHA-1", "9876FEDCBA1234"))); product.setDownload (download); try { product = dao.create (product); } catch (Exception e) { Assert.fail ("Creation of product fails", e); } product.getDownload ().getChecksums ().clear (); product.getDownload ().getChecksums ().putAll ( Maps.newHashMap (ImmutableMap.of( "SHA-256", "4554ABCDEF98765", "SHA-512", "ABDEFFE9876FEDCBA1234"))); try { dao.update (product); } catch (Exception e) { Assert.fail ("Modifying checksums with map clear/put fails", e); } product.getDownload ().setChecksums ( Maps.newHashMap (ImmutableMap.of( "MD5", "54ABCDEF98765", "SHA-1", "9876FEDCBA1234"))); try { dao.update (product); } catch (Exception e) { Assert.fail ("Modifying checksums with \"set\" fails", e); } cancelListeners (getHibernateDao ()); dao.delete (product); }
@Override public void delete (Product product) { Product p = read (product.getId ()); List<Collection>cls = collectionDao.getCollectionsOfProduct (p.getId ()); User user = userDao.getRootUser(); if (cls!=null) { for (Collection c: cls) { LOGGER.info("deconnect product from collection " + c.getName ()); collectionDao.removeProduct (c.getUUID (), p.getId (), user); } } productCartDao.deleteProductReferences(p); setIndexes (p.getId (), null); evictionDao.removeProduct (p); super.delete (p); }
ProductDao extends HibernateDao<Product, Long> { @Override public void delete (Product product) { Product p = read (product.getId ()); List<Collection>cls = collectionDao.getCollectionsOfProduct (p.getId ()); User user = userDao.getRootUser(); if (cls!=null) { for (Collection c: cls) { LOGGER.info("deconnect product from collection " + c.getName ()); collectionDao.removeProduct (c.getUUID (), p.getId (), user); } } productCartDao.deleteProductReferences(p); setIndexes (p.getId (), null); evictionDao.removeProduct (p); super.delete (p); } }
ProductDao extends HibernateDao<Product, Long> { @Override public void delete (Product product) { Product p = read (product.getId ()); List<Collection>cls = collectionDao.getCollectionsOfProduct (p.getId ()); User user = userDao.getRootUser(); if (cls!=null) { for (Collection c: cls) { LOGGER.info("deconnect product from collection " + c.getName ()); collectionDao.removeProduct (c.getUUID (), p.getId (), user); } } productCartDao.deleteProductReferences(p); setIndexes (p.getId (), null); evictionDao.removeProduct (p); super.delete (p); }  }
ProductDao extends HibernateDao<Product, Long> { @Override public void delete (Product product) { Product p = read (product.getId ()); List<Collection>cls = collectionDao.getCollectionsOfProduct (p.getId ()); User user = userDao.getRootUser(); if (cls!=null) { for (Collection c: cls) { LOGGER.info("deconnect product from collection " + c.getName ()); collectionDao.removeProduct (c.getUUID (), p.getId (), user); } } productCartDao.deleteProductReferences(p); setIndexes (p.getId (), null); evictionDao.removeProduct (p); super.delete (p); }  static int getMaxPageSize(); Product getProductByPath(final URL path); @Override List<Product> listCriteria(DetachedCriteria detached, int skip,
         int top); @SuppressWarnings ("unchecked") List<Product> read(List<Long>ids); boolean exists(URL url); @Override List<Product> scroll(String clauses, int skip, int n); Iterator<Product> scrollFiltered(String filter, final Long collection_id, int skip); int count(String filter, final String collection_uuid); @Override void deleteAll(); @Override void delete(Product product); void setIndexes(Product product, List<MetadataIndex>indexes); void setIndexes(Long id, List<MetadataIndex>indexes); Iterator<Product> getProductsByIngestionDate(Date max_date); Iterator<Product> getProductsLowerAccess(Date max_date); static String getPathFromProduct(Product product); static String getPathFromURL(URL product); @SuppressWarnings ("unchecked") List<Long> getAuthorizedProducts(String user_uuid); @SuppressWarnings ("unchecked") Product getProductByDownloadableFilename(final String filename,
         final Collection collection); Product getProductByUuid(String uuid); List<Product> getNoCollectionProducts(User user); List<Product> scrollUploadedProducts(final User user, final int skip,
      final int top); @SuppressWarnings ("unchecked") List<Product> getUploadedProducts(final User user); User getOwnerOfProduct(final Product product); boolean isAuthorized(final String user_uuid, final long product_id); Iterator<Product> getUnprocessedProducts(); Iterator<Product> getAllProducts(); Product getProductByIdentifier(String identifier); }
ProductDao extends HibernateDao<Product, Long> { @Override public void delete (Product product) { Product p = read (product.getId ()); List<Collection>cls = collectionDao.getCollectionsOfProduct (p.getId ()); User user = userDao.getRootUser(); if (cls!=null) { for (Collection c: cls) { LOGGER.info("deconnect product from collection " + c.getName ()); collectionDao.removeProduct (c.getUUID (), p.getId (), user); } } productCartDao.deleteProductReferences(p); setIndexes (p.getId (), null); evictionDao.removeProduct (p); super.delete (p); }  static int getMaxPageSize(); Product getProductByPath(final URL path); @Override List<Product> listCriteria(DetachedCriteria detached, int skip,
         int top); @SuppressWarnings ("unchecked") List<Product> read(List<Long>ids); boolean exists(URL url); @Override List<Product> scroll(String clauses, int skip, int n); Iterator<Product> scrollFiltered(String filter, final Long collection_id, int skip); int count(String filter, final String collection_uuid); @Override void deleteAll(); @Override void delete(Product product); void setIndexes(Product product, List<MetadataIndex>indexes); void setIndexes(Long id, List<MetadataIndex>indexes); Iterator<Product> getProductsByIngestionDate(Date max_date); Iterator<Product> getProductsLowerAccess(Date max_date); static String getPathFromProduct(Product product); static String getPathFromURL(URL product); @SuppressWarnings ("unchecked") List<Long> getAuthorizedProducts(String user_uuid); @SuppressWarnings ("unchecked") Product getProductByDownloadableFilename(final String filename,
         final Collection collection); Product getProductByUuid(String uuid); List<Product> getNoCollectionProducts(User user); List<Product> scrollUploadedProducts(final User user, final int skip,
      final int top); @SuppressWarnings ("unchecked") List<Product> getUploadedProducts(final User user); User getOwnerOfProduct(final Product product); boolean isAuthorized(final String user_uuid, final long product_id); Iterator<Product> getUnprocessedProducts(); Iterator<Product> getAllProducts(); Product getProductByIdentifier(String identifier);  }