| Line 3... |
Line 3... |
| 3 |
import java.util.HashMap;
|
3 |
import java.util.HashMap;
|
| 4 |
import java.util.Map;
|
4 |
import java.util.Map;
|
| 5 |
|
5 |
|
| 6 |
import javax.servlet.http.HttpServletRequest;
|
6 |
import javax.servlet.http.HttpServletRequest;
|
| 7 |
|
7 |
|
| - |
|
8 |
import org.apache.http.conn.HttpHostConnectException;
|
| 8 |
import org.slf4j.Logger;
|
9 |
import org.slf4j.Logger;
|
| 9 |
import org.slf4j.LoggerFactory;
|
10 |
import org.slf4j.LoggerFactory;
|
| 10 |
import org.springframework.beans.factory.annotation.Autowired;
|
11 |
import org.springframework.beans.factory.annotation.Autowired;
|
| 11 |
import org.springframework.beans.factory.annotation.Value;
|
12 |
import org.springframework.beans.factory.annotation.Value;
|
| 12 |
import org.springframework.http.ResponseEntity;
|
13 |
import org.springframework.http.ResponseEntity;
|
| Line 75... |
Line 76... |
| 75 |
}
|
76 |
}
|
| 76 |
}
|
77 |
}
|
| 77 |
|
78 |
|
| 78 |
@RequestMapping(value = "/pin-info/{pinCode}", method=RequestMethod.GET)
|
79 |
@RequestMapping(value = "/pin-info/{pinCode}", method=RequestMethod.GET)
|
| 79 |
public ResponseEntity<?> getPinInfo(HttpServletRequest request, @PathVariable(value="pinCode") String pinCode){
|
80 |
public ResponseEntity<?> getPinInfo(HttpServletRequest request, @PathVariable(value="pinCode") String pinCode){
|
| - |
|
81 |
String remoteUrl = "pincodeValidation/" + pinCode;
|
| 80 |
try {
|
82 |
try {
|
| 81 |
RestClient rc = new RestClient(SchemeType.HTTP, host, port);
|
83 |
RestClient rc = new RestClient();
|
| 82 |
Map<String, String> params = new HashMap<>();
|
84 |
Map<String, String> params = new HashMap<>();
|
| 83 |
String response = rc.get("pincodeValidation/" + pinCode, params);
|
85 |
String response = rc.get(SchemeType.HTTP, host, port, remoteUrl, params);
|
| 84 |
JsonObject result_json = Json.parse(response).asObject();
|
86 |
JsonObject result_json = Json.parse(response).asObject();
|
| 85 |
return responseSender.ok(result_json);
|
87 |
return responseSender.ok(result_json);
|
| 86 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
88 |
}catch (ProfitMandiBusinessException profitMandiBusinessException) {
|
| 87 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
89 |
LOGGER.error("ProfitMandi error: ", profitMandiBusinessException);
|
| 88 |
return responseSender.badRequest(profitMandiBusinessException);
|
90 |
return responseSender.badRequest(profitMandiBusinessException);
|
| - |
|
91 |
}catch (HttpHostConnectException hhce) {
|
| - |
|
92 |
LOGGER.error("Cannot connect to remote url: {}", remoteUrl);
|
| - |
|
93 |
return responseSender.badRequest(new ProfitMandiBusinessException("None", "None", "cannot connect to remote url" + remoteUrl));
|
| - |
|
94 |
|
| 89 |
}
|
95 |
}
|
| 90 |
}
|
96 |
}
|
| 91 |
|
97 |
|
| 92 |
}
|
98 |
}
|