| 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.MediaType;
|
13 |
import org.springframework.http.MediaType;
|
| Line 52... |
Line 53... |
| 52 |
})
|
53 |
})
|
| 53 |
|
54 |
|
| 54 |
@ApiOperation(value = "Get entity content")
|
55 |
@ApiOperation(value = "Get entity content")
|
| 55 |
public ResponseEntity<?> getEntity(HttpServletRequest request, @PathVariable(value="entityId") String entityId)throws ProfitMandiBusinessException{
|
56 |
public ResponseEntity<?> getEntity(HttpServletRequest request, @PathVariable(value="entityId") String entityId)throws ProfitMandiBusinessException{
|
| 56 |
logger.info("Entity Id "+entityId);
|
57 |
logger.info("Entity Id "+entityId);
|
| 57 |
RestClient rc = new RestClient(SchemeType.HTTP, host , port);
|
58 |
RestClient rc = new RestClient();
|
| 58 |
Map<String, String> params = new HashMap<String, String>();
|
59 |
Map<String, String> params = new HashMap<String, String>();
|
| 59 |
String response = null;
|
60 |
String response = null;
|
| 60 |
String uri = webapp+"/entity/"+entityId;
|
61 |
String uri = webapp+"/entity/"+entityId;
|
| 61 |
EntityResponse entityResponse=null;
|
62 |
EntityResponse entityResponse=null;
|
| - |
|
63 |
try {
|
| 62 |
response = rc.get(uri, params);
|
64 |
response = rc.get(SchemeType.HTTP, host , port, uri, params);
|
| - |
|
65 |
} catch (HttpHostConnectException e) {
|
| - |
|
66 |
throw new ProfitMandiBusinessException("", "", "Could not connect to host");
|
| - |
|
67 |
}
|
| 63 |
|
68 |
|
| 64 |
Gson gson = new Gson();
|
69 |
Gson gson = new Gson();
|
| 65 |
entityResponse = gson.fromJson(response, EntityResponse.class);
|
70 |
entityResponse = gson.fromJson(response, EntityResponse.class);
|
| 66 |
return responseSender.ok(entityResponse);
|
71 |
return responseSender.ok(entityResponse);
|
| 67 |
}
|
72 |
}
|