Lwm2m Fix bug review edit formatting
This commit is contained in:
parent
7f681a993f
commit
157e2361f6
@ -348,16 +348,13 @@ public class LwM2MClient implements Serializable {
|
|||||||
} else if (resourceModel.operations.isWritable() && resourceModel.mandatory) {
|
} else if (resourceModel.operations.isWritable() && resourceModel.mandatory) {
|
||||||
throw new IllegalArgumentException("Resource id=" + resourceId + " is mandatory. The value of this resource must not be null.");
|
throw new IllegalArgumentException("Resource id=" + resourceId + " is mandatory. The value of this resource must not be null.");
|
||||||
}
|
}
|
||||||
}
|
} else if (resourceModel.operations.isWritable() && resourceModel.mandatory) {
|
||||||
else if (resourceModel.operations.isWritable() && resourceModel.mandatory) {
|
|
||||||
throw new IllegalArgumentException("Resource id=" + resourceId + " is mandatory. The value of this resource must not be null.");
|
throw new IllegalArgumentException("Resource id=" + resourceId + " is mandatory. The value of this resource must not be null.");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
} else if (params == null) {
|
||||||
else if (params == null) {
|
|
||||||
throw new IllegalArgumentException("The value of this resource must not be null.");
|
throw new IllegalArgumentException("The value of this resource must not be null.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
throw new IllegalArgumentException("The value of this resource must be in Map format and size > 0");
|
throw new IllegalArgumentException("The value of this resource must be in Map format and size > 0");
|
||||||
}
|
}
|
||||||
return resources;
|
return resources;
|
||||||
|
|||||||
@ -37,12 +37,12 @@ import org.thingsboard.server.queue.util.TbLwM2mTransportComponent;
|
|||||||
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
|
import org.thingsboard.server.transport.lwm2m.config.LwM2MTransportServerConfig;
|
||||||
import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MSecurityInfo;
|
import org.thingsboard.server.transport.lwm2m.secure.TbLwM2MSecurityInfo;
|
||||||
import org.thingsboard.server.transport.lwm2m.server.LwM2MTransportContext;
|
import org.thingsboard.server.transport.lwm2m.server.LwM2MTransportContext;
|
||||||
import org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil;
|
|
||||||
import org.thingsboard.server.transport.lwm2m.server.ota.LwM2MOtaUpdateService;
|
import org.thingsboard.server.transport.lwm2m.server.ota.LwM2MOtaUpdateService;
|
||||||
import org.thingsboard.server.transport.lwm2m.server.session.LwM2MSessionManager;
|
import org.thingsboard.server.transport.lwm2m.server.session.LwM2MSessionManager;
|
||||||
import org.thingsboard.server.transport.lwm2m.server.store.TbLwM2MClientStore;
|
import org.thingsboard.server.transport.lwm2m.server.store.TbLwM2MClientStore;
|
||||||
import org.thingsboard.server.transport.lwm2m.server.store.TbMainSecurityStore;
|
import org.thingsboard.server.transport.lwm2m.server.store.TbMainSecurityStore;
|
||||||
import org.thingsboard.server.transport.lwm2m.server.uplink.DefaultLwM2MUplinkMsgHandler;
|
import org.thingsboard.server.transport.lwm2m.server.uplink.DefaultLwM2MUplinkMsgHandler;
|
||||||
|
import org.thingsboard.server.transport.lwm2m.utils.LwM2MTransportUtil;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|||||||
@ -352,7 +352,7 @@ public class LwM2MTransportUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Map convertMultiResourceValuesFromRpcBody(Object value, ResourceModel.Type type, String versionedId) throws Exception {
|
public static Map convertMultiResourceValuesFromRpcBody(Object value, ResourceModel.Type type, String versionedId) throws Exception {
|
||||||
String valueJsonStr = JsonUtils.riteValueAsString(value);
|
String valueJsonStr = JsonUtils.writeValueAsString(value);
|
||||||
JsonElement element = JsonUtils.parse(valueJsonStr);
|
JsonElement element = JsonUtils.parse(valueJsonStr);
|
||||||
return convertMultiResourceValuesFromJson(element, type, versionedId);
|
return convertMultiResourceValuesFromJson(element, type, versionedId);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,7 +57,7 @@ public class JsonUtils {
|
|||||||
return jsonParser.parse(params);
|
return jsonParser.parse(params);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String riteValueAsString (Object value) throws JsonProcessingException {
|
public static String writeValueAsString(Object value) throws JsonProcessingException {
|
||||||
return json.writeValueAsString(value);
|
return json.writeValueAsString(value);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,39 +124,4 @@ public class JacksonUtil {
|
|||||||
public static <T> T treeToValue(JsonNode tree, Class<T> type) throws JsonProcessingException {
|
public static <T> T treeToValue(JsonNode tree, Class<T> type) throws JsonProcessingException {
|
||||||
return OBJECT_MAPPER.treeToValue(tree, type);
|
return OBJECT_MAPPER.treeToValue(tree, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {bootstrap:client:host, client, client:port, client:endpoint}
|
|
||||||
* @param ":"
|
|
||||||
* @return
|
|
||||||
* - "bootstrap:client:host"
|
|
||||||
* -- if in nodeCredentialsValue is absent:
|
|
||||||
* --- "bootstrap" or "bootstrap:client" or "bootstrap:client:host" -> return "host"
|
|
||||||
* -- if in nodeCredentialsValue is absent:
|
|
||||||
* --- "client:port" -> return "port"
|
|
||||||
* -- if the nodeCredentialsValue contains:
|
|
||||||
* --- "client" and "client:port" -> "port" not add to Set
|
|
||||||
*/
|
|
||||||
public static String validateFieldsToTree(JsonNode nodeCredentialsValue, String[] fields, String delimiter) {
|
|
||||||
try {
|
|
||||||
StringBuilder msgSet = new StringBuilder();
|
|
||||||
for (String field : fields) {
|
|
||||||
String[] keys = field.split(delimiter);
|
|
||||||
JsonNode nodeVal = nodeCredentialsValue;
|
|
||||||
for (String key : keys) {
|
|
||||||
if (!nodeVal.hasNonNull(key)) {
|
|
||||||
msgSet.append(" " + keys[keys.length - 1]);
|
|
||||||
break;
|
|
||||||
} else {
|
|
||||||
nodeVal = nodeVal.get(key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return msgSet.toString().trim();
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new IllegalArgumentException(e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user