From 6eb8af9e945ed27e795e0c855167cc374966a8f0 Mon Sep 17 00:00:00 2001 From: ruibaby Date: Sat, 1 Jun 2019 16:53:46 +0800 Subject: [PATCH] Translate some exception messgae. --- .../halo/app/controller/content/MainController.java | 2 +- .../halo/app/event/comment/CommentEventListener.java | 2 +- .../app/security/filter/AdminAuthenticationFilter.java | 2 +- .../run/halo/app/service/impl/BasePostServiceImpl.java | 4 ++-- .../run/halo/app/service/impl/CategoryServiceImpl.java | 2 +- .../java/run/halo/app/service/impl/TagServiceImpl.java | 2 +- .../run/halo/app/service/impl/ThemeServiceImpl.java | 10 +++++----- 7 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/main/java/run/halo/app/controller/content/MainController.java b/src/main/java/run/halo/app/controller/content/MainController.java index be84b0cfc..5d1b9964a 100644 --- a/src/main/java/run/halo/app/controller/content/MainController.java +++ b/src/main/java/run/halo/app/controller/content/MainController.java @@ -50,7 +50,7 @@ public class MainController { @GetMapping("/avatar") public void avatar(HttpServletResponse response) throws IOException { - User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("Can not find blog owner")); + User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("找不到博主信息")); if (StringUtils.isNotEmpty(user.getAvatar())) { response.sendRedirect(user.getAvatar()); } diff --git a/src/main/java/run/halo/app/event/comment/CommentEventListener.java b/src/main/java/run/halo/app/event/comment/CommentEventListener.java index 8afddcb2c..213f4c5ee 100644 --- a/src/main/java/run/halo/app/event/comment/CommentEventListener.java +++ b/src/main/java/run/halo/app/event/comment/CommentEventListener.java @@ -65,7 +65,7 @@ public class CommentEventListener { return; } - User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("Can not find blog owner")); + User user = userService.getCurrentUser().orElseThrow(() -> new ServiceException("找不到博主信息")); Map data = new HashMap<>(); diff --git a/src/main/java/run/halo/app/security/filter/AdminAuthenticationFilter.java b/src/main/java/run/halo/app/security/filter/AdminAuthenticationFilter.java index cc7494ebc..736ab2f53 100644 --- a/src/main/java/run/halo/app/security/filter/AdminAuthenticationFilter.java +++ b/src/main/java/run/halo/app/security/filter/AdminAuthenticationFilter.java @@ -98,7 +98,7 @@ public class AdminAuthenticationFilter extends AbstractAuthenticationFilter { Optional optionalUserId = cacheStore.getAny(SecurityUtils.buildTokenAccessKey(token), Integer.class); if (!optionalUserId.isPresent()) { - getFailureHandler().onFailure(request, response, new AuthenticationException("The token has been expired or not exist").setErrorData(token)); + getFailureHandler().onFailure(request, response, new AuthenticationException("Token 已过期或不存在").setErrorData(token)); return; } diff --git a/src/main/java/run/halo/app/service/impl/BasePostServiceImpl.java b/src/main/java/run/halo/app/service/impl/BasePostServiceImpl.java index 163586804..56c8c1a9a 100644 --- a/src/main/java/run/halo/app/service/impl/BasePostServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/BasePostServiceImpl.java @@ -77,7 +77,7 @@ public abstract class BasePostServiceImpl extends Abstrac public POST getByUrl(String url) { Assert.hasText(url, "Url must not be blank"); - return basePostRepository.getByUrl(url).orElseThrow(() -> new NotFoundException("The post does not exist").setErrorData(url)); + return basePostRepository.getByUrl(url).orElseThrow(() -> new NotFoundException("该文章不存在").setErrorData(url)); } @Override @@ -87,7 +87,7 @@ public abstract class BasePostServiceImpl extends Abstrac Optional postOptional = basePostRepository.getByUrlAndStatus(url, status); - return postOptional.orElseThrow(() -> new NotFoundException("The post with status " + status + " and url " + url + "was not existed").setErrorData(url)); + return postOptional.orElseThrow(() -> new NotFoundException("The post with status " + status + " and url " + url + " was not existed").setErrorData(url)); } @Override diff --git a/src/main/java/run/halo/app/service/impl/CategoryServiceImpl.java b/src/main/java/run/halo/app/service/impl/CategoryServiceImpl.java index 2b78e82a6..e03dbc184 100644 --- a/src/main/java/run/halo/app/service/impl/CategoryServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/CategoryServiceImpl.java @@ -152,7 +152,7 @@ public class CategoryServiceImpl extends AbstractCrudService */ @Override public Category getBySlugName(String slugName) { - return categoryRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("The Category does not exist").setErrorData(slugName)); + return categoryRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该分类已存在").setErrorData(slugName)); } @Override diff --git a/src/main/java/run/halo/app/service/impl/TagServiceImpl.java b/src/main/java/run/halo/app/service/impl/TagServiceImpl.java index e2c49b6ad..87b794610 100644 --- a/src/main/java/run/halo/app/service/impl/TagServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/TagServiceImpl.java @@ -57,7 +57,7 @@ public class TagServiceImpl extends AbstractCrudService implements */ @Override public Tag getBySlugNameOfNonNull(String slugName) { - return tagRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("The tag does not exist").setErrorData(slugName)); + return tagRepository.getBySlugName(slugName).orElseThrow(() -> new NotFoundException("该标签已存在").setErrorData(slugName)); } diff --git a/src/main/java/run/halo/app/service/impl/ThemeServiceImpl.java b/src/main/java/run/halo/app/service/impl/ThemeServiceImpl.java index 442dfaef2..7481bc68d 100644 --- a/src/main/java/run/halo/app/service/impl/ThemeServiceImpl.java +++ b/src/main/java/run/halo/app/service/impl/ThemeServiceImpl.java @@ -223,7 +223,7 @@ public class ThemeServiceImpl implements ThemeService { try { return new String(Files.readAllBytes(path), StandardCharsets.UTF_8); } catch (IOException e) { - throw new ServiceException("Failed to read file " + absolutePath, e); + throw new ServiceException("读取模板内容失败 " + absolutePath, e); } } @@ -237,7 +237,7 @@ public class ThemeServiceImpl implements ThemeService { try { Files.write(path, content.getBytes(StandardCharsets.UTF_8)); } catch (IOException e) { - throw new ServiceException("Failed to write file " + absolutePath, e); + throw new ServiceException("保存模板内容失败 " + absolutePath, e); } } @@ -418,7 +418,7 @@ public class ThemeServiceImpl implements ThemeService { .anyMatch(themeProperty -> themeProperty.getId().equalsIgnoreCase(tmpThemeProperty.getId())); if (isExist) { - throw new AlreadyExistsException("The theme with id " + tmpThemeProperty.getId() + " has already existed"); + throw new AlreadyExistsException("当前安装的主题已存在"); } // Copy the temporary path to current theme folder @@ -722,7 +722,7 @@ public class ThemeServiceImpl implements ThemeService { */ @NonNull private Path getThemePropertyPath(@NonNull Path themePath) { - return getThemePropertyPathOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException(themePath + " dose not exist any theme property file").setErrorData(themePath)); + return getThemePropertyPathOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException(themePath + " 没有说明文件").setErrorData(themePath)); } private Optional getPropertyOfNullable(Path themePath) { @@ -773,7 +773,7 @@ public class ThemeServiceImpl implements ThemeService { */ @NonNull private ThemeProperty getProperty(@NonNull Path themePath) { - return getPropertyOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException("Cannot resolve theme property").setErrorData(themePath)); + return getPropertyOfNullable(themePath).orElseThrow(() -> new ThemePropertyMissingException("该主题没有说明文件").setErrorData(themePath)); } /**