Fix tenant scope on retrieval of target groups (#2847)
* Fix tenant scope on retrieval of target groups Signed-off-by: strailov <Stanislav.Trailov@bosch.io> * fix build Signed-off-by: strailov <Stanislav.Trailov@bosch.io> --------- Signed-off-by: strailov <Stanislav.Trailov@bosch.io>
This commit is contained in:
committed by
GitHub
parent
e6367d0b0c
commit
3bc8a91883
@@ -14,6 +14,7 @@ import static org.eclipse.hawkbit.mgmt.rest.resource.util.PagingUtility.sanitize
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.eclipse.hawkbit.context.AccessContext;
|
||||||
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
import org.eclipse.hawkbit.mgmt.json.model.PagedList;
|
||||||
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
|
import org.eclipse.hawkbit.mgmt.json.model.target.MgmtTarget;
|
||||||
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetGroupRestApi;
|
import org.eclipse.hawkbit.mgmt.rest.api.MgmtTargetGroupRestApi;
|
||||||
@@ -87,7 +88,7 @@ public class MgmtTargetGroupResource implements MgmtTargetGroupRestApi {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ResponseEntity<List<String>> getTargetGroups() {
|
public ResponseEntity<List<String>> getTargetGroups() {
|
||||||
final List<String> groups = targetManagement.findGroups();
|
final List<String> groups = targetManagement.findGroups(AccessContext.tenant());
|
||||||
return ResponseEntity.ok(groups);
|
return ResponseEntity.ok(groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -375,7 +375,7 @@ public interface TargetManagement<T extends Target>
|
|||||||
* @return list of all distinct target groups
|
* @return list of all distinct target groups
|
||||||
*/
|
*/
|
||||||
@PreAuthorize(HAS_READ_REPOSITORY)
|
@PreAuthorize(HAS_READ_REPOSITORY)
|
||||||
List<String> findGroups();
|
List<String> findGroups(String tenant);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates or updates a meta-data value.
|
* Creates or updates a meta-data value.
|
||||||
|
|||||||
@@ -381,8 +381,8 @@ public class JpaTargetManagement
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> findGroups() {
|
public List<String> findGroups(String tenant) {
|
||||||
return jpaRepository.findDistinctGroups();
|
return jpaRepository.findDistinctGroups(tenant);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -102,6 +102,6 @@ public interface TargetRepository extends BaseEntityRepository<JpaTarget> {
|
|||||||
* Finds all available distinct target groups
|
* Finds all available distinct target groups
|
||||||
* @return all target groups
|
* @return all target groups
|
||||||
*/
|
*/
|
||||||
@Query(value = "SELECT DISTINCT target_group FROM sp_target WHERE target_group IS NOT NULL", nativeQuery = true)
|
@Query(value = "SELECT DISTINCT target_group FROM sp_target WHERE tenant = ?1 AND target_group IS NOT NULL", nativeQuery = true)
|
||||||
List<String> findDistinctGroups();
|
List<String> findDistinctGroups(@Param("tenant") String tenant);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user