Source:
<code>public void processCommandUpdate(JsonObject request, WebSocketSession session) { HivePrincipal principal = (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); String deviceId = gson.fromJson(request.get(DEVICE_ID), String.class);; final Long id = Long.valueOf(request.get(COMMAND_ID).getAsString()); final DeviceCommandWrapper commandUpdate = gson .fromJson(request.getAsJsonObject(COMMAND), DeviceCommandWrapper.class); logger.debug("command/update requested for session: {}. Device ID: {}. Command id: {}", session, deviceId, id); if (id == null) { logger.debug("command/update canceled for session: {}. Command id is not provided", session); throw new HiveException(Messages.COMMAND_ID_REQUIRED, SC_BAD_REQUEST); } Set<DeviceVO> devices = new HashSet<>(); if (deviceId == null) { throw new HiveException(Messages.DEVICE_ID_REQUIRED, SC_BAD_REQUEST); } DeviceVO deviceVO = deviceService.findByIdWithPermissionsCheck(deviceId, principal); if (deviceVO == null) { <START> throw new HiveException(String.format(Messages.DEVICE_NOT_FOUND, deviceId), SC_NOT_FOUND); <END> } devices.add(deviceVO); if (devices.isEmpty()) { throw new HiveException(String.format(Messages.DEVICE_NOT_FOUND, id), SC_NOT_FOUND); } Optional<DeviceCommand> savedCommand = Optional.empty(); for (DeviceVO device : devices) { savedCommand = commandService.findOne(id, device.getDeviceId()).join(); if (savedCommand.isPresent()) { commandService.update(savedCommand.get(), commandUpdate); } } if (!savedCommand.isPresent()) { throw new HiveException(String.format(Messages.COMMAND_NOT_FOUND, id), SC_NOT_FOUND); } logger.debug("command/update proceed successfully for session: {}. Device ID: {}. Command id: {}", session, deviceId, id); clientHandler.sendMessage(request, new WebSocketResponse(), session); }</code><technical_language>Logging</technical_language>

Target:
public void processCommandUpdate(JsonObject request, WebSocketSession session) { HivePrincipal principal = (HivePrincipal) SecurityContextHolder.getContext().getAuthentication().getPrincipal(); String deviceId = gson.fromJson(request.get(DEVICE_ID), String.class);; final Long id = Long.valueOf(request.get(COMMAND_ID).getAsString()); final DeviceCommandWrapper commandUpdate = gson .fromJson(request.getAsJsonObject(COMMAND), DeviceCommandWrapper.class); logger.debug("command/update requested for session: {}. Device ID: {}. Command id: {}", session, deviceId, id); if (id == null) { logger.debug("command/update canceled for session: {}. Command id is not provided", session); throw new HiveException(Messages.COMMAND_ID_REQUIRED, SC_BAD_REQUEST); } Set<DeviceVO> devices = new HashSet<>(); if (deviceId == null) { throw new HiveException(Messages.DEVICE_ID_REQUIRED, SC_BAD_REQUEST); } DeviceVO deviceVO = deviceService.findByIdWithPermissionsCheck(deviceId, principal); if (deviceVO == null) { throw new HiveException(String.format(Messages.DEVICE_NOT_FOUND, deviceId), SC_NOT_FOUND); } devices.add(deviceVO); Optional<DeviceCommand> savedCommand = Optional.empty(); for (DeviceVO device : devices) { savedCommand = commandService.findOne(id, device.getDeviceId()).join(); if (savedCommand.isPresent()) { commandService.update(savedCommand.get(), commandUpdate); } } if (!savedCommand.isPresent()) { throw new HiveException(String.format(Messages.COMMAND_NOT_FOUND, id), SC_NOT_FOUND); } logger.debug("command/update proceed successfully for session: {}. Device ID: {}. Command id: {}", session, deviceId, id); clientHandler.sendMessage(request, new WebSocketResponse(), session); }