コード例 #1
0
 @PreAuthorize("hasRole('ROLE_DOWNLOAD')")
 @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
 @Cacheable(value = "product", key = "#id")
 public Product getProductToDownload(Long id) {
   // TODO remove method cause duplicated and not used
   return productDao.read(id);
 }
コード例 #2
0
  public void addProduct(
      URL path,
      User owner,
      final List<Collection> collections,
      String origin,
      Scanner scanner,
      FileScannerWrapper wrapper)
      throws DataStoreAlreadyExistException {
    if (productDao.exists(path)) {
      throw new DataStoreAlreadyExistException(
          "Product \"" + path.toExternalForm() + "\" already present in the system.");
    }

    /* **** CRITICAL SECTION *** */
    /** THIS SECTION SHALL NEVER BE STOPPED BY CNTRL-C OR OTHER SIGNALS */
    /* TODO: check if shutdownHook can protect this section */
    Product product = new Product();
    product.setPath(path);
    product.setOrigin(origin);
    List<User> users = new ArrayList<User>();

    if (owner != null) {
      product.setOwner(owner);
      users.add(userDao.read(owner.getId()));
      product.setAuthorizedUsers(new HashSet<User>(users));
    }

    product = productDao.create(product);

    // FIX
    product = productDao.read(product.getId());
    /* **** CRITICAL SECTION *** */
    processProduct(product, owner, collections, scanner, wrapper);
  }
コード例 #3
0
 @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
 @CacheEvict(
     value = {"indexes"},
     key = "#product_id")
 public void setIndexes(Long product_id, List<MetadataIndex> indexes) {
   Product product = productDao.read(product_id);
   product.setIndexes(indexes);
   productDao.update(product);
 }
コード例 #4
0
 @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
 @Cacheable(
     value = {"indexes"},
     key = "#product_id")
 public List<MetadataIndex> getIndexes(Long product_id) {
   Product product = productDao.read(product_id);
   Hibernate.initialize(product.getIndexes());
   return product.getIndexes();
 }
コード例 #5
0
  @Transactional(readOnly = false, propagation = Propagation.REQUIRED)
  @Caching(
      evict = {
        @CacheEvict(value = "indexes", key = "#pid"),
        @CacheEvict(value = "product", key = "#pid"),
        @CacheEvict(value = "products", allEntries = true)
      })
  @IncrementCache(name = "product_count", key = "all", value = -1)
  public void systemDeleteProduct(Long pid) {
    Product product = productDao.read(pid);

    if (product == null) {
      throw new DataStoreException("Product #" + pid + " not found in the system.");
    }

    if (product.getLocked()) {
      throw new DataStoreException(
          "Cannot delete product #" + pid + ". Product is locked in the system.");
    }
    productDao.delete(product);
  }
コード例 #6
0
 @PreAuthorize("hasAnyRole('ROLE_DATA_MANAGER','ROLE_SEARCH')")
 @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
 @Cacheable(value = "products", key = "#ids")
 public List<Product> getProducts(List<Long> ids) {
   return productDao.read(ids);
 }
コード例 #7
0
 @Transactional(readOnly = true, propagation = Propagation.REQUIRED)
 @Cacheable(value = "product", key = "#id")
 public Product systemGetProduct(Long id) {
   return productDao.read(id);
 }