异常处理

dev
youhong.ai 2023-07-14 20:41:18 +08:00
parent 31c1ca0202
commit b23aadb572
3 changed files with 217 additions and 229 deletions

View File

@ -16,7 +16,6 @@ import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.net.URI; import java.net.URI;
import java.net.URISyntaxException; import java.net.URISyntaxException;
import java.util.Date; import java.util.Date;
@ -166,7 +165,7 @@ public class SignFtService {
try { try {
try { try {
tokenUtils.setAlgorithm(Algorithm.HMAC256(secretMap.get("clientSecret"))); tokenUtils.setAlgorithm(Algorithm.HMAC256(secretMap.get("clientSecret")));
} catch (UnsupportedEncodingException e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
tokenUtils.setExpiresAt(new Date()); tokenUtils.setExpiresAt(new Date());

View File

@ -12,7 +12,6 @@ import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import java.io.UnsupportedEncodingException;
import java.util.Date; import java.util.Date;
import java.util.Map; import java.util.Map;
@ -68,7 +67,7 @@ public class TokenUtils {
this.secret = secret; this.secret = secret;
try { try {
this.algorithm = Algorithm.HMAC256(secret); this.algorithm = Algorithm.HMAC256(secret);
} catch (UnsupportedEncodingException e) { } catch (Exception e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
this.claims = claims; this.claims = claims;

View File

@ -22,7 +22,6 @@ import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.StreamingOutput; import javax.ws.rs.core.StreamingOutput;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder; import java.net.URLDecoder;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.Base64; import java.util.Base64;
@ -42,8 +41,7 @@ public class FaDDController {
/** /**
* *
* *
* @param workflowId * @param workflowId id
* id
* @return * @return
*/ */
@GET @GET
@ -60,8 +58,7 @@ public class FaDDController {
/** /**
* *
* *
* @param params * @param params
*
* @return * @return
*/ */
@Path("/signature") @Path("/signature")
@ -80,10 +77,8 @@ public class FaDDController {
/** /**
* *
* *
* @param workflowId * @param workflowId id
* id * @param requestId id
* @param requestId
* id
* @return * @return
*/ */
@Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}") @Path("/signedContract/{languageGroupId}/{requestId}/{workflowId}")
@ -108,10 +103,8 @@ public class FaDDController {
/** /**
* *
* *
* @param workflowId * @param workflowId id
* id * @param requestId id
* @param requestId
* id
* @return * @return
*/ */
@Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}") @Path("/signedContract/own/{languageGroupId}/{requestId}/{workflowId}")
@ -135,7 +128,7 @@ public class FaDDController {
String info = language.get("contractSignedInfo"); String info = language.get("contractSignedInfo");
return ApiResult.success(info); return ApiResult.success(info);
} catch (Exception e) { } catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString()); toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString()); return ApiResult.error(e.toString());
} }
} }
@ -143,8 +136,7 @@ public class FaDDController {
/** /**
* *
* *
* @param requestId * @param requestId id
* id
* @return * @return
*/ */
@Path("/contract/download/{workflowId}/{requestId}") @Path("/contract/download/{workflowId}/{requestId}")
@ -158,7 +150,7 @@ public class FaDDController {
return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip") return Response.ok(contractZipStream, MediaType.APPLICATION_OCTET_STREAM).type("application/zip")
.header("Content-Disposition", "attachment;filename=contracts.zip").build(); .header("Content-Disposition", "attachment;filename=contracts.zip").build();
} catch (Exception e) { } catch (Exception e) {
toolUtil.writeErrorLog("转换失败," + e.toString()); toolUtil.writeErrorLog("转换失败," + e);
return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.APPLICATION_JSON).build(); return Response.ok(ApiResult.error("出现错误,错误原因: " + e), MediaType.APPLICATION_JSON).build();
} }
} }
@ -166,8 +158,7 @@ public class FaDDController {
/** /**
* *
* *
* @param workflowId * @param workflowId id
* id
* @return id * @return id
*/ */
@Path("/getAllVersion/{workflowId}/{markOnly}") @Path("/getAllVersion/{workflowId}/{markOnly}")
@ -179,7 +170,7 @@ public class FaDDController {
Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly); Map<String, Object> allVersion = faDDService.getAllVersion(workflowId, markOnly);
return ApiResult.success(allVersion); return ApiResult.success(allVersion);
} catch (Exception e) { } catch (Exception e) {
toolUtil.writeErrorLog("错误:" + e.toString()); toolUtil.writeErrorLog("错误:" + e);
return ApiResult.error(e.toString()); return ApiResult.error(e.toString());
} }
} }
@ -187,8 +178,7 @@ public class FaDDController {
/** /**
* *
* *
* @param requestId * @param requestId id
* id
* @return * @return
*/ */
@Path("/isAllSigned/{workflowId}/{requestId}") @Path("/isAllSigned/{workflowId}/{requestId}")
@ -236,14 +226,14 @@ public class FaDDController {
byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8)); byte[] decode = Base64.getDecoder().decode(bizContent.getBytes(StandardCharsets.UTF_8));
String decodeStr = null; String decodeStr = null;
try { try {
decodeStr = new String(decode, "UTF-8"); decodeStr = new String(decode, StandardCharsets.UTF_8);
} catch (UnsupportedEncodingException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
String jsonStr = null; String jsonStr = null;
try { try {
jsonStr = URLDecoder.decode(decodeStr, "UTF-8"); jsonStr = URLDecoder.decode(decodeStr, "UTF-8");
} catch (UnsupportedEncodingException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
JSONObject jsonObject = JSON.parseObject(jsonStr); JSONObject jsonObject = JSON.parseObject(jsonStr);