in backend/src/main/java/org/apache/iotdb/admin/controller/IotDBController.java [1017:1162]
private void checkPrivilegeInfoDTO(PrivilegeInfoDTO privilegeInfoDTO) throws BaseException {
Integer type = privilegeInfoDTO.getType();
List<String> groupPaths = privilegeInfoDTO.getGroupPaths();
List<String> devicePaths = privilegeInfoDTO.getDevicePaths();
List<String> timeseriesPaths = privilegeInfoDTO.getTimeseriesPaths();
List<String> delDevicePaths = privilegeInfoDTO.getDelDevicePaths();
List<String> delGroupPaths = privilegeInfoDTO.getDelGroupPaths();
List<String> delTimeseriesPaths = privilegeInfoDTO.getDelTimeseriesPaths();
if (type == null) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
switch (type) {
case 0:
if (groupPaths != null && groupPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (devicePaths != null && devicePaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (timeseriesPaths != null && timeseriesPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delDevicePaths != null && delDevicePaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delGroupPaths != null && delGroupPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delTimeseriesPaths != null && delTimeseriesPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
break;
case 1:
if (devicePaths != null && devicePaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (timeseriesPaths != null && timeseriesPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delDevicePaths != null && delDevicePaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delTimeseriesPaths != null && delTimeseriesPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
break;
case 2:
if (groupPaths != null && groupPaths.size() > 0) {
if (groupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (devicePaths == null || devicePaths.size() == 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (devicePaths != null && devicePaths.size() > 0) {
if (groupPaths == null || groupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (timeseriesPaths != null && timeseriesPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delGroupPaths != null && delGroupPaths.size() > 0) {
if (delGroupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delDevicePaths == null || delDevicePaths.size() == 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (delDevicePaths != null && delDevicePaths.size() > 0) {
if (delGroupPaths == null || delGroupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (delTimeseriesPaths != null && delTimeseriesPaths.size() > 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
break;
case 3:
if (groupPaths != null && groupPaths.size() > 0) {
if (groupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (devicePaths == null || devicePaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (timeseriesPaths == null || timeseriesPaths.size() == 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (devicePaths != null && devicePaths.size() > 0) {
if (devicePaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (groupPaths == null || groupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (timeseriesPaths == null || timeseriesPaths.size() == 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (timeseriesPaths != null && timeseriesPaths.size() > 0) {
if (groupPaths == null || groupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (devicePaths == null || devicePaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (delGroupPaths != null && delGroupPaths.size() > 0) {
if (delGroupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delDevicePaths == null || delDevicePaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delTimeseriesPaths == null || delTimeseriesPaths.size() == 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (delDevicePaths != null && delDevicePaths.size() > 0) {
if (delDevicePaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delGroupPaths == null || delGroupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delTimeseriesPaths == null || delTimeseriesPaths.size() == 0) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
if (delTimeseriesPaths != null && delTimeseriesPaths.size() > 0) {
if (delGroupPaths == null || delGroupPaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
if (delDevicePaths == null || delDevicePaths.size() != 1) {
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}
break;
default:
throw new BaseException(ErrorCode.WRONG_DB_PARAM, ErrorCode.WRONG_DB_PARAM_MSG);
}
}