From 42c4e4784b9dd8246764d05b2a96873595cbc32d Mon Sep 17 00:00:00 2001 From: tanghc Date: Sat, 23 Mar 2019 12:21:29 +0800 Subject: [PATCH] alicode,sonar --- pom.xml | 3 +- .../pages/service/serviceList.js | 17 +- .../api/service/result/ServiceInfoVo.java | 2 +- sop-common/pom.xml | 188 +++++++++++++++ sop-common/readme.md | 5 + .../sop-gateway-common}/.gitignore | 0 sop-common/sop-gateway-common/pom.xml | 62 +++++ .../sop-gateway-common}/readme.md | 0 .../bean/AbstractTargetRoute.java | 0 .../sop/gatewaycommon/bean/ApiConfig.java | 2 +- .../sop/gatewaycommon/bean/ApiContext.java | 0 .../bean/BaseRouteDefinition.java | 0 .../bean/BaseServiceRouteInfo.java | 0 .../sop/gatewaycommon/bean/RouteStatus.java | 0 .../sop/gatewaycommon/bean/SopConstants.java | 3 + .../sop/gatewaycommon/bean/TargetRoute.java | 0 .../easyopen/EasyopenResultExecutor.java | 0 .../easyopen/EasyopenSigner.java | 3 +- .../easyopen/EasyopenZuulConfiguration.java | 2 - .../gatewaycommon/exception/ApiException.java | 2 +- .../gatewaycommon/gateway/GatewayContext.java | 0 .../AlipayGatewayConfiguration.java | 0 .../BaseGatewayConfiguration.java | 0 .../TaobaoGatewayConfiguration.java | 0 .../GatewayModifyResponseGatewayFilter.java | 0 .../filter/LoadBalancerClientExtFilter.java | 0 .../gateway/filter/ValidateFilter.java | 0 .../handler/GatewayExceptionHandler.java | 16 +- .../gateway/param/GatewayParamBuilder.java | 0 .../gateway/result/GatewayResult.java | 0 .../gateway/result/GatewayResultExecutor.java | 0 .../route/GatewayFilterDefinition.java | 0 .../route/GatewayPredicateDefinition.java | 0 .../gateway/route/GatewayRouteDefinition.java | 0 .../gateway/route/GatewayRouteRepository.java | 0 .../route/GatewayServiceRouteInfo.java | 0 .../gateway/route/GatewayTargetRoute.java | 0 .../route/GatewayZookeeperRouteManager.java | 0 .../NameVersionRoutePredicateFactory.java | 0 .../route/ReadBodyRoutePredicateFactory.java | 6 +- .../manager/BaseRouteManager.java | 0 .../gatewaycommon/manager/RouteManager.java | 0 .../manager/RouteRepository.java | 0 .../manager/RouteRepositoryContext.java | 3 + .../sop/gatewaycommon/message/Error.java | 0 .../sop/gatewaycommon/message/ErrorEnum.java | 118 +++++++++ .../gatewaycommon/message/ErrorFactory.java | 8 +- .../sop/gatewaycommon/message/ErrorImpl.java | 0 .../sop/gatewaycommon/message/ErrorMeta.java | 2 - .../sop/gatewaycommon/param/ApiParam.java | 30 +-- .../gatewaycommon/param/ApiParamFactory.java | 3 + .../gatewaycommon/param/ApiUploadContext.java | 0 .../gitee/sop/gatewaycommon/param/Param.java | 0 .../sop/gatewaycommon/param/ParamBuilder.java | 0 .../sop/gatewaycommon/param/ParamNames.java | 0 .../gatewaycommon/param/UploadContext.java | 0 .../sop/gatewaycommon/result/ApiResult.java | 2 - .../result/BaseExecutorAdapter.java | 0 .../sop/gatewaycommon/result/Result.java | 0 .../gatewaycommon/result/ResultExecutor.java | 2 - .../secret/AppSecretManager.java | 0 .../secret/CacheAppSecretManager.java | 2 +- .../secret/FileAppSecretManager.java | 2 +- .../gatewaycommon/session/ApiHttpSession.java | 42 ++-- .../session/ApiRedisTemplate.java | 0 .../session/ApiSessionManager.java | 3 +- .../session/RedisHttpSession.java | 9 +- .../session/RedisSessionManager.java | 0 .../gatewaycommon/session/SessionManager.java | 0 .../gitee/sop/gatewaycommon/util/AESUtil.java | 0 .../sop/gatewaycommon/util/KeyStore.java | 0 .../sop/gatewaycommon/util/RSANewUtil.java | 0 .../gitee/sop/gatewaycommon/util/RSAUtil.java | 0 .../sop/gatewaycommon/util/RedisLockUtil.java | 2 + .../sop/gatewaycommon/util/RequestUtil.java | 9 +- .../sop/gatewaycommon/util/ResponseUtil.java | 19 +- .../sop/gatewaycommon/util/RouteUtil.java | 2 + .../validate/AbstractSigner.java | 0 .../gatewaycommon/validate/ApiEncrypter.java | 0 .../sop/gatewaycommon/validate/ApiSigner.java | 2 +- .../gatewaycommon/validate/ApiValidator.java | 55 +++-- .../sop/gatewaycommon/validate/Encrypter.java | 0 .../gatewaycommon/validate/SignEncipher.java | 0 .../validate/SignEncipherHMAC_MD5.java | 0 .../validate/SignEncipherMD5.java | 0 .../sop/gatewaycommon/validate/Signer.java | 0 .../sop/gatewaycommon/validate/Validator.java | 0 .../validate/alipay/AlipayConstants.java | 0 .../validate/alipay/AlipaySignature.java | 0 .../validate/alipay/AlipaySigner.java | 3 - .../validate/alipay/StreamUtil.java | 2 + .../validate/alipay/StringUtils.java | 4 +- .../validate/taobao/TaobaoSigner.java | 2 +- .../sop/gatewaycommon/zuul/ZuulContext.java | 24 +- .../AlipayZuulConfiguration.java | 0 .../configuration/BaseZuulConfiguration.java | 3 - .../TaobaoZuulConfiguration.java | 0 .../configuration/ZuulErrorController.java | 0 .../zuul/filter/BaseZuulFilter.java | 4 - .../zuul/filter/ErrorFilter.java | 0 .../zuul/filter/PostResultFilter.java | 0 .../zuul/filter/PreValidateFilter.java | 0 .../zuul/param/ZuulParamBuilder.java | 78 +++--- .../zuul/result/ZuulResultExecutor.java | 0 .../zuul/route/SopRouteLocator.java | 0 .../zuul/route/ZuulRouteDefinition.java | 0 .../zuul/route/ZuulRouteRepository.java | 0 .../zuul/route/ZuulServiceRouteInfo.java | 2 - .../zuul/route/ZuulTargetRoute.java | 0 .../zuul/route/ZuulZookeeperRouteManager.java | 0 .../resources/i18n/open/error_en.properties | 0 .../i18n/open/error_zh_CN.properties | 0 .../sop-service-common}/.gitignore | 0 sop-common/sop-service-common/pom.xml | 40 ++++ .../sop-service-common}/readme.md | 0 .../servercommon/annotation/ApiAbility.java | 0 .../servercommon/annotation/ApiMapping.java | 0 .../sop/servercommon/bean/ParamNames.java | 0 .../sop/servercommon/bean/ServiceApiInfo.java | 0 .../sop/servercommon/bean/ServiceConfig.java | 2 +- .../sop/servercommon/bean/ServiceContext.java | 0 .../AlipayServiceConfiguration.java | 0 .../BaseServiceConfiguration.java | 2 +- .../DefaultGlobalExceptionHandler.java | 6 +- .../EasyopenServiceConfiguration.java | 6 +- .../configuration/GlobalExceptionHandler.java | 0 .../TaobaoServiceConfiguration.java | 0 .../exception/ServiceException.java | 2 +- .../ServiceContextInterceptor.java | 0 .../servercommon/manager/ApiMetaManager.java | 2 - .../manager/DefaultRequestMappingEvent.java | 11 +- .../manager/RedisApiMetaManager.java | 1 + .../manager/RequestMappingEvent.java | 0 .../ServiceZookeeperApiMetaManager.java | 17 +- .../mapping/ApiMappingHandlerMapping.java | 0 .../servercommon/mapping/ApiMappingInfo.java | 0 .../mapping/ApiMappingRequestCondition.java | 13 +- .../ApiMappingStringValueResolver.java | 0 .../servercommon/message/ServiceError.java | 0 .../message/ServiceErrorEnum.java | 0 .../message/ServiceErrorFactory.java | 6 +- .../message/ServiceErrorImpl.java | 0 .../message/ServiceErrorMeta.java | 0 .../param/ApiArgumentResolver.java | 0 .../servercommon/param/ParamValidator.java | 0 .../param/ServiceParamValidator.java | 0 .../result/DefaultServiceResultBuilder.java | 0 .../result/ServiceResultBuilder.java | 2 +- .../route/GatewayFilterDefinition.java | 0 .../route/GatewayPredicateDefinition.java | 6 +- .../route/GatewayRouteDefinition.java | 0 .../servercommon/route/ServiceRouteInfo.java | 0 .../resources/i18n/isp/error_en.properties | 0 .../resources/i18n/isp/error_zh_CN.properties | 0 sop-gateway-common/pom.xml | 223 ------------------ .../sop/gatewaycommon/message/ErrorEnum.java | 66 ------ .../gitee/sop/gatewaycommon/util/XmlUtil.java | 32 --- sop-service-common/pom.xml | 185 --------------- 158 files changed, 633 insertions(+), 737 deletions(-) create mode 100644 sop-common/pom.xml create mode 100644 sop-common/readme.md rename {sop-gateway-common => sop-common/sop-gateway-common}/.gitignore (100%) create mode 100644 sop-common/sop-gateway-common/pom.xml rename {sop-gateway-common => sop-common/sop-gateway-common}/readme.md (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/AbstractTargetRoute.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java (98%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiContext.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseRouteDefinition.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseServiceRouteInfo.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java (97%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java (87%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java (84%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java (91%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/GatewayContext.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/AlipayGatewayConfiguration.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/BaseGatewayConfiguration.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/TaobaoGatewayConfiguration.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LoadBalancerClientExtFilter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/ValidateFilter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java (91%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/param/GatewayParamBuilder.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResult.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayFilterDefinition.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayPredicateDefinition.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteDefinition.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayServiceRouteInfo.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayTargetRoute.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayZookeeperRouteManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/NameVersionRoutePredicateFactory.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java (87%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/manager/BaseRouteManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepository.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java (92%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/message/Error.java (100%) create mode 100644 sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java (93%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java (94%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java (89%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java (97%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/ApiUploadContext.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/Param.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/ParamBuilder.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/ParamNames.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/param/UploadContext.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java (94%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/result/Result.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java (94%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/secret/AppSecretManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java (90%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java (92%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java (86%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/session/ApiRedisTemplate.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java (97%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java (97%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/session/RedisSessionManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/session/SessionManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/AESUtil.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/KeyStore.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/RSANewUtil.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/RSAUtil.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java (99%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java (92%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java (88%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java (96%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/AbstractSigner.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiEncrypter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java (96%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java (76%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/Encrypter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipher.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherHMAC_MD5.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherMD5.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/Signer.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/Validator.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipayConstants.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySignature.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java (91%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java (99%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java (96%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java (97%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java (83%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/AlipayZuulConfiguration.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java (95%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/TaobaoZuulConfiguration.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/ZuulErrorController.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java (96%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/ErrorFilter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PostResultFilter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreValidateFilter.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java (59%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/SopRouteLocator.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteDefinition.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java (70%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulTargetRoute.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulZookeeperRouteManager.java (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/resources/i18n/open/error_en.properties (100%) rename {sop-gateway-common => sop-common/sop-gateway-common}/src/main/resources/i18n/open/error_zh_CN.properties (100%) rename {sop-service-common => sop-common/sop-service-common}/.gitignore (100%) create mode 100644 sop-common/sop-service-common/pom.xml rename {sop-service-common => sop-common/sop-service-common}/readme.md (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/annotation/ApiAbility.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/annotation/ApiMapping.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/bean/ParamNames.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/bean/ServiceApiInfo.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java (96%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/bean/ServiceContext.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/configuration/AlipayServiceConfiguration.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java (98%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java (92%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java (95%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/configuration/GlobalExceptionHandler.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/configuration/TaobaoServiceConfiguration.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java (92%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java (84%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java (88%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java (94%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/manager/RequestMappingEvent.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java (96%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingHandlerMapping.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingInfo.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java (85%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingStringValueResolver.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/message/ServiceError.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorEnum.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorFactory.java (95%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorImpl.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorMeta.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/param/ParamValidator.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/result/DefaultServiceResultBuilder.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java (94%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/route/GatewayFilterDefinition.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java (82%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/route/GatewayRouteDefinition.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/java/com/gitee/sop/servercommon/route/ServiceRouteInfo.java (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/resources/i18n/isp/error_en.properties (100%) rename {sop-service-common => sop-common/sop-service-common}/src/main/resources/i18n/isp/error_zh_CN.properties (100%) delete mode 100644 sop-gateway-common/pom.xml delete mode 100644 sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java delete mode 100644 sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/XmlUtil.java delete mode 100644 sop-service-common/pom.xml diff --git a/pom.xml b/pom.xml index b1179e21..5af1da5e 100644 --- a/pom.xml +++ b/pom.xml @@ -9,11 +9,10 @@ pom + sop-common sop-admin sop-registry sop-gateway - sop-gateway-common - sop-service-common sop-story sop-book sop-test diff --git a/sop-admin/sop-admin-front/pages/service/serviceList.js b/sop-admin/sop-admin-front/pages/service/serviceList.js index fe45c9ea..d2a09d78 100644 --- a/sop-admin/sop-admin-front/pages/service/serviceList.js +++ b/sop-admin/sop-admin-front/pages/service/serviceList.js @@ -23,13 +23,24 @@ lib.config({ page: false, cols: [[ {type: 'numbers'}, - {field: 'name', title: '服务名称', width: 200}, + {field: 'name', title: '服务名称(serviceId)', width: 200}, {field: 'instanceId', title: 'instanceId', width: 220}, {field: 'ipAddr', title: 'IP地址', width: 150}, {field: 'serverPort', title: '端口号', width: 100}, - {field: 'status', title: 'status', width: 100}, + {field: 'status', title: '服务状态', width: 100, templet: function (row) { + if (row.parentId > 0) { + var html = []; + if (row.status === 'UP') { + return '已上线' + } + if (row.status === 'OUT_OF_SERVICE') { + return '已下线' + } + } + return ''; + }}, {field: 'updateTime', title: '最后更新时间', width: 150}, - {fixed: 'right', title: '操作', width: 200, templet: function (row) { + {fixed: 'right', title: '操作', width: 150, templet: function (row) { if (row.parentId > 0) { var html = []; if (row.status === 'UP') { diff --git a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfoVo.java b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfoVo.java index e1065cd9..d94dd4bf 100644 --- a/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfoVo.java +++ b/sop-admin/sop-admin-server/src/main/java/com/gitee/sop/adminserver/api/service/result/ServiceInfoVo.java @@ -27,7 +27,7 @@ public class ServiceInfoVo { @ApiDocField(description = "端口") private String serverPort; - @ApiDocField(description = "status") + @ApiDocField(description = "status,服务状态,UP:已上线,OUT_OF_SERVICE:已下线") private String status; @ApiDocField(description = "statusPageUrl") diff --git a/sop-common/pom.xml b/sop-common/pom.xml new file mode 100644 index 00000000..a6547b24 --- /dev/null +++ b/sop-common/pom.xml @@ -0,0 +1,188 @@ + + + 4.0.0 + com.gitee.sop + sop-common + 1.0.0-SNAPSHOT + pom + + + 1.8 + UTF-8 + 1.8 + 1.8 + Greenwich.RELEASE + 2.1.2.RELEASE + + 1.0.13 + 1.7.5 + + + 4.11 + + 1.2.15 + 2.5 + 1.3.3 + 3.2.2 + 3.8.1 + 1.11 + 3.4.12 + + + + sop-gateway-common + sop-service-common + + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + org.springframework.cloud + spring-cloud-dependencies + ${spring-cloud.version} + pom + import + + + + + + + + org.springframework.cloud + spring-cloud-starter-zookeeper-all + + + + org.springframework.cloud + spring-cloud-starter-zookeeper-discovery + + + + org.apache.zookeeper + zookeeper + + + + + org.apache.zookeeper + zookeeper + ${zookeeper.version} + + + org.slf4j + slf4j-log4j12 + + + + + + com.alibaba + fastjson + ${fastjson.version} + + + + + org.apache.commons + commons-lang3 + ${commons-lang3.version} + + + commons-collections + commons-collections + ${commons-collection.version} + + + commons-io + commons-io + ${commons-io.version} + + + + + org.springframework.data + spring-data-redis + 2.1.4.RELEASE + true + + + + + org.projectlombok + lombok + 1.18.4 + provided + + + javax.servlet + javax.servlet-api + 3.1.0 + provided + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + + true + + + + org.apache.maven.plugins + maven-compiler-plugin + + ${java.version} + ${java.version} + UTF-8 + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + + jar-no-fork + + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + attach-javadocs + + jar + + + + -Xdoclint:none + + + + + + + + \ No newline at end of file diff --git a/sop-common/readme.md b/sop-common/readme.md new file mode 100644 index 00000000..1ab02597 --- /dev/null +++ b/sop-common/readme.md @@ -0,0 +1,5 @@ +# sop-common + +- 打包成jar:`mvn clean package` +- 上传到本机仓库:`mvn clean install` +- 上传到maven私服:`mvn clean deploy` \ No newline at end of file diff --git a/sop-gateway-common/.gitignore b/sop-common/sop-gateway-common/.gitignore similarity index 100% rename from sop-gateway-common/.gitignore rename to sop-common/sop-gateway-common/.gitignore diff --git a/sop-common/sop-gateway-common/pom.xml b/sop-common/sop-gateway-common/pom.xml new file mode 100644 index 00000000..9bf8d342 --- /dev/null +++ b/sop-common/sop-gateway-common/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + + com.gitee.sop + sop-common + 1.0.0-SNAPSHOT + ../pom.xml + + com.gitee.sop + sop-gateway-common + ${parent.version} + jar + + sop-gateway-common + sop-gateway-common + + + 1.8 + + + + + commons-fileupload + commons-fileupload + ${commons-fileupload.version} + + + commons-codec + commons-codec + ${commons-codec.version} + + + + org.springframework.cloud + spring-cloud-netflix-ribbon + compile + + + + + org.springframework.cloud + spring-cloud-starter-netflix-zuul + true + + + + org.springframework.cloud + spring-cloud-starter-gateway + true + + + org.springframework.boot + spring-boot-starter-webflux + true + + + + + + diff --git a/sop-gateway-common/readme.md b/sop-common/sop-gateway-common/readme.md similarity index 100% rename from sop-gateway-common/readme.md rename to sop-common/sop-gateway-common/readme.md diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/AbstractTargetRoute.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/AbstractTargetRoute.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/AbstractTargetRoute.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/AbstractTargetRoute.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java similarity index 98% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java index 28b451c1..649c2b1f 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiConfig.java @@ -90,7 +90,7 @@ public class ApiConfig { /** * 错误模块 */ - private List i18nModules = new ArrayList(); + private List i18nModules = new ArrayList<>(); // -------- fields --------- diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiContext.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiContext.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/ApiContext.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseRouteDefinition.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseRouteDefinition.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseRouteDefinition.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseRouteDefinition.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseServiceRouteInfo.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseServiceRouteInfo.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseServiceRouteInfo.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/BaseServiceRouteInfo.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/RouteStatus.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java similarity index 97% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java index 191804cc..1e75bb76 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/SopConstants.java @@ -7,6 +7,8 @@ import java.nio.charset.StandardCharsets; * @author tanghc */ public class SopConstants { + + private SopConstants() {} public static final Charset CHARSET_UTF8 = StandardCharsets.UTF_8; public static final String FORMAT_JSON = "json"; @@ -35,4 +37,5 @@ public class SopConstants { * zookeeper存放接口路由信息的根目录 */ public static final String SOP_SERVICE_ROUTE_PATH = "/com.gitee.sop.route"; + } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/bean/TargetRoute.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenResultExecutor.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java similarity index 87% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java index d77eb6cd..daf23ba9 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenSigner.java @@ -2,7 +2,6 @@ package com.gitee.sop.gatewaycommon.easyopen; import com.gitee.sop.gatewaycommon.param.ApiParam; import com.gitee.sop.gatewaycommon.validate.AbstractSigner; -import com.gitee.sop.gatewaycommon.validate.taobao.TaobaoSigner; import org.apache.commons.codec.digest.DigestUtils; import java.util.ArrayList; @@ -17,7 +16,7 @@ public class EasyopenSigner extends AbstractSigner { @Override protected String buildServerSign(ApiParam params, String secret) { Set keySet = params.keySet(); - List paramNames = new ArrayList(keySet); + List paramNames = new ArrayList<>(keySet); Collections.sort(paramNames); diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java similarity index 84% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java index cc8741eb..6475368c 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/easyopen/EasyopenZuulConfiguration.java @@ -2,9 +2,7 @@ package com.gitee.sop.gatewaycommon.easyopen; import com.gitee.sop.gatewaycommon.bean.ApiConfig; import com.gitee.sop.gatewaycommon.bean.ApiContext; -import com.gitee.sop.gatewaycommon.gateway.configuration.BaseGatewayConfiguration; import com.gitee.sop.gatewaycommon.param.ParamNames; -import com.gitee.sop.gatewaycommon.validate.taobao.TaobaoSigner; import com.gitee.sop.gatewaycommon.zuul.configuration.BaseZuulConfiguration; /** diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java similarity index 91% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java index ae6bb9ac..af0da78b 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/exception/ApiException.java @@ -8,7 +8,7 @@ import com.gitee.sop.gatewaycommon.message.Error; */ public class ApiException extends RuntimeException { - private Error error; + private transient final Error error; public ApiException(Throwable cause, Error error) { super(cause); diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/GatewayContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/GatewayContext.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/GatewayContext.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/GatewayContext.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/AlipayGatewayConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/AlipayGatewayConfiguration.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/AlipayGatewayConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/AlipayGatewayConfiguration.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/BaseGatewayConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/BaseGatewayConfiguration.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/BaseGatewayConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/BaseGatewayConfiguration.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/TaobaoGatewayConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/TaobaoGatewayConfiguration.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/TaobaoGatewayConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/configuration/TaobaoGatewayConfiguration.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/GatewayModifyResponseGatewayFilter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LoadBalancerClientExtFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LoadBalancerClientExtFilter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LoadBalancerClientExtFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/LoadBalancerClientExtFilter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/ValidateFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/ValidateFilter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/ValidateFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/filter/ValidateFilter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java similarity index 91% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java index ad959680..a1eec192 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/handler/GatewayExceptionHandler.java @@ -24,6 +24,7 @@ import java.util.List; /** * 统一异常处理 + * * @author thc */ public class GatewayExceptionHandler implements ErrorWebExceptionHandler { @@ -46,9 +47,10 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler { if (exchange.getResponse().isCommitted()) { return Mono.error(ex); } - exceptionHandlerResult.set(errorResult); ServerRequest newRequest = ServerRequest.create(exchange, this.messageReaders); - return RouterFunctions.route(RequestPredicates.all(), this::renderErrorResponse).route(newRequest) + return RouterFunctions.route(RequestPredicates.all(), (serverRequest) -> { + return this.renderErrorResponse(errorResult); + }).route(newRequest) .switchIfEmpty(Mono.error(ex)) .flatMap((handler) -> handler.handle(newRequest)) .flatMap((response) -> write(exchange, response)); @@ -70,11 +72,6 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler { */ private List viewResolvers = Collections.emptyList(); - /** - * 存储处理异常后的信息 - */ - private ThreadLocal exceptionHandlerResult = new ThreadLocal<>(); - /** * 参考AbstractErrorWebExceptionHandler * @@ -108,11 +105,10 @@ public class GatewayExceptionHandler implements ErrorWebExceptionHandler { /** * 参考DefaultErrorWebExceptionHandler * - * @param request + * @param result * @return */ - protected Mono renderErrorResponse(ServerRequest request) { - GatewayResult result = exceptionHandlerResult.get(); + protected Mono renderErrorResponse(GatewayResult result) { return ServerResponse .status(result.getHttpStatus()) .contentType(result.getContentType()) diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/param/GatewayParamBuilder.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/param/GatewayParamBuilder.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/param/GatewayParamBuilder.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/param/GatewayParamBuilder.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResult.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResult.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResult.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResult.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/result/GatewayResultExecutor.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayFilterDefinition.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayFilterDefinition.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayFilterDefinition.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayFilterDefinition.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayPredicateDefinition.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayPredicateDefinition.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayPredicateDefinition.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayPredicateDefinition.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteDefinition.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteDefinition.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteDefinition.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteDefinition.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayRouteRepository.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayServiceRouteInfo.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayServiceRouteInfo.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayServiceRouteInfo.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayServiceRouteInfo.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayTargetRoute.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayTargetRoute.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayTargetRoute.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayTargetRoute.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayZookeeperRouteManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayZookeeperRouteManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayZookeeperRouteManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/GatewayZookeeperRouteManager.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/NameVersionRoutePredicateFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/NameVersionRoutePredicateFactory.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/NameVersionRoutePredicateFactory.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/NameVersionRoutePredicateFactory.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java similarity index 87% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java index ca19347e..d53e1988 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/gateway/route/ReadBodyRoutePredicateFactory.java @@ -2,6 +2,8 @@ package com.gitee.sop.gatewaycommon.gateway.route; import org.springframework.cloud.gateway.handler.predicate.ReadBodyPredicateFactory; +import java.util.Objects; + /** * 获取form表单插件,使用方式: * @Bean @@ -17,9 +19,7 @@ public class ReadBodyRoutePredicateFactory extends ReadBodyPredicateFactory { public Config newConfig() { Config config = super.newConfig(); config.setInClass(String.class); - config.setPredicate(body -> { - return body != null; - }); + config.setPredicate(Objects::nonNull); return config; } } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/BaseRouteManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/BaseRouteManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/BaseRouteManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/BaseRouteManager.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteManager.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepository.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepository.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepository.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepository.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java similarity index 92% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java index 33d9446b..4b4d4df7 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/manager/RouteRepositoryContext.java @@ -6,6 +6,9 @@ import com.gitee.sop.gatewaycommon.bean.TargetRoute; * @author tanghc */ public class RouteRepositoryContext { + + private RouteRepositoryContext(){} + private static RouteRepository routeRepository; public static RouteRepository getRouteRepository() { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/Error.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/Error.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/Error.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/Error.java diff --git a/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java new file mode 100644 index 00000000..7a6986dd --- /dev/null +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java @@ -0,0 +1,118 @@ +package com.gitee.sop.gatewaycommon.message; + +/** + * 网关错误定义 + * @author tanghc + */ +public enum ErrorEnum { + /** 成功 */ + SUCCESS(Codes.CODE_SUCCESS, ""), + + /** 服务暂不可用 */ + ISP_UNKNOW_ERROR(Codes.CODE_UNKNOW, "isp.unknow-error"), + /** */ + AOP_UNKNOW_ERROR(Codes.CODE_UNKNOW, "aop.unknow-error"), + + /** 无效的访问令牌 */ + AOP_INVALID_AUTH_TOKEN(Codes.CODE_AUTH, "aop.invalid-auth-token"), + /** 访问令牌已过期 */ + AOP_AUTH_TOKEN_TIME_OUT(Codes.CODE_AUTH, "aop.auth-token-time-out"), + /** 无效的应用授权令牌 */ + AOP_INVALID_APP_AUTH_TOKEN(Codes.CODE_AUTH, "aop.invalid-app-auth-token"), + /** 商户未授权当前接口 */ + AOP_INVALID_APP_AUTH_TOKEN_NO_API(Codes.CODE_AUTH, "aop.invalid-app-auth-token-no-api"), + /** 应用授权令牌已过期 */ + AOP_APP_AUTH_TOKEN_TIME_OUT(Codes.CODE_AUTH, "aop.app-auth-token-time-out"), + /** 商户未签约任何产品 */ + AOP_NO_PRODUCT_REG_BY_PARTNER(Codes.CODE_AUTH, "aop.no-product-reg-by-partner"), + + /** 缺少方法名参数 */ + ISV_MISSING_METHOD(Codes.CODE_MISSING, "isv.missing-method"), + /** 缺少签名参数 */ + ISV_MISSING_SIGNATURE(Codes.CODE_MISSING, "isv.missing-signature"), + /** 缺少签名类型参数 */ + ISV_MISSING_SIGNATURE_TYPE(Codes.CODE_MISSING, "isv.missing-signature-type"), + /** 缺少签名配置 */ + ISV_MISSING_SIGNATURE_KEY(Codes.CODE_MISSING, "isv.missing-signature-key"), + /** 缺少appId参数 */ + ISV_MISSING_APP_ID(Codes.CODE_MISSING, "isv.missing-app-id"), + /** 缺少时间戳参数 */ + ISV_MISSING_TIMESTAMP(Codes.CODE_MISSING, "isv.missing-timestamp"), + /** 缺少版本参数 */ + ISV_MISSING_VERSION(Codes.CODE_MISSING, "isv.missing-version"), + /** 解密出错, 未指定加密算法 */ + ISV_DECRYPTION_ERROR_MISSING_ENCRYPT_TYPE(Codes.CODE_MISSING, "isv.decryption-error-missing-encrypt-type"), + + /** 参数无效 */ + ISV_INVALID_PARAMETER(Codes.CODE_INVALID, "isv.invalid-parameter"), + /** 文件上传失败 */ + ISV_UPLOAD_FAIL(Codes.CODE_INVALID, "isv.upload-fail"), + /** 文件扩展名无效 */ + ISV_INVALID_FILE_EXTENSION(Codes.CODE_INVALID, "isv.invalid-file-extension"), + /** 文件大小无效 */ + ISV_INVALID_FILE_SIZE(Codes.CODE_INVALID, "isv.invalid-file-size"), + /** 不存在的方法名 */ + ISV_INVALID_METHOD(Codes.CODE_INVALID, "isv.invalid-method"), + /** 无效的数据格式 */ + ISV_INVALID_FORMAT(Codes.CODE_INVALID, "isv.invalid-format"), + /** 无效的签名类型 */ + ISV_INVALID_SIGNATURE_TYPE(Codes.CODE_INVALID, "isv.invalid-signature-type"), + /** 无效签名 */ + ISV_INVALID_SIGNATURE(Codes.CODE_INVALID, "isv.invalid-signature"), + /** 无效的加密类型 */ + ISV_INVALID_ENCRYPT_TYPE(Codes.CODE_INVALID, "isv.invalid-encrypt-type"), + /** 解密异常 */ + ISV_INVALID_ENCRYPT(Codes.CODE_INVALID, "isv.invalid-encrypt"), + /** 无效的appId参数 */ + ISV_INVALID_APP_ID(Codes.CODE_INVALID, "isv.invalid-app-id"), + /** 非法的时间戳参数 */ + ISV_INVALID_TIMESTAMP(Codes.CODE_INVALID, "isv.invalid-timestamp"), + /** 字符集错误 */ + ISV_INVALID_CHARSET(Codes.CODE_INVALID, "isv.invalid-charset"), + /** 摘要错误 */ + ISV_INVALID_DIGEST(Codes.CODE_INVALID, "isv.invalid-digest"), + /** 解密出错,不支持的加密算法 */ + ISV_DECRYPTION_ERROR_NOT_VALID_ENCRYPT_TYPE(Codes.CODE_INVALID, "isv.decryption-error-not-valid-encrypt-type"), + /** 解密出错, 未配置加密密钥或加密密钥格式错误 */ + ISV_DECRYPTION_ERROR_NOT_VALID_ENCRYPT_KEY(Codes.CODE_INVALID, "isv.decryption-error-not-valid-encrypt-key"), + /** 解密出错,未知异常 */ + ISV_DECRYPTION_ERROR_UNKNOWN(Codes.CODE_INVALID, "isv.decryption-error-unknown"), + /** 验签出错, 未配置对应签名算法的公钥或者证书 */ + ISV_MISSING_SIGNATURE_CONFIG(Codes.CODE_INVALID, "isv.missing-signature-config"), + /** 本接口不支持第三方代理调用 */ + ISV_NOT_SUPPORT_APP_AUTH(Codes.CODE_INVALID, "isv.not-support-app-auth"), + /** 可疑的攻击请求 */ + ISV_SUSPECTED_ATTACK(Codes.CODE_INVALID, "isv.suspected-attack"), + /** 无效的content-type */ + ISV_INVALID_CONTENT_TYPE(Codes.CODE_INVALID, "isv.invalid-content-type"), + + /** 业务处理失败 */ + BIZ_ERROR(Codes.CODE_BIZ, ""), + + /** 请检查配置的账户是否有当前接口权限 */ + ISV_INSUFFICIENT_ISV_PERMISSIONS(Codes.CODE_ISV_PERM, "isv.insufficient-isv-permissions"), + /** 代理的商户没有当前接口权限 */ + ISV_INSUFFICIENT_USER_PERMISSIONS(Codes.CODE_ISV_PERM, "isv.insufficient-user-permissions"), + + ; + private ErrorMeta errorMeta; + + ErrorEnum(String code, String subCode) { + this.errorMeta = new ErrorMeta("open.error_", code, subCode); + } + + public ErrorMeta getErrorMeta() { + return errorMeta; + } + + private static class Codes { + public static final String CODE_SUCCESS = "10000"; + public static final String CODE_AUTH = "20001"; + public static final String CODE_MISSING = "40001"; + public static final String CODE_INVALID = "40002"; + public static final String CODE_BIZ = "40004"; + public static final String CODE_ISV_PERM = "40006"; + public static final String CODE_UNKNOW = "20000"; + } + +} diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java similarity index 93% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java index c6df7fbc..784ff58a 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorFactory.java @@ -22,12 +22,14 @@ import java.util.Set; @Slf4j public class ErrorFactory { + private ErrorFactory(){} + public static final String SYS_ERR = "系统错误"; private static final String I18N_OPEN_ERROR = "i18n/open/error"; public static final String UNDERLINE = "_"; - private static Set noModuleCache = new HashSet(); + private static Set noModuleCache = new HashSet<>(); private static Map errorCache = new HashMap<>(64); @@ -40,7 +42,7 @@ public class ErrorFactory { * 设置国际化资源信息 */ public static void initMessageSource(List isvModules) { - HashSet baseNamesSet = new HashSet(); + HashSet baseNamesSet = new HashSet<>(); baseNamesSet.add(I18N_OPEN_ERROR); if (!isvModules.isEmpty()) { @@ -84,7 +86,7 @@ public class ErrorFactory { } // solution暂未实现,如果要实现,可以这样配置: // open.error_20000_isp.unknow-error_solution=Service is temporarily unavailable - // String solution = getErrorMessage(modulePrefix + code + UNDERLINE + subCode + "_solution", locale, params); + // String solution = getErrorMessage(modulePrefix + code + UNDERLINE + subCode + "_solution", locale, params); error = new ErrorImpl(code, msg, subCode, subMsg, null); errorCache.put(key, error); } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorImpl.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java similarity index 94% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java index 70070830..c5ad6f41 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorMeta.java @@ -1,10 +1,8 @@ package com.gitee.sop.gatewaycommon.message; -import com.gitee.sop.gatewaycommon.bean.ApiContext; import com.gitee.sop.gatewaycommon.exception.ApiException; import com.netflix.zuul.context.RequestContext; import lombok.Getter; -import sun.plugin.cache.CacheUpdateHelper; import javax.servlet.http.HttpServletRequest; import java.util.Locale; diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java similarity index 89% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java index 268312e8..c91564f6 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParam.java @@ -2,11 +2,8 @@ package com.gitee.sop.gatewaycommon.param; import com.alibaba.fastjson.JSONObject; import com.gitee.sop.gatewaycommon.bean.SopConstants; -//import com.netflix.zuul.context.RequestContext; -//import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringUtils; -import javax.servlet.http.HttpServletRequest; import java.util.Map; /** @@ -29,6 +26,8 @@ public class ApiParam extends JSONObject implements Param { private String restName; private String restVersion; + private transient ApiUploadContext apiUploadContext; + /** * 获取sign,并从param中删除 * @@ -40,11 +39,6 @@ public class ApiParam extends JSONObject implements Param { return sign; } - public HttpServletRequest fetchRequest() { -// return RequestContext.getCurrentContext().getRequest(); - return null; - } - /** * 是否忽略验证签名 * @@ -191,13 +185,21 @@ public class ApiParam extends JSONObject implements Param { return getString(ParamNames.CHARSET_NAME); } - @Override - public ApiParam clone() { - ApiParam param = new ApiParam(this); - param.ignoreSign = this.ignoreSign; - param.ignoreValidate = this.ignoreValidate; - return param; + public void setApiUploadContext(ApiUploadContext apiUploadContext) { + this.apiUploadContext = apiUploadContext; + } + + public ApiUploadContext fetchApiUploadContext() { + return apiUploadContext; } + @Override + public boolean equals(Object obj) { + return super.equals(obj); + } + @Override + public int hashCode() { + return super.hashCode(); + } } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java similarity index 97% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java index 038d9fdb..c82e4b66 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiParamFactory.java @@ -15,6 +15,9 @@ import java.util.Map; */ @Slf4j public class ApiParamFactory { + + private ApiParamFactory(){} + public static ApiParam build(Map params) { ApiParam apiParam = new ApiParam(); for (Map.Entry entry : params.entrySet()) { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiUploadContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiUploadContext.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiUploadContext.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ApiUploadContext.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/Param.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/Param.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/Param.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/Param.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamBuilder.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamBuilder.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamBuilder.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamBuilder.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamNames.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamNames.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamNames.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/ParamNames.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/UploadContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/UploadContext.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/UploadContext.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/param/UploadContext.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java similarity index 94% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java index 9247cc76..bcc5b08f 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ApiResult.java @@ -1,7 +1,6 @@ package com.gitee.sop.gatewaycommon.result; import com.gitee.sop.gatewaycommon.message.ErrorEnum; -import com.thoughtworks.xstream.annotations.XStreamAlias; import lombok.Data; /** @@ -49,7 +48,6 @@ import lombok.Data; * * @author tanghc */ -@XStreamAlias("response") @Data public class ApiResult implements Result { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/BaseExecutorAdapter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/Result.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/Result.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/Result.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/Result.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java similarity index 94% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java index f7a264df..d20ff5ea 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/result/ResultExecutor.java @@ -1,7 +1,5 @@ package com.gitee.sop.gatewaycommon.result; -import com.gitee.sop.gatewaycommon.gateway.result.GatewayResult; - /** * 对返回结果进行处理 * 成功示例 diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/AppSecretManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/AppSecretManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/AppSecretManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/AppSecretManager.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java similarity index 90% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java index 59060361..8d0e89d4 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/CacheAppSecretManager.java @@ -10,7 +10,7 @@ import java.util.Map; */ public class CacheAppSecretManager implements AppSecretManager { - private Map secretMap = new HashMap(64); + private Map secretMap = new HashMap<>(64); @Override public void addAppSecret(Map appSecretStore) { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java similarity index 92% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java index bfbc46ff..ca1a9b85 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/secret/FileAppSecretManager.java @@ -34,7 +34,7 @@ public class FileAppSecretManager implements AppSecretManager { Resource resource = resourceLoader.getResource(appSecretFile); properties = PropertiesLoaderUtils.loadProperties(resource); } catch (IOException e) { - throw new RuntimeException("在类路径下找不到appSecret.properties的应用密钥的属性文件"); + throw new IllegalArgumentException("在类路径下找不到appSecret.properties的应用密钥的属性文件"); } } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java similarity index 86% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java index 8dfe97a4..d235f572 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiHttpSession.java @@ -22,6 +22,7 @@ import java.util.Vector; @SuppressWarnings("deprecation") public class ApiHttpSession implements HttpSession, Serializable { private static final long serialVersionUID = 946272038219216222L; + private static final String ATTRIBUTE_NAME_MUST_NOT_BE_NULL = "Attribute name must not be null"; private final String id; @@ -31,9 +32,9 @@ public class ApiHttpSession implements HttpSession, Serializable { private long lastAccessedTime = System.currentTimeMillis(); - private final ServletContext servletContext; + private final transient ServletContext servletContext; - private final Map attributes = new LinkedHashMap(); + private final transient Map attributes = new LinkedHashMap<>(); private boolean invalid = false; @@ -48,9 +49,8 @@ public class ApiHttpSession implements HttpSession, Serializable { /** * Create a new ApiHttpSession. - * - * @param servletContext - * the ServletContext that the session runs in + * + * @param servletContext the ServletContext that the session runs in */ public ApiHttpSession(ServletContext servletContext) { this(servletContext, null); @@ -58,11 +58,9 @@ public class ApiHttpSession implements HttpSession, Serializable { /** * Create a new ApiHttpSession. - * - * @param servletContext - * the ServletContext that the session runs in - * @param id - * a unique identifier for this session + * + * @param servletContext the ServletContext that the session runs in + * @param id a unique identifier for this session */ public ApiHttpSession(ServletContext servletContext, String id) { this.servletContext = servletContext; @@ -108,14 +106,19 @@ public class ApiHttpSession implements HttpSession, Serializable { return this.maxInactiveInterval; } + /** + * @return + * @deprecated 已废弃不能使用 + */ @Override + @Deprecated public HttpSessionContext getSessionContext() { throw new UnsupportedOperationException("getSessionContext"); } @Override public Object getAttribute(String name) { - Assert.notNull(name, "Attribute name must not be null"); + Assert.notNull(name, ATTRIBUTE_NAME_MUST_NOT_BE_NULL); return this.attributes.get(name); } @@ -136,7 +139,7 @@ public class ApiHttpSession implements HttpSession, Serializable { @Override public void setAttribute(String name, Object value) { - Assert.notNull(name, "Attribute name must not be null"); + Assert.notNull(name, ATTRIBUTE_NAME_MUST_NOT_BE_NULL); if (value != null) { this.attributes.put(name, value); if (value instanceof HttpSessionBindingListener) { @@ -154,7 +157,7 @@ public class ApiHttpSession implements HttpSession, Serializable { @Override public void removeAttribute(String name) { - Assert.notNull(name, "Attribute name must not be null"); + Assert.notNull(name, ATTRIBUTE_NAME_MUST_NOT_BE_NULL); Object value = this.attributes.remove(name); if (value instanceof HttpSessionBindingListener) { ((HttpSessionBindingListener) value).valueUnbound(new HttpSessionBindingEvent(this, name, value)); @@ -170,7 +173,7 @@ public class ApiHttpSession implements HttpSession, Serializable { * Clear all of this session's attributes. */ public void clearAttributes() { - for (Iterator> it = this.attributes.entrySet().iterator(); it.hasNext();) { + for (Iterator> it = this.attributes.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = it.next(); String name = entry.getKey(); Object value = entry.getValue(); @@ -203,12 +206,12 @@ public class ApiHttpSession implements HttpSession, Serializable { /** * Serialize the attributes of this session into an object that can be * turned into a byte array with standard Java serialization. - * + * * @return a representation of this session's serialized state */ public Serializable serializeState() { - HashMap state = new HashMap(16); - for (Iterator> it = this.attributes.entrySet().iterator(); it.hasNext();) { + HashMap state = new HashMap<>(16); + for (Iterator> it = this.attributes.entrySet().iterator(); it.hasNext(); ) { Map.Entry entry = it.next(); String name = entry.getKey(); Object value = entry.getValue(); @@ -229,9 +232,8 @@ public class ApiHttpSession implements HttpSession, Serializable { /** * Deserialize the attributes of this session from a state object created by * {@link #serializeState()}. - * - * @param state - * a representation of this session's serialized state + * + * @param state a representation of this session's serialized state */ @SuppressWarnings("unchecked") public void deserializeState(Serializable state) { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiRedisTemplate.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiRedisTemplate.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiRedisTemplate.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiRedisTemplate.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java similarity index 97% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java index 465b4bbb..5791ef38 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/ApiSessionManager.java @@ -33,8 +33,7 @@ public class ApiSessionManager implements SessionManager { return this.createSession(sessionId); } try { - HttpSession session = cache.get(sessionId); - return session; + return cache.get(sessionId); } catch (Exception e) { logger.error(e.getMessage(), e); throw ErrorEnum.AOP_UNKNOW_ERROR.getErrorMeta().getException(); diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java similarity index 97% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java index ac23f5fe..fab86419 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisHttpSession.java @@ -40,9 +40,9 @@ public class RedisHttpSession implements HttpSession, Serializable { */ private String id; - private ServletContext servletContext; + private transient ServletContext servletContext; - private RedisTemplate redisTemplate; + private transient RedisTemplate redisTemplate; private RedisHttpSession() { } @@ -160,7 +160,12 @@ public class RedisHttpSession implements HttpSession, Serializable { return Integer.valueOf(String.valueOf(maxInactiveInterval)); } + /** + * @deprecated 已废弃,始终返回null + * @return + */ @Override + @Deprecated public HttpSessionContext getSessionContext() { return null; } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisSessionManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisSessionManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisSessionManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/RedisSessionManager.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/SessionManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/SessionManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/SessionManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/session/SessionManager.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/AESUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/AESUtil.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/AESUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/AESUtil.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/KeyStore.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/KeyStore.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/KeyStore.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/KeyStore.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSANewUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSANewUtil.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSANewUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSANewUtil.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSAUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSAUtil.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSAUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RSAUtil.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java similarity index 99% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java index 2221badc..6b3e9ad5 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RedisLockUtil.java @@ -44,6 +44,8 @@ end */ public class RedisLockUtil { + private RedisLockUtil(){} + private static final Long SUCCESS = 1L; /** 加锁脚本 */ diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java similarity index 92% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java index e203da08..2670b487 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RequestUtil.java @@ -4,6 +4,7 @@ import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.StringUtils; import javax.servlet.http.HttpServletRequest; +import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.URLDecoder; import java.util.Collections; @@ -17,6 +18,8 @@ import java.util.Set; */ public class RequestUtil { + private RequestUtil(){} + private static final String UTF8 = "UTF-8"; /** @@ -37,7 +40,7 @@ public class RequestUtil { try { params.put(paramArr[0], URLDecoder.decode(paramArr[1], UTF8)); } catch (UnsupportedEncodingException e) { - e.printStackTrace(); + throw new RuntimeException(e); } } else if (paramArr.length == 1) { params.put(paramArr[0], ""); @@ -57,7 +60,7 @@ public class RequestUtil { if(paramMap == null || paramMap.isEmpty()) { return Collections.emptyMap(); } - Map retMap = new HashMap(paramMap.size()); + Map retMap = new HashMap<>(paramMap.size()); Set> entrySet = paramMap.entrySet(); @@ -76,7 +79,7 @@ public class RequestUtil { return retMap; } - public static String getText(HttpServletRequest request) throws Exception { + public static String getText(HttpServletRequest request) throws IOException { return IOUtils.toString(request.getInputStream(), UTF8); } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java similarity index 88% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java index 5169243a..085c4a48 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/ResponseUtil.java @@ -20,6 +20,8 @@ import java.util.Set; * @author tanghc */ public class ResponseUtil { + private ResponseUtil(){} + public static final String UTF_8 = "UTF-8"; private static Logger log = LoggerFactory.getLogger(ResponseUtil.class); @@ -46,7 +48,7 @@ public class ResponseUtil { } private static String doMap2xml(JSONObject parameters) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); Set es = parameters.entrySet(); Iterator it = es.iterator(); while (it.hasNext()) { @@ -73,7 +75,7 @@ public class ResponseUtil { } private static String buildItems(String key, JSONArray collection) { - StringBuffer sb = new StringBuffer(); + StringBuilder sb = new StringBuilder(); for (int i = 0; i < collection.size(); i++) { Object jsonObject = collection.get(i); sb.append("<").append(key).append(">"); @@ -87,19 +89,6 @@ public class ResponseUtil { return sb.toString(); } - public static void main(String[] args) { - Persion persion = new Persion(); - persion.setId(1); - persion.setName("aaa"); - - String jsonString = JSON.toJSONString(persion); - JSONObject jsonObject = JSON.parseObject(jsonString); - - String xml = mapToXml(jsonObject); - System.out.println(xml); - - } - @Data public static class Persion { int id; diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java similarity index 96% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java index ebe5d393..bc003390 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/RouteUtil.java @@ -5,6 +5,8 @@ package com.gitee.sop.gatewaycommon.util; */ public class RouteUtil { + private RouteUtil(){} + public static final String REGEX = "\\#"; public static final String PROTOCOL_LOAD_BALANCE = "lb://"; diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/AbstractSigner.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/AbstractSigner.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/AbstractSigner.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/AbstractSigner.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiEncrypter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiEncrypter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiEncrypter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiEncrypter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java similarity index 96% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java index 183fc5af..cdb57c28 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiSigner.java @@ -36,7 +36,7 @@ public class ApiSigner extends AbstractSigner { // 第一步:参数排序 Set keySet = param.keySet(); - List paramNames = new ArrayList(keySet); + List paramNames = new ArrayList<>(keySet); Collections.sort(paramNames); // 第二步:把所有参数名和参数值串在一起 diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java similarity index 76% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java index 37d60c10..b898ea78 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/ApiValidator.java @@ -7,6 +7,7 @@ import com.gitee.sop.gatewaycommon.param.ApiParam; import com.gitee.sop.gatewaycommon.param.ParamNames; import com.gitee.sop.gatewaycommon.param.UploadContext; import com.gitee.sop.gatewaycommon.secret.AppSecretManager; +import com.gitee.sop.gatewaycommon.zuul.ZuulContext; import org.apache.commons.codec.digest.DigestUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -39,17 +40,21 @@ public class ApiValidator implements Validator { public void validate(ApiParam param) { ApiConfig apiConfig = ApiContext.getApiConfig(); if (apiConfig.isIgnoreValidate() || param.fetchIgnoreValidate()) { - logger.debug("忽略所有验证(ignoreValidate=true), name:{}, version:{}", param.fetchName(), param.fetchVersion()); + if (logger.isDebugEnabled()) { + logger.debug("忽略所有验证(ignoreValidate=true), name:{}, version:{}", param.fetchName(), param.fetchVersion()); + } return; } if (param.fetchIgnoreSign()) { - logger.debug("忽略签名验证, name:{}, version:{}", param.fetchName(), param.fetchVersion()); + if (logger.isDebugEnabled()) { + logger.debug("忽略签名验证, name:{}, version:{}", param.fetchName(), param.fetchVersion()); + } } else { // 需要验证签名 checkAppKey(param); checkSign(param); } -// checkUploadFile(param); + checkUploadFile(param); checkTimeout(param); checkFormat(param); } @@ -59,28 +64,28 @@ public class ApiValidator implements Validator { * * @param param */ -// protected void checkUploadFile(ApiParam param) { -// UploadContext uploadContext = ApiContext.getUploadContext(); -// if (uploadContext != null) { -// try { -// List files = uploadContext.getAllFile(); -// for (MultipartFile file : files) { -// // 客户端传来的文件md5 -// String clientMd5 = param.getString(file.getName()); -// if (clientMd5 != null) { -// String fileMd5 = DigestUtils.md5Hex(file.getBytes()); -// if (!clientMd5.equals(fileMd5)) { -// throw ErrorEnum.ISV_UPLOAD_FAIL.getErrorMeta().getException(); -// } -// } -// } -// } catch (IOException e) { -// logger.error("验证上传文件MD5错误", e); -// throw ErrorEnum.ISV_UPLOAD_FAIL.getErrorMeta().getException(); -// } -// } -// -// } + protected void checkUploadFile(ApiParam param) { + UploadContext uploadContext = param.fetchApiUploadContext(); + if (uploadContext != null) { + try { + List files = uploadContext.getAllFile(); + for (MultipartFile file : files) { + // 客户端传来的文件md5 + String clientMd5 = param.getString(file.getName()); + if (clientMd5 != null) { + String fileMd5 = DigestUtils.md5Hex(file.getBytes()); + if (!clientMd5.equals(fileMd5)) { + throw ErrorEnum.ISV_UPLOAD_FAIL.getErrorMeta().getException(); + } + } + } + } catch (IOException e) { + logger.error("验证上传文件MD5错误", e); + throw ErrorEnum.ISV_UPLOAD_FAIL.getErrorMeta().getException(); + } + } + + } protected void checkTimeout(ApiParam param) { int timeoutSeconds = ApiContext.getApiConfig().getTimeoutSeconds(); diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Encrypter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Encrypter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Encrypter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Encrypter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipher.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipher.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipher.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipher.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherHMAC_MD5.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherHMAC_MD5.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherHMAC_MD5.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherHMAC_MD5.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherMD5.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherMD5.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherMD5.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/SignEncipherMD5.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Signer.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Signer.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Signer.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Signer.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Validator.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Validator.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Validator.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/Validator.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipayConstants.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipayConstants.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipayConstants.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipayConstants.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySignature.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySignature.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySignature.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySignature.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java similarity index 91% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java index 4cdf38f2..21fddabb 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/AlipaySigner.java @@ -1,12 +1,9 @@ package com.gitee.sop.gatewaycommon.validate.alipay; -import com.gitee.sop.gatewaycommon.bean.ApiContext; import com.gitee.sop.gatewaycommon.message.ErrorEnum; import com.gitee.sop.gatewaycommon.param.ApiParam; import com.gitee.sop.gatewaycommon.validate.Signer; -import javax.servlet.http.HttpServletRequest; - /** * 支付宝签名验证实现。 * diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java similarity index 99% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java index e9635b2c..e7eeb84a 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StreamUtil.java @@ -17,6 +17,8 @@ import java.io.Writer; * @author runzhi */ public class StreamUtil { + private StreamUtil(){} + private static final int DEFAULT_BUFFER_SIZE = 8192; public static void io(InputStream in, OutputStream out) throws IOException { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java similarity index 96% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java index 38a97fd9..dd04341b 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/alipay/StringUtils.java @@ -6,7 +6,7 @@ package com.gitee.sop.gatewaycommon.validate.alipay; * @author carver.gu * @since 1.0, Sep 12, 2009 */ -public abstract class StringUtils { +public class StringUtils { private StringUtils() {} @@ -155,7 +155,7 @@ public abstract class StringUtils { } } - private static String padding(int repeat, char padChar) throws IndexOutOfBoundsException { + private static String padding(int repeat, char padChar) { if (repeat < 0) { throw new IndexOutOfBoundsException("Cannot pad a negative amount: " + repeat); } else { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java similarity index 97% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java index d22ac812..00b33884 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/validate/taobao/TaobaoSigner.java @@ -41,7 +41,7 @@ public class TaobaoSigner extends AbstractSigner { // 第一步:参数排序 Set keySet = param.keySet(); - List paramNames = new ArrayList(keySet); + List paramNames = new ArrayList<>(keySet); Collections.sort(paramNames); // 第二步:把所有参数名和参数值串在一起 diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java similarity index 83% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java index 6bbe6aff..3c40c836 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/ZuulContext.java @@ -2,11 +2,8 @@ package com.gitee.sop.gatewaycommon.zuul; import com.gitee.sop.gatewaycommon.bean.ApiConfig; import com.gitee.sop.gatewaycommon.bean.ApiContext; -import com.gitee.sop.gatewaycommon.bean.SopConstants; -import com.gitee.sop.gatewaycommon.param.UploadContext; -import com.netflix.zuul.context.RequestContext; import com.gitee.sop.gatewaycommon.param.ApiParam; -import com.gitee.sop.gatewaycommon.session.SessionManager; +import com.netflix.zuul.context.RequestContext; import javax.servlet.ServletContext; import javax.servlet.http.HttpServletRequest; @@ -21,7 +18,6 @@ import java.util.Locale; public class ZuulContext extends ApiContext { private static final String ATTR_PARAM = "zuul.common.api.param"; - private static final String ATTR_UPLOAD_CONTEXT = "zuul.common.api.upload_context"; private static void setAttr(String name, Object val) { HttpServletRequest request = getRequest(); @@ -39,7 +35,6 @@ public class ZuulContext extends ApiContext { } - /** * 获取HttpServletRequest * @@ -64,10 +59,10 @@ public class ZuulContext extends ApiContext { } - /** * 同getSessionId() - * @return 返回accessToken,没有返回null + * + * @return 返回accessToken, 没有返回null */ public static String getAccessToken() { return getSessionId(); @@ -145,20 +140,9 @@ public class ZuulContext extends ApiContext { return ctx; } - /** - * 获取上传文件,如果客户端有文件上传,从这里取。 - * @return 如果没有文件上传,返回null - */ - public static UploadContext getUploadContext() { - return (UploadContext) getAttr(ATTR_UPLOAD_CONTEXT); - } - - public static void setUploadContext(UploadContext uploadCtx) { - setAttr(ATTR_UPLOAD_CONTEXT, uploadCtx); - } - /** * 获取response + * * @return 返回response */ public static HttpServletResponse getResponse() { diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/AlipayZuulConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/AlipayZuulConfiguration.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/AlipayZuulConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/AlipayZuulConfiguration.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java similarity index 95% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java index 5189660e..2e53cd4c 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/BaseZuulConfiguration.java @@ -1,9 +1,7 @@ package com.gitee.sop.gatewaycommon.zuul.configuration; import com.gitee.sop.gatewaycommon.bean.ApiContext; -import com.gitee.sop.gatewaycommon.bean.TargetRoute; import com.gitee.sop.gatewaycommon.manager.RouteManager; -import com.gitee.sop.gatewaycommon.manager.RouteRepository; import com.gitee.sop.gatewaycommon.manager.RouteRepositoryContext; import com.gitee.sop.gatewaycommon.message.ErrorFactory; import com.gitee.sop.gatewaycommon.zuul.filter.ErrorFilter; @@ -11,7 +9,6 @@ import com.gitee.sop.gatewaycommon.zuul.filter.PostResultFilter; import com.gitee.sop.gatewaycommon.zuul.filter.PreValidateFilter; import com.gitee.sop.gatewaycommon.zuul.route.SopRouteLocator; import com.gitee.sop.gatewaycommon.zuul.route.ZuulRouteRepository; -import com.gitee.sop.gatewaycommon.zuul.route.ZuulTargetRoute; import com.gitee.sop.gatewaycommon.zuul.route.ZuulZookeeperRouteManager; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.web.ServerProperties; diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/TaobaoZuulConfiguration.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/TaobaoZuulConfiguration.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/TaobaoZuulConfiguration.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/TaobaoZuulConfiguration.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/ZuulErrorController.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/ZuulErrorController.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/ZuulErrorController.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/configuration/ZuulErrorController.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java similarity index 96% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java index 28ce09b1..9cfec839 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/BaseZuulFilter.java @@ -81,10 +81,6 @@ public abstract class BaseZuulFilter extends ZuulFilter { requestContext.setResponseBody(JSON.toJSONString(result)); } - public static void main(String[] args) { - System.out.println(JSON.toJSONString(new ApiResult())); - } - /** * to classify a filter by type. Standard types in Zuul are "pre" for pre-routing filtering, * "routeDefinition" for routing to an origin, "post" for post-routing filters, "error" for error handling. diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/ErrorFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/ErrorFilter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/ErrorFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/ErrorFilter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PostResultFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PostResultFilter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PostResultFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PostResultFilter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreValidateFilter.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreValidateFilter.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreValidateFilter.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/filter/PreValidateFilter.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java similarity index 59% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java index a4e1556a..2cff83b6 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/param/ZuulParamBuilder.java @@ -2,13 +2,11 @@ package com.gitee.sop.gatewaycommon.zuul.param; import com.alibaba.fastjson.JSON; import com.gitee.sop.gatewaycommon.bean.SopConstants; -import com.gitee.sop.gatewaycommon.message.ErrorEnum; import com.gitee.sop.gatewaycommon.param.ApiParam; import com.gitee.sop.gatewaycommon.param.ApiParamFactory; import com.gitee.sop.gatewaycommon.param.ApiUploadContext; import com.gitee.sop.gatewaycommon.param.ParamBuilder; import com.gitee.sop.gatewaycommon.util.RequestUtil; -import com.gitee.sop.gatewaycommon.zuul.ZuulContext; import com.netflix.zuul.context.RequestContext; import com.netflix.zuul.http.HttpServletRequestWrapper; import lombok.extern.slf4j.Slf4j; @@ -38,31 +36,34 @@ public class ZuulParamBuilder implements ParamBuilder { @Override public ApiParam build(RequestContext ctx) { HttpServletRequest request = ctx.getRequest(); - Map params = this.getParams(request); - return ApiParamFactory.build(params); - } - - public Map getParams(HttpServletRequest request) { // zuul会做一层包装 if (request instanceof HttpServletRequestWrapper) { HttpServletRequestWrapper req = (HttpServletRequestWrapper) request; request = req.getRequest(); } + Map params = this.getParams(request); + ApiParam apiParams = ApiParamFactory.build(params); + ApiUploadContext apiUploadContext = this.buildApiUploadContext(request); + apiParams.setApiUploadContext(apiUploadContext); + return apiParams; + } + + public Map getParams(HttpServletRequest request) { Map params = null; if (GET.equalsIgnoreCase(request.getMethod())) { params = RequestUtil.convertRequestParamsToMap(request); } else { - String contectType = request.getContentType(); + String contentType = request.getContentType(); - if (contectType == null) { - contectType = ""; + if (contentType == null) { + contentType = ""; } - contectType = contectType.toLowerCase(); + contentType = contentType.toLowerCase(); // json或者纯文本形式 - if (contectType.contains(CONTENT_TYPE_JSON) || contectType.contains(CONTENT_TYPE_TEXT)) { + if (contentType.contains(CONTENT_TYPE_JSON) || contentType.contains(CONTENT_TYPE_TEXT)) { String txt = SopConstants.EMPTY_JSON; try { txt = RequestUtil.getText(request); @@ -70,9 +71,6 @@ public class ZuulParamBuilder implements ParamBuilder { log.error("获取纯文本内容失败", e); } params = JSON.parseObject(txt); - } else if (contectType.contains(CONTENT_TYPE_MULTIPART)) { - // 上传文件形式 - params = this.parseUploadRequest(request); } else { params = RequestUtil.convertRequestParamsToMap(request); } @@ -81,36 +79,32 @@ public class ZuulParamBuilder implements ParamBuilder { return params; } - /** - * 解析文件上传请求 - * - * @param request - * @return 返回json字符串 - */ - protected Map parseUploadRequest(HttpServletRequest request) { - CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver( - request.getSession().getServletContext()); - // 检查form中是否有enctype="multipart/form-data" - if (multipartResolver.isMultipart(request)) { - MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request; - Map fileMap = multiRequest.getFileMap(); - Map finalMap = new HashMap<>(fileMap.size()); - - Set keys = fileMap.keySet(); - for (String name : keys) { - MultipartFile file = fileMap.get(name); - if (file.getSize() > 0) { - finalMap.put(name, file); + protected ApiUploadContext buildApiUploadContext(HttpServletRequest request) { + ApiUploadContext apiUploadContext = null; + String contectType = request.getContentType(); + if (contectType.contains(CONTENT_TYPE_MULTIPART)) { + CommonsMultipartResolver multipartResolver = new CommonsMultipartResolver( + request.getSession().getServletContext()); + // 检查form中是否有enctype="multipart/form-data" + if (multipartResolver.isMultipart(request)) { + MultipartHttpServletRequest multiRequest = (MultipartHttpServletRequest) request; + Map fileMap = multiRequest.getFileMap(); + Map finalMap = new HashMap<>(fileMap.size()); + + Set keys = fileMap.keySet(); + for (String name : keys) { + MultipartFile file = fileMap.get(name); + if (file.getSize() > 0) { + finalMap.put(name, file); + } + } + if (finalMap.size() > 0) { + // 保存上传文件 + apiUploadContext = new ApiUploadContext(finalMap); } - } - if (finalMap.size() > 0) { - // 保存上传文件 - ZuulContext.setUploadContext(new ApiUploadContext(finalMap)); } } - - return RequestUtil.convertRequestParamsToMap(request); + return apiUploadContext; } - } diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/result/ZuulResultExecutor.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/SopRouteLocator.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/SopRouteLocator.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/SopRouteLocator.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/SopRouteLocator.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteDefinition.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteDefinition.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteDefinition.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteDefinition.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulRouteRepository.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java similarity index 70% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java index c877a055..792767c3 100644 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java +++ b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulServiceRouteInfo.java @@ -1,8 +1,6 @@ package com.gitee.sop.gatewaycommon.zuul.route; import com.gitee.sop.gatewaycommon.bean.BaseServiceRouteInfo; -import com.gitee.sop.gatewaycommon.gateway.route.GatewayRouteDefinition; -import lombok.Data; /** * @author thc diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulTargetRoute.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulTargetRoute.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulTargetRoute.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulTargetRoute.java diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulZookeeperRouteManager.java b/sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulZookeeperRouteManager.java similarity index 100% rename from sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulZookeeperRouteManager.java rename to sop-common/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/zuul/route/ZuulZookeeperRouteManager.java diff --git a/sop-gateway-common/src/main/resources/i18n/open/error_en.properties b/sop-common/sop-gateway-common/src/main/resources/i18n/open/error_en.properties similarity index 100% rename from sop-gateway-common/src/main/resources/i18n/open/error_en.properties rename to sop-common/sop-gateway-common/src/main/resources/i18n/open/error_en.properties diff --git a/sop-gateway-common/src/main/resources/i18n/open/error_zh_CN.properties b/sop-common/sop-gateway-common/src/main/resources/i18n/open/error_zh_CN.properties similarity index 100% rename from sop-gateway-common/src/main/resources/i18n/open/error_zh_CN.properties rename to sop-common/sop-gateway-common/src/main/resources/i18n/open/error_zh_CN.properties diff --git a/sop-service-common/.gitignore b/sop-common/sop-service-common/.gitignore similarity index 100% rename from sop-service-common/.gitignore rename to sop-common/sop-service-common/.gitignore diff --git a/sop-common/sop-service-common/pom.xml b/sop-common/sop-service-common/pom.xml new file mode 100644 index 00000000..c9ed1955 --- /dev/null +++ b/sop-common/sop-service-common/pom.xml @@ -0,0 +1,40 @@ + + + + 4.0.0 + + com.gitee.sop + sop-common + 1.0.0-SNAPSHOT + ../pom.xml + + com.gitee.sop + sop-service-common + ${parent.version} + jar + + sop-service-common + sop-service-common + + + 1.8 + + + + + org.springframework + spring-webmvc + 5.1.4.RELEASE + true + + + net.oschina.durcframework + easyopen + 1.16.0 + true + + + + + diff --git a/sop-service-common/readme.md b/sop-common/sop-service-common/readme.md similarity index 100% rename from sop-service-common/readme.md rename to sop-common/sop-service-common/readme.md diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiAbility.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiAbility.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiAbility.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiAbility.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiMapping.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiMapping.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiMapping.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/annotation/ApiMapping.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ParamNames.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ParamNames.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ParamNames.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ParamNames.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceApiInfo.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceApiInfo.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceApiInfo.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceApiInfo.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java similarity index 96% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java index 83f7f6be..1d34b39a 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceConfig.java @@ -33,7 +33,7 @@ public class ServiceConfig { /** * 错误模块 */ - private List i18nModules = new ArrayList(); + private List i18nModules = new ArrayList<>(); /** * 解析业务参数 diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceContext.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceContext.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceContext.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/bean/ServiceContext.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/AlipayServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/AlipayServiceConfiguration.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/AlipayServiceConfiguration.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/AlipayServiceConfiguration.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java similarity index 98% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java index 72ce4e96..1cbddcab 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/BaseServiceConfiguration.java @@ -38,7 +38,7 @@ public class BaseServiceConfiguration extends WebMvcConfigurationSupport { /** * 自定义Mapping,详见@ApiMapping - * @return + * @return 返回RequestMappingHandlerMapping */ @Override protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java similarity index 92% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java index 17e6edf8..0f4a9249 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/DefaultGlobalExceptionHandler.java @@ -29,13 +29,13 @@ public class DefaultGlobalExceptionHandler implements GlobalExceptionHandler { @ExceptionHandler(ServiceException.class) @ResponseBody - public Object serviceExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) throws Exception { + public Object serviceExceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) { return this.processError(request, response, exception); } @ExceptionHandler(Exception.class) @ResponseBody - public Object exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) throws Exception { + public Object exceptionHandler(HttpServletRequest request, HttpServletResponse response, Exception exception) { log.error("系统错误", exception); return this.processError(request, response, new RuntimeException("系统错误")); } @@ -46,7 +46,7 @@ public class DefaultGlobalExceptionHandler implements GlobalExceptionHandler { * @param request * @param response * @param exception - * @return + * @return 返回最终结果 */ protected Object processError(HttpServletRequest request, HttpServletResponse response, Exception exception) { ServiceResultBuilder serviceResultBuilder = ServiceConfig.getInstance().getServiceResultBuilder(); diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java similarity index 95% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java index 6a229866..ad1bcaa2 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/EasyopenServiceConfiguration.java @@ -36,11 +36,11 @@ public class EasyopenServiceConfiguration extends BaseServiceConfiguration { public EasyopenRequestMappingEvent(ApiMetaManager apiMetaManager, Environment environment) { super(apiMetaManager, environment); - String prefixPath = getEnvironment().getProperty("easyopen.prefix-path"); - if (prefixPath == null) { + String path = getEnvironment().getProperty("easyopen.prefix-path"); + if (path == null) { throw new IllegalArgumentException("请在application.propertis中设置easyopen.prefix-path属性,填IndexController上面的@RequestMapping()中的值"); } - this.prefixPath = prefixPath; + this.prefixPath = path; } @Override diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/GlobalExceptionHandler.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/GlobalExceptionHandler.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/GlobalExceptionHandler.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/GlobalExceptionHandler.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/TaobaoServiceConfiguration.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/TaobaoServiceConfiguration.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/TaobaoServiceConfiguration.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/configuration/TaobaoServiceConfiguration.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java similarity index 92% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java index 86d5d84e..e97efcd4 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/exception/ServiceException.java @@ -8,7 +8,7 @@ import com.gitee.sop.servercommon.message.ServiceErrorImpl; */ public class ServiceException extends RuntimeException { - private ServiceError error; + private final transient ServiceError error; public ServiceException(String subCode, String subMsg) { super(subMsg); diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/interceptor/ServiceContextInterceptor.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java similarity index 84% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java index 6b0161a4..da689771 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ApiMetaManager.java @@ -6,8 +6,6 @@ import com.gitee.sop.servercommon.bean.ServiceApiInfo; * @author tanghc */ public interface ApiMetaManager { - String API_STORE_KEY = "com.gitee.sop.api"; - /** * 上传API * @param serviceApiInfo diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java similarity index 88% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java index 4170803f..c7d7ebd9 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/DefaultRequestMappingEvent.java @@ -37,16 +37,11 @@ public class DefaultRequestMappingEvent implements RequestMappingEvent { public void onRegisterSuccess(ApiMappingHandlerMapping apiMappingHandlerMapping) { String serviceId = environment.getProperty("spring.application.name"); if (serviceId == null) { - throw new RuntimeException("请在application.properties中指定spring.application.name属性"); + throw new IllegalArgumentException("请在application.properties中指定spring.application.name属性"); } List apis = this.buildApiMetaList(apiMappingHandlerMapping); // 排序 - Collections.sort(apis, new Comparator() { - @Override - public int compare(ServiceApiInfo.ApiMeta o1, ServiceApiInfo.ApiMeta o2) { - return o1.fetchNameVersion().compareTo(o2.fetchNameVersion()); - } - }); + apis.sort(Comparator.comparing(ServiceApiInfo.ApiMeta::fetchNameVersion)); ServiceApiInfo serviceApiInfo = new ServiceApiInfo(); serviceApiInfo.setServiceId(serviceId); @@ -68,7 +63,7 @@ public class DefaultRequestMappingEvent implements RequestMappingEvent { } String key = apiMeta.fetchNameVersion(); if (store.contains(key)) { - throw new RuntimeException("重复申明接口,请检查path和version,path:" + apiMeta.getPath() + ", version:" + apiMeta.getVersion()); + throw new IllegalArgumentException("重复申明接口,请检查path和version,path:" + apiMeta.getPath() + ", version:" + apiMeta.getVersion()); } else { store.add(key); } diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java similarity index 94% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java index 8cd2f166..27c792cb 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RedisApiMetaManager.java @@ -10,6 +10,7 @@ import org.springframework.data.redis.core.StringRedisTemplate; */ @Slf4j public class RedisApiMetaManager implements ApiMetaManager { + public static final String API_STORE_KEY = "com.gitee.sop.api"; public static final String API_CHANGE_CHANNEL = "channel.sop.api.change"; private StringRedisTemplate redisTemplate; diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RequestMappingEvent.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RequestMappingEvent.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RequestMappingEvent.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/RequestMappingEvent.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java similarity index 96% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java index 0c35012b..b0410cdf 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/manager/ServiceZookeeperApiMetaManager.java @@ -21,6 +21,7 @@ import java.util.List; /** * 上传路由到zookeeper + * * @author tanghc */ @Slf4j @@ -43,6 +44,7 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { private static ServiceApiInfo.ApiMeta FIRST_API_META = new ServiceApiInfo.ApiMeta("_first.route_", "/", "v_000"); private final String routeRootPath; + private final String zookeeperServerAddr; private Environment environment; @@ -50,6 +52,10 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { this.environment = environment; String profile = environment.getProperty("spring.profiles.active", "default"); this.routeRootPath = SOP_SERVICE_ROUTE_PATH + "-" + profile; + zookeeperServerAddr = environment.getProperty("spring.cloud.zookeeper.connect-string"); + if (StringUtils.isEmpty(zookeeperServerAddr)) { + throw new IllegalArgumentException("未指定spring.cloud.zookeeper.connect-string参数"); + } } @Override @@ -62,7 +68,7 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { * 构建接口信息,符合spring cloud gateway的格式 * * @param serviceApiInfo - * @return + * @return 返回服务路由信息 */ protected ServiceRouteInfo buildServiceGatewayInfo(ServiceApiInfo serviceApiInfo) { List apis = serviceApiInfo.getApis(); @@ -83,7 +89,7 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { /** * 添加com.gitee.sop.gatewaycommon.routeDefinition.ReadBodyRoutePredicateFactory,解决form表单获取不到问题 * - * @return + * @return 返回路由定义 */ protected GatewayRouteDefinition buildReadBodyRouteDefinition(ServiceApiInfo serviceApiInfo) { GatewayRouteDefinition readBodyRouteDefinition = this.buildGatewayRouteDefinition(serviceApiInfo, FIRST_API_META); @@ -140,11 +146,6 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { * @param serviceRouteInfo */ protected void uploadServiceRouteInfoToZookeeper(ServiceRouteInfo serviceRouteInfo) { - String zookeeperServerAddr = environment.getProperty("spring.cloud.zookeeper.connect-string"); - String profile = environment.getProperty("spring.profiles.active", "default"); - if (StringUtils.isEmpty(zookeeperServerAddr)) { - throw new RuntimeException("未指定spring.cloud.zookeeper.connect-string参数"); - } CuratorFramework client = null; try { // 保存路径 @@ -175,6 +176,7 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { /** * 上传文件夹内容 + * * @param client * @param serviceRouteInfo * @return 返回文件夹路径 @@ -190,6 +192,7 @@ public class ServiceZookeeperApiMetaManager implements ApiMetaManager { /** * 上传路由信息 + * * @param client * @param serviceRouteInfo * @throws Exception diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingHandlerMapping.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingHandlerMapping.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingHandlerMapping.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingHandlerMapping.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingInfo.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingInfo.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingInfo.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingInfo.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java similarity index 85% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java index 96e1ba8f..73c7f289 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/mapping/ApiMappingRequestCondition.java @@ -33,7 +33,7 @@ public class ApiMappingRequestCondition implements RequestCondition noModuleCache = new HashSet(); + private static Set noModuleCache = new HashSet<>(); private static Map errorCache = new HashMap<>(64); @@ -39,7 +41,7 @@ public class ServiceErrorFactory { * 设置国际化资源信息 */ public static void initMessageSource(List isvModules) { - HashSet baseNamesSet = new HashSet(); + HashSet baseNamesSet = new HashSet<>(); baseNamesSet.add(I18N_OPEN_ERROR); if (!isvModules.isEmpty()) { diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorImpl.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorImpl.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorImpl.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorImpl.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorMeta.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorMeta.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorMeta.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/message/ServiceErrorMeta.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ApiArgumentResolver.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ParamValidator.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ParamValidator.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ParamValidator.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ParamValidator.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/param/ServiceParamValidator.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/DefaultServiceResultBuilder.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/DefaultServiceResultBuilder.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/result/DefaultServiceResultBuilder.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/DefaultServiceResultBuilder.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java similarity index 94% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java index 46713c27..ac439375 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/result/ServiceResultBuilder.java @@ -22,7 +22,7 @@ public interface ServiceResultBuilder { * 构建错误返回结果 * @param subCode * @param subMsg - * @return + * @return 返回最终结果 */ Object buildError(String subCode, String subMsg); diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayFilterDefinition.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayFilterDefinition.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayFilterDefinition.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayFilterDefinition.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java similarity index 82% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java index 09c37650..08107e88 100644 --- a/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java +++ b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayPredicateDefinition.java @@ -27,10 +27,10 @@ public class GatewayPredicateDefinition { throw new ValidationException("Unable to parse GatewayPredicateDefinition text '" + text + "', must be of the form name=value"); } else { this.setName(text.substring(0, eqIdx)); - String[] args = StringUtils.tokenizeToStringArray(text.substring(eqIdx + 1), ","); + String[] params = StringUtils.tokenizeToStringArray(text.substring(eqIdx + 1), ","); - for(int i = 0; i < args.length; ++i) { - this.args.put(generateName(i), args[i]); + for(int i = 0; i < params.length; ++i) { + this.args.put(generateName(i), params[i]); } } diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayRouteDefinition.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayRouteDefinition.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayRouteDefinition.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/GatewayRouteDefinition.java diff --git a/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/ServiceRouteInfo.java b/sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/ServiceRouteInfo.java similarity index 100% rename from sop-service-common/src/main/java/com/gitee/sop/servercommon/route/ServiceRouteInfo.java rename to sop-common/sop-service-common/src/main/java/com/gitee/sop/servercommon/route/ServiceRouteInfo.java diff --git a/sop-service-common/src/main/resources/i18n/isp/error_en.properties b/sop-common/sop-service-common/src/main/resources/i18n/isp/error_en.properties similarity index 100% rename from sop-service-common/src/main/resources/i18n/isp/error_en.properties rename to sop-common/sop-service-common/src/main/resources/i18n/isp/error_en.properties diff --git a/sop-service-common/src/main/resources/i18n/isp/error_zh_CN.properties b/sop-common/sop-service-common/src/main/resources/i18n/isp/error_zh_CN.properties similarity index 100% rename from sop-service-common/src/main/resources/i18n/isp/error_zh_CN.properties rename to sop-common/sop-service-common/src/main/resources/i18n/isp/error_zh_CN.properties diff --git a/sop-gateway-common/pom.xml b/sop-gateway-common/pom.xml deleted file mode 100644 index b861d3ae..00000000 --- a/sop-gateway-common/pom.xml +++ /dev/null @@ -1,223 +0,0 @@ - - - 4.0.0 - com.gitee.sop - sop-gateway-common - 1.0.0-SNAPSHOT - jar - sop-gateway-common - sop-gateway-common - - - 1.8 - Greenwich.RELEASE - 2.1.2.RELEASE - 1.8 - 1.8 - - 1.0.13 - 1.7.5 - - - 4.11 - - 1.2.15 - 2.5 - 1.3.3 - 3.2.2 - 3.8.1 - 1.11 - 1.4.7 - 3.4.12 - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - org.springframework.cloud - spring-cloud-starter-netflix-zuul - true - - - org.springframework.cloud - spring-cloud-netflix-ribbon - compile - - - - org.springframework.cloud - spring-cloud-starter-gateway - true - - - org.springframework.boot - spring-boot-starter-webflux - true - - - - - org.springframework.cloud - spring-cloud-starter-zookeeper-all - - - - org.springframework.cloud - spring-cloud-starter-zookeeper-discovery - - - - org.apache.zookeeper - zookeeper - - - - - org.apache.zookeeper - zookeeper - ${zookeeper.version} - - - org.slf4j - slf4j-log4j12 - - - - - - org.springframework.boot - spring-boot-starter-data-redis - - - - org.springframework.boot - spring-boot-starter-test - test - - - - com.thoughtworks.xstream - xstream - ${xstream.version} - compile - - - com.alibaba - fastjson - ${fastjson.version} - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - commons-collections - commons-collections - ${commons-collection.version} - - - commons-io - commons-io - ${commons-io.version} - - - commons-fileupload - commons-fileupload - ${commons-fileupload.version} - - - commons-codec - commons-codec - ${commons-codec.version} - - - org.projectlombok - lombok - 1.18.4 - provided - - - javax.servlet - javax.servlet-api - 3.1.0 - provided - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - UTF-8 - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - attach-javadocs - - jar - - - - -Xdoclint:none - - - - - - - - diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java b/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java deleted file mode 100644 index c9ce2aa9..00000000 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/message/ErrorEnum.java +++ /dev/null @@ -1,66 +0,0 @@ -package com.gitee.sop.gatewaycommon.message; - -/** - * @author tanghc - */ -public enum ErrorEnum { - SUCCESS("10000", ""), - - ISP_UNKNOW_ERROR("20000", "isp.unknow-error"), - AOP_UNKNOW_ERROR("20000", "aop.unknow-error"), - - AOP_INVALID_AUTH_TOKEN("20001", "aop.invalid-auth-token"), - AOP_INVALID_AUTH_OKEN("20001", "aop.invalid-auth-token"), - AOP_AUTH_TOKEN_TIME_OUT("20001", "aop.auth-token-time-out"), - AOP_INVALID_APP_AUTH_TOKEN("20001", "aop.invalid-app-auth-token"), - AOP_INVALID_APP_AUTH_TOKEN_NO_API("20001", "aop.invalid-app-auth-token-no-api"), - AOP_APP_AUTH_TOKEN_TIME_OUT("20001", "aop.app-auth-token-time-out"), - AOP_NO_PRODUCT_REG_BY_PARTNER("20001", "aop.no-product-reg-by-partner"), - - ISV_MISSING_METHOD("40001", "isv.missing-method"), - ISV_MISSING_SIGNATURE("40001", "isv.missing-signature"), - ISV_MISSING_SIGNATURE_TYPE("40001", "isv.missing-signature-type"), - ISV_MISSING_SIGNATURE_KEY("40001", "isv.missing-signature-key"), - ISV_MISSING_APP_ID("40001", "isv.missing-app-id"), - ISV_MISSING_TIMESTAMP("40001", "isv.missing-timestamp"), - ISV_MISSING_VERSION("40001", "isv.missing-version"), - ISV_DECRYPTION_ERROR_MISSING_ENCRYPT_TYPE("40001", "isv.decryption-error-missing-encrypt-type"), - - ISV_INVALID_PARAMETER("40002", "isv.invalid-parameter"), - ISV_UPLOAD_FAIL("40002", "isv.upload-fail"), - ISV_INVALID_FILE_EXTENSION("40002", "isv.invalid-file-extension"), - ISV_INVALID_FILE_SIZE("40002", "isv.invalid-file-size"), - ISV_INVALID_METHOD("40002", "isv.invalid-method"), - ISV_INVALID_FORMAT("40002", "isv.invalid-format"), - ISV_INVALID_SIGNATURE_TYPE("40002", "isv.invalid-signature-type"), - ISV_INVALID_SIGNATURE("40002", "isv.invalid-signature"), - ISV_INVALID_ENCRYPT_TYPE("40002", "isv.invalid-encrypt-type"), - ISV_INVALID_ENCRYPT("40002", "isv.invalid-encrypt"), - ISV_INVALID_APP_ID("40002", "isv.invalid-app-id"), - ISV_INVALID_TIMESTAMP("40002", "isv.invalid-timestamp"), - ISV_INVALID_CHARSET("40002", "isv.invalid-charset"), - ISV_INVALID_DIGEST("40002", "isv.invalid-digest"), - ISV_DECRYPTION_ERROR_NOT_VALID_ENCRYPT_TYPE("40002", "isv.decryption-error-not-valid-encrypt-type"), - ISV_DECRYPTION_ERROR_NOT_VALID_ENCRYPT_KEY("40002", "isv.decryption-error-not-valid-encrypt-key"), - ISV_DECRYPTION_ERROR_UNKNOWN("40002", "isv.decryption-error-unknown"), - ISV_MISSING_SIGNATURE_CONFIG("40002", "isv.missing-signature-config"), - ISV_NOT_SUPPORT_APP_AUTH("40002", "isv.not-support-app-auth"), - ISV_SUSPECTED_ATTACK("40002", "isv.suspected-attack"), - ISV_INVALID_CONTENT_TYPE("40002", "isv.invalid-content-type"), - - BIZ_ERROR("40004", ""), - - ISV_INSUFFICIENT_ISV_PERMISSIONS("40006", "isv.insufficient-isv-permissions"), - ISV_INSUFFICIENT_USER_PERMISSIONS("40006", "isv.insufficient-user-permissions"), - - ; - private ErrorMeta errorMeta; - - ErrorEnum(String code, String subCode) { - this.errorMeta = new ErrorMeta("open.error_", code, subCode); - } - - public ErrorMeta getErrorMeta() { - return errorMeta; - } -} diff --git a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/XmlUtil.java b/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/XmlUtil.java deleted file mode 100644 index 7c62ff1b..00000000 --- a/sop-gateway-common/src/main/java/com/gitee/sop/gatewaycommon/util/XmlUtil.java +++ /dev/null @@ -1,32 +0,0 @@ -package com.gitee.sop.gatewaycommon.util; - -import com.gitee.sop.gatewaycommon.result.ApiResult; -import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.naming.NoNameCoder; -import com.thoughtworks.xstream.io.xml.StaxDriver; - -/** - * @author tanghc - */ -public class XmlUtil { - private static XStream xStream = new XStream(new StaxDriver(new NoNameCoder())); - static { - xStream.processAnnotations(ApiResult.class); - xStream.aliasSystemAttribute(null, "class"); - } - - public static String serialize(Object obj) { - return getXStream().toXML(obj); - } - - public static T unserialize(String xml, Class clazz) { - xStream.processAnnotations(clazz); - Object object = xStream.fromXML(xml); - T cast = clazz.cast(object); - return cast; - } - - public static XStream getXStream() { - return xStream; - } -} diff --git a/sop-service-common/pom.xml b/sop-service-common/pom.xml deleted file mode 100644 index fd3bb690..00000000 --- a/sop-service-common/pom.xml +++ /dev/null @@ -1,185 +0,0 @@ - - - - 4.0.0 - com.gitee.sop - sop-service-common - sop-service-common - 1.0.0-SNAPSHOT - jar - - - 1.8 - UTF-8 - Greenwich.RELEASE - 2.1.2.RELEASE - 1.8 - 1.8 - 3.8.1 - 1.2.15 - 3.4.12 - - - - - - - org.springframework.boot - spring-boot-dependencies - ${spring-boot.version} - pom - import - - - org.springframework.cloud - spring-cloud-dependencies - ${spring-cloud.version} - pom - import - - - - - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-data-redis - - - - - org.apache.commons - commons-lang3 - ${commons-lang3.version} - - - - com.alibaba - fastjson - ${fastjson.version} - - - - - org.springframework.cloud - spring-cloud-starter-zookeeper-all - - - - org.springframework.cloud - spring-cloud-starter-zookeeper-discovery - - - org.apache.zookeeper - zookeeper - - - - - org.apache.zookeeper - zookeeper - ${zookeeper.version} - - - org.slf4j - slf4j-log4j12 - - - - - - net.oschina.durcframework - easyopen - 1.16.0 - true - - - - - org.projectlombok - lombok - 1.18.4 - provided - - - javax.servlet - javax.servlet-api - 3.1.0 - provided - - - - junit - junit - 4.11 - test - - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - true - - - - org.apache.maven.plugins - maven-compiler-plugin - - ${java.version} - ${java.version} - UTF-8 - - - - org.apache.maven.plugins - maven-source-plugin - 2.2.1 - - - attach-sources - - jar-no-fork - - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - attach-javadocs - - jar - - - - -Xdoclint:none - - - - - - - - - - spring-milestones - Spring Milestones - https://repo.spring.io/milestone - - -