This is an automated email from the ASF dual-hosted git repository.
casion pushed a commit to branch dev-1.3.2
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.3.2 by this push:
new 354c497cd [ISSUE-3873]Exception handling added key parameter
information (#3892)
354c497cd is described below
commit 354c497cd7c4f47908923bf2a5209004af2c46cb
Author: 成彬彬 <[email protected]>
AuthorDate: Wed Nov 30 21:57:25 2022 +0800
[ISSUE-3873]Exception handling added key parameter information (#3892)
* Exception handling added key parameter information
* add MessageFormat
---
.../exception/WorkspaceExceptionManager.java | 61 ++++++++++++----------
.../filesystem/restful/api/FsRestfulApi.java | 50 +++++++++---------
.../linkis/filesystem/util/WorkspaceUtil.java | 2 +-
3 files changed, 59 insertions(+), 54 deletions(-)
diff --git
a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/exception/WorkspaceExceptionManager.java
b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/exception/WorkspaceExceptionManager.java
index 3af7428ea..de2e8ef42 100644
---
a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/exception/WorkspaceExceptionManager.java
+++
b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/exception/WorkspaceExceptionManager.java
@@ -17,6 +17,7 @@
package org.apache.linkis.filesystem.exception;
+import java.text.MessageFormat;
import java.util.HashMap;
import java.util.Map;
@@ -27,50 +28,54 @@ public class WorkspaceExceptionManager {
{
put(
"80001",
- "Requesting IO-Engine to initialize fileSystem
failed!(请求IO-Engine初始化fileSystem失败!)");
+ "Requesting IO-Engine to initialize fileSystem
failed(请求IO-Engine初始化fileSystem失败)!");
put(
"80002",
- "The user has obtained the filesystem for more than %d ms.
Please contact the administrator.(用户获取filesystem的时间超过%d ms,请联系管理员)");
+ "The user has obtained the filesystem for more than {0} ms.
Please contact the administrator(用户获取filesystem的时间超过{0} ms,请联系管理员)");
put(
"80003",
- "User local root directory does not exist, please contact
administrator to add(用户本地根目录不存在,请联系管理员添加)");
- put("80004", "path:(路径:)%sIs empty!(为空!)");
- put("80005", "The created folder name is duplicated!(创建的文件夹名重复!)");
- put("80006", "The file name created is duplicated!(创建的文件名重复!)");
- put("80007", "The renamed name is repeated!(重命名的名字重复!)");
- put("80008", "The deleted file or folder does not
exist!(删除的文件or文件夹不存在!)");
+ "User local root directory:{0} does not exist, please contact
administrator to add(用户本地根目录:{0}不存在,请联系管理员添加)");
+ put("80004", "The path:{0} is empty(路径:{0} 为空)!");
+ put("80005", "The created folder name:{0} is duplicated(创建的文件夹名:{0}
重复)");
+ put("80006", "The file name:{0} created is duplicated(创建的文件名:{0}
重复)");
+ put("80007", "The renamed name:{0} is repeated,(重命名的名字:{0} 重复)");
+ put("80008", "The deleted file or folder does not
exist(删除的文件or文件夹不存在)!");
put(
"80009",
- "This user does not have permission to delete this file or
folder!(该用户无权删除此文件或文件夹!)");
+ "This user does not have permission to delete this file or
folder(该用户无权删除此文件或文件夹)!");
put(
"80010",
- "The user does not have permission to view the contents of the
directory(该用户无权限查看该目录的内容)");
- put("80011", "The downloaded file does not exist!(下载的文件不存在!)");
- put("80012", "This user has no permission to read this file!");
- put("80013", "file does not exist!(文件不存在!)");
+ "The user: {0} has no permission to view the contents of the
directory:{1}(该用户:{0}无权限查看该目录:{1}的内容).");
+ put("80011", "Downloaded file: {0} does not exist(下载的文件:{0}不存在)");
+ put("80012", "This user has no permission to read this
file(该用户无权读取该文件)!");
+ put("80013", "File: {0} does not exist(文件:{0}不存在)");
put(
"80014",
- "The user has no permission to modify the contents of this file
and cannot save it!(该用户无权限对此文件内容进行修改,无法保存!)");
- put("80015", "unsupported resultset output type");
- put("80016", "The file content is empty and cannot be
imported!(文件内容为空,不能进行导入操作!)");
+ "The user has no permission to modify the contents of this file
and cannot save it(该用户无权限对此文件内容进行修改,无法保存)!");
+ put("80015", "Unsupported resultset output type(不支持的结果集输出类型)");
+ put("80016", "The file content is empty and cannot be
imported(文件内容为空,不能进行导入操作)!");
put(
"80017",
- "The header of the file has no qualifiers. Do not check the
first behavior header or set no qualifier!(该文件的表头没有限定符,请勿勾选首行为表头或者设置无限定符!)");
- put("80018", "This user has no permission to read this
log!(该用户无权限读取此日志!)");
- put("80019", "scriptContent is empty,this is normal!");
- put("80021", "上传失败");
- put("80022", "更新失败");
- put("80023", "下载失败");
- put("80024", "非table类型的结果集不能下载为excel");
- put("80028", "the path exist special char");
- put("80029", "empty dir!");
- put("80030", "Failed to create user path");
- put("80031", "The user was not initialized(用户未初始化)");
+ "The header of the file has no qualifiers. Do not check the
first behavior header or set no qualifier(该文件的表头没有限定符,请勿勾选首行为表头或者设置无限定符)!");
+ put("80018", "This user has no permission to read this
log(该用户无权限读取此日志)!");
+ put("80019", "ScriptContent is empty,this is normal(scriptContent
为空,这是正常的)!");
+ put("80021", "Upload failed(上传失败)");
+ put("80022", "Update failed(更新失败)");
+ put("80023", "Download failed(下载失败)");
+ put(
+ "80024",
+ "Non-tabular result sets cannot be downloaded as
excel(非table类型的结果集不能下载为excel)");
+ put(
+ "80028",
+ "The path exist special char,only support numbers, uppercase
letters, underscores, Chinese(路径存在特殊字符,只支持数字,字母大小写,下划线,中文)");
+ put("80029", "Empty dir(空目录)!");
+ put("80030", "Creating user path: {0} failed(创建用户路径:{0}失败)");
+ put("80031", "User: {0} not initialized(用户:{0}未初始化)");
}
};
public static WorkSpaceException createException(int errorCode, Object...
format) {
return new WorkSpaceException(
- errorCode, String.format(desc.get(String.valueOf(errorCode)), format));
+ errorCode, MessageFormat.format(desc.get(String.valueOf(errorCode)),
format));
}
}
diff --git
a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java
b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java
index 8b3412295..7b9ed97eb 100644
---
a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java
+++
b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/restful/api/FsRestfulApi.java
@@ -141,7 +141,7 @@ public class FsRestfulApi {
if (!fileSystem.exists(fsPath)) {
if (!FsPath.WINDOWS && !UserGroupUtils.isUserExist(userName)) {
LOGGER.warn("User {} not exist in linkis node.", userName);
- throw WorkspaceExceptionManager.createException(80031);
+ throw WorkspaceExceptionManager.createException(80031, userName);
}
if (FILESYSTEM_PATH_AUTO_CREATE.getValue()) {
try {
@@ -149,10 +149,10 @@ public class FsRestfulApi {
return Message.ok().data(String.format("user%sRootPath",
returnType), path);
} catch (IOException e) {
LOGGER.error(e.getMessage(), e);
- throw WorkspaceExceptionManager.createException(80030);
+ throw WorkspaceExceptionManager.createException(80030, path);
}
}
- throw WorkspaceExceptionManager.createException(80003);
+ throw WorkspaceExceptionManager.createException(80003, path);
}
return Message.ok().data(String.format("user%sRootPath", returnType),
path);
}
@@ -172,13 +172,13 @@ public class FsRestfulApi {
throw WorkspaceExceptionManager.createException(80004, path);
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
WorkspaceUtil.fileAndDirNameSpecialCharCheck(path);
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
if (fileSystem.exists(fsPath)) {
- throw WorkspaceExceptionManager.createException(80005);
+ throw WorkspaceExceptionManager.createException(80005, path);
}
fileSystem.mkdirs(fsPath);
return Message.ok();
@@ -198,13 +198,13 @@ public class FsRestfulApi {
throw WorkspaceExceptionManager.createException(80004, path);
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
WorkspaceUtil.fileAndDirNameSpecialCharCheck(path);
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
if (fileSystem.exists(fsPath)) {
- throw WorkspaceExceptionManager.createException(80006);
+ throw WorkspaceExceptionManager.createException(80006, path);
}
fileSystem.createNewFile(fsPath);
return Message.ok();
@@ -231,7 +231,7 @@ public class FsRestfulApi {
PathValidator$.MODULE$.validate(newDest, userName);
}
if (!checkIsUsersDirectory(newDest, userName)) {
- throw WorkspaceExceptionManager.createException(80010, newDest);
+ throw WorkspaceExceptionManager.createException(80010, userName,
newDest);
}
if (StringUtils.isEmpty(oldDest)) {
throw WorkspaceExceptionManager.createException(80004, oldDest);
@@ -245,7 +245,7 @@ public class FsRestfulApi {
FsPath fsPathNew = new FsPath(newDest);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPathOld);
if (fileSystem.exists(fsPathNew)) {
- throw WorkspaceExceptionManager.createException(80007);
+ throw WorkspaceExceptionManager.createException(80007, newDest);
}
fileSystem.renameTo(fsPathOld, fsPathNew);
return Message.ok();
@@ -278,7 +278,7 @@ public class FsRestfulApi {
PathValidator$.MODULE$.validate(newDir, userName);
}
if (!checkIsUsersDirectory(filePath, userName)) {
- throw WorkspaceExceptionManager.createException(80010, filePath);
+ throw WorkspaceExceptionManager.createException(80010, userName,
filePath);
}
FsPath flieOldPath = new FsPath(filePath);
String name =
@@ -288,7 +288,7 @@ public class FsRestfulApi {
WorkspaceUtil.fileAndDirNameSpecialCharCheck(flieOldPath.getPath());
WorkspaceUtil.fileAndDirNameSpecialCharCheck(flieNewPath.getPath());
if (!fileSystem.exists(flieOldPath)) {
- throw WorkspaceExceptionManager.createException(80013);
+ throw WorkspaceExceptionManager.createException(80013, filePath);
}
fileSystem.renameTo(flieOldPath, flieNewPath);
return Message.ok();
@@ -312,7 +312,7 @@ public class FsRestfulApi {
}
String userName = ModuleUserUtils.getOperationUser(req, "upload " + path);
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
@@ -344,7 +344,7 @@ public class FsRestfulApi {
throw WorkspaceExceptionManager.createException(80004, path);
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
@@ -373,7 +373,7 @@ public class FsRestfulApi {
}
String userName = ModuleUserUtils.getOperationUser(req, "getDirFileTrees "
+ path);
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
@@ -385,7 +385,7 @@ public class FsRestfulApi {
// if(!isInUserWorkspace(path,userName)) throw new WorkSpaceException("The
user does not
// have permission to view the contents of the directory");
if (!fileSystem.canExecute(fsPath) || !fileSystem.canRead(fsPath)) {
- throw WorkspaceExceptionManager.createException(80010);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
dirFileTree.setName(new File(path).getName());
dirFileTree.setChildren(new ArrayList<>());
@@ -434,14 +434,14 @@ public class FsRestfulApi {
charset = Consts.UTF_8.toString();
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FsPath fsPath = new FsPath(path);
// TODO: 2018/11/29 Judging the directory, the directory cannot be
// downloaded(判断目录,目录不能下载)
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
if (!fileSystem.exists(fsPath)) {
- throw WorkspaceExceptionManager.createException(8011);
+ throw WorkspaceExceptionManager.createException(8011, path);
}
inputStream = fileSystem.read(fsPath);
byte[] buffer = new byte[1024];
@@ -484,7 +484,7 @@ public class FsRestfulApi {
throw WorkspaceExceptionManager.createException(80004, path);
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
return Message.ok().data("isExist", fileSystem.exists(fsPath));
@@ -566,7 +566,7 @@ public class FsRestfulApi {
}
String userName = ModuleUserUtils.getOperationUser(req, "openFile " +
path);
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
@@ -618,7 +618,7 @@ public class FsRestfulApi {
charset = Consts.UTF_8.toString();
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
String scriptContent = (String) json.get("scriptContent");
Object params = json.get("params");
@@ -627,7 +627,7 @@ public class FsRestfulApi {
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
if (!fileSystem.exists(fsPath)) {
- throw WorkspaceExceptionManager.createException(80013);
+ throw WorkspaceExceptionManager.createException(80013, path);
}
if (!fileSystem.canWrite(fsPath)) {
throw WorkspaceExceptionManager.createException(80014);
@@ -719,7 +719,7 @@ public class FsRestfulApi {
throw WorkspaceExceptionManager.createException(80004, path);
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
response.addHeader(
"Content-Disposition",
@@ -823,7 +823,7 @@ public class FsRestfulApi {
throw WorkspaceExceptionManager.createException(80004, path);
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
// list目录下的文件
FsPathListWithError fsPathListWithError =
fileSystem.listPathWithError(fsPath);
@@ -915,7 +915,7 @@ public class FsRestfulApi {
}
String userName = ModuleUserUtils.getOperationUser(req, "formate " + path);
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
String suffix = path.substring(path.lastIndexOf("."));
FsPath fsPath = new FsPath(path);
@@ -982,7 +982,7 @@ public class FsRestfulApi {
userName = proxyUser;
}
if (!checkIsUsersDirectory(path, userName)) {
- throw WorkspaceExceptionManager.createException(80010, path);
+ throw WorkspaceExceptionManager.createException(80010, userName, path);
}
FsPath fsPath = new FsPath(path);
FileSystem fileSystem = fsService.getFileSystem(userName, fsPath);
diff --git
a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/util/WorkspaceUtil.java
b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/util/WorkspaceUtil.java
index 7d9ddfd96..f21ada7db 100644
---
a/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/util/WorkspaceUtil.java
+++
b/linkis-public-enhancements/linkis-script-dev/linkis-storage-script-dev-server/src/main/java/org/apache/linkis/filesystem/util/WorkspaceUtil.java
@@ -90,7 +90,7 @@ public class WorkspaceUtil {
if (i != -1) {
name = name.substring(0, i);
}
- // 只支持数字,字母大小写,下划线,中文
+ // Only support numbers, uppercase letters, underscores,
Chinese(只支持数字,字母大小写,下划线,中文)
String specialRegEx = "^[\\w\\u4e00-\\u9fa5]{1,200}$";
Pattern specialPattern = Pattern.compile(specialRegEx);
if (!specialPattern.matcher(name).find()) {
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]