Format code and remove useless import.

pull/167/head
ruibaby 2019-05-23 15:30:26 +08:00
parent b187c5e5c7
commit 7f1ea3dfb2
85 changed files with 217 additions and 278 deletions

View File

@ -1,12 +1,12 @@
package run.halo.app;
import org.springframework.scheduling.annotation.EnableAsync;
import run.halo.app.repository.base.BaseRepositoryImpl;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.data.jpa.repository.config.EnableJpaAuditing;
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.annotation.EnableScheduling;
import run.halo.app.repository.base.BaseRepositoryImpl;
/**
* <pre>

View File

@ -94,6 +94,12 @@ public class InMemoryCacheStore extends StringCacheStore {
log.debug("Removed key: [{}]", key);
}
@PreDestroy
public void preDestroy() {
log.debug("Cancelling all timer tasks");
timer.cancel();
}
/**
* Cache cleaner.
*
@ -111,10 +117,4 @@ public class InMemoryCacheStore extends StringCacheStore {
});
}
}
@PreDestroy
public void preDestroy() {
log.debug("Cancelling all timer tasks");
timer.cancel();
}
}

View File

@ -8,7 +8,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.converter.json.Jackson2ObjectMapperBuilder;
import org.springframework.web.client.RestTemplate;

View File

@ -3,7 +3,6 @@ package run.halo.app.config;
import com.fasterxml.classmate.TypeResolver;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;

View File

@ -4,10 +4,7 @@ import io.swagger.annotations.ApiOperation;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.OptionDTO;
import run.halo.app.model.params.MailParam;
import run.halo.app.model.params.OptionParam;
import run.halo.app.model.support.BaseResponse;
import run.halo.app.service.MailService;
import run.halo.app.service.OptionService;
import javax.validation.Valid;

View File

@ -1,6 +1,5 @@
package run.halo.app.controller.base;
import run.halo.app.model.support.BaseResponse;
import org.springframework.core.MethodParameter;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;

View File

@ -1,16 +1,12 @@
package run.halo.app.controller.base;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import run.halo.app.exception.HaloException;
import run.halo.app.model.support.BaseResponse;
import run.halo.app.utils.ExceptionUtils;
import run.halo.app.utils.ValidationUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.dao.DataIntegrityViolationException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.HttpMessageNotReadableException;
import org.springframework.util.Assert;
import org.springframework.web.HttpMediaTypeNotAcceptableException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.MissingServletRequestParameterException;

View File

@ -33,15 +33,11 @@ import static org.springframework.data.domain.Sort.Direction.DESC;
@Controller
public class ContentFeedController {
private final PostService postService;
private final OptionService optionService;
private final FreeMarkerConfigurer freeMarker;
private final static String UTF_8_SUFFIX = ";charset=UTF-8";
private final static String XML_MEDIA_TYPE = MediaType.APPLICATION_XML_VALUE + UTF_8_SUFFIX;
private final PostService postService;
private final OptionService optionService;
private final FreeMarkerConfigurer freeMarker;
public ContentFeedController(PostService postService,
OptionService optionService,

View File

@ -1,11 +1,11 @@
package run.halo.app.controller.content.api;
import run.halo.app.model.vo.ArchiveMonthVO;
import run.halo.app.model.vo.ArchiveYearVO;
import run.halo.app.service.PostService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.model.vo.ArchiveMonthVO;
import run.halo.app.model.vo.ArchiveYearVO;
import run.halo.app.service.PostService;
import java.util.List;

View File

@ -1,7 +1,5 @@
package run.halo.app.controller.content.api;
import run.halo.app.model.vo.LinkTeamVO;
import run.halo.app.service.LinkService;
import org.springframework.data.domain.Sort;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

View File

@ -1,13 +1,13 @@
package run.halo.app.controller.content.api;
import run.halo.app.model.dto.MenuDTO;
import run.halo.app.service.MenuService;
import io.swagger.annotations.ApiOperation;
import org.springframework.data.domain.Sort;
import org.springframework.data.web.SortDefault;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.model.dto.MenuDTO;
import run.halo.app.service.MenuService;
import java.util.List;

View File

@ -1,12 +1,12 @@
package run.halo.app.controller.content.api;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import org.springframework.util.CollectionUtils;
import org.springframework.web.bind.annotation.*;
import run.halo.app.model.dto.OptionDTO;
import run.halo.app.model.support.BaseResponse;
import run.halo.app.service.OptionService;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpStatus;
import java.util.List;
import java.util.Map;

View File

@ -1,11 +1,11 @@
package run.halo.app.controller.content.api;
import run.halo.app.model.dto.UserDTO;
import run.halo.app.service.UserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import run.halo.app.model.dto.UserDTO;
import run.halo.app.service.UserService;
/**
* Portal user controller.
@ -26,6 +26,6 @@ public class UserController {
@GetMapping("profile")
@ApiOperation("Gets blogger profile")
public UserDTO getProfile() {
return userService.getCurrentUser().map(user -> new UserDTO().<UserDTO>convertFrom(user)).get();
return userService.getCurrentUser().map(user -> (UserDTO) new UserDTO().convertFrom(user)).get();
}
}

View File

@ -1,6 +1,5 @@
package run.halo.app.controller.support;
import run.halo.app.model.support.CommentPage;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;

View File

@ -1,9 +1,6 @@
package run.halo.app.event.theme;
import org.springframework.context.ApplicationEvent;
import org.springframework.lang.NonNull;
import org.springframework.util.Assert;
import run.halo.app.handler.theme.config.support.ThemeProperty;
/**
* Theme activated event.

View File

@ -1,7 +1,6 @@
package run.halo.app.event.theme;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component;
import run.halo.app.cache.StringCacheStore;
import run.halo.app.event.options.OptionUpdatedEvent;

View File

@ -1,10 +1,10 @@
package run.halo.app.filter;
import run.halo.app.security.filter.AdminAuthenticationFilter;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.HttpHeaders;
import org.springframework.web.cors.CorsUtils;
import org.springframework.web.filter.GenericFilterBean;
import run.halo.app.security.filter.AdminAuthenticationFilter;
import javax.servlet.FilterChain;
import javax.servlet.ServletException;

View File

@ -22,6 +22,39 @@ public interface FileHandler {
MediaType IMAGE_TYPE = MediaType.valueOf("image/*");
/**
* Check whether media type provided is an image type.
*
* @param mediaType media type provided
* @return true if it is an image type
*/
static boolean isImageType(@Nullable String mediaType) {
return mediaType != null && IMAGE_TYPE.includes(MediaType.valueOf(mediaType));
}
/**
* Check whether media type provided is an image type.
*
* @param mediaType media type provided
* @return true if it is an image type
*/
static boolean isImageType(@Nullable MediaType mediaType) {
return mediaType != null && IMAGE_TYPE.includes(mediaType);
}
/**
* Normalize directory full name, ensure the end path separator.
*
* @param dir directory full name must not be blank
* @return normalized directory full name with end path separator
*/
@NonNull
static String normalizeDirectory(@NonNull String dir) {
Assert.hasText(dir, "Directory full name must not be blank");
return StringUtils.appendIfMissing(dir, FILE_SEPARATOR);
}
/**
* Uploads file.
*
@ -47,39 +80,4 @@ public interface FileHandler {
* @return true if supported; false or else
*/
boolean supportType(@Nullable AttachmentType type);
/**
* Check whether media type provided is an image type.
*
* @param mediaType media type provided
* @return true if it is an image type
*/
static boolean isImageType(@Nullable String mediaType) {
return mediaType != null && IMAGE_TYPE.includes(MediaType.valueOf(mediaType));
}
/**
* Check whether media type provided is an image type.
*
* @param mediaType media type provided
* @return true if it is an image type
*/
static boolean isImageType(@Nullable MediaType mediaType) {
return mediaType != null && IMAGE_TYPE.includes(mediaType);
}
/**
* Normalize directory full name, ensure the end path separator.
*
* @param dir directory full name must not be blank
* @return normalized directory full name with end path separator
*/
@NonNull
static String normalizeDirectory(@NonNull String dir) {
Assert.hasText(dir, "Directory full name must not be blank");
return StringUtils.appendIfMissing(dir, FILE_SEPARATOR);
}
}

