Skip to content
Permalink
Browse files

Fixes for CoLabs that use contest type permissioning.

  • Loading branch information...
carlosbpf committed Sep 17, 2019
1 parent 5fec77c commit 3588dc9dd6aedd81cd65c63f2a18221ea373d8b1
@@ -7,6 +7,7 @@
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import org.xcolab.client.user.pojo.tables.pojos.Role;
import org.xcolab.client.user.exceptions.RoleGroupNotFoundException;
import org.xcolab.client.user.permissions.SystemRole;
import org.xcolab.client.user.pojo.IRole;
@@ -27,7 +28,7 @@
IRoleGroup create(@RequestBody IRoleGroup roleGroup) ;

@RequestMapping(value = "/roleGroups/{roleGroupId}/roles", method = RequestMethod.GET)
List<IRole> getRolesInGroup(@PathVariable("roleGroupId") Long roleGroupId) throws RoleGroupNotFoundException;
List<RoleWrapper> getRolesInGroup(@PathVariable("roleGroupId") Long roleGroupId) throws RoleGroupNotFoundException;

@RequestMapping(value = "/roleGroups/{roleGroupId}/roles", method = RequestMethod.POST)
String addRoleToRoleGroup(@PathVariable Long roleGroupId, @RequestParam Long roleId);
@@ -87,7 +88,8 @@ default boolean canStaff(Long userId) {
default boolean hasRoleGroup(long userId, long roleGroupId) {
try {

final List<IRole> roles = getRolesInGroup(roleGroupId);
final List<RoleWrapper> roles = getRolesInGroup(roleGroupId);

for (IRole role : roles) {
if (memberHasRole(userId, role.getId())) {
return true;
@@ -2,6 +2,7 @@

import org.xcolab.client.user.pojo.IRole;
import org.xcolab.client.user.pojo.IRoleGroup;
import org.xcolab.client.user.pojo.wrapper.RoleWrapper;

import java.util.List;

@@ -13,7 +14,7 @@

void removeRoleFromGroup(Long roleGroupId, Long roleId);

List<IRole> getAllRolesInGroup(Long groupId);
List<RoleWrapper> getAllRolesInGroup(Long groupId);

boolean groupHasRole(Long roleGroupId, Long groupId);
}
@@ -7,6 +7,7 @@

import org.xcolab.client.user.pojo.IRole;
import org.xcolab.client.user.pojo.IRoleGroup;
import org.xcolab.client.user.pojo.wrapper.RoleWrapper;
import org.xcolab.model.tables.records.RoleGroupRecord;

import java.util.List;
@@ -60,12 +61,12 @@ public void removeRoleFromGroup(Long roleGroupId, Long roleId) {


@Override
public List<IRole> getAllRolesInGroup(Long groupId) {
public List<RoleWrapper> getAllRolesInGroup(Long groupId) {
return this.dslContext.select()
.from(ROLE_GROUP_ROLE)
.innerJoin(ROLE).on(ROLE.ID.eq(ROLE_GROUP_ROLE.ROLE_ID))
.where(ROLE_GROUP_ROLE.ROLE_GROUP_ID.eq(groupId))
.fetchInto(IRole.class);
.fetchInto(RoleWrapper.class);
}

@Override
@@ -5,6 +5,7 @@

import org.xcolab.client.user.exceptions.RoleGroupNotFoundException;
import org.xcolab.client.user.pojo.IRole;
import org.xcolab.client.user.pojo.wrapper.RoleWrapper;
import org.xcolab.service.members.domain.rolegroup.RoleGroupDao;
import org.xcolab.util.http.exceptions.EntityNotFoundException;

@@ -35,7 +36,7 @@ public void removeRoleFromGroup(Long roleGroupId, Long roleId) throws RoleGroupN
}
}

public List<IRole> getAllRolesInGroup(Long groupId) {
public List<RoleWrapper> getAllRolesInGroup(Long groupId) {
return this.roleGroupDao.getAllRolesInGroup(groupId);
}

@@ -12,6 +12,7 @@
import org.xcolab.client.user.exceptions.RoleGroupNotFoundException;
import org.xcolab.client.user.pojo.IRole;
import org.xcolab.client.user.pojo.IRoleGroup;
import org.xcolab.client.user.pojo.wrapper.RoleWrapper;
import org.xcolab.service.members.domain.rolegroup.RoleGroupDao;
import org.xcolab.service.members.service.rolegroup.RoleGroupService;

@@ -33,7 +34,7 @@ public IRoleGroup create(@RequestBody IRoleGroup roleGroup) {
}

@RequestMapping(value = "/roleGroups/{roleGroupId}/roles", method = RequestMethod.GET)
public List<IRole> getRolesInGroup(@PathVariable("roleGroupId") Long roleGroupId)
public List<RoleWrapper> getRolesInGroup(@PathVariable("roleGroupId") Long roleGroupId)
throws RoleGroupNotFoundException {
if (roleGroupId != null) {
return roleGroupService.getAllRolesInGroup(roleGroupId);
@@ -296,6 +296,11 @@
<artifactId>sentry-spring</artifactId>
<version>${sentry.version}</version>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.1</version>
</dependency>
</dependencies>
</dependencyManagement>

0 comments on commit 3588dc9

Please sign in to comment.
You can’t perform that action at this time.