Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
OTSWithFeign
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Siva Naga Someswara Jatla
OTSWithFeign
Commits
7140b2c2
Commit
7140b2c2
authored
May 05, 2020
by
sgandhi@nisum.com
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
EPE-006 : Added exception handler and removed configuration class
parent
c1f321e7
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
24 additions
and
51 deletions
+24
-51
build.gradle
build.gradle
+1
-0
FeignClientService.java
...um/offertransactionservice/client/FeignClientService.java
+1
-2
CustomErrorDecoder.java
...um/offertransactionservice/config/CustomErrorDecoder.java
+0
-25
FeignClientConfiguration.java
...ertransactionservice/config/FeignClientConfiguration.java
+0
-18
FeignExceptionHandler.java
...ffertransactionservice/handler/FeignExceptionHandler.java
+19
-0
OfferCallingPEService.java
...ffertransactionservice/service/OfferCallingPEService.java
+2
-4
application.properties
src/main/resources/application.properties
+1
-2
No files found.
build.gradle
View file @
7140b2c2
...
...
@@ -32,6 +32,7 @@ ext {
dependencies
{
//TODO: Make it
compile
group:
'org.json'
,
name:
'json'
,
version:
'20190722'
compile
'org.mapstruct:mapstruct:1.3.1.Final'
implementation
'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation
'org.springframework.cloud:spring-cloud-starter-netflix-eureka-client'
...
...
src/main/java/com/nisum/offertransactionservice/client/FeignClientService.java
View file @
7140b2c2
package
com
.
nisum
.
offertransactionservice
.
client
;
import
com.nisum.offertransactionservice.config.FeignClientConfiguration
;
import
com.nisum.offertransactionservice.dto.PERequest
;
import
com.nisum.offertransactionservice.dto.PEResponse
;
import
org.springframework.cloud.openfeign.FeignClient
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.web.bind.annotation.PostMapping
;
@FeignClient
(
name
=
"${pe.application.name}"
,
configuration
=
FeignClientConfiguration
.
class
)
@FeignClient
(
name
=
"${pe.application.name}"
)
public
interface
FeignClientService
{
@PostMapping
(
value
=
"${endpoint.url.promotionEngineUrl}"
)
...
...
src/main/java/com/nisum/offertransactionservice/config/CustomErrorDecoder.java
deleted
100644 → 0
View file @
c1f321e7
package
com
.
nisum
.
offertransactionservice
.
config
;
import
com.nisum.offertransactionservice.genericexception.GlobalApiGenericException
;
import
feign.Response
;
import
feign.codec.ErrorDecoder
;
public
class
CustomErrorDecoder
implements
ErrorDecoder
{
@Override
public
Exception
decode
(
String
methodKey
,
Response
response
)
{
String
httpStatusDesc
=
null
;
switch
(
response
.
status
())
{
case
400
:
httpStatusDesc
=
"Bad Request"
;
break
;
case
404
:
httpStatusDesc
=
"Not found"
;
break
;
case
500
:
httpStatusDesc
=
"Internal Error"
;
break
;
default
:
httpStatusDesc
=
"Generic error"
;
}
return
new
GlobalApiGenericException
(
Integer
.
toString
(
response
.
status
()),
true
,
null
);
}
}
src/main/java/com/nisum/offertransactionservice/config/FeignClientConfiguration.java
deleted
100644 → 0
View file @
c1f321e7
package
com
.
nisum
.
offertransactionservice
.
config
;
import
feign.Logger
;
import
feign.codec.ErrorDecoder
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
public
class
FeignClientConfiguration
{
@Bean
public
Logger
.
Level
feignLoggerLevel
()
{
return
Logger
.
Level
.
FULL
;
}
@Bean
public
ErrorDecoder
errorDecoder
()
{
return
new
CustomErrorDecoder
();
}
}
\ No newline at end of file
src/main/java/com/nisum/offertransactionservice/handler/FeignExceptionHandler.java
0 → 100644
View file @
7140b2c2
package
com
.
nisum
.
offertransactionservice
.
handler
;
import
feign.FeignException
;
import
org.json.JSONObject
;
import
org.springframework.web.bind.annotation.ExceptionHandler
;
import
org.springframework.web.bind.annotation.RestControllerAdvice
;
import
javax.servlet.http.HttpServletResponse
;
import
java.util.Map
;
@RestControllerAdvice
public
class
FeignExceptionHandler
{
@ExceptionHandler
({
FeignException
.
BadRequest
.
class
,
FeignException
.
InternalServerError
.
class
,
FeignException
.
NotFound
.
class
})
public
Map
<
String
,
Object
>
handleFeignStatusException
(
FeignException
e
,
HttpServletResponse
response
)
{
response
.
setStatus
(
e
.
status
());
return
new
JSONObject
(
e
.
contentUTF8
()).
toMap
();
}
}
src/main/java/com/nisum/offertransactionservice/service/OfferCallingPEService.java
View file @
7140b2c2
...
...
@@ -59,11 +59,9 @@ public class OfferCallingPEService {
PERequest
peRequest
=
INSTANCE
.
map
(
offerTransactionRequest
);
peRequest
.
setEligibleOffers
(
offerLookupDTOList
);
log
.
info
(
"Promotional Engine Feign client call Start"
);
/*PEResponse peResponseFlux = clientService.getPeResponseFlux(peRequest);*/
ResponseEntity
<
PEResponse
>
peResponseFlux
=
feignClientService
.
callPEService
(
peRequest
);
ResponseEntity
<
PEResponse
>
peResponse
=
feignClientService
.
callPEService
(
peRequest
);
log
.
debug
(
"Promotional Engine Feign client call End"
);
offerTransactionResponse
=
INSTANCE
.
map
(
peResponse
Flux
.
getBody
());
offerTransactionResponse
=
INSTANCE
.
map
(
peResponse
.
getBody
());
offerTransactionResponse
.
setTransactionId
(
offerTransactionRequest
.
getTransactionId
());
log
.
debug
(
"Offer Transaction Response {}"
,
offerTransactionResponse
);
return
offerTransactionResponse
;
...
...
src/main/resources/application.properties
View file @
7140b2c2
...
...
@@ -8,5 +8,4 @@ endpoint.url.spBaseUrl=http://localhost:7070
server.port
=
7072
spring.application.name
=
ots
eureka.client.serviceUrl.defaultZone
=
http://localhost:8761/eureka
spring.jpa.properties.hibernate.format_sql
=
true
spring.jpa.show-sql
=
true
\ No newline at end of file
//
TODO
:
add refresh eureka endpoint properties
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment