mirror of https://github.com/halo-dev/halo
Perfect codes.
parent
9c0c610338
commit
11d798ffa3
|
@ -27,7 +27,7 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
/**
|
||||
* Cache container.
|
||||
*/
|
||||
private final static ConcurrentHashMap<String, CacheWrapper<String>> cacheContainer = new ConcurrentHashMap<>();
|
||||
private final static ConcurrentHashMap<String, CacheWrapper<String>> CACHE_CONTAINER = new ConcurrentHashMap<>();
|
||||
|
||||
private final Timer timer;
|
||||
|
||||
|
@ -46,7 +46,7 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
Optional<CacheWrapper<String>> getInternal(String key) {
|
||||
Assert.hasText(key, "Cache key must not be blank");
|
||||
|
||||
return Optional.ofNullable(cacheContainer.get(key));
|
||||
return Optional.ofNullable(CACHE_CONTAINER.get(key));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -55,7 +55,7 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
Assert.notNull(cacheWrapper, "Cache wrapper must not be null");
|
||||
|
||||
// Put the cache wrapper
|
||||
CacheWrapper<String> putCacheWrapper = cacheContainer.put(key, cacheWrapper);
|
||||
CacheWrapper<String> putCacheWrapper = CACHE_CONTAINER.put(key, cacheWrapper);
|
||||
|
||||
log.debug("Put [{}] cache result: [{}], original cache wrapper: [{}]", key, putCacheWrapper, cacheWrapper);
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
public void delete(String key) {
|
||||
Assert.hasText(key, "Cache key must not be blank");
|
||||
|
||||
cacheContainer.remove(key);
|
||||
CACHE_CONTAINER.remove(key);
|
||||
log.debug("Removed key: [{}]", key);
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class InMemoryCacheStore extends StringCacheStore {
|
|||
|
||||
@Override
|
||||
public void run() {
|
||||
cacheContainer.keySet().forEach(key -> {
|
||||
CACHE_CONTAINER.keySet().forEach(key -> {
|
||||
if (!InMemoryCacheStore.this.get(key).isPresent()) {
|
||||
log.debug("Deleted the cache: [{}] for expiration", key);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,12 @@ public class Item {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Item item = (Item) o;
|
||||
return name.equals(item.name);
|
||||
}
|
||||
|
|
|
@ -85,8 +85,12 @@ public class ThemeProperty {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
ThemeProperty that = (ThemeProperty) o;
|
||||
return id.equals(that.id);
|
||||
}
|
||||
|
|
|
@ -80,7 +80,7 @@ public class StartedListener implements ApplicationListener<ApplicationStartedEv
|
|||
|
||||
Path source;
|
||||
|
||||
if (themeUri.getScheme().equalsIgnoreCase("jar")) {
|
||||
if ("jar".equalsIgnoreCase(themeUri.getScheme())) {
|
||||
// Create new file system for jar
|
||||
FileSystem fileSystem = FileSystems.newFileSystem(themeUri, Collections.emptyMap());
|
||||
source = fileSystem.getPath("/BOOT-INF/classes/" + ThemeService.THEME_FOLDER);
|
||||
|
|
|
@ -43,8 +43,12 @@ public class PostCategory extends BaseEntity {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PostCategory that = (PostCategory) o;
|
||||
return categoryId.equals(that.categoryId) &&
|
||||
postId.equals(that.postId);
|
||||
|
|
|
@ -44,8 +44,12 @@ public class PostTag extends BaseEntity {
|
|||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
PostTag postTag = (PostTag) o;
|
||||
return Objects.equals(postId, postTag.postId) &&
|
||||
Objects.equals(tagId, postTag.tagId);
|
||||
|
|
|
@ -30,15 +30,15 @@ public enum Mode {
|
|||
@Nullable
|
||||
@JsonCreator
|
||||
public static Mode valueFrom(@Nullable String value) {
|
||||
if (StringUtils.isBlank(value) || value.equalsIgnoreCase("prod")) {
|
||||
if (StringUtils.isBlank(value) || "prod".equalsIgnoreCase(value)) {
|
||||
return Mode.PRODUCTION;
|
||||
}
|
||||
|
||||
if (value.equalsIgnoreCase("dev")) {
|
||||
if ("dev".equalsIgnoreCase(value)) {
|
||||
return Mode.DEVELOPMENT;
|
||||
}
|
||||
|
||||
if (value.equalsIgnoreCase("test")) {
|
||||
if ("test".equalsIgnoreCase(value)) {
|
||||
return Mode.TEST;
|
||||
}
|
||||
|
||||
|
|
|
@ -8,8 +8,14 @@ package run.halo.app.model.properties;
|
|||
*/
|
||||
public enum ApiProperties implements PropertyEnum {
|
||||
|
||||
/**
|
||||
* api_enabled
|
||||
*/
|
||||
API_ENABLED("api_enabled", Boolean.class, "false"),
|
||||
|
||||
/**
|
||||
* api_access_key
|
||||
*/
|
||||
API_ACCESS_KEY("api_access_key", String.class, "");
|
||||
|
||||
private final String value;
|
||||
|
|
|
@ -10,6 +10,9 @@ import run.halo.app.model.enums.AttachmentType;
|
|||
*/
|
||||
public enum AttachmentProperties implements PropertyEnum {
|
||||
|
||||
/**
|
||||
* attachment_type
|
||||
*/
|
||||
ATTACHMENT_TYPE("attachment_type", AttachmentType.class, AttachmentType.LOCAL.name());
|
||||
|
||||
private final String value;
|
||||
|
|
|
@ -23,6 +23,7 @@ public class BaseCommentWithParentVO extends BaseCommentDTO implements Cloneable
|
|||
*/
|
||||
private BaseCommentWithParentVO parent;
|
||||
|
||||
@Override
|
||||
public BaseCommentWithParentVO clone() {
|
||||
try {
|
||||
return (BaseCommentWithParentVO) super.clone();
|
||||
|
|
|
@ -29,5 +29,6 @@ public interface PostCommentRepository extends BaseCommentRepository<PostComment
|
|||
"where comment.parentId in ?1 " +
|
||||
"group by comment.parentId")
|
||||
@NonNull
|
||||
@Override
|
||||
List<CommentChildrenCountProjection> findDirectChildrenCount(@NonNull Iterable<Long> commentIds);
|
||||
}
|
||||
|
|
|
@ -29,5 +29,6 @@ public interface SheetCommentRepository extends BaseCommentRepository<SheetComme
|
|||
"where comment.parentId in ?1 " +
|
||||
"group by comment.parentId")
|
||||
@NonNull
|
||||
@Override
|
||||
List<CommentChildrenCountProjection> findDirectChildrenCount(@NonNull Iterable<Long> commentIds);
|
||||
}
|
||||
|
|
|
@ -25,5 +25,6 @@ public interface SheetRepository extends BasePostRepository<Sheet> {
|
|||
Long countLike();
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
Optional<Sheet> getByUrlAndStatus(@NonNull String url, @NonNull PostStatus status);
|
||||
}
|
||||
|
|
|
@ -323,7 +323,7 @@ public class AdminServiceImpl implements AdminService {
|
|||
String contentType = aAssetMap.getOrDefault("content_type", "").toString();
|
||||
|
||||
Object name = aAssetMap.getOrDefault("name", "");
|
||||
return name.toString().matches(HALO_ADMIN_VERSION_REGEX) && contentType.equalsIgnoreCase("application/zip");
|
||||
return name.toString().matches(HALO_ADMIN_VERSION_REGEX) && "application/zip".equalsIgnoreCase(contentType);
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -390,7 +390,7 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
|
|||
Assert.notNull(toCompareComment, "Comment to compare must not be null");
|
||||
|
||||
// Get sort order
|
||||
Sort.Order order = sort.filter(anOrder -> anOrder.getProperty().equals("id"))
|
||||
Sort.Order order = sort.filter(anOrder -> "id".equals(anOrder.getProperty()))
|
||||
.get()
|
||||
.findFirst()
|
||||
.orElseGet(() -> Sort.Order.desc("id"));
|
||||
|
@ -404,6 +404,7 @@ public abstract class BaseCommentServiceImpl<COMMENT extends BaseComment> extend
|
|||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public List<BaseCommentVO> convertToVo(@Nullable List<COMMENT> comments, @Nullable Comparator<BaseCommentVO> comparator) {
|
||||
if (CollectionUtils.isEmpty(comments)) {
|
||||
return Collections.emptyList();
|
||||
|
|
|
@ -200,7 +200,7 @@ public class RecoveryServiceImpl implements RecoveryService {
|
|||
String postType = postMap.getOrDefault("postType", "post").toString();
|
||||
|
||||
try {
|
||||
if (postType.equalsIgnoreCase("post")) {
|
||||
if ("post".equalsIgnoreCase(postType)) {
|
||||
// Handle post
|
||||
result.add(handlePost(post, postMap));
|
||||
} else {
|
||||
|
|
Loading…
Reference in New Issue