View File

@ -1,9 +1,5 @@
package run.halo.app.handler.file;
import run.halo.app.exception.FileOperationException;
import run.halo.app.model.entity.Attachment;
import run.halo.app.model.enums.AttachmentType;
import run.halo.app.model.support.UploadResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationContext;
import org.springframework.lang.NonNull;
@ -12,6 +8,10 @@ import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import org.springframework.web.multipart.MultipartFile;
import run.halo.app.exception.FileOperationException;
import run.halo.app.model.entity.Attachment;
import run.halo.app.model.enums.AttachmentType;
import run.halo.app.model.support.UploadResult;
import java.util.Collection;
import java.util.LinkedList;

View File

@ -1,5 +1,12 @@
package run.halo.app.handler.file;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import org.springframework.http.MediaType;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.web.multipart.MultipartFile;
import run.halo.app.config.properties.HaloProperties;
import run.halo.app.exception.FileOperationException;
import run.halo.app.exception.ServiceException;
@ -8,13 +15,6 @@ import run.halo.app.model.support.UploadResult;
import run.halo.app.service.OptionService;
import run.halo.app.utils.FilenameUtils;
import run.halo.app.utils.HaloUtils;
import lombok.extern.slf4j.Slf4j;
import net.coobird.thumbnailator.Thumbnails;
import org.springframework.http.MediaType;
import org.springframework.lang.NonNull;
import org.springframework.stereotype.Component;
import org.springframework.util.Assert;
import org.springframework.web.multipart.MultipartFile;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

