@Override public String getThingId() { return thingQueryCommand.getThingId(); }
@Override public String getThingId() { return thingQueryCommand.getThingId(); }
private static ThingNotAccessibleException notAccessible(final ThingQueryCommand<?> command) { return new ThingNotAccessibleException(command.getThingId(), command.getDittoHeaders()); }
private static ThingNotAccessibleException notAccessible(final ThingQueryCommand<?> command) { return new ThingNotAccessibleException(command.getThingId(), command.getDittoHeaders()); }
private static WithDittoHeaders getRetrieveThingResponse(@Nullable final Thing thing, final ThingQueryCommand<RetrieveThing> command) { if (thing != null) { return RetrieveThingResponse.of(command.getThingId(), getThingJson(thing, command), command.getDittoHeaders()); } else { return notAccessible(command); } }
private static WithDittoHeaders getRetrieveThingResponse(@Nullable final Thing thing, final ThingQueryCommand<RetrieveThing> command) { if (thing != null) { return RetrieveThingResponse.of(command.getThingId(), getThingJson(thing, command), command.getDittoHeaders()); } else { return notAccessible(command); } }
private static Adaptable handleSingleRetrieve(final ThingQueryCommand<?> command, final TopicPath.Channel channel) { final TopicPathBuilder topicPathBuilder = ProtocolFactory.newTopicPathBuilder(command.getThingId()); final CommandsTopicPathBuilder commandsTopicPathBuilder; commandsTopicPathBuilder = fromTopicPathBuilderWithChannel(topicPathBuilder, channel); final String commandName = command.getClass().getSimpleName().toLowerCase(); if (!commandName.startsWith(TopicPath.Action.RETRIEVE.toString())) { throw UnknownCommandException.newBuilder(commandName).build(); } final PayloadBuilder payloadBuilder = Payload.newBuilder(command.getResourcePath()); command.getSelectedFields().ifPresent(payloadBuilder::withFields); return Adaptable.newBuilder(commandsTopicPathBuilder.retrieve().build()) .withPayload(payloadBuilder.build()) .withHeaders(ProtocolFactory.newHeadersWithDittoContentType(command.getDittoHeaders())) .build(); }
private static Adaptable handleSingleRetrieve(final ThingQueryCommand<?> command, final TopicPath.Channel channel) { final TopicPathBuilder topicPathBuilder = ProtocolFactory.newTopicPathBuilder(command.getThingId()); final CommandsTopicPathBuilder commandsTopicPathBuilder; commandsTopicPathBuilder = fromTopicPathBuilderWithChannel(topicPathBuilder, channel); final String commandName = command.getClass().getSimpleName().toLowerCase(); if (!commandName.startsWith(TopicPath.Action.RETRIEVE.toString())) { throw UnknownCommandException.newBuilder(commandName).build(); } final PayloadBuilder payloadBuilder = Payload.newBuilder(command.getResourcePath()); command.getSelectedFields().ifPresent(payloadBuilder::withFields); return Adaptable.newBuilder(commandsTopicPathBuilder.retrieve().build()) .withPayload(payloadBuilder.build()) .withHeaders(ProtocolFactory.newHeadersWithDittoContentType(command.getDittoHeaders())) .build(); }
/** * Report timeout of {@code ThingQueryCommand}. * * @param command the original command. * @param sender sender of the command. * @param askTimeoutException the timeout exception. */ private void reportTimeoutForThingQuery( final ThingQueryCommand command, final ActorRef sender, final AskTimeoutException askTimeoutException) { log(command).error(askTimeoutException, "Timeout before building JsonView"); replyToSender(ThingUnavailableException.newBuilder(command.getThingId()) .dittoHeaders(command.getDittoHeaders()) .build(), sender); }