Issue #SC-1193 read data from registry if es fails - #45
Conversation
| */ | ||
| public interface UserJsonKey { | ||
|
|
||
| String OSID = "osid"; |
There was a problem hiding this comment.
move this constant under Jsonkey file as it will be used across the application not only user related file.
There was a problem hiding this comment.
This must not be hardcoded. Remember we have an env var uuidPropertyName.
There was a problem hiding this comment.
Yes it is configurable property. Now got this value from DbConnectionInfoMngr bean.
| Response response = null; | ||
| try { | ||
| response = userESDao.getUserById((String) request.getRequest().get(JsonKey.USER_ID)); | ||
| } catch (Exception e) { |
There was a problem hiding this comment.
Add logger in catch block to print sacktrace, to know what went wrong.
| try { | ||
| response = userESDao.getUserById((String) request.getRequest().get(JsonKey.USER_ID)); | ||
| } catch (Exception e) { | ||
| ProjectLogger.log("Exception occurred while reading user ES.", e); |
There was a problem hiding this comment.
Logger parretn need to be same for all places, we are following "className:methodName message,LoggerEum.Value.name"
| response = userESDao.getUserById((String) request.getRequest().get(JsonKey.USER_ID)); | ||
| } catch (Exception e) { | ||
| ProjectLogger.log("Exception occurred while reading user ES.", e); | ||
| userService = new UserServiceImpl(); |
There was a problem hiding this comment.
Use service factory , no need to create instance every places,
There was a problem hiding this comment.
Created factory for service object creation.
| * @return response | ||
| * @throws BaseException | ||
| */ | ||
| public Response readUser(JsonNode userId) throws BaseException; |
There was a problem hiding this comment.
why requested userId is JsonNode , it should be String
There was a problem hiding this comment.
This method attribute name incorrect, here we constructed json node with valid input to read method, now attribute name changed
| public Response readUser(JsonNode inputNode) throws BaseException { | ||
| Response response = new Response(); | ||
| try { | ||
| JsonNode responseNode = registryHelper.readEntity(inputNode,""); |
There was a problem hiding this comment.
use overide method for readEntity with one and two argument .
There was a problem hiding this comment.
This change should be at user-registry, i hope here it is not necessary.
| response.putAll(objectMapper.convertValue(responseNode,Map.class)); | ||
| return response; | ||
| } catch (Exception e) { | ||
| ProjectLogger.log("Exception occurred while reading user from open saber.", e); |
| + "Exception in getting the record from ES : " | ||
| + e.getMessage(), | ||
| LoggerEnum.ERROR.name()); | ||
| ProjectLogger.log("Exception occurred while reading user ES.", e); |
There was a problem hiding this comment.
remove ProjectLogger.log("Exception occurred while reading user ES.", e); because we already have logger above.
| try { | ||
| response = userESDao.getUserById((String) request.getRequest().get(JsonKey.USER_ID)); | ||
| } catch (Exception e) { | ||
| ProjectLogger.log("Exception occurred while reading user ES.", e); |
|
|
||
| public static Object getService(String serviceName) { | ||
| Object serviceObj = null; | ||
| if(serviceName.equals(ServiceImplType.USER.getServiceType())) { |
There was a problem hiding this comment.
DO reverse check to avoid NPE.
serviceName.equals(ServiceImplType.USER.getServiceType()) to ServiceImplType.USER.getServiceType().equals(serviceName)
When read-api fails to fetch data from elastic-search, request is routed to user-registry for the data.