public void createUser(GenericRequestParam genericRequestParam) { if (genericRequestParam != null && MapUtils.isNotEmpty(genericRequestParam.getParams())) { Map<String, Object> params = genericRequestParam.getParams(); String username = null; { if (params.containsKey("username")) { username = params.get("username").toString(); } } String courierCode = null; { if (params.containsKey("courier")) { courierCode = params.get("courier").toString(); } } String wirelessCenterCode = null; { if (params.containsKey("wireless")) { wirelessCenterCode = params.get("wireless").toString(); } } if (username != null) { User user = ObjectUtils.defaultIfNull( userRepository.findOne(User_.username(username)), new User(username)); if (StringUtils.isNotBlank(courierCode)) { Courier courier = courierService.findOneByCode(courierCode); if (courier != null) { user.setCourier(courier); } } if (StringUtils.isNotBlank(wirelessCenterCode)) { WirelessCenter wirelessCenter = wirelessCenterService.findOneByCode(wirelessCenterCode); if (wirelessCenter != null) { user.setWirelessCenter(wirelessCenter); } } userRepository.save(user); } } }
public User getLoggedInPrincipalAsUserDomain() { return userRepository.findOne(User_.username(authorizationService.getUsername())); }