mirror of
https://github.com/Kingsrook/qqq.git
synced 2025-07-18 13:10:44 +00:00
CE-882 add filterForWriteLockTree
This commit is contained in:
@ -23,6 +23,7 @@ package com.kingsrook.qqq.backend.core.model.metadata.security;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
@ -50,12 +51,36 @@ public class RecordSecurityLockFilters
|
|||||||
** filter a list of locks so that we only see the ones that apply to reads.
|
** filter a list of locks so that we only see the ones that apply to reads.
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
public static MultiRecordSecurityLock filterForReadLockTree(List<RecordSecurityLock> recordSecurityLocks)
|
public static MultiRecordSecurityLock filterForReadLockTree(List<RecordSecurityLock> recordSecurityLocks)
|
||||||
|
{
|
||||||
|
return filterForLockTree(recordSecurityLocks, Set.of(RecordSecurityLock.LockScope.READ_AND_WRITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** filter a list of locks so that we only see the ones that apply to writes.
|
||||||
|
*******************************************************************************/
|
||||||
|
public static MultiRecordSecurityLock filterForWriteLockTree(List<RecordSecurityLock> recordSecurityLocks)
|
||||||
|
{
|
||||||
|
return filterForLockTree(recordSecurityLocks, Set.of(RecordSecurityLock.LockScope.READ_AND_WRITE, RecordSecurityLock.LockScope.WRITE));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*******************************************************************************
|
||||||
|
** filter a list of locks so that we only see the ones that apply to any of the
|
||||||
|
** input set of scopes.
|
||||||
|
*******************************************************************************/
|
||||||
|
private static MultiRecordSecurityLock filterForLockTree(List<RecordSecurityLock> recordSecurityLocks, Set<RecordSecurityLock.LockScope> allowedScopes)
|
||||||
{
|
{
|
||||||
if(recordSecurityLocks == null)
|
if(recordSecurityLocks == null)
|
||||||
{
|
{
|
||||||
return (null);
|
return (null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
|
// at the top-level we build a multi-lock with AND operator //
|
||||||
|
//////////////////////////////////////////////////////////////
|
||||||
MultiRecordSecurityLock result = new MultiRecordSecurityLock();
|
MultiRecordSecurityLock result = new MultiRecordSecurityLock();
|
||||||
result.setOperator(MultiRecordSecurityLock.BooleanOperator.AND);
|
result.setOperator(MultiRecordSecurityLock.BooleanOperator.AND);
|
||||||
|
|
||||||
@ -69,7 +94,7 @@ public class RecordSecurityLockFilters
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if(RecordSecurityLock.LockScope.READ_AND_WRITE.equals(recordSecurityLock.getLockScope()))
|
if(allowedScopes.contains(recordSecurityLock.getLockScope()))
|
||||||
{
|
{
|
||||||
result.withLock(recordSecurityLock);
|
result.withLock(recordSecurityLock);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user