Commit 75ce9158 authored by liaozan's avatar liaozan 🏀

Generate toString method with callSuper=true

parent 9f4bf6fc
package com.schbrain.common.web.exception; package com.schbrain.common.web.exception;
import com.schbrain.common.web.annotation.ResponseWrapOption; import com.schbrain.common.web.annotation.ResponseWrapOption;
import lombok.EqualsAndHashCode;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.context.request.ServletWebRequest; import org.springframework.web.context.request.ServletWebRequest;
import org.springframework.web.method.HandlerMethod; import org.springframework.web.method.HandlerMethod;
...@@ -30,7 +29,6 @@ import static com.schbrain.common.web.utils.HandlerMethodAnnotationUtils.getAnno ...@@ -30,7 +29,6 @@ import static com.schbrain.common.web.utils.HandlerMethodAnnotationUtils.getAnno
* @since 2022/8/30 * @since 2022/8/30
*/ */
@Slf4j @Slf4j
@EqualsAndHashCode(callSuper = true)
public class DefaultGlobalExceptionResolver extends AbstractHandlerMethodExceptionResolver { public class DefaultGlobalExceptionResolver extends AbstractHandlerMethodExceptionResolver {
private final GlobalExceptionHandler exceptionHandler; private final GlobalExceptionHandler exceptionHandler;
...@@ -49,6 +47,9 @@ public class DefaultGlobalExceptionResolver extends AbstractHandlerMethodExcepti ...@@ -49,6 +47,9 @@ public class DefaultGlobalExceptionResolver extends AbstractHandlerMethodExcepti
@Override @Override
protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object handler) { protected boolean shouldApplyTo(HttpServletRequest request, @Nullable Object handler) {
if (handler == null) {
return super.shouldApplyTo(request, null);
}
if (handler instanceof HandlerMethod) { if (handler instanceof HandlerMethod) {
HandlerMethod handlerMethod = (HandlerMethod) handler; HandlerMethod handlerMethod = (HandlerMethod) handler;
ResponseWrapOption responseWrapOption = getAnnotation(handlerMethod, ResponseWrapOption.class); ResponseWrapOption responseWrapOption = getAnnotation(handlerMethod, ResponseWrapOption.class);
......
...@@ -39,12 +39,13 @@ public class ExceptionHandingWebMvcConfigurer implements WebMvcConfigurer { ...@@ -39,12 +39,13 @@ public class ExceptionHandingWebMvcConfigurer implements WebMvcConfigurer {
} }
} }
int index;
if (adviceExceptionResolver == null) { if (adviceExceptionResolver == null) {
log.warn("ExceptionHandlerExceptionResolver is not exist, ignore global exception handing"); index = 0;
return; } else {
index = resolvers.indexOf(adviceExceptionResolver) + 1;
} }
int index = resolvers.indexOf(adviceExceptionResolver) + 1;
resolvers.add(index, createExceptionResolver(adviceExceptionResolver)); resolvers.add(index, createExceptionResolver(adviceExceptionResolver));
} }
......
...@@ -2,17 +2,17 @@ package com.schbrain.framework.autoconfigure.oss.bean; ...@@ -2,17 +2,17 @@ package com.schbrain.framework.autoconfigure.oss.bean;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString;
/** /**
* @author lik * @author lik
* @since 2022/9/6 * @since 2022/9/6
*/ */
@Data @Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class CopyResult extends OssOperationResult { public class CopyResult extends OssOperationResult {
private static final long serialVersionUID = 7322484488471640978L;
private String destinationKey; private String destinationKey;
private String destinationBucket; private String destinationBucket;
......
...@@ -2,6 +2,7 @@ package com.schbrain.framework.autoconfigure.oss.bean; ...@@ -2,6 +2,7 @@ package com.schbrain.framework.autoconfigure.oss.bean;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString;
import java.util.List; import java.util.List;
...@@ -10,11 +11,10 @@ import java.util.List; ...@@ -10,11 +11,10 @@ import java.util.List;
* @since 2022/9/6 * @since 2022/9/6
*/ */
@Data @Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class DeleteResult extends OssOperationResult { public class DeleteResult extends OssOperationResult {
private static final long serialVersionUID = -1964404722922995469L;
private List<String> deleteObjectKeys; private List<String> deleteObjectKeys;
public static DeleteResult success(String bucket, List<String> objectKeys) { public static DeleteResult success(String bucket, List<String> objectKeys) {
......
...@@ -3,17 +3,17 @@ package com.schbrain.framework.autoconfigure.oss.bean; ...@@ -3,17 +3,17 @@ package com.schbrain.framework.autoconfigure.oss.bean;
import com.aliyun.oss.model.OSSObject; import com.aliyun.oss.model.OSSObject;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString;
/** /**
* @author liaozan * @author liaozan
* @since 2021/12/3 * @since 2021/12/3
*/ */
@Data @Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class DownloadResult extends OssOperationResult { public class DownloadResult extends OssOperationResult {
private static final long serialVersionUID = -9010079317621184645L;
private OSSObject ossObject; private OSSObject ossObject;
public static DownloadResult success(String bucket, String objectKey, OSSObject ossObject) { public static DownloadResult success(String bucket, String objectKey, OSSObject ossObject) {
......
...@@ -3,6 +3,8 @@ package com.schbrain.framework.autoconfigure.oss.bean; ...@@ -3,6 +3,8 @@ package com.schbrain.framework.autoconfigure.oss.bean;
import com.aliyuncs.auth.sts.AssumeRoleResponse.Credentials; import com.aliyuncs.auth.sts.AssumeRoleResponse.Credentials;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.ToString;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.ZoneId; import java.time.ZoneId;
...@@ -14,11 +16,11 @@ import java.time.format.DateTimeFormatter; ...@@ -14,11 +16,11 @@ import java.time.format.DateTimeFormatter;
* @since 2021/12/4 * @since 2021/12/4
*/ */
@Data @Data
@NoArgsConstructor
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class UploadCredentials extends OssOperationResult { public class UploadCredentials extends OssOperationResult {
private static final long serialVersionUID = 5546792221041679671L;
private String accessKeyId; private String accessKeyId;
private String accessKeySecret; private String accessKeySecret;
...@@ -27,11 +29,6 @@ public class UploadCredentials extends OssOperationResult { ...@@ -27,11 +29,6 @@ public class UploadCredentials extends OssOperationResult {
private LocalDateTime expiration; private LocalDateTime expiration;
// for json deserialize
public UploadCredentials() {
}
public UploadCredentials(Credentials credentials) { public UploadCredentials(Credentials credentials) {
this.success = true; this.success = true;
this.accessKeyId = credentials.getAccessKeyId(); this.accessKeyId = credentials.getAccessKeyId();
......
...@@ -2,17 +2,17 @@ package com.schbrain.framework.autoconfigure.oss.bean; ...@@ -2,17 +2,17 @@ package com.schbrain.framework.autoconfigure.oss.bean;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.ToString;
/** /**
* @author liaozan * @author liaozan
* @since 2021/12/3 * @since 2021/12/3
*/ */
@Data @Data
@ToString(callSuper = true)
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public class UploadResult extends OssOperationResult { public class UploadResult extends OssOperationResult {
private static final long serialVersionUID = 7408490108665799098L;
private String url; private String url;
public static UploadResult success(String bucket, String objectKey, String url) { public static UploadResult success(String bucket, String objectKey, String url) {
......
...@@ -16,6 +16,7 @@ import com.aliyuncs.http.MethodType; ...@@ -16,6 +16,7 @@ import com.aliyuncs.http.MethodType;
import com.aliyuncs.profile.DefaultProfile; import com.aliyuncs.profile.DefaultProfile;
import com.aliyuncs.profile.IClientProfile; import com.aliyuncs.profile.IClientProfile;
import com.schbrain.common.util.ApplicationName; import com.schbrain.common.util.ApplicationName;
import com.schbrain.common.util.StreamUtils;
import com.schbrain.common.util.ValidateUtils; import com.schbrain.common.util.ValidateUtils;
import com.schbrain.framework.autoconfigure.oss.bean.*; import com.schbrain.framework.autoconfigure.oss.bean.*;
import com.schbrain.framework.autoconfigure.oss.exception.OssException; import com.schbrain.framework.autoconfigure.oss.exception.OssException;
...@@ -23,6 +24,7 @@ import com.schbrain.framework.autoconfigure.oss.properties.OssProperties; ...@@ -23,6 +24,7 @@ import com.schbrain.framework.autoconfigure.oss.properties.OssProperties;
import com.schbrain.framework.autoconfigure.oss.properties.OssProperties.StsProperties; import com.schbrain.framework.autoconfigure.oss.properties.OssProperties.StsProperties;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import java.io.File; import java.io.File;
...@@ -33,7 +35,6 @@ import java.time.*; ...@@ -33,7 +35,6 @@ import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @author liaozan * @author liaozan
...@@ -265,8 +266,8 @@ public class OssUtils { ...@@ -265,8 +266,8 @@ public class OssUtils {
public static DeleteResult deleteObject(String bucket, List<String> objectKeys) { public static DeleteResult deleteObject(String bucket, List<String> objectKeys) {
ValidateUtils.notEmpty(bucket, "bucket can not be empty"); ValidateUtils.notEmpty(bucket, "bucket can not be empty");
ValidateUtils.notEmpty(objectKeys, "objectKeys can not be empty"); ValidateUtils.notEmpty(objectKeys, "objectKeys can not be empty");
String notExistKeys = objectKeys.stream().filter(key -> !exist(bucket, key)).collect(Collectors.joining(",")); List<String> notExistKeys = StreamUtils.filterToList(objectKeys, key -> !exist(bucket, key));
if (StringUtils.isNotBlank(notExistKeys)) { if (CollectionUtils.isNotEmpty(notExistKeys)) {
String errorMsg = StrFormatter.format("objectKeys:[{}] not exist", notExistKeys); String errorMsg = StrFormatter.format("objectKeys:[{}] not exist", notExistKeys);
return DeleteResult.fail(bucket, objectKeys, errorMsg); return DeleteResult.fail(bucket, objectKeys, errorMsg);
} }
...@@ -286,8 +287,12 @@ public class OssUtils { ...@@ -286,8 +287,12 @@ public class OssUtils {
private static DownloadResult download0(String bucket, String objectKey) { private static DownloadResult download0(String bucket, String objectKey) {
GetObjectRequest request = new GetObjectRequest(bucket, objectKey); GetObjectRequest request = new GetObjectRequest(bucket, objectKey);
try {
OSSObject ossObject = getOssClient().getObject(request); OSSObject ossObject = getOssClient().getObject(request);
return DownloadResult.success(bucket, objectKey, ossObject); return DownloadResult.success(bucket, objectKey, ossObject);
} catch (Exception e) {
return DownloadResult.fail(bucket, objectKey, e.getMessage());
}
} }
private static UploadResult upload0(Object object, String bucket, String objectKey, boolean allowOverwrite, boolean appendPrefix, ObjectMetadata metadata) { private static UploadResult upload0(Object object, String bucket, String objectKey, boolean allowOverwrite, boolean appendPrefix, ObjectMetadata metadata) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment