mirror of
https://github.com/sismics/docs.git
synced 2024-11-22 14:07:55 +01:00
Fix batch for ACLs on tags
This commit is contained in:
parent
e234440ce6
commit
6f89a50fe5
@ -335,28 +335,32 @@ public class AppResource extends BaseResource {
|
|||||||
|
|
||||||
// Get all tags
|
// Get all tags
|
||||||
TagDao tagDao = new TagDao();
|
TagDao tagDao = new TagDao();
|
||||||
|
UserDao userDao = new UserDao();
|
||||||
List<TagDto> tagDtoList = tagDao.findByCriteria(new TagCriteria(), null);
|
List<TagDto> tagDtoList = tagDao.findByCriteria(new TagCriteria(), null);
|
||||||
|
|
||||||
// Add READ and WRITE ACLs
|
// Add READ and WRITE ACLs
|
||||||
for (TagDto tagDto : tagDtoList) {
|
for (TagDto tagDto : tagDtoList) {
|
||||||
|
// Remove old ACLs
|
||||||
AclDao aclDao = new AclDao();
|
AclDao aclDao = new AclDao();
|
||||||
List<AclDto> aclDtoList = aclDao.getBySourceId(tagDto.getId());
|
List<AclDto> aclDtoList = aclDao.getBySourceId(tagDto.getId());
|
||||||
|
String userId = userDao.getActiveByUsername(tagDto.getCreator()).getId();
|
||||||
|
for (AclDto aclDto : aclDtoList) {
|
||||||
|
aclDao.delete(aclDto.getSourceId(), aclDto.getPerm(), aclDto.getTargetId(), userId);
|
||||||
|
}
|
||||||
|
|
||||||
if (aclDtoList.size() == 0) {
|
|
||||||
// Create read ACL
|
// Create read ACL
|
||||||
Acl acl = new Acl();
|
Acl acl = new Acl();
|
||||||
acl.setPerm(PermType.READ);
|
acl.setPerm(PermType.READ);
|
||||||
acl.setSourceId(tagDto.getId());
|
acl.setSourceId(tagDto.getId());
|
||||||
acl.setTargetId(principal.getId());
|
acl.setTargetId(userId);
|
||||||
aclDao.create(acl, principal.getId());
|
aclDao.create(acl, userId);
|
||||||
|
|
||||||
// Create write ACL
|
// Create write ACL
|
||||||
acl = new Acl();
|
acl = new Acl();
|
||||||
acl.setPerm(PermType.WRITE);
|
acl.setPerm(PermType.WRITE);
|
||||||
acl.setSourceId(tagDto.getId());
|
acl.setSourceId(tagDto.getId());
|
||||||
acl.setTargetId(principal.getId());
|
acl.setTargetId(userId);
|
||||||
aclDao.create(acl, principal.getId());
|
aclDao.create(acl, userId);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Always return OK
|
// Always return OK
|
||||||
|
Loading…
Reference in New Issue
Block a user