Commit 612532bbd9038f43e67bf031d5a56145019ca87e
Committed by
Andrew Shvayka
1 parent
9552ab05
Lwm2m: back: fix bug final and pom
Showing
6 changed files
with
27 additions
and
25 deletions
... | ... | @@ -166,13 +166,13 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { |
166 | 166 | if (this.getValidatedSecurityMode(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap, lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer)) { |
167 | 167 | lwM2MBootstrapConfig.bootstrapServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.bootstrapServer, profileServerBootstrap); |
168 | 168 | lwM2MBootstrapConfig.lwm2mServer = new LwM2MServerBootstrap(lwM2MBootstrapConfig.lwm2mServer, profileLwm2mServer); |
169 | - String logMsg = String.format(LOG_LW2M_INFO + ": getParametersBootstrap: %s Access connect client with bootstrap server.", store.getEndPoint()); | |
169 | + String logMsg = String.format("%s: getParametersBootstrap: %s Access connect client with bootstrap server.", LOG_LW2M_INFO, store.getEndPoint()); | |
170 | 170 | context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo); |
171 | 171 | return lwM2MBootstrapConfig; |
172 | 172 | } else { |
173 | 173 | log.error(" [{}] Different values SecurityMode between of client and profile.", store.getEndPoint()); |
174 | - log.error(LOG_LW2M_ERROR + " getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", store.getEndPoint()); | |
175 | - String logMsg = String.format(LOG_LW2M_ERROR + ": getParametersBootstrap: %s Different values SecurityMode between of client and profile.", store.getEndPoint()); | |
174 | + log.error("{} getParametersBootstrap: [{}] Different values SecurityMode between of client and profile.", LOG_LW2M_ERROR, store.getEndPoint()); | |
175 | + String logMsg = String.format("%s: getParametersBootstrap: %s Different values SecurityMode between of client and profile.", LOG_LW2M_ERROR, store.getEndPoint()); | |
176 | 176 | context.sentParametersOnThingsboard(context.getTelemetryMsgObject(logMsg), LwM2MTransportHandler.DEVICE_TELEMETRY_TOPIC, sessionInfo); |
177 | 177 | return null; |
178 | 178 | } |
... | ... | @@ -188,6 +188,7 @@ public class LwM2MBootstrapSecurityStore implements BootstrapSecurityStore { |
188 | 188 | /** |
189 | 189 | * Bootstrap security have to sync between (bootstrapServer in credential and bootstrapServer in profile) |
190 | 190 | * and (lwm2mServer in credential and lwm2mServer in profile |
191 | + * | |
191 | 192 | * @param bootstrapFromCredential - Bootstrap -> Security of bootstrapServer in credential |
192 | 193 | * @param profileServerBootstrap - Bootstrap -> Security of bootstrapServer in profile |
193 | 194 | * @param lwm2mFromCredential - Bootstrap -> Security of lwm2mServer in credential | ... | ... |
... | ... | @@ -39,7 +39,6 @@ import org.eclipse.leshan.core.response.DeleteResponse; |
39 | 39 | import org.eclipse.leshan.core.response.DiscoverResponse; |
40 | 40 | import org.eclipse.leshan.core.response.ExecuteResponse; |
41 | 41 | import org.eclipse.leshan.core.response.LwM2mResponse; |
42 | -import org.eclipse.leshan.core.response.ObserveResponse; | |
43 | 42 | import org.eclipse.leshan.core.response.ReadResponse; |
44 | 43 | import org.eclipse.leshan.core.response.ResponseCallback; |
45 | 44 | import org.eclipse.leshan.core.response.WriteAttributesResponse; |
... | ... | @@ -242,15 +241,15 @@ public class LwM2MTransportRequest { |
242 | 241 | if (isSuccess(((Response) response.getCoapResponse()).getCode())) { |
243 | 242 | this.handleResponse(registration, request.getPath().toString(), response, request); |
244 | 243 | if (request instanceof WriteRequest && ((WriteRequest) request).isReplaceRequest()) { |
245 | - String msg = String.format(LOG_LW2M_INFO + ": sendRequest Replace: CoapCde - %s Lwm2m code - %d name - %s Resource path - %s value - %s SendRequest to Client", | |
246 | - ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString(), | |
244 | + String msg = String.format("%s: sendRequest Replace: CoapCde - %s Lwm2m code - %d name - %s Resource path - %s value - %s SendRequest to Client", | |
245 | + LOG_LW2M_INFO, ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString(), | |
247 | 246 | ((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue().toString()); |
248 | 247 | service.sentLogsToThingsboard(msg, registration); |
249 | 248 | log.info("[{}] [{}] - [{}] [{}] Update SendRequest[{}]", registration.getEndpoint(), ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString(), |
250 | 249 | ((LwM2mSingleResource) ((WriteRequest) request).getNode()).getValue()); |
251 | 250 | } |
252 | 251 | } else { |
253 | - String msg = String.format(LOG_LW2M_ERROR + ": sendRequest: CoapCode - %s Lwm2m code - %d name - %s Resource path - %s SendRequest to Client", | |
252 | + String msg = String.format("%s: sendRequest: CoapCode - %s Lwm2m code - %d name - %s Resource path - %s SendRequest to Client", LOG_LW2M_ERROR, | |
254 | 253 | ((Response) response.getCoapResponse()).getCode(), response.getCode().getCode(), response.getCode().getName(), request.getPath().toString()); |
255 | 254 | service.sentLogsToThingsboard(msg, registration); |
256 | 255 | log.error("[{}] - [{}] [{}] error SendRequest", ((Response) response.getCoapResponse()).getCode(), response.getCode(), request.getPath().toString()); |
... | ... | @@ -259,8 +258,8 @@ public class LwM2MTransportRequest { |
259 | 258 | if (!lwM2MClient.isInit()) { |
260 | 259 | lwM2MClient.initValue(this.service, request.getPath().toString()); |
261 | 260 | } |
262 | - String msg = String.format(LOG_LW2M_ERROR + ": sendRequest: Resource path - %s msg error - %s SendRequest to Client", | |
263 | - request.getPath().toString(), e.toString()); | |
261 | + String msg = String.format("%s: sendRequest: Resource path - %s msg error - %s SendRequest to Client", | |
262 | + LOG_LW2M_ERROR, request.getPath().toString(), e.toString()); | |
264 | 263 | service.sentLogsToThingsboard(msg, registration); |
265 | 264 | log.error("[{}] - [{}] error SendRequest", request.getPath().toString(), e.toString()); |
266 | 265 | }); |
... | ... | @@ -314,7 +313,7 @@ public class LwM2MTransportRequest { |
314 | 313 | * @param response - |
315 | 314 | */ |
316 | 315 | private void sendResponse(Registration registration, String path, LwM2mResponse response, DownlinkRequest request) { |
317 | - if (response instanceof ObserveResponse || response instanceof ReadResponse) { | |
316 | + if (response instanceof ReadResponse) { | |
318 | 317 | service.onObservationResponse(registration, path, (ReadResponse) response); |
319 | 318 | } else if (response instanceof CancelObservationResponse) { |
320 | 319 | log.info("[{}] Path [{}] CancelObservationResponse 3_Send", path, response); | ... | ... |
... | ... | @@ -300,12 +300,14 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { |
300 | 300 | ContentFormat.TLV.getName(), null, value, this.context.getCtxServer().getTimeout()); |
301 | 301 | } else { |
302 | 302 | log.error("Resource path - [{}] value - [{}] is not Writable and cannot be updated", path, value); |
303 | - String logMsg = String.format(LOG_LW2M_ERROR + ": attributeUpdate: Resource path - %s value - %s is not Writable and cannot be updated", path, value); | |
303 | + String logMsg = String.format("%s: attributeUpdate: Resource path - %s value - %s is not Writable and cannot be updated", | |
304 | + LOG_LW2M_ERROR, path, value); | |
304 | 305 | this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration()); |
305 | 306 | } |
306 | 307 | } else { |
307 | 308 | log.error("Attribute name - [{}] value - [{}] is not present as attribute in profile and cannot be updated", de.getKey(), value); |
308 | - String logMsg = String.format(LOG_LW2M_ERROR + ": attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated", de.getKey(), value); | |
309 | + String logMsg = String.format("%s: attributeUpdate: attribute name - %s value - %s is not present as attribute in profile and cannot be updated", | |
310 | + LOG_LW2M_ERROR, de.getKey(), value); | |
309 | 311 | this.sentLogsToThingsboard(logMsg, lwM2MClient.getRegistration()); |
310 | 312 | } |
311 | 313 | }); |
... | ... | @@ -581,7 +583,8 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { |
581 | 583 | * Start observe/read: Attr/Telemetry |
582 | 584 | * #1 - Analyze: |
583 | 585 | * #1.1 path in resource profile == client resource |
584 | - * @param lwServer - | |
586 | + * | |
587 | + * @param lwServer - | |
585 | 588 | * @param registration - |
586 | 589 | */ |
587 | 590 | private void initReadAttrTelemetryObserveToClient(LeshanServer lwServer, Registration registration, LwM2MClient lwM2MClient, String typeOper) { |
... | ... | @@ -592,8 +595,7 @@ public class LwM2MTransportServiceImpl implements LwM2MTransportService { |
592 | 595 | if (GET_TYPE_OPER_READ.equals(typeOper)) { |
593 | 596 | result = new ObjectMapper().readValue(lwM2MClientProfile.getPostAttributeProfile().getAsJsonArray().toString().getBytes(), Set.class); |
594 | 597 | result.addAll(new ObjectMapper().readValue(lwM2MClientProfile.getPostTelemetryProfile().getAsJsonArray().toString().getBytes(), Set.class)); |
595 | - } | |
596 | - else { | |
598 | + } else { | |
597 | 599 | result = new ObjectMapper().readValue(lwM2MClientProfile.getPostObserveProfile().getAsJsonArray().toString().getBytes(), Set.class); |
598 | 600 | } |
599 | 601 | Set<String> pathSent = ConcurrentHashMap.newKeySet(); | ... | ... |
... | ... | @@ -49,10 +49,10 @@ public class LwM2MClient implements Cloneable { |
49 | 49 | private LwM2MTransportServiceImpl lwM2MTransportServiceImpl; |
50 | 50 | private Registration registration; |
51 | 51 | private ValidateDeviceCredentialsResponseMsg credentialsResponse; |
52 | - private Map<String, String> attributes; | |
53 | - private Map<String, ResourceValue> resources; | |
54 | - private Map<String, TransportProtos.TsKvProto> delayedRequests; | |
55 | - private List<String> pendingRequests; | |
52 | + private final Map<String, String> attributes; | |
53 | + private final Map<String, ResourceValue> resources; | |
54 | + private final Map<String, TransportProtos.TsKvProto> delayedRequests; | |
55 | + private final List<String> pendingRequests; | |
56 | 56 | private boolean init; |
57 | 57 | private final LwM2mValueConverterImpl converter; |
58 | 58 | ... | ... |
... | ... | @@ -168,7 +168,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore { |
168 | 168 | LwM2MClient lwM2MClient = this.sessions.get(registration.getEndpoint()); |
169 | 169 | lwM2MClient.setLwServer(lwServer); |
170 | 170 | lwM2MClient.setRegistration(registration); |
171 | - lwM2MClient.setAttributes(registration.getAdditionalRegistrationAttributes()); | |
171 | + lwM2MClient.getAttributes().putAll(registration.getAdditionalRegistrationAttributes()); | |
172 | 172 | this.sessions.remove(registration.getEndpoint()); |
173 | 173 | this.sessions.put(registration.getId(), lwM2MClient); |
174 | 174 | return lwM2MClient; | ... | ... |
... | ... | @@ -625,11 +625,11 @@ |
625 | 625 | <artifactId>maven-install-plugin</artifactId> |
626 | 626 | <version>3.0.0-M1</version> |
627 | 627 | </plugin> |
628 | - <plugin> | |
629 | - <groupId>org.apache.maven.plugins</groupId> | |
630 | - <artifactId>maven-deploy-plugin</artifactId> | |
631 | - <version>3.0.0-M1</version> | |
632 | - </plugin> | |
628 | +<!-- <plugin>--> | |
629 | +<!-- <groupId>org.apache.maven.plugins</groupId>--> | |
630 | +<!-- <artifactId>maven-deploy-plugin</artifactId>--> | |
631 | +<!-- <version>3.0.0-M1</version>--> | |
632 | +<!-- </plugin>--> | |
633 | 633 | <plugin> |
634 | 634 | <groupId>org.apache.maven.plugins</groupId> |
635 | 635 | <artifactId>maven-dependency-plugin</artifactId> | ... | ... |