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(); }
private static Adaptable handleMultipleRetrieve(final RetrieveThings command, final TopicPath.Channel channel) { final String commandName = command.getClass().getSimpleName().toLowerCase(); if (!commandName.startsWith(TopicPath.Action.RETRIEVE.toString())) { throw UnknownCommandException.newBuilder(commandName).build(); } final String namespace = command.getNamespace().orElse("_"); final TopicPathBuilder topicPathBuilder = ProtocolFactory.newTopicPathBuilderFromNamespace(namespace); final CommandsTopicPathBuilder commandsTopicPathBuilder = fromTopicPathBuilderWithChannel(topicPathBuilder, channel); final PayloadBuilder payloadBuilder = Payload.newBuilder(command.getResourcePath()); command.getSelectedFields().ifPresent(payloadBuilder::withFields); payloadBuilder.withValue(createIdsPayload(command.getThingIds())); return Adaptable.newBuilder(commandsTopicPathBuilder.retrieve().build()) .withPayload(payloadBuilder.build()) .withHeaders(ProtocolFactory.newHeadersWithDittoContentType(command.getDittoHeaders())) .build(); }
private static Adaptable handleMultipleRetrieve(final RetrieveThings command, final TopicPath.Channel channel) { final String commandName = command.getClass().getSimpleName().toLowerCase(); if (!commandName.startsWith(TopicPath.Action.RETRIEVE.toString())) { throw UnknownCommandException.newBuilder(commandName).build(); } final String namespace = command.getNamespace().orElse("_"); final TopicPathBuilder topicPathBuilder = ProtocolFactory.newTopicPathBuilderFromNamespace(namespace); final CommandsTopicPathBuilder commandsTopicPathBuilder = fromTopicPathBuilderWithChannel(topicPathBuilder, channel); final PayloadBuilder payloadBuilder = Payload.newBuilder(command.getResourcePath()); command.getSelectedFields().ifPresent(payloadBuilder::withFields); payloadBuilder.withValue(createIdsPayload(command.getThingIds())); return Adaptable.newBuilder(commandsTopicPathBuilder.retrieve().build()) .withPayload(payloadBuilder.build()) .withHeaders(ProtocolFactory.newHeadersWithDittoContentType(command.getDittoHeaders())) .build(); }