1
0
mirror of https://github.com/sismics/docs.git synced 2025-12-13 17:56:20 +00:00

File sharing (server done)

This commit is contained in:
jendib
2013-08-14 00:47:58 +02:00
parent 5cfc487193
commit 4cb5b7fdbb
5 changed files with 95 additions and 25 deletions

View File

@@ -64,6 +64,12 @@ public class FileDao {
// Delete the file
Date dateNow = new Date();
fileDb.setDeleteDate(dateNow);
// Delete linked data
q = em.createQuery("update FileShare fs set fs.deleteDate = :dateNow where fs.fileId = :fileId and fs.deleteDate is null");
q.setParameter("fileId", id);
q.setParameter("dateNow", dateNow);
q.executeUpdate();
}
/**

View File

@@ -46,7 +46,11 @@ public class FileShareDao {
EntityManager em = ThreadLocalContext.get().getEntityManager();
Query q = em.createQuery("select fs from FileShare fs where fs.id = :id and fs.deleteDate is null");
q.setParameter("id", id);
return (FileShare) q.getSingleResult();
try {
return (FileShare) q.getSingleResult();
} catch (NoResultException e) {
return null;
}
}
/**