in backend/src/main/java/org/apache/iotdb/admin/service/impl/IotDBServiceImpl.java [4210:4241]
private void grantOrRevokePaths(
String grantOrRevoke,
String userOrRole,
String name,
String privilege,
List<String> paths,
SessionPool sessionPool)
throws BaseException {
String sql = null;
String show_version = executeQueryOneValue(sessionPool, "show version");
if (show_version.contains("0.13") || show_version.contains("0.14")) {
sql = grantOrRevoke + " " + userOrRole + " " + name + " privileges " + privilege + " on ";
} else if (show_version.contains("0.12")) {
sql = grantOrRevoke + " " + userOrRole + " " + name + " privileges '" + privilege + "' on ";
}
if (notNullAndNotZero(paths)) {
for (String groupPath : paths) {
try {
sessionPool.executeNonQueryStatement(sql + groupPath);
} catch (StatementExecutionException e) {
logger.error(e.getMessage());
if (e.getStatusCode() == 602) {
throw new BaseException(
ErrorCode.NO_PRI_GRANT_PRIVILEGE, ErrorCode.NO_PRI_GRANT_PRIVILEGE_MSG);
}
} catch (IoTDBConnectionException e) {
logger.error(e.getMessage());
throw new BaseException(ErrorCode.GET_SESSION_FAIL, ErrorCode.GET_SESSION_FAIL_MSG);
}
}
}
}