diff --git a/build.gradle b/build.gradle
index c98802c97..1bd8d3f09 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,7 +1,7 @@
plugins {
id 'org.springframework.boot' version '2.2.2.RELEASE'
id "io.freefair.lombok" version "3.6.6"
-// id 'war'
+ id 'checkstyle'
id 'java'
}
diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml
new file mode 100644
index 000000000..47422c615
--- /dev/null
+++ b/config/checkstyle/checkstyle.xml
@@ -0,0 +1,90 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/haloCodeStyle.xml b/haloCodeStyle.xml
deleted file mode 100644
index 8756f6089..000000000
--- a/haloCodeStyle.xml
+++ /dev/null
@@ -1,26 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/src/main/java/run/halo/app/Application.java b/src/main/java/run/halo/app/Application.java
index 6b7852598..cc4b4a59a 100755
--- a/src/main/java/run/halo/app/Application.java
+++ b/src/main/java/run/halo/app/Application.java
@@ -25,14 +25,14 @@ import run.halo.app.repository.base.BaseRepositoryImpl;
@EnableJpaRepositories(basePackages = "run.halo.app.repository", repositoryBaseClass = BaseRepositoryImpl.class)
public class Application extends SpringBootServletInitializer {
- private static ConfigurableApplicationContext context;
+ private static ConfigurableApplicationContext CONTEXT;
public static void main(String[] args) {
// Customize the spring config location
System.setProperty("spring.config.additional-location", "file:${user.home}/.halo/,file:${user.home}/halo-dev/");
// Run application
- context = SpringApplication.run(Application.class, args);
+ CONTEXT = SpringApplication.run(Application.class, args);
}
@@ -40,11 +40,11 @@ public class Application extends SpringBootServletInitializer {
* Restart Application.
*/
public static void restart() {
- ApplicationArguments args = context.getBean(ApplicationArguments.class);
+ ApplicationArguments args = CONTEXT.getBean(ApplicationArguments.class);
Thread thread = new Thread(() -> {
- context.close();
- context = SpringApplication.run(Application.class, args.getSourceArgs());
+ CONTEXT.close();
+ CONTEXT = SpringApplication.run(Application.class, args.getSourceArgs());
});
thread.setDaemon(false);
diff --git a/src/main/java/run/halo/app/cache/LevelCacheStore.java b/src/main/java/run/halo/app/cache/LevelCacheStore.java
index 954b90d8f..1c57f20c1 100644
--- a/src/main/java/run/halo/app/cache/LevelCacheStore.java
+++ b/src/main/java/run/halo/app/cache/LevelCacheStore.java
@@ -28,8 +28,7 @@ public class LevelCacheStore extends StringCacheStore {
*/
private final static long PERIOD = 60 * 1000;
- private static DB leveldb;
-
+ private static DB LEVEL_DB;
private Timer timer;
@@ -38,7 +37,7 @@ public class LevelCacheStore extends StringCacheStore {
@PostConstruct
public void init() {
- if (leveldb != null) return;
+ if (LEVEL_DB != null) return;
try {
//work path
File folder = new File(haloProperties.getWorkDir() + ".leveldb");
@@ -46,7 +45,7 @@ public class LevelCacheStore extends StringCacheStore {
Options options = new Options();
options.createIfMissing(true);
//open leveldb store folder
- leveldb = factory.open(folder, options);
+ LEVEL_DB = factory.open(folder, options);
timer = new Timer();
timer.scheduleAtFixedRate(new CacheExpiryCleaner(), 0, PERIOD);
} catch (Exception ex) {
@@ -60,7 +59,7 @@ public class LevelCacheStore extends StringCacheStore {
@PreDestroy
public void preDestroy() {
try {
- leveldb.close();
+ LEVEL_DB.close();
timer.cancel();
} catch (IOException e) {
log.error("close leveldb error ", e);
@@ -70,7 +69,7 @@ public class LevelCacheStore extends StringCacheStore {
@Override
Optional> getInternal(String key) {
Assert.hasText(key, "Cache key must not be blank");
- byte[] bytes = leveldb.get(stringToBytes(key));
+ byte[] bytes = LEVEL_DB.get(stringToBytes(key));
if (bytes != null) {
String valueJson = bytesToString(bytes);
return StringUtils.isEmpty(valueJson) ? Optional.empty() : jsonToCacheWrapper(valueJson);
@@ -88,9 +87,9 @@ public class LevelCacheStore extends StringCacheStore {
Assert.hasText(key, "Cache key must not be blank");
Assert.notNull(cacheWrapper, "Cache wrapper must not be null");
try {
- leveldb.put(
- stringToBytes(key),
- stringToBytes(JsonUtils.objectToJson(cacheWrapper))
+ LEVEL_DB.put(
+ stringToBytes(key),
+ stringToBytes(JsonUtils.objectToJson(cacheWrapper))
);
return true;
} catch (JsonProcessingException e) {
@@ -102,7 +101,7 @@ public class LevelCacheStore extends StringCacheStore {
@Override
public void delete(String key) {
- leveldb.delete(stringToBytes(key));
+ LEVEL_DB.delete(stringToBytes(key));
log.debug("cache remove key: [{}]", key);
}
@@ -132,9 +131,9 @@ public class LevelCacheStore extends StringCacheStore {
@Override
public void run() {
//batch
- WriteBatch writeBatch = leveldb.createWriteBatch();
+ WriteBatch writeBatch = LEVEL_DB.createWriteBatch();
- DBIterator iterator = leveldb.iterator();
+ DBIterator iterator = LEVEL_DB.iterator();
long currentTimeMillis = System.currentTimeMillis();
while (iterator.hasNext()) {
Map.Entry next = iterator.next();
@@ -147,8 +146,8 @@ public class LevelCacheStore extends StringCacheStore {
if (stringCacheWrapper.isPresent()) {
//get expireat time
long expireAtTime = stringCacheWrapper.map(CacheWrapper::getExpireAt)
- .map(Date::getTime)
- .orElse(0L);
+ .map(Date::getTime)
+ .orElse(0L);
//if expire
if (expireAtTime != 0 && currentTimeMillis > expireAtTime) {
writeBatch.delete(next.getKey());
@@ -156,7 +155,7 @@ public class LevelCacheStore extends StringCacheStore {
}
}
}
- leveldb.write(writeBatch);
+ LEVEL_DB.write(writeBatch);
}
}
}
diff --git a/src/main/java/run/halo/app/config/HaloConfiguration.java b/src/main/java/run/halo/app/config/HaloConfiguration.java
index b2792d068..0b8d63d03 100644
--- a/src/main/java/run/halo/app/config/HaloConfiguration.java
+++ b/src/main/java/run/halo/app/config/HaloConfiguration.java
@@ -55,10 +55,10 @@ public class HaloConfiguration {
@Bean
public RestTemplate httpsRestTemplate(RestTemplateBuilder builder)
- throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
+ throws NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
RestTemplate httpsRestTemplate = builder.build();
httpsRestTemplate.setRequestFactory(new HttpComponentsClientHttpRequestFactory(HttpClientUtils.createHttpsClient(
- (int) haloProperties.getDownloadTimeout().toMillis())));
+ (int) haloProperties.getDownloadTimeout().toMillis())));
return httpsRestTemplate;
}
@@ -125,12 +125,12 @@ public class HaloConfiguration {
String adminPattern = HaloUtils.ensureBoth(haloProperties.getAdminPath(), "/") + "**";
contentFilter.addExcludeUrlPatterns(
- adminPattern,
- "/api/**",
- "/install",
- "/version",
- "/js/**",
- "/css/**");
+ adminPattern,
+ "/api/**",
+ "/install",
+ "/version",
+ "/js/**",
+ "/css/**");
FilterRegistrationBean contentFrb = new FilterRegistrationBean<>();
contentFrb.addUrlPatterns("/*");
@@ -148,9 +148,9 @@ public class HaloConfiguration {
OneTimeTokenService oneTimeTokenService) {
ApiAuthenticationFilter apiFilter = new ApiAuthenticationFilter(haloProperties, optionService, cacheStore, oneTimeTokenService);
apiFilter.addExcludeUrlPatterns(
- "/api/content/*/comments",
- "/api/content/**/comments/**",
- "/api/content/options/comment"
+ "/api/content/*/comments",
+ "/api/content/**/comments/**",
+ "/api/content/options/comment"
);
DefaultAuthenticationFailureHandler failureHandler = new DefaultAuthenticationFailureHandler();
@@ -176,7 +176,7 @@ public class HaloConfiguration {
OptionService optionService,
OneTimeTokenService oneTimeTokenService) {
AdminAuthenticationFilter adminAuthenticationFilter = new AdminAuthenticationFilter(cacheStore, userService,
- haloProperties, optionService, oneTimeTokenService);
+ haloProperties, optionService, oneTimeTokenService);
DefaultAuthenticationFailureHandler failureHandler = new DefaultAuthenticationFailureHandler();
failureHandler.setProductionEnv(haloProperties.isProductionEnv());
@@ -184,14 +184,14 @@ public class HaloConfiguration {
// Config the admin filter
adminAuthenticationFilter.addExcludeUrlPatterns(
- "/api/admin/login",
- "/api/admin/refresh/*",
- "/api/admin/installations",
- "/api/admin/recoveries/migrations/*",
- "/api/admin/migrations/*",
- "/api/admin/is_installed",
- "/api/admin/password/code",
- "/api/admin/password/reset"
+ "/api/admin/login",
+ "/api/admin/refresh/*",
+ "/api/admin/installations",
+ "/api/admin/recoveries/migrations/*",
+ "/api/admin/migrations/*",
+ "/api/admin/is_installed",
+ "/api/admin/password/code",
+ "/api/admin/password/reset"
);
adminAuthenticationFilter.setFailureHandler(failureHandler);
diff --git a/src/main/java/run/halo/app/config/SwaggerConfiguration.java b/src/main/java/run/halo/app/config/SwaggerConfiguration.java
index e87cf19e3..7ac736661 100644
--- a/src/main/java/run/halo/app/config/SwaggerConfiguration.java
+++ b/src/main/java/run/halo/app/config/SwaggerConfiguration.java
@@ -47,12 +47,12 @@ public class SwaggerConfiguration {
private final HaloProperties haloProperties;
private final List globalResponses = Arrays.asList(
- new ResponseMessageBuilder().code(200).message("Success").build(),
- new ResponseMessageBuilder().code(400).message("Bad request").build(),
- new ResponseMessageBuilder().code(401).message("Unauthorized").build(),
- new ResponseMessageBuilder().code(403).message("Forbidden").build(),
- new ResponseMessageBuilder().code(404).message("Not found").build(),
- new ResponseMessageBuilder().code(500).message("Internal server error").build());
+ new ResponseMessageBuilder().code(200).message("Success").build(),
+ new ResponseMessageBuilder().code(400).message("Bad request").build(),
+ new ResponseMessageBuilder().code(401).message("Unauthorized").build(),
+ new ResponseMessageBuilder().code(403).message("Forbidden").build(),
+ new ResponseMessageBuilder().code(404).message("Not found").build(),
+ new ResponseMessageBuilder().code(500).message("Internal server error").build());
public SwaggerConfiguration(HaloProperties haloProperties) {
this.haloProperties = haloProperties;
@@ -65,11 +65,11 @@ public class SwaggerConfiguration {
}
return buildApiDocket("run.halo.app.content.api",
- "run.halo.app.controller.content.api",
- "/api/content/**")
- .securitySchemes(contentApiKeys())
- .securityContexts(contentSecurityContext())
- .enable(!haloProperties.isDocDisabled());
+ "run.halo.app.controller.content.api",
+ "/api/content/**")
+ .securitySchemes(contentApiKeys())
+ .securityContexts(contentSecurityContext())
+ .enable(!haloProperties.isDocDisabled());
}
@Bean
@@ -79,24 +79,24 @@ public class SwaggerConfiguration {
}
return buildApiDocket("run.halo.app.admin.api",
- "run.halo.app.controller.admin",
- "/api/admin/**")
- .securitySchemes(adminApiKeys())
- .securityContexts(adminSecurityContext())
- .enable(!haloProperties.isDocDisabled());
+ "run.halo.app.controller.admin",
+ "/api/admin/**")
+ .securitySchemes(adminApiKeys())
+ .securityContexts(adminSecurityContext())
+ .enable(!haloProperties.isDocDisabled());
}
@Bean
SecurityConfiguration security() {
return SecurityConfigurationBuilder.builder()
- .clientId("halo-app-client-id")
- .clientSecret("halo-app-client-secret")
- .realm("halo-app-realm")
- .appName("halo-app")
- .scopeSeparator(",")
- .additionalQueryStringParams(null)
- .useBasicAuthenticationWithAccessCodeGrant(false)
- .build();
+ .clientId("halo-app-client-id")
+ .clientSecret("halo-app-client-secret")
+ .realm("halo-app-realm")
+ .appName("halo-app")
+ .scopeSeparator(",")
+ .additionalQueryStringParams(null)
+ .useBasicAuthenticationWithAccessCodeGrant(false)
+ .build();
}
private Docket buildApiDocket(@NonNull String groupName, @NonNull String basePackage, @NonNull String antPattern) {
@@ -105,74 +105,74 @@ public class SwaggerConfiguration {
Assert.hasText(antPattern, "Ant pattern must not be blank");
return new Docket(DocumentationType.SWAGGER_2)
- .groupName(groupName)
- .select()
- .apis(RequestHandlerSelectors.basePackage(basePackage))
- .paths(PathSelectors.ant(antPattern))
- .build()
- .apiInfo(apiInfo())
- .useDefaultResponseMessages(false)
- .globalResponseMessage(RequestMethod.GET, globalResponses)
- .globalResponseMessage(RequestMethod.POST, globalResponses)
- .globalResponseMessage(RequestMethod.DELETE, globalResponses)
- .globalResponseMessage(RequestMethod.PUT, globalResponses)
- .directModelSubstitute(Temporal.class, String.class);
+ .groupName(groupName)
+ .select()
+ .apis(RequestHandlerSelectors.basePackage(basePackage))
+ .paths(PathSelectors.ant(antPattern))
+ .build()
+ .apiInfo(apiInfo())
+ .useDefaultResponseMessages(false)
+ .globalResponseMessage(RequestMethod.GET, globalResponses)
+ .globalResponseMessage(RequestMethod.POST, globalResponses)
+ .globalResponseMessage(RequestMethod.DELETE, globalResponses)
+ .globalResponseMessage(RequestMethod.PUT, globalResponses)
+ .directModelSubstitute(Temporal.class, String.class);
}
private List adminApiKeys() {
return Arrays.asList(
- new ApiKey("Token from header", ADMIN_TOKEN_HEADER_NAME, In.HEADER.name()),
- new ApiKey("Token from query", ADMIN_TOKEN_QUERY_NAME, In.QUERY.name())
+ new ApiKey("Token from header", ADMIN_TOKEN_HEADER_NAME, In.HEADER.name()),
+ new ApiKey("Token from query", ADMIN_TOKEN_QUERY_NAME, In.QUERY.name())
);
}
private List adminSecurityContext() {
return Collections.singletonList(
- SecurityContext.builder()
- .securityReferences(defaultAuth())
- .forPaths(PathSelectors.regex("/api/admin/.*"))
- .build()
+ SecurityContext.builder()
+ .securityReferences(defaultAuth())
+ .forPaths(PathSelectors.regex("/api/admin/.*"))
+ .build()
);
}
private List contentApiKeys() {
return Arrays.asList(
- new ApiKey("Access key from header", API_ACCESS_KEY_HEADER_NAME, In.HEADER.name()),
- new ApiKey("Access key from query", API_ACCESS_KEY_QUERY_NAME, In.QUERY.name())
+ new ApiKey("Access key from header", API_ACCESS_KEY_HEADER_NAME, In.HEADER.name()),
+ new ApiKey("Access key from query", API_ACCESS_KEY_QUERY_NAME, In.QUERY.name())
);
}
private List contentSecurityContext() {
return Collections.singletonList(
- SecurityContext.builder()
- .securityReferences(contentApiAuth())
- .forPaths(PathSelectors.regex("/api/content/.*"))
- .build()
+ SecurityContext.builder()
+ .securityReferences(contentApiAuth())
+ .forPaths(PathSelectors.regex("/api/content/.*"))
+ .build()
);
}
private List defaultAuth() {
AuthorizationScope[] authorizationScopes = {new AuthorizationScope("Admin api", "Access admin api")};
return Arrays.asList(new SecurityReference("Token from header", authorizationScopes),
- new SecurityReference("Token from query", authorizationScopes));
+ new SecurityReference("Token from query", authorizationScopes));
}
private List contentApiAuth() {
AuthorizationScope[] authorizationScopes = {new AuthorizationScope("content api", "Access content api")};
return Arrays.asList(new SecurityReference("Access key from header", authorizationScopes),
- new SecurityReference("Access key from query", authorizationScopes));
+ new SecurityReference("Access key from query", authorizationScopes));
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
- .title("Halo API Documentation")
- .description("Documentation for Halo API")
- .version(HALO_VERSION)
- .termsOfServiceUrl("https://github.com/halo-dev")
- .contact(new Contact("halo-dev", "https://github.com/halo-dev/halo/issues", "i#ryanc.cc"))
- .license("GNU General Public License v3.0")
- .licenseUrl("https://github.com/halo-dev/halo/blob/master/LICENSE")
- .build();
+ .title("Halo API Documentation")
+ .description("Documentation for Halo API")
+ .version(HALO_VERSION)
+ .termsOfServiceUrl("https://github.com/halo-dev")
+ .contact(new Contact("halo-dev", "https://github.com/halo-dev/halo/issues", "i#ryanc.cc"))
+ .license("GNU General Public License v3.0")
+ .licenseUrl("https://github.com/halo-dev/halo/blob/master/LICENSE")
+ .build();
}
@Bean
@@ -186,10 +186,10 @@ public class SwaggerConfiguration {
@Override
public List rules() {
return Arrays.asList(
- newRule(User.class, emptyMixin(User.class)),
- newRule(UserDetail.class, emptyMixin(UserDetail.class)),
- newRule(resolver.resolve(Pageable.class), resolver.resolve(pageableMixin())),
- newRule(resolver.resolve(Sort.class), resolver.resolve(sortMixin())));
+ newRule(User.class, emptyMixin(User.class)),
+ newRule(UserDetail.class, emptyMixin(UserDetail.class)),
+ newRule(resolver.resolve(Pageable.class), resolver.resolve(pageableMixin())),
+ newRule(resolver.resolve(Sort.class), resolver.resolve(sortMixin())));
}
};
}
@@ -204,31 +204,31 @@ public class SwaggerConfiguration {
Assert.notNull(clazz, "class type must not be null");
return new AlternateTypeBuilder()
- .fullyQualifiedClassName(String.format("%s.generated.%s", clazz.getPackage().getName(), clazz.getSimpleName()))
- .withProperties(Collections.emptyList())
- .build();
+ .fullyQualifiedClassName(String.format("%s.generated.%s", clazz.getPackage().getName(), clazz.getSimpleName()))
+ .withProperties(Collections.emptyList())
+ .build();
}
private Type sortMixin() {
return new AlternateTypeBuilder()
- .fullyQualifiedClassName(String.format("%s.generated.%s", Sort.class.getPackage().getName(), Sort.class.getSimpleName()))
- .withProperties(Collections.singletonList(property(String[].class, "sort")))
- .build();
+ .fullyQualifiedClassName(String.format("%s.generated.%s", Sort.class.getPackage().getName(), Sort.class.getSimpleName()))
+ .withProperties(Collections.singletonList(property(String[].class, "sort")))
+ .build();
}
private Type pageableMixin() {
return new AlternateTypeBuilder()
- .fullyQualifiedClassName(String.format("%s.generated.%s", Pageable.class.getPackage().getName(), Pageable.class.getSimpleName()))
- .withProperties(Arrays.asList(property(Integer.class, "page"), property(Integer.class, "size"), property(String[].class, "sort")))
- .build();
+ .fullyQualifiedClassName(String.format("%s.generated.%s", Pageable.class.getPackage().getName(), Pageable.class.getSimpleName()))
+ .withProperties(Arrays.asList(property(Integer.class, "page"), property(Integer.class, "size"), property(String[].class, "sort")))
+ .build();
}
private AlternateTypePropertyBuilder property(Class> type, String name) {
return new AlternateTypePropertyBuilder()
- .withName(name)
- .withType(type)
- .withCanRead(true)
- .withCanWrite(true);
+ .withName(name)
+ .withType(type)
+ .withCanRead(true)
+ .withCanWrite(true);
}
}
diff --git a/src/main/java/run/halo/app/config/WebMvcAutoConfiguration.java b/src/main/java/run/halo/app/config/WebMvcAutoConfiguration.java
index e66ef1865..de99fbb9f 100644
--- a/src/main/java/run/halo/app/config/WebMvcAutoConfiguration.java
+++ b/src/main/java/run/halo/app/config/WebMvcAutoConfiguration.java
@@ -76,15 +76,16 @@ public class WebMvcAutoConfiguration extends WebMvcConfigurationSupport {
@Override
public void extendMessageConverters(List> converters) {
converters.stream()
- .filter(c -> c instanceof MappingJackson2HttpMessageConverter)
- .findFirst().ifPresent(converter -> {
- MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = (MappingJackson2HttpMessageConverter) converter;
- Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json();
- JsonComponentModule module = new JsonComponentModule();
- module.addSerializer(PageImpl.class, new PageJacksonSerializer());
- ObjectMapper objectMapper = builder.modules(module).build();
- mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
- });
+ .filter(c -> c instanceof MappingJackson2HttpMessageConverter)
+ .findFirst()
+ .ifPresent(converter -> {
+ MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter = (MappingJackson2HttpMessageConverter) converter;
+ Jackson2ObjectMapperBuilder builder = Jackson2ObjectMapperBuilder.json();
+ JsonComponentModule module = new JsonComponentModule();
+ module.addSerializer(PageImpl.class, new PageJacksonSerializer());
+ ObjectMapper objectMapper = builder.modules(module).build();
+ mappingJackson2HttpMessageConverter.setObjectMapper(objectMapper);
+ });
}
@Override
@@ -105,29 +106,29 @@ public class WebMvcAutoConfiguration extends WebMvcConfigurationSupport {
// register /** resource handler.
registry.addResourceHandler("/**")
- .addResourceLocations(workDir + "templates/admin/")
- .addResourceLocations("classpath:/admin/")
- .addResourceLocations(workDir + "static/");
+ .addResourceLocations(workDir + "templates/admin/")
+ .addResourceLocations("classpath:/admin/")
+ .addResourceLocations(workDir + "static/");
// register /themes/** resource handler.
registry.addResourceHandler("/themes/**")
- .addResourceLocations(workDir + "templates/themes/");
+ .addResourceLocations(workDir + "templates/themes/");
String uploadUrlPattern = ensureBoth(haloProperties.getUploadUrlPrefix(), URL_SEPARATOR) + "**";
String adminPathPattern = ensureSuffix(haloProperties.getAdminPath(), URL_SEPARATOR) + "**";
registry.addResourceHandler(uploadUrlPattern)
- .addResourceLocations(workDir + "upload/");
+ .addResourceLocations(workDir + "upload/");
registry.addResourceHandler(adminPathPattern)
- .addResourceLocations(workDir + HALO_ADMIN_RELATIVE_PATH)
- .addResourceLocations("classpath:/admin/");
+ .addResourceLocations(workDir + HALO_ADMIN_RELATIVE_PATH)
+ .addResourceLocations("classpath:/admin/");
if (!haloProperties.isDocDisabled()) {
// If doc is enable
registry.addResourceHandler("swagger-ui.html")
- .addResourceLocations("classpath:/META-INF/resources/");
+ .addResourceLocations("classpath:/META-INF/resources/");
registry.addResourceHandler("/webjars/**")
- .addResourceLocations("classpath:/META-INF/resources/webjars/");
+ .addResourceLocations("classpath:/META-INF/resources/webjars/");
}
}
diff --git a/src/main/java/run/halo/app/controller/admin/api/BackupController.java b/src/main/java/run/halo/app/controller/admin/api/BackupController.java
index b250f2da0..451a97503 100644
--- a/src/main/java/run/halo/app/controller/admin/api/BackupController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/BackupController.java
@@ -72,9 +72,9 @@ public class BackupController {
}
return ResponseEntity.ok()
- .contentType(MediaType.parseMediaType(contentType))
- .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + backupResource.getFilename() + "\"")
- .body(backupResource);
+ .contentType(MediaType.parseMediaType(contentType))
+ .header(HttpHeaders.CONTENT_DISPOSITION, "attachment; filename=\"" + backupResource.getFilename() + "\"")
+ .body(backupResource);
}
@DeleteMapping("halo")
diff --git a/src/main/java/run/halo/app/controller/admin/api/CategoryController.java b/src/main/java/run/halo/app/controller/admin/api/CategoryController.java
index 219835ac7..2af07e9c7 100644
--- a/src/main/java/run/halo/app/controller/admin/api/CategoryController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/CategoryController.java
@@ -46,8 +46,8 @@ public class CategoryController {
@GetMapping
@ApiOperation("Lists all categories")
public List extends CategoryDTO> listAll(
- @SortDefault(sort = "updateTime", direction = DESC) Sort sort,
- @RequestParam(name = "more", required = false, defaultValue = "false") boolean more) {
+ @SortDefault(sort = "updateTime", direction = DESC) Sort sort,
+ @RequestParam(name = "more", required = false, defaultValue = "false") boolean more) {
if (more) {
return postCategoryService.listCategoryWithPostCountDto(sort);
}
diff --git a/src/main/java/run/halo/app/controller/admin/api/InstallController.java b/src/main/java/run/halo/app/controller/admin/api/InstallController.java
index bfb0fb32d..60852aa07 100644
--- a/src/main/java/run/halo/app/controller/admin/api/InstallController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/InstallController.java
@@ -110,7 +110,7 @@ public class InstallController {
createDefaultMenu();
eventPublisher.publishEvent(
- new LogEvent(this, user.getId().toString(), LogType.BLOG_INITIALIZED, "博客已成功初始化")
+ new LogEvent(this, user.getId().toString(), LogType.BLOG_INITIALIZED, "博客已成功初始化")
);
return BaseResponse.ok("安装完成!");
@@ -167,8 +167,8 @@ public class InstallController {
postParam.setTitle("Hello Halo");
postParam.setStatus(PostStatus.PUBLISHED);
postParam.setOriginalContent("## Hello Halo!\n" +
- "\n" +
- "感谢使用 [Halo](https://github.com/halo-dev/halo) 进行创作,请删除该文章开始吧!");
+ "\n" +
+ "感谢使用 [Halo](https://github.com/halo-dev/halo) 进行创作,请删除该文章开始吧!");
if (category != null) {
Set categoryIds = new HashSet<>();
@@ -218,7 +218,7 @@ public class InstallController {
properties.put(BlogProperties.BLOG_LOCALE, installParam.getLocale());
properties.put(BlogProperties.BLOG_TITLE, installParam.getTitle());
properties.put(BlogProperties.BLOG_URL, StringUtils.isBlank(installParam.getUrl()) ?
- optionService.getBlogBaseUrl() : installParam.getUrl());
+ optionService.getBlogBaseUrl() : installParam.getUrl());
properties.put(PrimaryProperties.BIRTHDAY, String.valueOf(System.currentTimeMillis()));
// Create properties
diff --git a/src/main/java/run/halo/app/controller/admin/api/LinkController.java b/src/main/java/run/halo/app/controller/admin/api/LinkController.java
index 9934dddb4..798b36563 100644
--- a/src/main/java/run/halo/app/controller/admin/api/LinkController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/LinkController.java
@@ -72,7 +72,7 @@ public class LinkController {
}
@GetMapping("teams")
- @ApiOperation(("Lists all link teams"))
+ @ApiOperation("Lists all link teams")
public List teams() {
return linkService.listAllTeams();
}
diff --git a/src/main/java/run/halo/app/controller/admin/api/MenuController.java b/src/main/java/run/halo/app/controller/admin/api/MenuController.java
index 8aeb534df..50fb3df83 100644
--- a/src/main/java/run/halo/app/controller/admin/api/MenuController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/MenuController.java
@@ -85,7 +85,7 @@ public class MenuController {
}
@GetMapping("teams")
- @ApiOperation(("Lists all menu teams"))
+ @ApiOperation("Lists all menu teams")
public List teams() {
return menuService.listAllTeams();
}
diff --git a/src/main/java/run/halo/app/controller/admin/api/PostController.java b/src/main/java/run/halo/app/controller/admin/api/PostController.java
index 3fca601b8..102199deb 100644
--- a/src/main/java/run/halo/app/controller/admin/api/PostController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/PostController.java
@@ -125,8 +125,8 @@ public class PostController {
@PutMapping("{postId:\\d+}/status/{status}")
@ApiOperation("Updates post status")
public BasePostMinimalDTO updateStatusBy(
- @PathVariable("postId") Integer postId,
- @PathVariable("status") PostStatus status) {
+ @PathVariable("postId") Integer postId,
+ @PathVariable("status") PostStatus status) {
Post post = postService.updateStatus(status, postId);
return new BasePostMinimalDTO().convertFrom(post);
@@ -142,8 +142,8 @@ public class PostController {
@PutMapping("{postId:\\d+}/status/draft/content")
@ApiOperation("Updates draft")
public BasePostDetailDTO updateDraftBy(
- @PathVariable("postId") Integer postId,
- @RequestBody PostContentParam contentParam) {
+ @PathVariable("postId") Integer postId,
+ @RequestBody PostContentParam contentParam) {
// Update draft content
Post post = postService.updateDraftContent(contentParam.getContent(), postId);
diff --git a/src/main/java/run/halo/app/controller/admin/api/RecoveryController.java b/src/main/java/run/halo/app/controller/admin/api/RecoveryController.java
index 76407ee15..7b9e8463f 100644
--- a/src/main/java/run/halo/app/controller/admin/api/RecoveryController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/RecoveryController.java
@@ -38,8 +38,8 @@ public class RecoveryController {
@ApiOperation("Migrates from halo v0.4.3")
@CacheLock
public void migrateFromVersion_0_4_3(
- @ApiParam("This file content type should be json")
- @RequestPart("file") MultipartFile file) {
+ @ApiParam("This file content type should be json")
+ @RequestPart("file") MultipartFile file) {
if (optionService.getByPropertyOrDefault(PrimaryProperties.IS_INSTALLED, Boolean.class, false)) {
throw new BadRequestException("无法在博客初始化完成之后迁移数据");
}
diff --git a/src/main/java/run/halo/app/controller/admin/api/SheetController.java b/src/main/java/run/halo/app/controller/admin/api/SheetController.java
index 83647639d..3d5bdb0e0 100644
--- a/src/main/java/run/halo/app/controller/admin/api/SheetController.java
+++ b/src/main/java/run/halo/app/controller/admin/api/SheetController.java
@@ -82,9 +82,9 @@ public class SheetController {
@PutMapping("{sheetId:\\d+}")
@ApiOperation("Updates a sheet")
public SheetDetailVO updateBy(
- @PathVariable("sheetId") Integer sheetId,
- @RequestBody @Valid SheetParam sheetParam,
- @RequestParam(value = "autoSave", required = false, defaultValue = "false") Boolean autoSave) {
+ @PathVariable("sheetId") Integer sheetId,
+ @RequestBody @Valid SheetParam sheetParam,
+ @RequestParam(value = "autoSave", required = false, defaultValue = "false") Boolean autoSave) {
Sheet sheetToUpdate = sheetService.getById(sheetId);
sheetParam.update(sheetToUpdate);
@@ -97,8 +97,8 @@ public class SheetController {
@PutMapping("{sheetId:\\d+}/{status}")
@ApiOperation("Updates a sheet")
public void updateStatusBy(
- @PathVariable("sheetId") Integer sheetId,
- @PathVariable("status") PostStatus status) {
+ @PathVariable("sheetId") Integer sheetId,
+ @PathVariable("status") PostStatus status) {
Sheet sheet = sheetService.getById(sheetId);
// Set status
diff --git a/src/main/java/run/halo/app/controller/content/model/PostModel.java b/src/main/java/run/halo/app/controller/content/model/PostModel.java
index f56b9e4a4..cc28e9b55 100644
--- a/src/main/java/run/halo/app/controller/content/model/PostModel.java
+++ b/src/main/java/run/halo/app/controller/content/model/PostModel.java
@@ -107,7 +107,7 @@ public class PostModel {
model.addAttribute("comments", Page.empty());
if (themeService.templateExists(
- ThemeService.CUSTOM_POST_PREFIX + post.getTemplate() + HaloConst.SUFFIX_FTL)) {
+ ThemeService.CUSTOM_POST_PREFIX + post.getTemplate() + HaloConst.SUFFIX_FTL)) {
return themeService.render(ThemeService.CUSTOM_POST_PREFIX + post.getTemplate());
}
@@ -117,7 +117,7 @@ public class PostModel {
public String list(Integer page, Model model, String decide, String template) {
int pageSize = optionService.getPostPageSize();
Pageable pageable = PageRequest
- .of(page >= 1 ? page - 1 : page, pageSize, postService.getPostDefaultSort());
+ .of(page >= 1 ? page - 1 : page, pageSize, postService.getPostDefaultSort());
Page postPage = postService.pageBy(PostStatus.PUBLISHED, pageable);
Page posts = postService.convertToListVo(postPage);
@@ -135,15 +135,15 @@ public class PostModel {
}
nextPageFullPath.append("/page/")
- .append(posts.getNumber() + 2)
- .append(optionService.getPathSuffix());
+ .append(posts.getNumber() + 2)
+ .append(optionService.getPathSuffix());
if (posts.getNumber() == 1) {
prePageFullPath.append("/");
} else {
prePageFullPath.append("/page/")
- .append(posts.getNumber())
- .append(optionService.getPathSuffix());
+ .append(posts.getNumber())
+ .append(optionService.getPathSuffix());
}
model.addAttribute(decide, true);
diff --git a/src/main/java/run/halo/app/controller/core/CommonController.java b/src/main/java/run/halo/app/controller/core/CommonController.java
index 4d332a211..f152b2425 100644
--- a/src/main/java/run/halo/app/controller/core/CommonController.java
+++ b/src/main/java/run/halo/app/controller/core/CommonController.java
@@ -70,10 +70,10 @@ public class CommonController extends AbstractErrorController {
@GetMapping
public String handleError(HttpServletRequest request, HttpServletResponse response, Model model) {
log.error("Request URL: [{}], URI: [{}], Request Method: [{}], IP: [{}]",
- request.getRequestURL(),
- request.getRequestURI(),
- request.getMethod(),
- ServletUtil.getClientIP(request));
+ request.getRequestURL(),
+ request.getRequestURI(),
+ request.getMethod(),
+ ServletUtil.getClientIP(request));
handleCustomException(request);
@@ -138,9 +138,9 @@ public class CommonController extends AbstractErrorController {
StringBuilder path = new StringBuilder();
path.append("themes/")
- .append(themeService.getActivatedTheme().getFolderName())
- .append('/')
- .append(FilenameUtils.getBasename(template));
+ .append(themeService.getActivatedTheme().getFolderName())
+ .append('/')
+ .append(FilenameUtils.getBasename(template));
return path.toString();
}
diff --git a/src/main/java/run/halo/app/core/CommonResultControllerAdvice.java b/src/main/java/run/halo/app/core/CommonResultControllerAdvice.java
index 53a731c57..e2c3e7acf 100644
--- a/src/main/java/run/halo/app/core/CommonResultControllerAdvice.java
+++ b/src/main/java/run/halo/app/core/CommonResultControllerAdvice.java
@@ -43,7 +43,7 @@ public class CommonResultControllerAdvice implements ResponseBodyAdvice