@Override public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId) { LOG.debug("getControllerBase({})", controllerId); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, IpUtil .getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties)); final Action action = controllerManagement.findOldestActiveActionByTarget(controllerId).orElse(null); checkAndCancelExpiredAction(action); return new ResponseEntity<>( DataConversionHelper.fromTarget(target, action, action == null ? controllerManagement.getPollingTime() : controllerManagement.getPollingTimeForAction(action.getId()), tenantAware), HttpStatus.OK); }
@Override public ResponseEntity<DdiControllerBase> getControllerBase(@PathVariable("tenant") final String tenant, @PathVariable("controllerId") final String controllerId) { LOG.debug("getControllerBase({})", controllerId); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(controllerId, IpUtil .getClientIpFromRequest(requestResponseContextHolder.getHttpServletRequest(), securityProperties)); final Action action = controllerManagement.findOldestActiveActionByTarget(controllerId).orElse(null); checkAndCancelExpiredAction(action); return new ResponseEntity<>( DataConversionHelper.fromTarget(target, action, action == null ? controllerManagement.getPollingTime() : controllerManagement.getPollingTimeForAction(action.getId()), tenantAware), HttpStatus.OK); }
/** * Method to create a new target or to find the target if it already exists. * * @param targetID * the ID of the target/thing * @param ip * the ip of the target/thing */ private void registerTarget(final Message message, final String virtualHost) { final String thingId = getStringHeaderKey(message, MessageHeaderKey.THING_ID, "ThingId is null"); final String replyTo = message.getMessageProperties().getReplyTo(); if (StringUtils.isEmpty(replyTo)) { logAndThrowMessageError(message, "No ReplyTo was set for the createThing message."); } final URI amqpUri = IpUtil.createAmqpUri(virtualHost, replyTo); final Target target = controllerManagement.findOrRegisterTargetIfItDoesNotexist(thingId, amqpUri); LOG.debug("Target {} reported online state.", thingId); lookIfUpdateAvailable(target); }