Exemple #1
0
 private void createOrUpdateFile(FileRecord file)
     throws DigitalLibraryException, IOException, NotFoundException, AccessDeniedException {
   HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().begin();
   try {
     InputStream f = file.open();
     ResourceMetadata r1 = dl.createOrUpdateFile(RO_URI, file.path, f, file.mimeType);
     f.close();
     assertNotNull(r1);
   } finally {
     HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
   }
 }
Exemple #2
0
 private void checkCantCreateOrUpdateFile(FileRecord file)
     throws DigitalLibraryException, IOException, NotFoundException {
   HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().begin();
   InputStream f = file.open();
   try {
     dl.createOrUpdateFile(RO_URI, file.path, f, file.mimeType);
     fail("Should throw an exception when creating file");
   } catch (Exception e) {
     // good
   } finally {
     f.close();
     HibernateUtil.getSessionFactory().getCurrentSession().getTransaction().commit();
   }
 }