| Line 1... |
Line 1... |
| 1 |
package com.spice.profitmandi.web.util;
|
1 |
package com.spice.profitmandi.web.util;
|
| 2 |
|
2 |
|
| 3 |
import java.util.HashMap;
|
- |
|
| 4 |
import java.util.Map;
|
- |
|
| 5 |
|
- |
|
| 6 |
import org.apache.logging.log4j.Logger;
|
- |
|
| 7 |
import org.apache.logging.log4j.LogManager;
|
- |
|
| 8 |
import org.springframework.stereotype.Component;
|
- |
|
| 9 |
|
- |
|
| 10 |
import com.fasterxml.jackson.core.JsonProcessingException;
|
3 |
import com.fasterxml.jackson.core.JsonProcessingException;
|
| 11 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
4 |
import com.fasterxml.jackson.databind.ObjectMapper;
|
| 12 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
5 |
import com.spice.profitmandi.common.ResponseCodeHolder;
|
| - |
|
6 |
import org.apache.logging.log4j.LogManager;
|
| - |
|
7 |
import org.apache.logging.log4j.Logger;
|
| - |
|
8 |
import org.springframework.beans.factory.annotation.Autowired;
|
| - |
|
9 |
import org.springframework.stereotype.Component;
|
| - |
|
10 |
|
| - |
|
11 |
import java.util.HashMap;
|
| - |
|
12 |
import java.util.Map;
|
| 13 |
|
13 |
|
| 14 |
@Component
|
14 |
@Component
|
| 15 |
public class MVCResponseSender {
|
15 |
public class MVCResponseSender {
|
| 16 |
|
- |
|
| 17 |
private ObjectMapper objectMapper = new ObjectMapper();
|
- |
|
| 18 |
|
16 |
|
| 19 |
private static final Logger LOGGER = LogManager.getLogger(MVCResponseSender.class);
|
17 |
private static final Logger LOGGER = LogManager.getLogger(MVCResponseSender.class);
|
| - |
|
18 |
@Autowired
|
| - |
|
19 |
ObjectMapper objectMapper;
|
| 20 |
|
20 |
|
| 21 |
public String createResponseString(String responseCode, boolean status, String redirectUrl) throws Exception{
|
21 |
public String createResponseString(String responseCode, boolean status, String redirectUrl) throws Exception {
|
| 22 |
Map<String, Object> response = new HashMap<>();
|
22 |
Map<String, Object> response = new HashMap<>();
|
| 23 |
response.put("message", ResponseCodeHolder.getMessage(responseCode));
|
23 |
response.put("message", ResponseCodeHolder.getMessage(responseCode));
|
| 24 |
response.put("status", status);
|
24 |
response.put("status", status);
|
| 25 |
response.put("redirectUrl", redirectUrl);
|
25 |
response.put("redirectUrl", redirectUrl);
|
| 26 |
try {
|
26 |
try {
|
| Line 28... |
Line 28... |
| 28 |
} catch (JsonProcessingException e) {
|
28 |
} catch (JsonProcessingException e) {
|
| 29 |
LOGGER.error("Error occured while converting response to json", e);
|
29 |
LOGGER.error("Error occured while converting response to json", e);
|
| 30 |
throw e;
|
30 |
throw e;
|
| 31 |
}
|
31 |
}
|
| 32 |
}
|
32 |
}
|
| - |
|
33 |
|
| 33 |
public String createResponseString(String responseCode, boolean status, String redirectUrl,String name) throws Exception{
|
34 |
public String createResponseString(String responseCode, boolean status, String redirectUrl, String name) throws Exception {
|
| 34 |
Map<String, Object> response = new HashMap<>();
|
35 |
Map<String, Object> response = new HashMap<>();
|
| 35 |
response.put("message", ResponseCodeHolder.getMessage(responseCode));
|
36 |
response.put("message", ResponseCodeHolder.getMessage(responseCode));
|
| 36 |
response.put("status", status);
|
37 |
response.put("status", status);
|
| 37 |
response.put("redirectUrl", redirectUrl);
|
38 |
response.put("redirectUrl", redirectUrl);
|
| 38 |
response.put("name",name);
|
39 |
response.put("name",name);
|