View File

@ -73,6 +73,19 @@ public class ThemeProperty {
*/
private String screenshots;
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ThemeProperty that = (ThemeProperty) o;
return id.equals(that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
@Data
public static class Author {
@ -91,17 +104,4 @@ public class ThemeProperty {
*/
private String avatar;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
ThemeProperty that = (ThemeProperty) o;
return id.equals(that.id);
}
@Override
public int hashCode() {
return Objects.hash(id);
}
}

View File

@ -1,9 +1,9 @@
package run.halo.app.model.dto;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Attachment;
import run.halo.app.model.enums.AttachmentType;
import lombok.Data;
import java.util.Date;

View File

@ -1,10 +1,10 @@
package run.halo.app.model.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Category;
import lombok.Data;
/**
* Category output dto.

View File

@ -1,8 +1,8 @@
package run.halo.app.model.dto;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Link;
import lombok.Data;
/**
* Link output dto.

View File

@ -1,11 +1,11 @@
package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Log;
import run.halo.app.model.enums.LogType;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Log;
import run.halo.app.model.enums.LogType;
import java.util.Date;

View File

@ -1,8 +1,8 @@
package run.halo.app.model.dto;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Menu;
import lombok.Data;
/**
* Menu output dto.

View File

@ -1,8 +1,8 @@
package run.halo.app.model.dto;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Photo;
import lombok.Data;
import java.util.Date;

View File

@ -1,8 +1,8 @@
package run.halo.app.model.dto;
import lombok.Data;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.Tag;
import lombok.Data;
/**
* Tag output dto.

View File

@ -1,10 +1,10 @@
package run.halo.app.model.dto;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.User;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.base.OutputConverter;
import run.halo.app.model.entity.User;
import java.util.Date;

View File

@ -1,7 +1,6 @@
package run.halo.app.model.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.persistence.*;

View File

@ -1,7 +1,6 @@
package run.halo.app.model.entity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import javax.persistence.*;

View File

@ -29,12 +29,6 @@ public enum DataType implements ValueEnum<Integer> {
this.value = value;
}
@Override
public Integer getValue() {
return value;
}
/**
* Data type of string.
*
@ -53,6 +47,11 @@ public enum DataType implements ValueEnum<Integer> {
return STRING;
}
@Override
public Integer getValue() {
return value;
}
/**
* Converts data to corresponding type.
*

View File

@ -12,13 +12,6 @@ import java.util.stream.Stream;
*/
public interface ValueEnum<T> {
/**
* Gets enum value.
*
* @return enum value
*/
T getValue();
/**
* Converts value to corresponding enum.
*
@ -39,4 +32,11 @@ public interface ValueEnum<T> {
.orElseThrow(() -> new IllegalArgumentException("unknown database value: " + value));
}
/**
* Gets enum value.
*
* @return enum value
*/
T getValue();
}

View File

@ -1,6 +1,5 @@
package run.halo.app.model.enums.converter;
import run.halo.app.model.enums.AttachmentType;
import run.halo.app.model.enums.AttachmentType;
import javax.persistence.Converter;

View File

@ -1,11 +1,11 @@
package run.halo.app.model.params;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Category;
import run.halo.app.utils.HaloUtils;
import run.halo.app.utils.SlugUtils;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

View File

@ -1,9 +1,9 @@
package run.halo.app.model.params;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Link;
import lombok.Data;
import org.hibernate.validator.constraints.URL;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Link;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

View File

@ -1,7 +1,6 @@
package run.halo.app.model.params;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import run.halo.app.model.dto.base.InputConverter;

View File

@ -1,8 +1,8 @@
package run.halo.app.model.params;
import lombok.Data;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Option;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;

View File

@ -1,13 +1,13 @@
package run.halo.app.model.params;
import cn.hutool.crypto.digest.BCrypt;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Post;
import run.halo.app.model.enums.PostCreateFrom;
import run.halo.app.model.enums.PostStatus;
import run.halo.app.utils.HaloUtils;
import cn.hutool.crypto.digest.BCrypt;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;

View File

@ -1,11 +1,9 @@
package run.halo.app.model.params;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Tag;
import run.halo.app.utils.HaloUtils;
import run.halo.app.utils.SlugUtils;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import run.halo.app.model.dto.base.InputConverter;
import run.halo.app.model.entity.Tag;
import run.halo.app.utils.HaloUtils;
import run.halo.app.utils.SlugUtils;

View File

@ -51,4 +51,5 @@ public enum CommentProperties implements PropertyEnum {
@Override
public String getValue() {
return value;
}}
}
}

