Commit 52ef95ac1be6988d5be7ef8e93fd98ff7911d53e
1 parent
cc5b18f3
Refactoring of MQTT Transport and removing data structures
Showing
71 changed files
with
136 additions
and
1950 deletions
... | ... | @@ -42,12 +42,8 @@ import org.thingsboard.server.common.msg.TbMsgDataType; |
42 | 42 | import org.thingsboard.server.common.msg.TbMsgMetaData; |
43 | 43 | import org.thingsboard.server.common.msg.cluster.ClusterEventMsg; |
44 | 44 | import org.thingsboard.server.common.msg.cluster.ServerAddress; |
45 | -import org.thingsboard.server.common.msg.core.ActorSystemToDeviceSessionActorMsg; | |
46 | -import org.thingsboard.server.common.msg.core.RuleEngineError; | |
47 | -import org.thingsboard.server.common.msg.core.RuleEngineErrorMsg; | |
48 | 45 | import org.thingsboard.server.common.msg.rpc.ToDeviceRpcRequest; |
49 | 46 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
50 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
51 | 47 | import org.thingsboard.server.common.msg.timeout.DeviceActorClientSideRpcTimeoutMsg; |
52 | 48 | import org.thingsboard.server.common.msg.timeout.DeviceActorServerSideRpcTimeoutMsg; |
53 | 49 | import org.thingsboard.server.gen.transport.TransportProtos; |
... | ... | @@ -481,17 +477,6 @@ public class DeviceActorMessageProcessor extends AbstractContextAwareMsgProcesso |
481 | 477 | } |
482 | 478 | } |
483 | 479 | |
484 | - private void sendMsgToSessionActor(ActorSystemToDeviceSessionActorMsg response, Optional<ServerAddress> sessionAddress) { | |
485 | - if (sessionAddress.isPresent()) { | |
486 | - ServerAddress address = sessionAddress.get(); | |
487 | - logger.debug("{} Forwarding msg: {}", address, response); | |
488 | - systemContext.getRpcService().tell(systemContext.getEncodingService() | |
489 | - .convertToProtoDataMessage(sessionAddress.get(), response)); | |
490 | - } else { | |
491 | -// systemContext.getSessionManagerActor().tell(response, ActorRef.noSender()); | |
492 | - } | |
493 | - } | |
494 | - | |
495 | 480 | void processCredentialsUpdate() { |
496 | 481 | sessions.forEach(this::closeSession); |
497 | 482 | attributeSubscriptions.clear(); | ... | ... |
... | ... | @@ -37,7 +37,6 @@ import org.thingsboard.server.common.data.id.EntityId; |
37 | 37 | import org.thingsboard.server.common.data.id.TenantId; |
38 | 38 | import org.thingsboard.server.common.data.plugin.ComponentLifecycleEvent; |
39 | 39 | import org.thingsboard.server.common.msg.TbActorMsg; |
40 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | |
41 | 40 | import org.thingsboard.server.common.msg.cluster.ClusterEventMsg; |
42 | 41 | import org.thingsboard.server.common.msg.cluster.SendToClusterMsg; |
43 | 42 | import org.thingsboard.server.common.msg.cluster.ServerAddress; | ... | ... |
application/src/main/java/org/thingsboard/server/actors/shared/SessionTimeoutMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.actors.shared; | |
17 | - | |
18 | -import lombok.Data; | |
19 | -import org.thingsboard.server.common.msg.MsgType; | |
20 | -import org.thingsboard.server.common.msg.TbActorMsg; | |
21 | - | |
22 | -import java.io.Serializable; | |
23 | - | |
24 | -@Data | |
25 | -public class SessionTimeoutMsg implements Serializable, TbActorMsg { | |
26 | - | |
27 | - private static final long serialVersionUID = 1L; | |
28 | - | |
29 | - private final SessionId sessionId; | |
30 | - | |
31 | - @Override | |
32 | - public MsgType getMsgType() { | |
33 | - return MsgType.SESSION_TIMEOUT_MSG; | |
34 | - } | |
35 | -} |
... | ... | @@ -59,7 +59,6 @@ import org.thingsboard.server.common.data.kv.ReadTsKvQuery; |
59 | 59 | import org.thingsboard.server.common.data.kv.StringDataEntry; |
60 | 60 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
61 | 61 | import org.thingsboard.server.common.msg.cluster.SendToClusterMsg; |
62 | -import org.thingsboard.server.common.msg.core.TelemetryUploadRequest; | |
63 | 62 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
64 | 63 | import org.thingsboard.server.dao.attributes.AttributesService; |
65 | 64 | import org.thingsboard.server.dao.timeseries.TimeseriesService; |
... | ... | @@ -352,7 +351,7 @@ public class TelemetryController extends BaseController { |
352 | 351 | } |
353 | 352 | |
354 | 353 | private DeferredResult<ResponseEntity> saveTelemetry(EntityId entityIdSrc, String requestBody, long ttl) throws ThingsboardException { |
355 | - TelemetryUploadRequest telemetryRequest; | |
354 | + Map<Long, List<KvEntry>> telemetryRequest; | |
356 | 355 | JsonElement telemetryJson; |
357 | 356 | try { |
358 | 357 | telemetryJson = new JsonParser().parse(requestBody); |
... | ... | @@ -360,12 +359,12 @@ public class TelemetryController extends BaseController { |
360 | 359 | return getImmediateDeferredResult("Unable to parse timeseries payload: Invalid JSON body!", HttpStatus.BAD_REQUEST); |
361 | 360 | } |
362 | 361 | try { |
363 | - telemetryRequest = JsonConverter.convertToTelemetry(telemetryJson); | |
362 | + telemetryRequest = JsonConverter.convertToTelemetry(telemetryJson, System.currentTimeMillis()); | |
364 | 363 | } catch (Exception e) { |
365 | 364 | return getImmediateDeferredResult("Unable to parse timeseries payload. Invalid JSON body: " + e.getMessage(), HttpStatus.BAD_REQUEST); |
366 | 365 | } |
367 | 366 | List<TsKvEntry> entries = new ArrayList<>(); |
368 | - for (Map.Entry<Long, List<KvEntry>> entry : telemetryRequest.getData().entrySet()) { | |
367 | + for (Map.Entry<Long, List<KvEntry>> entry : telemetryRequest.entrySet()) { | |
369 | 368 | for (KvEntry kv : entry.getValue()) { |
370 | 369 | entries.add(new BasicTsKvEntry(entry.getKey(), kv)); |
371 | 370 | } | ... | ... |
... | ... | @@ -22,11 +22,8 @@ import org.thingsboard.rule.engine.api.msg.ToDeviceActorNotificationMsg; |
22 | 22 | import org.thingsboard.server.common.data.id.DeviceId; |
23 | 23 | import org.thingsboard.server.common.data.id.TenantId; |
24 | 24 | import org.thingsboard.server.common.msg.MsgType; |
25 | -import org.thingsboard.server.common.msg.cluster.ServerAddress; | |
26 | 25 | import org.thingsboard.server.common.msg.core.ToServerRpcResponseMsg; |
27 | 26 | |
28 | -import java.util.Optional; | |
29 | - | |
30 | 27 | /** |
31 | 28 | * Created by ashvayka on 16.04.18. |
32 | 29 | */ | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/aware/SessionAwareMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.aware; | |
17 | - | |
18 | -public interface SessionAwareMsg { | |
19 | - | |
20 | - SessionId getSessionId(); | |
21 | - | |
22 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/ActorSystemToDeviceSessionActorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.TbActorMsg; | |
19 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | |
20 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
21 | - | |
22 | -import java.io.Serializable; | |
23 | - | |
24 | -/** | |
25 | - * @author Andrew Shvayka | |
26 | - */ | |
27 | -public interface ActorSystemToDeviceSessionActorMsg extends SessionAwareMsg, Serializable, TbActorMsg { | |
28 | - | |
29 | - ToDeviceMsg getMsg(); | |
30 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/AttributesSubscribeMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | - | |
21 | -/** | |
22 | - * @author Andrew Shvayka | |
23 | - */ | |
24 | -public class AttributesSubscribeMsg implements FromDeviceMsg { | |
25 | - @Override | |
26 | - public SessionMsgType getMsgType() { | |
27 | - return SessionMsgType.SUBSCRIBE_ATTRIBUTES_REQUEST; | |
28 | - } | |
29 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/AttributesUnsubscribeMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -/** | |
23 | - * @author Andrew Shvayka | |
24 | - */ | |
25 | -public class AttributesUnsubscribeMsg implements FromDeviceMsg { | |
26 | - @Override | |
27 | - public SessionMsgType getMsgType() { | |
28 | - return SessionMsgType.UNSUBSCRIBE_ATTRIBUTES_REQUEST; | |
29 | - } | |
30 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/AttributesUpdateNotification.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.ToString; | |
19 | -import org.thingsboard.server.common.msg.kv.AttributesKVMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
23 | - | |
24 | -@ToString | |
25 | -public class AttributesUpdateNotification implements ToDeviceMsg { | |
26 | - | |
27 | - private static final long serialVersionUID = 1L; | |
28 | - | |
29 | - private AttributesKVMsg data; | |
30 | - | |
31 | - public AttributesUpdateNotification(AttributesKVMsg data) { | |
32 | - this.data = data; | |
33 | - } | |
34 | - | |
35 | - @Override | |
36 | - public boolean isSuccess() { | |
37 | - return true; | |
38 | - } | |
39 | - | |
40 | - public SessionMsgType getSessionMsgType() { | |
41 | - return SessionMsgType.ATTRIBUTES_UPDATE_NOTIFICATION; | |
42 | - } | |
43 | - | |
44 | - public AttributesKVMsg getData() { | |
45 | - return data; | |
46 | - } | |
47 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/AttributesUpdateRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.util.Set; | |
19 | - | |
20 | -import org.thingsboard.server.common.data.kv.AttributeKvEntry; | |
21 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
22 | -import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; | |
23 | - | |
24 | -public interface AttributesUpdateRequest extends FromDeviceRequestMsg { | |
25 | - | |
26 | - Set<AttributeKvEntry> getAttributes(); | |
27 | - | |
28 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicAttributesUpdateRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.util.Collection; | |
19 | -import java.util.LinkedHashSet; | |
20 | -import java.util.Set; | |
21 | - | |
22 | -import org.thingsboard.server.common.data.kv.AttributeKvEntry; | |
23 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
24 | - | |
25 | -public class BasicAttributesUpdateRequest extends BasicRequest implements AttributesUpdateRequest { | |
26 | - | |
27 | - private static final long serialVersionUID = 1L; | |
28 | - | |
29 | - private final Set<AttributeKvEntry> data; | |
30 | - | |
31 | - public BasicAttributesUpdateRequest() { | |
32 | - this(DEFAULT_REQUEST_ID); | |
33 | - } | |
34 | - | |
35 | - public BasicAttributesUpdateRequest(Integer requestId) { | |
36 | - super(requestId); | |
37 | - this.data = new LinkedHashSet<>(); | |
38 | - } | |
39 | - | |
40 | - public void add(AttributeKvEntry entry) { | |
41 | - this.data.add(entry); | |
42 | - } | |
43 | - | |
44 | - public void add(Collection<AttributeKvEntry> entries) { | |
45 | - this.data.addAll(entries); | |
46 | - } | |
47 | - | |
48 | - @Override | |
49 | - public SessionMsgType getMsgType() { | |
50 | - return SessionMsgType.POST_ATTRIBUTES_REQUEST; | |
51 | - } | |
52 | - | |
53 | - @Override | |
54 | - public Set<AttributeKvEntry> getAttributes() { | |
55 | - return data; | |
56 | - } | |
57 | - | |
58 | - @Override | |
59 | - public String toString() { | |
60 | - return "BasicAttributesUpdateRequest [data=" + data + "]"; | |
61 | - } | |
62 | - | |
63 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicCommandAckResponse.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | - | |
21 | -public class BasicCommandAckResponse extends BasicResponseMsg<Integer> implements StatusCodeResponse { | |
22 | - | |
23 | - private static final long serialVersionUID = 1L; | |
24 | - | |
25 | - public static BasicCommandAckResponse onSuccess(SessionMsgType requestMsgType, Integer requestId) { | |
26 | - return BasicCommandAckResponse.onSuccess(requestMsgType, requestId, 200); | |
27 | - } | |
28 | - | |
29 | - public static BasicCommandAckResponse onSuccess(SessionMsgType requestMsgType, Integer requestId, Integer code) { | |
30 | - return new BasicCommandAckResponse(requestMsgType, requestId, true, null, code); | |
31 | - } | |
32 | - | |
33 | - public static BasicCommandAckResponse onError(SessionMsgType requestMsgType, Integer requestId, Exception error) { | |
34 | - return new BasicCommandAckResponse(requestMsgType, requestId, false, error, null); | |
35 | - } | |
36 | - | |
37 | - private BasicCommandAckResponse(SessionMsgType requestMsgType, Integer requestId, boolean success, Exception error, Integer code) { | |
38 | - super(requestMsgType, requestId, SessionMsgType.TO_DEVICE_RPC_RESPONSE_ACK, success, error, code); | |
39 | - } | |
40 | - | |
41 | - @Override | |
42 | - public String toString() { | |
43 | - return "BasicStatusCodeResponse []"; | |
44 | - } | |
45 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicGetAttributesRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.ToString; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -import java.util.Collections; | |
23 | -import java.util.Optional; | |
24 | -import java.util.Set; | |
25 | - | |
26 | -@ToString | |
27 | -public class BasicGetAttributesRequest extends BasicRequest implements GetAttributesRequest { | |
28 | - | |
29 | - private static final long serialVersionUID = 1L; | |
30 | - | |
31 | - private final Set<String> clientKeys; | |
32 | - private final Set<String> sharedKeys; | |
33 | - | |
34 | - public BasicGetAttributesRequest(Integer requestId) { | |
35 | - this(requestId, Collections.emptySet(), Collections.emptySet()); | |
36 | - } | |
37 | - | |
38 | - public BasicGetAttributesRequest(Integer requestId, Set<String> clientKeys, Set<String> sharedKeys) { | |
39 | - super(requestId); | |
40 | - this.clientKeys = clientKeys; | |
41 | - this.sharedKeys = sharedKeys; | |
42 | - } | |
43 | - | |
44 | - @Override | |
45 | - public SessionMsgType getMsgType() { | |
46 | - return SessionMsgType.GET_ATTRIBUTES_REQUEST; | |
47 | - } | |
48 | - | |
49 | - @Override | |
50 | - public Optional<Set<String>> getClientAttributeNames() { | |
51 | - return Optional.ofNullable(clientKeys); | |
52 | - } | |
53 | - | |
54 | - @Override | |
55 | - public Optional<Set<String>> getSharedAttributeNames() { | |
56 | - return Optional.ofNullable(sharedKeys); | |
57 | - } | |
58 | - | |
59 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicGetAttributesResponse.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.ToString; | |
19 | -import org.thingsboard.server.common.msg.kv.AttributesKVMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | - | |
23 | -@ToString | |
24 | -public class BasicGetAttributesResponse extends BasicResponseMsg<AttributesKVMsg> implements GetAttributesResponse { | |
25 | - | |
26 | - private static final long serialVersionUID = 1L; | |
27 | - | |
28 | - public static BasicGetAttributesResponse onSuccess(SessionMsgType requestMsgType, int requestId, AttributesKVMsg code) { | |
29 | - return new BasicGetAttributesResponse(requestMsgType, requestId, true, null, code); | |
30 | - } | |
31 | - | |
32 | - public static BasicGetAttributesResponse onError(SessionMsgType requestMsgType, int requestId, Exception error) { | |
33 | - return new BasicGetAttributesResponse(requestMsgType, requestId, false, error, null); | |
34 | - } | |
35 | - | |
36 | - private BasicGetAttributesResponse(SessionMsgType requestMsgType, int requestId, boolean success, Exception error, AttributesKVMsg code) { | |
37 | - super(requestMsgType, requestId, SessionMsgType.GET_ATTRIBUTES_RESPONSE, success, error, code); | |
38 | - } | |
39 | - | |
40 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.io.Serializable; | |
19 | - | |
20 | -/** | |
21 | - * @author Andrew Shvayka | |
22 | - */ | |
23 | -public class BasicRequest implements Serializable { | |
24 | - | |
25 | - public static final Integer DEFAULT_REQUEST_ID = 0; | |
26 | - | |
27 | - private final Integer requestId; | |
28 | - | |
29 | - public BasicRequest(Integer requestId) { | |
30 | - this.requestId = requestId; | |
31 | - } | |
32 | - | |
33 | - public Integer getRequestId() { | |
34 | - return requestId; | |
35 | - } | |
36 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicResponseMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.io.Serializable; | |
19 | -import java.util.Optional; | |
20 | - | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
23 | - | |
24 | - | |
25 | -public class BasicResponseMsg<T extends Serializable> implements ResponseMsg<T> { | |
26 | - | |
27 | - private static final long serialVersionUID = 1L; | |
28 | - | |
29 | - private final SessionMsgType requestMsgType; | |
30 | - private final Integer requestId; | |
31 | - private final SessionMsgType sessionMsgType; | |
32 | - private final boolean success; | |
33 | - private final T data; | |
34 | - private final Exception error; | |
35 | - | |
36 | - protected BasicResponseMsg(SessionMsgType requestMsgType, Integer requestId, SessionMsgType sessionMsgType, boolean success, Exception error, T data) { | |
37 | - super(); | |
38 | - this.requestMsgType = requestMsgType; | |
39 | - this.requestId = requestId; | |
40 | - this.sessionMsgType = sessionMsgType; | |
41 | - this.success = success; | |
42 | - this.error = error; | |
43 | - this.data = data; | |
44 | - } | |
45 | - | |
46 | - @Override | |
47 | - public SessionMsgType getRequestMsgType() { | |
48 | - return requestMsgType; | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public Integer getRequestId() { | |
53 | - return requestId; | |
54 | - } | |
55 | - | |
56 | - @Override | |
57 | - public boolean isSuccess() { | |
58 | - return success; | |
59 | - } | |
60 | - | |
61 | - @Override | |
62 | - public Optional<Exception> getError() { | |
63 | - return Optional.ofNullable(error); | |
64 | - } | |
65 | - | |
66 | - @Override | |
67 | - public Optional<T> getData() { | |
68 | - return Optional.ofNullable(data); | |
69 | - } | |
70 | - | |
71 | - @Override | |
72 | - public String toString() { | |
73 | - return "BasicResponseMsg [success=" + success + ", data=" + data + ", error=" + error + "]"; | |
74 | - } | |
75 | - | |
76 | - public SessionMsgType getSessionMsgType() { | |
77 | - return sessionMsgType; | |
78 | - } | |
79 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicStatusCodeResponse.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.ToString; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -@ToString | |
23 | -public class BasicStatusCodeResponse extends BasicResponseMsg<Integer> implements StatusCodeResponse { | |
24 | - | |
25 | - private static final long serialVersionUID = 1L; | |
26 | - | |
27 | - public static BasicStatusCodeResponse onSuccess(SessionMsgType requestMsgType, Integer requestId) { | |
28 | - return BasicStatusCodeResponse.onSuccess(requestMsgType, requestId, 0); | |
29 | - } | |
30 | - | |
31 | - public static BasicStatusCodeResponse onSuccess(SessionMsgType requestMsgType, Integer requestId, Integer code) { | |
32 | - return new BasicStatusCodeResponse(requestMsgType, requestId, true, null, code); | |
33 | - } | |
34 | - | |
35 | - public static BasicStatusCodeResponse onError(SessionMsgType requestMsgType, Integer requestId, Exception error) { | |
36 | - return new BasicStatusCodeResponse(requestMsgType, requestId, false, error, null); | |
37 | - } | |
38 | - | |
39 | - private BasicStatusCodeResponse(SessionMsgType requestMsgType, Integer requestId, boolean success, Exception error, Integer code) { | |
40 | - super(requestMsgType, requestId, SessionMsgType.STATUS_CODE_RESPONSE, success, error, code); | |
41 | - } | |
42 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/BasicTelemetryUploadRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.util.ArrayList; | |
19 | -import java.util.HashMap; | |
20 | -import java.util.List; | |
21 | -import java.util.Map; | |
22 | - | |
23 | -import org.thingsboard.server.common.data.kv.KvEntry; | |
24 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
25 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
26 | - | |
27 | -public class BasicTelemetryUploadRequest extends BasicRequest implements TelemetryUploadRequest { | |
28 | - | |
29 | - private static final long serialVersionUID = 1L; | |
30 | - | |
31 | - private final Map<Long, List<KvEntry>> data; | |
32 | - | |
33 | - public BasicTelemetryUploadRequest() { | |
34 | - this(DEFAULT_REQUEST_ID); | |
35 | - } | |
36 | - | |
37 | - public BasicTelemetryUploadRequest(Integer requestId) { | |
38 | - super(requestId); | |
39 | - this.data = new HashMap<>(); | |
40 | - } | |
41 | - | |
42 | - public void add(long ts, KvEntry entry) { | |
43 | - List<KvEntry> tsEntries = data.get(ts); | |
44 | - if (tsEntries == null) { | |
45 | - tsEntries = new ArrayList<>(); | |
46 | - data.put(ts, tsEntries); | |
47 | - } | |
48 | - tsEntries.add(entry); | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public SessionMsgType getMsgType() { | |
53 | - return SessionMsgType.POST_TELEMETRY_REQUEST; | |
54 | - } | |
55 | - | |
56 | - @Override | |
57 | - public Map<Long, List<KvEntry>> getData() { | |
58 | - return data; | |
59 | - } | |
60 | - | |
61 | - @Override | |
62 | - public String toString() { | |
63 | - return "BasicTelemetryUploadRequest [data=" + data + "]"; | |
64 | - } | |
65 | - | |
66 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/GetAttributesRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.util.Optional; | |
19 | -import java.util.Set; | |
20 | - | |
21 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
22 | -import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; | |
23 | - | |
24 | -public interface GetAttributesRequest extends FromDeviceRequestMsg { | |
25 | - | |
26 | - Optional<Set<String>> getClientAttributeNames(); | |
27 | - Optional<Set<String>> getSharedAttributeNames(); | |
28 | - | |
29 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/GetAttributesResponse.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.kv.AttributesKVMsg; | |
19 | - | |
20 | -public interface GetAttributesResponse extends ResponseMsg<AttributesKVMsg> { | |
21 | - | |
22 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/ResponseMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.io.Serializable; | |
19 | -import java.util.Optional; | |
20 | - | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
23 | - | |
24 | -public interface ResponseMsg<T extends Serializable> extends ToDeviceMsg { | |
25 | - | |
26 | - SessionMsgType getRequestMsgType(); | |
27 | - | |
28 | - Integer getRequestId(); | |
29 | - | |
30 | - Optional<Exception> getError(); | |
31 | - | |
32 | - Optional<T> getData(); | |
33 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/RpcSubscribeMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -/** | |
23 | - * @author Andrew Shvayka | |
24 | - */ | |
25 | -public class RpcSubscribeMsg implements FromDeviceMsg { | |
26 | - @Override | |
27 | - public SessionMsgType getMsgType() { | |
28 | - return SessionMsgType.SUBSCRIBE_RPC_COMMANDS_REQUEST; | |
29 | - } | |
30 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/RpcUnsubscribeMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -/** | |
23 | - * @author Andrew Shvayka | |
24 | - */ | |
25 | -public class RpcUnsubscribeMsg implements FromDeviceMsg { | |
26 | - @Override | |
27 | - public SessionMsgType getMsgType() { | |
28 | - return SessionMsgType.UNSUBSCRIBE_RPC_COMMANDS_REQUEST; | |
29 | - } | |
30 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/RuleEngineError.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -/** | |
19 | - * @author Andrew Shvayka | |
20 | - */ | |
21 | - | |
22 | -public enum RuleEngineError { | |
23 | - | |
24 | - QUEUE_PUT_TIMEOUT(true), SERVER_ERROR(true), TIMEOUT; | |
25 | - | |
26 | - private final boolean critical; | |
27 | - | |
28 | - RuleEngineError() { | |
29 | - this(false); | |
30 | - } | |
31 | - | |
32 | - RuleEngineError(boolean critical) { | |
33 | - this.critical = critical; | |
34 | - } | |
35 | - | |
36 | - public boolean isCritical() { | |
37 | - return critical; | |
38 | - } | |
39 | - | |
40 | - public int getPriority() { | |
41 | - return ordinal(); | |
42 | - } | |
43 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/RuleEngineErrorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.Data; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
22 | - | |
23 | -/** | |
24 | - * @author Andrew Shvayka | |
25 | - */ | |
26 | -@Data | |
27 | -public class RuleEngineErrorMsg implements ToDeviceMsg { | |
28 | - | |
29 | - private final SessionMsgType inSessionMsgType; | |
30 | - private final RuleEngineError error; | |
31 | - | |
32 | - @Override | |
33 | - public boolean isSuccess() { | |
34 | - return false; | |
35 | - } | |
36 | - | |
37 | - public SessionMsgType getSessionMsgType() { | |
38 | - return SessionMsgType.RULE_ENGINE_ERROR; | |
39 | - } | |
40 | - | |
41 | - public String getErrorMsg() { | |
42 | - switch (error) { | |
43 | - case QUEUE_PUT_TIMEOUT: | |
44 | - return "Timeout during persistence of the message to the queue!"; | |
45 | - case SERVER_ERROR: | |
46 | - return "Error during processing of message by the server!"; | |
47 | - case TIMEOUT: | |
48 | - return "Timeout during processing of message by the server!"; | |
49 | - default: | |
50 | - throw new RuntimeException("Error " + error + " is not supported!"); | |
51 | - } | |
52 | - } | |
53 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/SessionCloseMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -/** | |
23 | - * @author Andrew Shvayka | |
24 | - */ | |
25 | -public class SessionCloseMsg implements FromDeviceMsg { | |
26 | - @Override | |
27 | - public SessionMsgType getMsgType() { | |
28 | - return SessionMsgType.SESSION_CLOSE; | |
29 | - } | |
30 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/SessionCloseNotification.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.ToString; | |
19 | -import org.thingsboard.server.common.msg.kv.AttributesKVMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
23 | - | |
24 | -@ToString | |
25 | -public class SessionCloseNotification implements ToDeviceMsg { | |
26 | - | |
27 | - private static final long serialVersionUID = 1L; | |
28 | - | |
29 | - @Override | |
30 | - public boolean isSuccess() { | |
31 | - return true; | |
32 | - } | |
33 | - | |
34 | - public SessionMsgType getSessionMsgType() { | |
35 | - return SessionMsgType.SESSION_CLOSE; | |
36 | - } | |
37 | - | |
38 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/SessionOpenMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.Data; | |
19 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -/** | |
23 | - * @author Andrew Shvayka | |
24 | - */ | |
25 | -@Data | |
26 | -public class SessionOpenMsg implements FromDeviceMsg { | |
27 | - | |
28 | - @Override | |
29 | - public SessionMsgType getMsgType() { | |
30 | - return SessionMsgType.SESSION_OPEN; | |
31 | - } | |
32 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/StatusCodeResponse.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -public interface StatusCodeResponse extends ResponseMsg<Integer>{ | |
19 | - | |
20 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/TelemetryUploadRequest.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import java.util.List; | |
19 | -import java.util.Map; | |
20 | - | |
21 | -import org.thingsboard.server.common.data.kv.KvEntry; | |
22 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
23 | -import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; | |
24 | - | |
25 | -public interface TelemetryUploadRequest extends FromDeviceRequestMsg { | |
26 | - | |
27 | - Map<Long, List<KvEntry>> getData(); | |
28 | - | |
29 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/ToDeviceRpcRequestMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.Data; | |
19 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
22 | - | |
23 | -/** | |
24 | - * @author Andrew Shvayka | |
25 | - */ | |
26 | -@Data | |
27 | -public class ToDeviceRpcRequestMsg implements ToDeviceMsg { | |
28 | - | |
29 | - private final int requestId; | |
30 | - private final String method; | |
31 | - private final String params; | |
32 | - | |
33 | - public SessionMsgType getSessionMsgType() { | |
34 | - return SessionMsgType.TO_DEVICE_RPC_REQUEST; | |
35 | - } | |
36 | - | |
37 | - @Override | |
38 | - public boolean isSuccess() { | |
39 | - return true; | |
40 | - } | |
41 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/ToDeviceRpcResponseMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.Data; | |
19 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | - | |
23 | -/** | |
24 | - * @author Andrew Shvayka | |
25 | - */ | |
26 | -@Data | |
27 | -public class ToDeviceRpcResponseMsg implements FromDeviceMsg { | |
28 | - | |
29 | - private final int requestId; | |
30 | - private final String data; | |
31 | - | |
32 | - @Override | |
33 | - public SessionMsgType getMsgType() { | |
34 | - return SessionMsgType.TO_DEVICE_RPC_RESPONSE; | |
35 | - } | |
36 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/core/ToServerRpcRequestMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.core; | |
17 | - | |
18 | -import lombok.Data; | |
19 | -import org.thingsboard.server.common.msg.session.FromDeviceRequestMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | - | |
22 | -/** | |
23 | - * @author Andrew Shvayka | |
24 | - */ | |
25 | -@Data | |
26 | -public class ToServerRpcRequestMsg implements FromDeviceRequestMsg { | |
27 | - | |
28 | - private final Integer requestId; | |
29 | - private final String method; | |
30 | - private final String params; | |
31 | - | |
32 | - @Override | |
33 | - public SessionMsgType getMsgType() { | |
34 | - return SessionMsgType.TO_SERVER_RPC_REQUEST; | |
35 | - } | |
36 | -} |
... | ... | @@ -16,25 +16,16 @@ |
16 | 16 | package org.thingsboard.server.common.msg.core; |
17 | 17 | |
18 | 18 | import lombok.Data; |
19 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
20 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
21 | -import org.thingsboard.server.common.msg.session.SessionMsgType; | |
22 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
23 | 19 | |
24 | 20 | /** |
25 | 21 | * @author Andrew Shvayka |
26 | 22 | */ |
27 | 23 | @Data |
28 | -public class ToServerRpcResponseMsg implements ToDeviceMsg { | |
24 | +public class ToServerRpcResponseMsg { | |
29 | 25 | |
30 | 26 | private final int requestId; |
31 | 27 | private final String data; |
32 | 28 | |
33 | - public SessionMsgType getSessionMsgType() { | |
34 | - return SessionMsgType.TO_SERVER_RPC_RESPONSE; | |
35 | - } | |
36 | - | |
37 | - @Override | |
38 | 29 | public boolean isSuccess() { |
39 | 30 | return true; |
40 | 31 | } | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/session/AdaptorToSessionActorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -public interface AdaptorToSessionActorMsg extends SessionMsg { | |
19 | - | |
20 | - FromDeviceMsg getMsg(); | |
21 | - | |
22 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/BasicAdaptorToSessionActorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -public class BasicAdaptorToSessionActorMsg extends BasicSessionMsg implements AdaptorToSessionActorMsg { | |
19 | - | |
20 | - private final FromDeviceMsg msg; | |
21 | - | |
22 | - public BasicAdaptorToSessionActorMsg(SessionContext ctx, FromDeviceMsg msg) { | |
23 | - super(ctx); | |
24 | - this.msg = msg; | |
25 | - } | |
26 | - | |
27 | - @Override | |
28 | - public FromDeviceMsg getMsg() { | |
29 | - return msg; | |
30 | - } | |
31 | - | |
32 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/BasicSessionActorToAdaptorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -public class BasicSessionActorToAdaptorMsg extends BasicSessionMsg implements SessionActorToAdaptorMsg { | |
19 | - | |
20 | - private final ToDeviceMsg msg; | |
21 | - | |
22 | - public BasicSessionActorToAdaptorMsg(SessionContext ctx, ToDeviceMsg msg) { | |
23 | - super(ctx); | |
24 | - this.msg = msg; | |
25 | - } | |
26 | - | |
27 | - @Override | |
28 | - public ToDeviceMsg getMsg() { | |
29 | - return msg; | |
30 | - } | |
31 | - | |
32 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/BasicSessionMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -public class BasicSessionMsg implements SessionMsg { | |
19 | - | |
20 | - private final SessionContext ctx; | |
21 | - | |
22 | - public BasicSessionMsg(SessionContext ctx) { | |
23 | - super(); | |
24 | - this.ctx = ctx; | |
25 | - } | |
26 | - | |
27 | - @Override | |
28 | - public SessionId getSessionId() { | |
29 | - return ctx.getSessionId(); | |
30 | - } | |
31 | - | |
32 | - @Override | |
33 | - public SessionContext getSessionContext() { | |
34 | - return ctx; | |
35 | - } | |
36 | - | |
37 | - @Override | |
38 | - public String toString() { | |
39 | - return "BasicSessionMsg [ctx=" + ctx + "]"; | |
40 | - } | |
41 | - | |
42 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/BasicTransportToDeviceSessionActorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -import org.thingsboard.server.common.data.Device; | |
19 | -import org.thingsboard.server.common.data.id.CustomerId; | |
20 | -import org.thingsboard.server.common.data.id.DeviceId; | |
21 | -import org.thingsboard.server.common.data.id.TenantId; | |
22 | -import org.thingsboard.server.common.msg.MsgType; | |
23 | - | |
24 | -public class BasicTransportToDeviceSessionActorMsg implements TransportToDeviceSessionActorMsg { | |
25 | - | |
26 | - private final TenantId tenantId; | |
27 | - private final CustomerId customerId; | |
28 | - private final DeviceId deviceId; | |
29 | - private final AdaptorToSessionActorMsg msg; | |
30 | - | |
31 | - public BasicTransportToDeviceSessionActorMsg(Device device, AdaptorToSessionActorMsg msg) { | |
32 | - super(); | |
33 | - this.tenantId = device.getTenantId(); | |
34 | - this.customerId = device.getCustomerId(); | |
35 | - this.deviceId = device.getId(); | |
36 | - this.msg = msg; | |
37 | - } | |
38 | - | |
39 | - @Override | |
40 | - public DeviceId getDeviceId() { | |
41 | - return deviceId; | |
42 | - } | |
43 | - | |
44 | - @Override | |
45 | - public CustomerId getCustomerId() { | |
46 | - return customerId; | |
47 | - } | |
48 | - | |
49 | - public TenantId getTenantId() { | |
50 | - return tenantId; | |
51 | - } | |
52 | - | |
53 | - @Override | |
54 | - public SessionId getSessionId() { | |
55 | - return msg.getSessionId(); | |
56 | - } | |
57 | - | |
58 | - @Override | |
59 | - public AdaptorToSessionActorMsg getSessionMsg() { | |
60 | - return msg; | |
61 | - } | |
62 | - | |
63 | - @Override | |
64 | - public String toString() { | |
65 | - return "BasicTransportToDeviceSessionActorMsg [tenantId=" + tenantId + ", customerId=" + customerId + ", deviceId=" + deviceId + ", msg=" + msg | |
66 | - + "]"; | |
67 | - } | |
68 | - | |
69 | - @Override | |
70 | - public MsgType getMsgType() { | |
71 | - return MsgType.TRANSPORT_TO_DEVICE_SESSION_ACTOR_MSG; | |
72 | - } | |
73 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/FromDeviceMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -import java.io.Serializable; | |
19 | - | |
20 | -public interface FromDeviceMsg extends Serializable { | |
21 | - | |
22 | - SessionMsgType getMsgType(); | |
23 | - | |
24 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/FromDeviceRequestMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -/** | |
19 | - * @author Andrew Shvayka | |
20 | - */ | |
21 | -public interface FromDeviceRequestMsg extends FromDeviceMsg { | |
22 | - | |
23 | - Integer getRequestId(); | |
24 | - | |
25 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/SessionActorToAdaptorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -public interface SessionActorToAdaptorMsg extends SessionMsg { | |
19 | - | |
20 | - ToDeviceMsg getMsg(); | |
21 | - | |
22 | -} |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |
common/message/src/main/java/org/thingsboard/server/common/msg/session/SessionCtrlMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.TbActorMsg; | |
19 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | |
20 | - | |
21 | -public interface SessionCtrlMsg extends SessionAwareMsg, TbActorMsg { | |
22 | - | |
23 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/SessionMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | |
19 | - | |
20 | -public interface SessionMsg extends SessionAwareMsg { | |
21 | - | |
22 | - SessionContext getSessionContext(); | |
23 | - | |
24 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/SessionType.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -public enum SessionType { | |
19 | - | |
20 | - SYNC, ASYNC; | |
21 | - | |
22 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/ToDeviceMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -import java.io.Serializable; | |
19 | - | |
20 | -public interface ToDeviceMsg extends Serializable { | |
21 | - | |
22 | - boolean isSuccess(); | |
23 | - | |
24 | - SessionMsgType getSessionMsgType(); | |
25 | - | |
26 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/TransportToDeviceSessionActorMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.TbActorMsg; | |
19 | -import org.thingsboard.server.common.msg.aware.CustomerAwareMsg; | |
20 | -import org.thingsboard.server.common.msg.aware.DeviceAwareMsg; | |
21 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | |
22 | -import org.thingsboard.server.common.msg.aware.TenantAwareMsg; | |
23 | - | |
24 | -public interface TransportToDeviceSessionActorMsg extends DeviceAwareMsg, CustomerAwareMsg, TenantAwareMsg, SessionAwareMsg, TbActorMsg { | |
25 | - | |
26 | - AdaptorToSessionActorMsg getSessionMsg(); | |
27 | - | |
28 | -} |
common/message/src/main/java/org/thingsboard/server/common/msg/session/ctrl/SessionCloseMsg.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.common.msg.session.ctrl; | |
17 | - | |
18 | -import org.thingsboard.server.common.msg.MsgType; | |
19 | -import org.thingsboard.server.common.msg.session.SessionCtrlMsg; | |
20 | - | |
21 | -public class SessionCloseMsg implements SessionCtrlMsg { | |
22 | - | |
23 | - private final SessionId sessionId; | |
24 | - private final boolean revoked; | |
25 | - private final boolean timeout; | |
26 | - | |
27 | - public static SessionCloseMsg onDisconnect(SessionId sessionId) { | |
28 | - return new SessionCloseMsg(sessionId, false, false); | |
29 | - } | |
30 | - | |
31 | - public static SessionCloseMsg onError(SessionId sessionId) { | |
32 | - return new SessionCloseMsg(sessionId, false, false); | |
33 | - } | |
34 | - | |
35 | - public static SessionCloseMsg onTimeout(SessionId sessionId) { | |
36 | - return new SessionCloseMsg(sessionId, false, true); | |
37 | - } | |
38 | - | |
39 | - public static SessionCloseMsg onCredentialsRevoked(SessionId sessionId) { | |
40 | - return new SessionCloseMsg(sessionId, true, false); | |
41 | - } | |
42 | - | |
43 | - private SessionCloseMsg(SessionId sessionId, boolean unauthorized, boolean timeout) { | |
44 | - super(); | |
45 | - this.sessionId = sessionId; | |
46 | - this.revoked = unauthorized; | |
47 | - this.timeout = timeout; | |
48 | - } | |
49 | - | |
50 | - @Override | |
51 | - public SessionId getSessionId() { | |
52 | - return sessionId; | |
53 | - } | |
54 | - | |
55 | - public boolean isCredentialsRevoked() { | |
56 | - return revoked; | |
57 | - } | |
58 | - | |
59 | - public boolean isTimeout() { | |
60 | - return timeout; | |
61 | - } | |
62 | - | |
63 | - @Override | |
64 | - public MsgType getMsgType() { | |
65 | - return MsgType.SESSION_CTRL_MSG; | |
66 | - } | |
67 | -} |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
... | ... | @@ -31,12 +31,6 @@ import org.thingsboard.server.common.data.kv.DoubleDataEntry; |
31 | 31 | import org.thingsboard.server.common.data.kv.KvEntry; |
32 | 32 | import org.thingsboard.server.common.data.kv.LongDataEntry; |
33 | 33 | import org.thingsboard.server.common.data.kv.StringDataEntry; |
34 | -import org.thingsboard.server.common.msg.core.AttributesUpdateRequest; | |
35 | -import org.thingsboard.server.common.msg.core.BasicAttributesUpdateRequest; | |
36 | -import org.thingsboard.server.common.msg.core.BasicRequest; | |
37 | -import org.thingsboard.server.common.msg.core.BasicTelemetryUploadRequest; | |
38 | -import org.thingsboard.server.common.msg.core.TelemetryUploadRequest; | |
39 | -import org.thingsboard.server.common.msg.core.ToDeviceRpcRequestMsg; | |
40 | 34 | import org.thingsboard.server.common.msg.kv.AttributesKVMsg; |
41 | 35 | import org.thingsboard.server.gen.transport.TransportProtos; |
42 | 36 | import org.thingsboard.server.gen.transport.TransportProtos.AttributeUpdateNotificationMsg; |
... | ... | @@ -49,8 +43,12 @@ import org.thingsboard.server.gen.transport.TransportProtos.TsKvListProto; |
49 | 43 | import org.thingsboard.server.gen.transport.TransportProtos.TsKvProto; |
50 | 44 | |
51 | 45 | import java.util.ArrayList; |
46 | +import java.util.HashMap; | |
47 | +import java.util.HashSet; | |
52 | 48 | import java.util.List; |
49 | +import java.util.Map; | |
53 | 50 | import java.util.Map.Entry; |
51 | +import java.util.Set; | |
54 | 52 | import java.util.function.Consumer; |
55 | 53 | import java.util.stream.Collectors; |
56 | 54 | |
... | ... | @@ -60,18 +58,6 @@ public class JsonConverter { |
60 | 58 | private static final String CAN_T_PARSE_VALUE = "Can't parse value: "; |
61 | 59 | private static final String DEVICE_PROPERTY = "device"; |
62 | 60 | |
63 | - public static TelemetryUploadRequest convertToTelemetry(JsonElement jsonObject) throws JsonSyntaxException { | |
64 | - return convertToTelemetry(jsonObject, BasicRequest.DEFAULT_REQUEST_ID); | |
65 | - } | |
66 | - | |
67 | - public static TelemetryUploadRequest convertToTelemetry(JsonElement jsonObject, long ts) throws JsonSyntaxException { | |
68 | - return convertToTelemetry(jsonObject, ts, BasicRequest.DEFAULT_REQUEST_ID); | |
69 | - } | |
70 | - | |
71 | - public static TelemetryUploadRequest convertToTelemetry(JsonElement jsonObject, int requestId) throws JsonSyntaxException { | |
72 | - return convertToTelemetry(jsonObject, System.currentTimeMillis(), requestId); | |
73 | - } | |
74 | - | |
75 | 61 | public static PostTelemetryMsg convertToTelemetryProto(JsonElement jsonObject) throws JsonSyntaxException { |
76 | 62 | long systemTs = System.currentTimeMillis(); |
77 | 63 | PostTelemetryMsg.Builder builder = PostTelemetryMsg.newBuilder(); |
... | ... | @@ -170,74 +156,11 @@ public class JsonConverter { |
170 | 156 | return result; |
171 | 157 | } |
172 | 158 | |
173 | - private static TelemetryUploadRequest convertToTelemetry(JsonElement jsonObject, long systemTs, int requestId) throws JsonSyntaxException { | |
174 | - BasicTelemetryUploadRequest request = new BasicTelemetryUploadRequest(requestId); | |
175 | - if (jsonObject.isJsonObject()) { | |
176 | - parseObject(request, systemTs, jsonObject); | |
177 | - } else if (jsonObject.isJsonArray()) { | |
178 | - jsonObject.getAsJsonArray().forEach(je -> { | |
179 | - if (je.isJsonObject()) { | |
180 | - parseObject(request, systemTs, je.getAsJsonObject()); | |
181 | - } else { | |
182 | - throw new JsonSyntaxException(CAN_T_PARSE_VALUE + je); | |
183 | - } | |
184 | - }); | |
185 | - } else { | |
186 | - throw new JsonSyntaxException(CAN_T_PARSE_VALUE + jsonObject); | |
187 | - } | |
188 | - return request; | |
189 | - } | |
190 | - | |
191 | 159 | public static TransportProtos.ToServerRpcRequestMsg convertToServerRpcRequest(JsonElement json, int requestId) throws JsonSyntaxException { |
192 | 160 | JsonObject object = json.getAsJsonObject(); |
193 | 161 | return TransportProtos.ToServerRpcRequestMsg.newBuilder().setRequestId(requestId).setMethodName(object.get("method").getAsString()).setParams(GSON.toJson(object.get("params"))).build(); |
194 | 162 | } |
195 | 163 | |
196 | - private static void parseObject(BasicTelemetryUploadRequest request, long systemTs, JsonElement jsonObject) { | |
197 | - JsonObject jo = jsonObject.getAsJsonObject(); | |
198 | - if (jo.has("ts") && jo.has("values")) { | |
199 | - parseWithTs(request, jo); | |
200 | - } else { | |
201 | - parseWithoutTs(request, systemTs, jo); | |
202 | - } | |
203 | - } | |
204 | - | |
205 | - private static void parseWithoutTs(BasicTelemetryUploadRequest request, long systemTs, JsonObject jo) { | |
206 | - for (KvEntry entry : parseValues(jo)) { | |
207 | - request.add(systemTs, entry); | |
208 | - } | |
209 | - } | |
210 | - | |
211 | - public static void parseWithTs(BasicTelemetryUploadRequest request, JsonObject jo) { | |
212 | - long ts = jo.get("ts").getAsLong(); | |
213 | - JsonObject valuesObject = jo.get("values").getAsJsonObject(); | |
214 | - for (KvEntry entry : parseValues(valuesObject)) { | |
215 | - request.add(ts, entry); | |
216 | - } | |
217 | - } | |
218 | - | |
219 | - public static List<KvEntry> parseValues(JsonObject valuesObject) { | |
220 | - List<KvEntry> result = new ArrayList<>(); | |
221 | - for (Entry<String, JsonElement> valueEntry : valuesObject.entrySet()) { | |
222 | - JsonElement element = valueEntry.getValue(); | |
223 | - if (element.isJsonPrimitive()) { | |
224 | - JsonPrimitive value = element.getAsJsonPrimitive(); | |
225 | - if (value.isString()) { | |
226 | - result.add(new StringDataEntry(valueEntry.getKey(), value.getAsString())); | |
227 | - } else if (value.isBoolean()) { | |
228 | - result.add(new BooleanDataEntry(valueEntry.getKey(), value.getAsBoolean())); | |
229 | - } else if (value.isNumber()) { | |
230 | - parseNumericValue(result, valueEntry, value); | |
231 | - } else { | |
232 | - throw new JsonSyntaxException(CAN_T_PARSE_VALUE + value); | |
233 | - } | |
234 | - } else { | |
235 | - throw new JsonSyntaxException(CAN_T_PARSE_VALUE + element); | |
236 | - } | |
237 | - } | |
238 | - return result; | |
239 | - } | |
240 | - | |
241 | 164 | private static void parseNumericValue(List<KvEntry> result, Entry<String, JsonElement> valueEntry, JsonPrimitive value) { |
242 | 165 | if (value.getAsString().contains(".")) { |
243 | 166 | result.add(new DoubleDataEntry(valueEntry.getKey(), value.getAsDouble())); |
... | ... | @@ -251,21 +174,6 @@ public class JsonConverter { |
251 | 174 | } |
252 | 175 | } |
253 | 176 | |
254 | - public static AttributesUpdateRequest convertToAttributes(JsonElement element) { | |
255 | - return convertToAttributes(element, BasicRequest.DEFAULT_REQUEST_ID); | |
256 | - } | |
257 | - | |
258 | - public static AttributesUpdateRequest convertToAttributes(JsonElement element, int requestId) { | |
259 | - if (element.isJsonObject()) { | |
260 | - BasicAttributesUpdateRequest request = new BasicAttributesUpdateRequest(requestId); | |
261 | - long ts = System.currentTimeMillis(); | |
262 | - request.add(parseValues(element.getAsJsonObject()).stream().map(kv -> new BaseAttributeKvEntry(kv, ts)).collect(Collectors.toList())); | |
263 | - return request; | |
264 | - } else { | |
265 | - throw new JsonSyntaxException(CAN_T_PARSE_VALUE + element); | |
266 | - } | |
267 | - } | |
268 | - | |
269 | 177 | public static JsonObject toJson(GetAttributeResponseMsg payload) { |
270 | 178 | JsonObject result = new JsonObject(); |
271 | 179 | if (payload.getClientAttributeListCount() > 0) { |
... | ... | @@ -425,16 +333,6 @@ public class JsonConverter { |
425 | 333 | }; |
426 | 334 | } |
427 | 335 | |
428 | - public static JsonObject toJson(ToDeviceRpcRequestMsg msg, boolean includeRequestId) { | |
429 | - JsonObject result = new JsonObject(); | |
430 | - if (includeRequestId) { | |
431 | - result.addProperty("id", msg.getRequestId()); | |
432 | - } | |
433 | - result.addProperty("method", msg.getMethod()); | |
434 | - result.add("params", new JsonParser().parse(msg.getParams())); | |
435 | - return result; | |
436 | - } | |
437 | - | |
438 | 336 | public static JsonElement toJson(TransportProtos.ToServerRpcResponseMsg msg) { |
439 | 337 | if (StringUtils.isEmpty(msg.getError())) { |
440 | 338 | return new JsonParser().parse(msg.getPayload()); |
... | ... | @@ -457,4 +355,76 @@ public class JsonConverter { |
457 | 355 | result.add("data", JsonConverter.toJson(rpcRequest, true)); |
458 | 356 | return result; |
459 | 357 | } |
358 | + | |
359 | + public static Set<AttributeKvEntry> convertToAttributes(JsonElement element) { | |
360 | + Set<AttributeKvEntry> result = new HashSet<>(); | |
361 | + long ts = System.currentTimeMillis(); | |
362 | + result.addAll(parseValues(element.getAsJsonObject()).stream().map(kv -> new BaseAttributeKvEntry(kv, ts)).collect(Collectors.toList())); | |
363 | + return result; | |
364 | + } | |
365 | + | |
366 | + private static List<KvEntry> parseValues(JsonObject valuesObject) { | |
367 | + List<KvEntry> result = new ArrayList<>(); | |
368 | + for (Entry<String, JsonElement> valueEntry : valuesObject.entrySet()) { | |
369 | + JsonElement element = valueEntry.getValue(); | |
370 | + if (element.isJsonPrimitive()) { | |
371 | + JsonPrimitive value = element.getAsJsonPrimitive(); | |
372 | + if (value.isString()) { | |
373 | + result.add(new StringDataEntry(valueEntry.getKey(), value.getAsString())); | |
374 | + } else if (value.isBoolean()) { | |
375 | + result.add(new BooleanDataEntry(valueEntry.getKey(), value.getAsBoolean())); | |
376 | + } else if (value.isNumber()) { | |
377 | + parseNumericValue(result, valueEntry, value); | |
378 | + } else { | |
379 | + throw new JsonSyntaxException(CAN_T_PARSE_VALUE + value); | |
380 | + } | |
381 | + } else { | |
382 | + throw new JsonSyntaxException(CAN_T_PARSE_VALUE + element); | |
383 | + } | |
384 | + } | |
385 | + return result; | |
386 | + } | |
387 | + | |
388 | + public static Map<Long, List<KvEntry>> convertToTelemetry(JsonElement jsonObject, long systemTs) throws JsonSyntaxException { | |
389 | + Map<Long, List<KvEntry>> result = new HashMap<>(); | |
390 | + if (jsonObject.isJsonObject()) { | |
391 | + parseObject(result, systemTs, jsonObject); | |
392 | + } else if (jsonObject.isJsonArray()) { | |
393 | + jsonObject.getAsJsonArray().forEach(je -> { | |
394 | + if (je.isJsonObject()) { | |
395 | + parseObject(result, systemTs, je.getAsJsonObject()); | |
396 | + } else { | |
397 | + throw new JsonSyntaxException(CAN_T_PARSE_VALUE + je); | |
398 | + } | |
399 | + }); | |
400 | + } else { | |
401 | + throw new JsonSyntaxException(CAN_T_PARSE_VALUE + jsonObject); | |
402 | + } | |
403 | + return result; | |
404 | + } | |
405 | + | |
406 | + private static void parseObject(Map<Long, List<KvEntry>> result, long systemTs, JsonElement jsonObject) { | |
407 | + JsonObject jo = jsonObject.getAsJsonObject(); | |
408 | + if (jo.has("ts") && jo.has("values")) { | |
409 | + parseWithTs(result, jo); | |
410 | + } else { | |
411 | + parseWithoutTs(result, systemTs, jo); | |
412 | + } | |
413 | + } | |
414 | + | |
415 | + private static void parseWithoutTs(Map<Long, List<KvEntry>> result, long systemTs, JsonObject jo) { | |
416 | + for (KvEntry entry : parseValues(jo)) { | |
417 | + result.computeIfAbsent(systemTs, tmp -> new ArrayList<>()).add(entry); | |
418 | + } | |
419 | + } | |
420 | + | |
421 | + public static void parseWithTs(Map<Long, List<KvEntry>> result, JsonObject jo) { | |
422 | + long ts = jo.get("ts").getAsLong(); | |
423 | + JsonObject valuesObject = jo.get("values").getAsJsonObject(); | |
424 | + for (KvEntry entry : parseValues(valuesObject)) { | |
425 | + result.computeIfAbsent(ts, tmp -> new ArrayList<>()).add(entry); | |
426 | + } | |
427 | + } | |
428 | + | |
429 | + | |
460 | 430 | } | ... | ... |
... | ... | @@ -30,6 +30,8 @@ import java.util.UUID; |
30 | 30 | public abstract class DeviceAwareSessionContext implements SessionContext { |
31 | 31 | |
32 | 32 | @Getter |
33 | + protected final UUID sessionId; | |
34 | + @Getter | |
33 | 35 | private volatile DeviceId deviceId; |
34 | 36 | @Getter |
35 | 37 | private volatile DeviceInfoProto deviceInfo; | ... | ... |
... | ... | @@ -84,7 +84,7 @@ public class TbCopyAttributesToEntityViewNode implements TbNode { |
84 | 84 | long endTime = entityView.getEndTimeMs(); |
85 | 85 | if ((endTime != 0 && endTime > now && startTime < now) || (endTime == 0 && startTime < now)) { |
86 | 86 | Set<AttributeKvEntry> attributes = |
87 | - JsonConverter.convertToAttributes(new JsonParser().parse(msg.getData())).getAttributes(); | |
87 | + JsonConverter.convertToAttributes(new JsonParser().parse(msg.getData())); | |
88 | 88 | List<AttributeKvEntry> filteredAttributes = |
89 | 89 | attributes.stream() |
90 | 90 | .filter(attr -> { | ... | ... |
... | ... | @@ -63,7 +63,7 @@ public class TbMsgAttributesNode implements TbNode { |
63 | 63 | } |
64 | 64 | |
65 | 65 | String src = msg.getData(); |
66 | - Set<AttributeKvEntry> attributes = JsonConverter.convertToAttributes(new JsonParser().parse(src)).getAttributes(); | |
66 | + Set<AttributeKvEntry> attributes = JsonConverter.convertToAttributes(new JsonParser().parse(src)); | |
67 | 67 | ctx.getTelemetryService().saveAndNotify(msg.getOriginator(), config.getScope(), new ArrayList<>(attributes), new TelemetryNodeCallback(ctx, msg)); |
68 | 68 | if (msg.getOriginator().getEntityType() == EntityType.DEVICE && DataConstants.SHARED_SCOPE.equals(config.getScope())) { |
69 | 69 | ctx.getTelemetryService().onSharedAttributesUpdate(ctx.getTenantId(), new DeviceId(msg.getOriginator().getId()), attributes); | ... | ... |
... | ... | @@ -29,7 +29,6 @@ import org.thingsboard.server.common.data.kv.KvEntry; |
29 | 29 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
30 | 30 | import org.thingsboard.server.common.data.plugin.ComponentType; |
31 | 31 | import org.thingsboard.server.common.msg.TbMsg; |
32 | -import org.thingsboard.server.common.msg.core.TelemetryUploadRequest; | |
33 | 32 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
34 | 33 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; |
35 | 34 | |
... | ... | @@ -68,13 +67,13 @@ public class TbMsgTimeseriesNode implements TbNode { |
68 | 67 | if (!StringUtils.isEmpty(tsStr)) { |
69 | 68 | try { |
70 | 69 | ts = Long.parseLong(tsStr); |
71 | - } catch (NumberFormatException e) {} | |
70 | + } catch (NumberFormatException e) { | |
71 | + } | |
72 | 72 | } else { |
73 | 73 | ts = System.currentTimeMillis(); |
74 | 74 | } |
75 | 75 | String src = msg.getData(); |
76 | - TelemetryUploadRequest telemetryUploadRequest = JsonConverter.convertToTelemetry(new JsonParser().parse(src), ts); | |
77 | - Map<Long, List<KvEntry>> tsKvMap = telemetryUploadRequest.getData(); | |
76 | + Map<Long, List<KvEntry>> tsKvMap = JsonConverter.convertToTelemetry(new JsonParser().parse(src), ts); | |
78 | 77 | if (tsKvMap == null) { |
79 | 78 | ctx.tellFailure(msg, new IllegalArgumentException("Msg body is empty: " + src)); |
80 | 79 | return; | ... | ... |
... | ... | @@ -17,7 +17,6 @@ package org.thingsboard.server.transport.coap.adaptors; |
17 | 17 | |
18 | 18 | import java.util.*; |
19 | 19 | |
20 | -import com.google.gson.JsonElement; | |
21 | 20 | import lombok.extern.slf4j.Slf4j; |
22 | 21 | import org.eclipse.californium.core.coap.CoAP.ResponseCode; |
23 | 22 | import org.eclipse.californium.core.coap.Request; |
... | ... | @@ -25,13 +24,8 @@ import org.eclipse.californium.core.coap.Response; |
25 | 24 | import org.springframework.util.StringUtils; |
26 | 25 | import org.thingsboard.server.common.msg.core.*; |
27 | 26 | import org.thingsboard.server.common.msg.kv.AttributesKVMsg; |
28 | -import org.thingsboard.server.common.msg.session.AdaptorToSessionActorMsg; | |
29 | -import org.thingsboard.server.common.msg.session.BasicAdaptorToSessionActorMsg; | |
30 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
31 | 27 | import org.thingsboard.server.common.msg.session.SessionMsgType; |
32 | -import org.thingsboard.server.common.msg.session.SessionActorToAdaptorMsg; | |
33 | 28 | import org.thingsboard.server.common.msg.session.SessionContext; |
34 | -import org.thingsboard.server.common.msg.session.ToDeviceMsg; | |
35 | 29 | import org.thingsboard.server.common.msg.session.ex.ProcessingTimeoutException; |
36 | 30 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; |
37 | 31 | import org.thingsboard.server.common.transport.adaptor.JsonConverter; | ... | ... |
... | ... | @@ -20,10 +20,6 @@ import org.eclipse.californium.core.coap.CoAP.ResponseCode; |
20 | 20 | import org.eclipse.californium.core.coap.Request; |
21 | 21 | import org.eclipse.californium.core.coap.Response; |
22 | 22 | import org.eclipse.californium.core.server.resources.CoapExchange; |
23 | -import org.thingsboard.server.common.msg.session.SessionActorToAdaptorMsg; | |
24 | -import org.thingsboard.server.common.msg.session.SessionCtrlMsg; | |
25 | -import org.thingsboard.server.common.msg.session.SessionType; | |
26 | -import org.thingsboard.server.common.msg.session.ctrl.SessionCloseMsg; | |
27 | 23 | import org.thingsboard.server.common.msg.session.ex.SessionException; |
28 | 24 | import org.thingsboard.server.common.transport.SessionMsgProcessor; |
29 | 25 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; | ... | ... |
... | ... | @@ -34,26 +34,15 @@ import org.thingsboard.server.common.data.Device; |
34 | 34 | import org.thingsboard.server.common.data.id.CustomerId; |
35 | 35 | import org.thingsboard.server.common.data.id.DeviceId; |
36 | 36 | import org.thingsboard.server.common.data.id.TenantId; |
37 | -import org.thingsboard.server.common.data.kv.AttributeKvEntry; | |
38 | -import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry; | |
39 | -import org.thingsboard.server.common.data.kv.LongDataEntry; | |
40 | -import org.thingsboard.server.common.data.kv.StringDataEntry; | |
41 | 37 | import org.thingsboard.server.common.data.security.DeviceCredentialsFilter; |
42 | 38 | import org.thingsboard.server.common.data.security.DeviceCredentialsType; |
43 | 39 | import org.thingsboard.server.common.data.security.DeviceTokenCredentials; |
44 | -import org.thingsboard.server.common.msg.aware.SessionAwareMsg; | |
45 | -import org.thingsboard.server.common.msg.core.BasicGetAttributesResponse; | |
46 | -import org.thingsboard.server.common.msg.core.BasicRequest; | |
47 | -import org.thingsboard.server.common.msg.core.BasicStatusCodeResponse; | |
48 | -import org.thingsboard.server.common.msg.kv.BasicAttributeKVMsg; | |
49 | 40 | import org.thingsboard.server.common.msg.session.*; |
50 | 41 | import org.thingsboard.server.common.transport.SessionMsgProcessor; |
51 | 42 | import org.thingsboard.server.common.transport.auth.DeviceAuthResult; |
52 | 43 | import org.thingsboard.server.common.transport.auth.DeviceAuthService; |
53 | 44 | import org.thingsboard.server.common.transport.quota.host.HostRequestsQuotaService; |
54 | 45 | |
55 | -import java.util.ArrayList; | |
56 | -import java.util.List; | |
57 | 46 | import java.util.Optional; |
58 | 47 | import java.util.UUID; |
59 | 48 | ... | ... |
... | ... | @@ -15,34 +15,20 @@ |
15 | 15 | */ |
16 | 16 | package org.thingsboard.server.transport.http; |
17 | 17 | |
18 | -import com.google.gson.JsonObject; | |
19 | -import com.google.gson.JsonParser; | |
20 | -import com.google.gson.JsonSyntaxException; | |
21 | 18 | import lombok.extern.slf4j.Slf4j; |
22 | 19 | import org.springframework.beans.factory.annotation.Autowired; |
23 | 20 | import org.springframework.beans.factory.annotation.Value; |
24 | 21 | import org.springframework.http.HttpStatus; |
25 | 22 | import org.springframework.http.ResponseEntity; |
26 | -import org.springframework.util.StringUtils; | |
27 | 23 | import org.springframework.web.bind.annotation.*; |
28 | 24 | import org.springframework.web.context.request.async.DeferredResult; |
29 | -import org.thingsboard.server.common.data.security.DeviceTokenCredentials; | |
30 | 25 | import org.thingsboard.server.common.msg.core.*; |
31 | -import org.thingsboard.server.common.msg.session.AdaptorToSessionActorMsg; | |
32 | -import org.thingsboard.server.common.msg.session.BasicAdaptorToSessionActorMsg; | |
33 | -import org.thingsboard.server.common.msg.session.BasicTransportToDeviceSessionActorMsg; | |
34 | -import org.thingsboard.server.common.msg.session.FromDeviceMsg; | |
35 | 26 | import org.thingsboard.server.common.transport.SessionMsgProcessor; |
36 | -import org.thingsboard.server.common.transport.adaptor.JsonConverter; | |
37 | 27 | import org.thingsboard.server.common.transport.auth.DeviceAuthService; |
38 | -import org.thingsboard.server.common.transport.quota.QuotaService; | |
39 | 28 | import org.thingsboard.server.common.transport.quota.host.HostRequestsQuotaService; |
40 | 29 | import org.thingsboard.server.transport.http.session.HttpSessionCtx; |
41 | 30 | |
42 | 31 | import javax.servlet.http.HttpServletRequest; |
43 | -import java.util.Arrays; | |
44 | -import java.util.HashSet; | |
45 | -import java.util.Set; | |
46 | 32 | |
47 | 33 | /** |
48 | 34 | * @author Andrew Shvayka | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
... | ... | @@ -16,13 +16,9 @@ |
16 | 16 | package org.thingsboard.server.transport.mqtt.session; |
17 | 17 | |
18 | 18 | import io.netty.channel.ChannelHandlerContext; |
19 | -import io.netty.handler.codec.mqtt.*; | |
19 | +import io.netty.handler.codec.mqtt.MqttMessage; | |
20 | 20 | import lombok.Getter; |
21 | 21 | import lombok.extern.slf4j.Slf4j; |
22 | -import org.thingsboard.server.common.msg.session.SessionActorToAdaptorMsg; | |
23 | -import org.thingsboard.server.common.msg.session.SessionCtrlMsg; | |
24 | -import org.thingsboard.server.common.msg.session.SessionType; | |
25 | -import org.thingsboard.server.common.msg.session.ctrl.SessionCloseMsg; | |
26 | 22 | import org.thingsboard.server.common.msg.session.ex.SessionException; |
27 | 23 | import org.thingsboard.server.common.transport.adaptor.AdaptorException; |
28 | 24 | |
... | ... | @@ -36,29 +32,12 @@ import java.util.concurrent.atomic.AtomicInteger; |
36 | 32 | @Slf4j |
37 | 33 | public class DeviceSessionCtx extends MqttDeviceAwareSessionContext { |
38 | 34 | |
39 | - private final UUID sessionId; | |
40 | 35 | @Getter |
41 | 36 | private ChannelHandlerContext channel; |
42 | 37 | private AtomicInteger msgIdSeq = new AtomicInteger(0); |
43 | 38 | |
44 | 39 | public DeviceSessionCtx(UUID sessionId, ConcurrentMap<String, Integer> mqttQoSMap) { |
45 | - super(null, null, mqttQoSMap); | |
46 | - this.sessionId = sessionId; | |
47 | - } | |
48 | - | |
49 | - @Override | |
50 | - public SessionType getSessionType() { | |
51 | - return SessionType.ASYNC; | |
52 | - } | |
53 | - | |
54 | - @Override | |
55 | - public void onMsg(SessionActorToAdaptorMsg msg) throws SessionException { | |
56 | -// try { | |
57 | -// adaptor.convertToAdaptorMsg(this, msg).ifPresent(this::pushToNetwork); | |
58 | -// } catch (AdaptorException e) { | |
59 | -// //TODO: close channel with disconnect; | |
60 | -// logAndWrap(e); | |
61 | -// } | |
40 | + super(sessionId, mqttQoSMap); | |
62 | 41 | } |
63 | 42 | |
64 | 43 | private void logAndWrap(AdaptorException e) throws SessionException { |
... | ... | @@ -70,29 +49,6 @@ public class DeviceSessionCtx extends MqttDeviceAwareSessionContext { |
70 | 49 | channel.writeAndFlush(msg); |
71 | 50 | } |
72 | 51 | |
73 | - @Override | |
74 | - public void onMsg(SessionCtrlMsg msg) throws SessionException { | |
75 | - if (msg instanceof SessionCloseMsg) { | |
76 | - pushToNetwork(new MqttMessage(new MqttFixedHeader(MqttMessageType.DISCONNECT, false, MqttQoS.AT_MOST_ONCE, false, 0))); | |
77 | - channel.close(); | |
78 | - } | |
79 | - } | |
80 | - | |
81 | - @Override | |
82 | - public boolean isClosed() { | |
83 | - return false; | |
84 | - } | |
85 | - | |
86 | - @Override | |
87 | - public long getTimeout() { | |
88 | - return 0; | |
89 | - } | |
90 | - | |
91 | - @Override | |
92 | - public UUID getSessionId() { | |
93 | - return sessionId; | |
94 | - } | |
95 | - | |
96 | 52 | public void setChannel(ChannelHandlerContext channel) { |
97 | 53 | this.channel = channel; |
98 | 54 | } | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
... | ... | @@ -31,13 +31,11 @@ import java.util.concurrent.ConcurrentMap; |
31 | 31 | public class GatewayDeviceSessionCtx extends MqttDeviceAwareSessionContext implements SessionMsgListener { |
32 | 32 | |
33 | 33 | private final GatewaySessionCtx parent; |
34 | - private final UUID sessionId; | |
35 | 34 | private final SessionInfoProto sessionInfo; |
36 | 35 | |
37 | 36 | public GatewayDeviceSessionCtx(GatewaySessionCtx parent, DeviceInfoProto deviceInfo, ConcurrentMap<String, Integer> mqttQoSMap) { |
38 | - super(mqttQoSMap); | |
37 | + super(UUID.randomUUID(), mqttQoSMap); | |
39 | 38 | this.parent = parent; |
40 | - this.sessionId = UUID.randomUUID(); | |
41 | 39 | this.sessionInfo = SessionInfoProto.newBuilder() |
42 | 40 | .setNodeId(parent.getNodeId()) |
43 | 41 | .setSessionIdMSB(sessionId.getMostSignificantBits()) | ... | ... |
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ... | ... |
... | ... | @@ -22,6 +22,7 @@ import org.thingsboard.server.common.transport.auth.DeviceAuthService; |
22 | 22 | import org.thingsboard.server.common.transport.session.DeviceAwareSessionContext; |
23 | 23 | |
24 | 24 | import java.util.Map; |
25 | +import java.util.UUID; | |
25 | 26 | import java.util.concurrent.ConcurrentMap; |
26 | 27 | |
27 | 28 | /** |
... | ... | @@ -31,8 +32,8 @@ public abstract class MqttDeviceAwareSessionContext extends DeviceAwareSessionCo |
31 | 32 | |
32 | 33 | private final ConcurrentMap<String, Integer> mqttQoSMap; |
33 | 34 | |
34 | - public MqttDeviceAwareSessionContext(ConcurrentMap<String, Integer> mqttQoSMap) { | |
35 | - super(); | |
35 | + public MqttDeviceAwareSessionContext(UUID sessionId, ConcurrentMap<String, Integer> mqttQoSMap) { | |
36 | + super(sessionId); | |
36 | 37 | this.mqttQoSMap = mqttQoSMap; |
37 | 38 | } |
38 | 39 | ... | ... |
transport/mqtt-common/src/main/java/org/thingsboard/server/transport/mqtt/session/MqttSessionId.java
deleted
100644 → 0
1 | -/** | |
2 | - * Copyright © 2016-2018 The Thingsboard Authors | |
3 | - * | |
4 | - * Licensed under the Apache License, Version 2.0 (the "License"); | |
5 | - * you may not use this file except in compliance with the License. | |
6 | - * You may obtain a copy of the License at | |
7 | - * | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * | |
10 | - * Unless required by applicable law or agreed to in writing, software | |
11 | - * distributed under the License is distributed on an "AS IS" BASIS, | |
12 | - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 | - * See the License for the specific language governing permissions and | |
14 | - * limitations under the License. | |
15 | - */ | |
16 | -package org.thingsboard.server.transport.mqtt.session; | |
17 | - | |
18 | -import java.util.concurrent.atomic.AtomicLong; | |
19 | - | |
20 | -/** | |
21 | - * @author Andrew Shvayka | |
22 | - */ | |
23 | -public class MqttSessionId implements SessionId { | |
24 | - | |
25 | - private static final AtomicLong idSeq = new AtomicLong(); | |
26 | - | |
27 | - private final long id; | |
28 | - | |
29 | - public MqttSessionId() { | |
30 | - this.id = idSeq.incrementAndGet(); | |
31 | - } | |
32 | - | |
33 | - @Override | |
34 | - public boolean equals(Object o) { | |
35 | - if (this == o) return true; | |
36 | - if (o == null || getClass() != o.getClass()) return false; | |
37 | - | |
38 | - MqttSessionId that = (MqttSessionId) o; | |
39 | - | |
40 | - return id == that.id; | |
41 | - | |
42 | - } | |
43 | - | |
44 | - @Override | |
45 | - public String toString() { | |
46 | - return "MqttSessionId{" + | |
47 | - "id=" + id + | |
48 | - '}'; | |
49 | - } | |
50 | - | |
51 | - @Override | |
52 | - public int hashCode() { | |
53 | - return (int) (id ^ (id >>> 32)); | |
54 | - } | |
55 | - | |
56 | - @Override | |
57 | - public String toUidStr() { | |
58 | - return "mqtt" + id; | |
59 | - } | |
60 | -} |
transport/mqtt-transport/src/main/java/org/thingsboard/server/mqtt/service/MqttTransportService.java
1 | 1 | /** |
2 | 2 | * Copyright © 2016-2018 The Thingsboard Authors |
3 | - * <p> | |
3 | + * | |
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | 5 | * you may not use this file except in compliance with the License. |
6 | 6 | * You may obtain a copy of the License at |
7 | - * <p> | |
8 | - * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | - * <p> | |
7 | + * | |
8 | + * http://www.apache.org/licenses/LICENSE-2.0 | |
9 | + * | |
10 | 10 | * Unless required by applicable law or agreed to in writing, software |
11 | 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
... | ... | @@ -231,7 +231,7 @@ public class MqttTransportService implements TransportService { |
231 | 231 | |
232 | 232 | @Override |
233 | 233 | public void process(GetOrCreateDeviceFromGatewayRequestMsg msg, TransportServiceCallback<GetOrCreateDeviceFromGatewayResponseMsg> callback) { |
234 | - AsyncCallbackTemplate.withCallback(transportApiTemplate.post(msg.getTenantIdMSB() + msg.getTenantIdLSB() + msg.getDeviceName(), | |
234 | + AsyncCallbackTemplate.withCallback(transportApiTemplate.post(msg.getDeviceName(), | |
235 | 235 | TransportApiRequestMsg.newBuilder().setGetOrCreateDeviceRequestMsg(msg).build()), |
236 | 236 | response -> callback.onSuccess(response.getGetOrCreateDeviceResponseMsg()), callback::onError, transportCallbackExecutor); |
237 | 237 | } | ... | ... |