Skip to content

Commit 7f183da

Browse files
committed
return empty permissions set in case of document/folder unexistence
1 parent e3101c0 commit 7f183da

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

logicaldoc-core/src/main/java/com/logicaldoc/core/document/HibernateDocumentDAO.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1419,10 +1419,13 @@ private User getExistingtUser(long userId) throws PersistenceException {
14191419
public Set<Permission> getAllowedPermissions(long docId, long userId) throws PersistenceException {
14201420
final Set<Permission> permissions = new HashSet<>();
14211421
User user = getExistingtUser(userId);
1422+
if(user==null)
1423+
return new HashSet<>();
1424+
14221425
userDAO.initialize(user);
14231426

14241427
if (findById(docId) == null)
1425-
throw new PersistenceException("Unexisting document " + docId);
1428+
return new HashSet<>();
14261429

14271430
// If the user is an administrator bypass all controls
14281431
if (user.isAdmin()) {

logicaldoc-core/src/main/java/com/logicaldoc/core/folder/HibernateFolderDAO.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,8 @@ public void restore(long folderId, long parentId, FolderHistory transaction) thr
917917
public Set<Permission> getAllowedPermissions(long folderId, long userId) throws PersistenceException {
918918
final Set<Permission> permissions = new HashSet<>();
919919
User user = getExistingtUser(userId);
920+
if (user == null)
921+
return new HashSet<>();
920922

921923
// If the user is an administrator bypass all controls
922924
if (user.isMemberOf(Group.GROUP_ADMIN))
@@ -930,6 +932,8 @@ public Set<Permission> getAllowedPermissions(long folderId, long userId) throws
930932
// the policies
931933
long id = folderId;
932934
Folder folder = findById(folderId);
935+
if (folder == null)
936+
return new HashSet<>();
933937

934938
if (folder.getSecurityRef() != null) {
935939
id = folder.getSecurityRef().longValue();

0 commit comments

Comments
 (0)