View File

@ -47,4 +47,5 @@ public enum SeoProperties implements PropertyEnum {
@Override
public String getValue() {
return value;
}}
}
}

View File

@ -20,11 +20,9 @@ public enum UpYunProperties implements PropertyEnum {
OSS_SMALL_URL("oss_upyun_small_url", String.class, "");
private String value;
private Class<?> type;
private final String defaultValue;
private String value;
private Class<?> type;
UpYunProperties(String value, Class<?> type, String defaultValue) {
this.defaultValue = defaultValue;

View File

@ -1,9 +1,9 @@
package run.halo.app.model.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import run.halo.app.model.dto.CategoryDTO;
import lombok.Data;
import java.util.List;

View File

@ -1,8 +1,8 @@
package run.halo.app.model.vo;
import run.halo.app.model.dto.LinkDTO;
import lombok.Data;
import lombok.ToString;
import run.halo.app.model.dto.LinkDTO;
import java.util.List;

View File

@ -1,8 +1,8 @@
package run.halo.app.repository;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.Category;
import run.halo.app.repository.base.BaseRepository;
import org.springframework.lang.NonNull;
import java.util.Optional;

View File

@ -1,13 +1,8 @@
package run.halo.app.repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.JournalComment;
import run.halo.app.model.projection.CommentCountProjection;
import run.halo.app.repository.base.BaseCommentRepository;
import java.util.List;
/**
* Journal comment repository.
*

View File

@ -2,7 +2,6 @@ package run.halo.app.repository;
import run.halo.app.model.entity.Link;
import run.halo.app.repository.base.BaseRepository;
import run.halo.app.repository.base.BaseRepository;
/**
* Link repository.

View File

@ -1,11 +1,8 @@
package run.halo.app.repository;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.Menu;
import run.halo.app.repository.base.BaseRepository;
import org.springframework.lang.NonNull;
import run.halo.app.repository.base.BaseRepository;
import java.util.Optional;
/**
* Menu repository.

View File

@ -2,7 +2,6 @@ package run.halo.app.repository;
import run.halo.app.model.entity.Option;
import run.halo.app.repository.base.BaseRepository;
import run.halo.app.repository.base.BaseRepository;
import java.util.Optional;

View File

@ -1,13 +1,8 @@
package run.halo.app.repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.PostComment;
import run.halo.app.model.projection.CommentCountProjection;
import run.halo.app.repository.base.BaseCommentRepository;
import java.util.List;
/**
* PostComment repository.
*

View File

@ -1,10 +1,10 @@
package run.halo.app.repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.PostTag;
import run.halo.app.model.projection.TagPostPostCountProjection;
import run.halo.app.repository.base.BaseRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import java.util.List;
import java.util.Set;

View File

@ -1,13 +1,8 @@
package run.halo.app.repository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.SheetComment;
import run.halo.app.model.projection.CommentCountProjection;
import run.halo.app.repository.base.BaseCommentRepository;
import java.util.List;
/**
* Sheet comment repository.
*

View File

@ -1,8 +1,7 @@
package run.halo.app.repository;
import run.halo.app.model.entity.Tag;
import run.halo.app.repository.base.BaseRepository;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.Tag;
import run.halo.app.repository.base.BaseRepository;
import java.util.Optional;

View File

@ -1,8 +1,7 @@
package run.halo.app.repository;
import run.halo.app.model.entity.User;
import run.halo.app.repository.base.BaseRepository;
import org.springframework.lang.NonNull;
import run.halo.app.model.entity.User;
import run.halo.app.repository.base.BaseRepository;
import java.util.Optional;

View File

@ -40,6 +40,26 @@ public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN,
this.entityManager = entityManager;
}
/**
* Executes a count query and transparently sums up all values returned.
*
* @param query must not be {@literal null}.
* @return
*/
private static long executeCountQuery(TypedQuery<Long> query) {
Assert.notNull(query, "TypedQuery must not be null!");
List<Long> totals = query.getResultList();
long total = 0L;
for (Long element : totals) {
total += element == null ? 0 : element;
}
return total;
}
/**
* Finds all domain by id list and the specified sort.
*
@ -140,24 +160,4 @@ public class BaseRepositoryImpl<DOMAIN, ID> extends SimpleJpaRepository<DOMAIN,
return path.in(this.parameter);
}
}
/**
* Executes a count query and transparently sums up all values returned.
*
* @param query must not be {@literal null}.
* @return
*/
private static long executeCountQuery(TypedQuery<Long> query) {
Assert.notNull(query, "TypedQuery must not be null!");
List<Long> totals = query.getResultList();
long total = 0L;
for (Long element : totals) {
total += element == null ? 0 : element;
}
return total;
}
}

View File

@ -1,7 +1,7 @@
package run.halo.app.security.authentication;
import run.halo.app.security.support.UserDetail;
import org.springframework.lang.NonNull;
import run.halo.app.security.support.UserDetail;
/**
* Authentication.

View File

@ -1,6 +1,5 @@
package run.halo.app.security.context;
import run.halo.app.security.authentication.Authentication;
import org.springframework.lang.Nullable;
import run.halo.app.security.authentication.Authentication;

View File

@ -1,6 +1,5 @@
package run.halo.app.security.context;
import run.halo.app.security.authentication.Authentication;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

View File

@ -31,19 +31,15 @@ import java.util.Set;
*/
public abstract class AbstractAuthenticationFilter extends OncePerRequestFilter {
protected final AntPathMatcher antPathMatcher;
protected final HaloProperties haloProperties;
protected final OptionService optionService;
private AuthenticationFailureHandler failureHandler;
/**
* Exclude url patterns.
*/
private Set<String> excludeUrlPatterns = new HashSet<>(2);
protected final AntPathMatcher antPathMatcher;
protected final HaloProperties haloProperties;
protected final OptionService optionService;
protected AbstractAuthenticationFilter(HaloProperties haloProperties,
OptionService optionService) {
this.haloProperties = haloProperties;
@ -70,17 +66,6 @@ public abstract class AbstractAuthenticationFilter extends OncePerRequestFilter
return excludeUrlPatterns.stream().anyMatch(p -> antPathMatcher.match(p, request.getServletPath()));
}
/**
* Sets exclude url patterns.
*
* @param excludeUrlPatterns exclude urls
*/
public void setExcludeUrlPatterns(@NonNull Collection<String> excludeUrlPatterns) {
Assert.notNull(excludeUrlPatterns, "Exclude url patterns must not be null");
this.excludeUrlPatterns = new HashSet<>(excludeUrlPatterns);
}
/**
* Adds exclude url patterns.
*
@ -102,6 +87,16 @@ public abstract class AbstractAuthenticationFilter extends OncePerRequestFilter
return excludeUrlPatterns;
}
/**
* Sets exclude url patterns.
*
* @param excludeUrlPatterns exclude urls
*/
public void setExcludeUrlPatterns(@NonNull Collection<String> excludeUrlPatterns) {
Assert.notNull(excludeUrlPatterns, "Exclude url patterns must not be null");
this.excludeUrlPatterns = new HashSet<>(excludeUrlPatterns);
}
/**
* Gets authentication failure handler. (Default: @DefaultAuthenticationFailureHandler)

View File

@ -1,6 +1,5 @@
package run.halo.app.security.handler;
import run.halo.app.exception.HaloException;
import run.halo.app.exception.HaloException;
import javax.servlet.ServletException;

View File

@ -1,10 +1,5 @@
package run.halo.app.security.resolver;
import run.halo.app.exception.AuthenticationException;
import run.halo.app.model.entity.User;
import run.halo.app.security.authentication.Authentication;
import run.halo.app.security.context.SecurityContextHolder;
import run.halo.app.security.support.UserDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.MethodParameter;
import org.springframework.lang.Nullable;
@ -12,6 +7,11 @@ import org.springframework.web.bind.support.WebDataBinderFactory;
import org.springframework.web.context.request.NativeWebRequest;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.method.support.ModelAndViewContainer;
import run.halo.app.exception.AuthenticationException;
import run.halo.app.model.entity.User;
import run.halo.app.security.authentication.Authentication;
import run.halo.app.security.context.SecurityContextHolder;
import run.halo.app.security.support.UserDetail;
import java.util.Optional;

View File

@ -1,13 +1,12 @@
package run.halo.app.security.support;
import run.halo.app.exception.AuthenticationException;
import run.halo.app.model.entity.User;
import lombok.AllArgsConstructor;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import org.springframework.lang.NonNull;
import run.halo.app.exception.AuthenticationException;
import run.halo.app.model.entity.User;
/**
* User detail.

View File

@ -50,6 +50,7 @@ public interface AdminService {
/**
* Get system environments
*
* @return environments
*/
@NonNull

View File

@ -59,6 +59,7 @@ public interface AttachmentService extends CrudService<Attachment, Integer> {
/**
* List all media type.
*
* @return list of media type
*/
List<String> listAllMediaType();

View File

@ -1,12 +1,12 @@
package run.halo.app.service;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import run.halo.app.model.dto.LinkDTO;
import run.halo.app.model.entity.Link;
import run.halo.app.model.params.LinkParam;
import run.halo.app.model.vo.LinkTeamVO;
import run.halo.app.service.base.CrudService;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import java.util.List;

View File

@ -1,9 +1,9 @@
package run.halo.app.service;
import org.springframework.data.domain.Page;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.model.entity.Log;
import run.halo.app.service.base.CrudService;
import org.springframework.data.domain.Page;
/**
* Log service.

View File

@ -1,16 +1,16 @@
package run.halo.app.service;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.transaction.annotation.Transactional;
import run.halo.app.model.dto.TagWithPostCountDTO;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostTag;
import run.halo.app.model.entity.Tag;
import run.halo.app.service.base.CrudService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.util.Collection;
import java.util.List;

View File

@ -1,13 +1,13 @@
package run.halo.app.service.base;
import run.halo.app.exception.NotFoundException;
import run.halo.app.repository.base.BaseRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.exception.NotFoundException;
import run.halo.app.repository.base.BaseRepository;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;

View File

@ -122,6 +122,7 @@ public interface BasePostService<POST extends BasePost> extends CrudService<POST
/**
* Lists latest posts.
*
* @param top top number must not be less than 0
* @return latest posts
*/

View File

@ -1,12 +1,12 @@
package run.halo.app.service.base;
import org.springframework.transaction.annotation.Transactional;
import run.halo.app.exception.NotFoundException;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.transaction.annotation.Transactional;
import run.halo.app.exception.NotFoundException;
import java.util.Collection;
import java.util.List;

View File

@ -1,5 +1,12 @@
package run.halo.app.service.impl;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.exception.AlreadyExistsException;
import run.halo.app.model.dto.LinkDTO;
import run.halo.app.model.entity.Link;
@ -9,13 +16,6 @@ import run.halo.app.repository.LinkRepository;
import run.halo.app.service.LinkService;
import run.halo.app.service.base.AbstractCrudService;
import run.halo.app.utils.ServiceUtils;
import org.springframework.data.domain.Example;
import org.springframework.data.domain.Sort;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;
@ -107,7 +107,7 @@ public class LinkServiceImpl extends AbstractCrudService<Link, Integer> implemen
return Collections.emptyList();
}
return links.stream().map(link -> new LinkDTO().<LinkDTO>convertFrom(link))
return links.stream().map(link -> (LinkDTO) new LinkDTO().convertFrom(link))
.collect(Collectors.toList());
}
}

View File

@ -1,15 +1,15 @@
package run.halo.app.service.impl;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.model.entity.Log;
import run.halo.app.repository.LogRepository;
import run.halo.app.service.LogService;
import run.halo.app.service.base.AbstractCrudService;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import run.halo.app.model.dto.LogDTO;
import run.halo.app.model.entity.Log;
import run.halo.app.repository.LogRepository;
import run.halo.app.service.LogService;
import run.halo.app.service.base.AbstractCrudService;
/**
* LogService implementation class

View File

@ -153,7 +153,7 @@ public class MenuServiceImpl extends AbstractCrudService<Menu, Integer> implemen
}
return menus.stream()
.map(menu -> new MenuDTO().<MenuDTO>convertFrom(menu))
.map(menu -> (MenuDTO) new MenuDTO().convertFrom(menu))
.collect(Collectors.toList());
}

View File

@ -6,7 +6,6 @@ import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.model.dto.CategoryDTO;
import run.halo.app.model.dto.CategoryWithPostCountDTO;
import run.halo.app.model.entity.Category;
import run.halo.app.model.entity.Post;

View File

@ -1,5 +1,11 @@
package run.halo.app.service.impl;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import run.halo.app.model.dto.TagWithPostCountDTO;
import run.halo.app.model.entity.Post;
import run.halo.app.model.entity.PostTag;
@ -11,12 +17,6 @@ import run.halo.app.repository.TagRepository;
import run.halo.app.service.PostTagService;
import run.halo.app.service.base.AbstractCrudService;
import run.halo.app.utils.ServiceUtils;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils;
import java.util.*;
import java.util.stream.Collectors;

View File

@ -1,7 +1,6 @@
package run.halo.app.service.support;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.http.MediaType;
import java.nio.charset.Charset;

View File

@ -1,6 +1,5 @@
package run.halo.app.utils;
import run.halo.app.exception.BeanUtilsException;
import org.springframework.beans.BeanWrapperImpl;
import org.springframework.beans.BeansException;
import org.springframework.lang.NonNull;