Commit 65f4ca58001a3a71fdf7a654b53cd47122f1d44c
1 parent
c78bd55d
Lwm2m: back: add tenantId and repositoryTenant - test
Showing
10 changed files
with
140 additions
and
20 deletions
@@ -447,6 +447,7 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService | @@ -447,6 +447,7 @@ public class SqlDatabaseUpgradeService implements DatabaseEntitiesUpgradeService | ||
447 | " );"); | 447 | " );"); |
448 | 448 | ||
449 | conn.createStatement().execute("UPDATE tb_schema_settings SET schema_version = 3003000;"); | 449 | conn.createStatement().execute("UPDATE tb_schema_settings SET schema_version = 3003000;"); |
450 | + installScripts.loadSystemLwm2mResources(); | ||
450 | } catch (Exception e) { | 451 | } catch (Exception e) { |
451 | log.error("Failed updating schema!!!", e); | 452 | log.error("Failed updating schema!!!", e); |
452 | } | 453 | } |
@@ -33,7 +33,6 @@ import org.thingsboard.server.common.data.page.PageLink; | @@ -33,7 +33,6 @@ import org.thingsboard.server.common.data.page.PageLink; | ||
33 | import org.thingsboard.server.common.transport.lwm2m.LwM2MTransportConfigBootstrap; | 33 | import org.thingsboard.server.common.transport.lwm2m.LwM2MTransportConfigBootstrap; |
34 | import org.thingsboard.server.common.transport.lwm2m.LwM2MTransportConfigServer; | 34 | import org.thingsboard.server.common.transport.lwm2m.LwM2MTransportConfigServer; |
35 | import org.thingsboard.server.dao.service.Validator; | 35 | import org.thingsboard.server.dao.service.Validator; |
36 | -import org.thingsboard.server.queue.util.TbLwM2mTransportComponent; | ||
37 | import org.thingsboard.server.transport.lwm2m.secure.LwM2MSecurityMode; | 36 | import org.thingsboard.server.transport.lwm2m.secure.LwM2MSecurityMode; |
38 | 37 | ||
39 | import java.math.BigInteger; | 38 | import java.math.BigInteger; |
@@ -102,8 +101,8 @@ public class LwM2MModelsRepository { | @@ -102,8 +101,8 @@ public class LwM2MModelsRepository { | ||
102 | */ | 101 | */ |
103 | private List<LwM2mObject> getLwm2mObjects(Predicate<? super ObjectModel> predicate, String sortProperty, String sortOrder) { | 102 | private List<LwM2mObject> getLwm2mObjects(Predicate<? super ObjectModel> predicate, String sortProperty, String sortOrder) { |
104 | List<LwM2mObject> lwM2mObjects = new ArrayList<>(); | 103 | List<LwM2mObject> lwM2mObjects = new ArrayList<>(); |
105 | - List<ObjectModel> listObjects = (predicate == null) ? this.contextServer.getModelsValue() : | ||
106 | - contextServer.getModelsValue().stream() | 104 | + List<ObjectModel> listObjects = (predicate == null) ? this.contextServer.getModelsValueCommon() : |
105 | + contextServer.getModelsValueCommon().stream() | ||
107 | .filter(predicate) | 106 | .filter(predicate) |
108 | .collect(Collectors.toList()); | 107 | .collect(Collectors.toList()); |
109 | 108 |
@@ -94,7 +94,7 @@ public class LwM2MTransportBootstrapServerConfiguration { | @@ -94,7 +94,7 @@ public class LwM2MTransportBootstrapServerConfiguration { | ||
94 | builder.setCoapConfig(getCoapConfig(bootstrapPortNoSec, bootstrapSecurePort)); | 94 | builder.setCoapConfig(getCoapConfig(bootstrapPortNoSec, bootstrapSecurePort)); |
95 | 95 | ||
96 | /** Define model provider (Create Models )*/ | 96 | /** Define model provider (Create Models )*/ |
97 | - builder.setModel(new StaticModel(contextS.getLwM2MTransportConfigServer().getModelsValue())); | 97 | + builder.setModel(new StaticModel(contextS.getLwM2MTransportConfigServer().getModelsValueCommon())); |
98 | 98 | ||
99 | /** Create credentials */ | 99 | /** Create credentials */ |
100 | this.setServerWithCredentials(builder); | 100 | this.setServerWithCredentials(builder); |
@@ -188,8 +188,9 @@ public class LwM2mTransportHandler { | @@ -188,8 +188,9 @@ public class LwM2mTransportHandler { | ||
188 | return null; | 188 | return null; |
189 | } | 189 | } |
190 | 190 | ||
191 | - public static LwM2mClientProfile getNewProfileParameters(JsonObject profilesConfigData) { | 191 | + public static LwM2mClientProfile getNewProfileParameters(JsonObject profilesConfigData, String tenantId) { |
192 | LwM2mClientProfile lwM2MClientProfile = new LwM2mClientProfile(); | 192 | LwM2mClientProfile lwM2MClientProfile = new LwM2mClientProfile(); |
193 | + lwM2MClientProfile.setTenantId(tenantId); | ||
193 | lwM2MClientProfile.setPostClientLwM2mSettings(profilesConfigData.get(CLIENT_LWM2M_SETTINGS).getAsJsonObject()); | 194 | lwM2MClientProfile.setPostClientLwM2mSettings(profilesConfigData.get(CLIENT_LWM2M_SETTINGS).getAsJsonObject()); |
194 | lwM2MClientProfile.setPostKeyNameProfile(profilesConfigData.get(OBSERVE_ATTRIBUTE_TELEMETRY).getAsJsonObject().get(KEY_NAME).getAsJsonObject()); | 195 | lwM2MClientProfile.setPostKeyNameProfile(profilesConfigData.get(OBSERVE_ATTRIBUTE_TELEMETRY).getAsJsonObject().get(KEY_NAME).getAsJsonObject()); |
195 | lwM2MClientProfile.setPostAttributeProfile(profilesConfigData.get(OBSERVE_ATTRIBUTE_TELEMETRY).getAsJsonObject().get(ATTRIBUTE).getAsJsonArray()); | 196 | lwM2MClientProfile.setPostAttributeProfile(profilesConfigData.get(OBSERVE_ATTRIBUTE_TELEMETRY).getAsJsonObject().get(ATTRIBUTE).getAsJsonArray()); |
@@ -221,7 +222,7 @@ public class LwM2mTransportHandler { | @@ -221,7 +222,7 @@ public class LwM2mTransportHandler { | ||
221 | ObjectMapper mapper = new ObjectMapper(); | 222 | ObjectMapper mapper = new ObjectMapper(); |
222 | String profileStr = mapper.writeValueAsString(profile); | 223 | String profileStr = mapper.writeValueAsString(profile); |
223 | JsonObject profileJson = (profileStr != null) ? validateJson(profileStr) : null; | 224 | JsonObject profileJson = (profileStr != null) ? validateJson(profileStr) : null; |
224 | - return (getValidateCredentialsBodyFromThingsboard(profileJson)) ? LwM2mTransportHandler.getNewProfileParameters(profileJson) : null; | 225 | + return (getValidateCredentialsBodyFromThingsboard(profileJson)) ? LwM2mTransportHandler.getNewProfileParameters(profileJson, deviceProfile.getTenantId().getId().toString()) : null; |
225 | } catch (IOException e) { | 226 | } catch (IOException e) { |
226 | log.error("", e); | 227 | log.error("", e); |
227 | } | 228 | } |
@@ -24,7 +24,6 @@ import org.eclipse.leshan.server.californium.LeshanServer; | @@ -24,7 +24,6 @@ import org.eclipse.leshan.server.californium.LeshanServer; | ||
24 | import org.eclipse.leshan.server.californium.LeshanServerBuilder; | 24 | import org.eclipse.leshan.server.californium.LeshanServerBuilder; |
25 | import org.eclipse.leshan.server.californium.registration.CaliforniumRegistrationStore; | 25 | import org.eclipse.leshan.server.californium.registration.CaliforniumRegistrationStore; |
26 | import org.eclipse.leshan.server.model.LwM2mModelProvider; | 26 | import org.eclipse.leshan.server.model.LwM2mModelProvider; |
27 | -import org.eclipse.leshan.server.model.VersionedModelProvider; | ||
28 | import org.eclipse.leshan.server.security.DefaultAuthorizer; | 27 | import org.eclipse.leshan.server.security.DefaultAuthorizer; |
29 | import org.eclipse.leshan.server.security.EditableSecurityStore; | 28 | import org.eclipse.leshan.server.security.EditableSecurityStore; |
30 | import org.eclipse.leshan.server.security.SecurityChecker; | 29 | import org.eclipse.leshan.server.security.SecurityChecker; |
@@ -32,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; | @@ -32,6 +31,7 @@ import org.springframework.beans.factory.annotation.Autowired; | ||
32 | import org.springframework.context.annotation.Bean; | 31 | import org.springframework.context.annotation.Bean; |
33 | import org.springframework.stereotype.Component; | 32 | import org.springframework.stereotype.Component; |
34 | import org.thingsboard.server.queue.util.TbLwM2mTransportComponent; | 33 | import org.thingsboard.server.queue.util.TbLwM2mTransportComponent; |
34 | +import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClientContext; | ||
35 | import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl; | 35 | import org.thingsboard.server.transport.lwm2m.utils.LwM2mValueConverterImpl; |
36 | 36 | ||
37 | import java.math.BigInteger; | 37 | import java.math.BigInteger; |
@@ -77,6 +77,9 @@ public class LwM2mTransportServerConfiguration { | @@ -77,6 +77,9 @@ public class LwM2mTransportServerConfiguration { | ||
77 | @Autowired | 77 | @Autowired |
78 | private EditableSecurityStore securityStore; | 78 | private EditableSecurityStore securityStore; |
79 | 79 | ||
80 | + @Autowired | ||
81 | + private LwM2mClientContext lwM2mClientContext;; | ||
82 | + | ||
80 | @Bean | 83 | @Bean |
81 | public LeshanServer getLeshanServer() { | 84 | public LeshanServer getLeshanServer() { |
82 | log.info("Starting LwM2M transport Server... PostConstruct"); | 85 | log.info("Starting LwM2M transport Server... PostConstruct"); |
@@ -95,7 +98,8 @@ public class LwM2mTransportServerConfiguration { | @@ -95,7 +98,8 @@ public class LwM2mTransportServerConfiguration { | ||
95 | builder.setCoapConfig(getCoapConfig(serverPortNoSec, serverSecurePort)); | 98 | builder.setCoapConfig(getCoapConfig(serverPortNoSec, serverSecurePort)); |
96 | 99 | ||
97 | /** Define model provider (Create Models )*/ | 100 | /** Define model provider (Create Models )*/ |
98 | - LwM2mModelProvider modelProvider = new VersionedModelProvider(this.context.getLwM2MTransportConfigServer().getModelsValue()); | 101 | +// LwM2mModelProvider modelProvider = new VersionedModelProvider(this.context.getLwM2MTransportConfigServer().getModelsValueCommon()); |
102 | + LwM2mModelProvider modelProvider = new LwM2mVersionedModelProvider(this.context.getLwM2MTransportConfigServer().getModelsValueServer(), this.lwM2mClientContext); | ||
99 | builder.setObjectModelProvider(modelProvider); | 103 | builder.setObjectModelProvider(modelProvider); |
100 | 104 | ||
101 | /** Create credentials */ | 105 | /** Create credentials */ |
@@ -153,6 +153,8 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | @@ -153,6 +153,8 @@ public class LwM2mTransportServiceImpl implements LwM2mTransportService { | ||
153 | executorRegistered.submit(() -> { | 153 | executorRegistered.submit(() -> { |
154 | try { | 154 | try { |
155 | log.warn("[{}] [{{}] Client: create after Registration", registration.getEndpoint(), registration.getId()); | 155 | log.warn("[{}] [{{}] Client: create after Registration", registration.getEndpoint(), registration.getId()); |
156 | + ((LwM2mVersionedModelProvider)leshanServer.getModelProvider()).setRepository(this.lwM2mTransportContextServer.getLwM2MTransportConfigServer().getModelsValueCommon()); | ||
157 | +// (((VersionedModelProvider) (leshanServer)).modelProvider).repository; | ||
156 | LwM2mClient lwM2MClient = this.lwM2mClientContext.updateInSessionsLwM2MClient(registration); | 158 | LwM2mClient lwM2MClient = this.lwM2mClientContext.updateInSessionsLwM2MClient(registration); |
157 | if (lwM2MClient != null) { | 159 | if (lwM2MClient != null) { |
158 | SessionInfoProto sessionInfo = this.getValidateSessionInfo(registration); | 160 | SessionInfoProto sessionInfo = this.getValidateSessionInfo(registration); |
1 | +package org.thingsboard.server.transport.lwm2m.server; | ||
2 | + | ||
3 | +import org.eclipse.leshan.core.model.LwM2mModel; | ||
4 | +import org.eclipse.leshan.core.model.LwM2mModelRepository; | ||
5 | +import org.eclipse.leshan.core.model.ObjectModel; | ||
6 | +import org.eclipse.leshan.core.model.ResourceModel; | ||
7 | +import org.eclipse.leshan.server.model.LwM2mModelProvider; | ||
8 | +import org.eclipse.leshan.server.registration.Registration; | ||
9 | +import org.thingsboard.server.transport.lwm2m.server.client.LwM2mClientContext; | ||
10 | + | ||
11 | +import java.util.ArrayList; | ||
12 | +import java.util.Collection; | ||
13 | +import java.util.Map; | ||
14 | +import java.util.concurrent.ConcurrentHashMap; | ||
15 | + | ||
16 | +public class LwM2mVersionedModelProvider implements LwM2mModelProvider { | ||
17 | + | ||
18 | + private LwM2mModelRepository repository; | ||
19 | + private Map<String, LwM2mModelRepository> repositoriesTenant; | ||
20 | + private LwM2mClientContext lwM2mClientContext; | ||
21 | + | ||
22 | + public LwM2mVersionedModelProvider(Collection<ObjectModel> objectModels, LwM2mClientContext lwM2mClientContext) { | ||
23 | + this.repository = new LwM2mModelRepository(objectModels); | ||
24 | + this.lwM2mClientContext = lwM2mClientContext; | ||
25 | + this.repositoriesTenant = new ConcurrentHashMap<>(); | ||
26 | + } | ||
27 | + | ||
28 | + public LwM2mVersionedModelProvider(LwM2mModelRepository repository, LwM2mClientContext lwM2mClientContext) { | ||
29 | + this.repository = repository; | ||
30 | + this.lwM2mClientContext = lwM2mClientContext; | ||
31 | + this.repositoriesTenant = new ConcurrentHashMap<>(); | ||
32 | + } | ||
33 | + | ||
34 | + public void setRepositoriesTenant (String tenantID, LwM2mModelRepository repositoryTenant) { | ||
35 | + this.repositoriesTenant.put(tenantID, repositoryTenant); | ||
36 | + } | ||
37 | + | ||
38 | + public LwM2mModelRepository getRepositoriesTenant (String tenantID) { | ||
39 | + return this.repositoriesTenant.get(tenantID); | ||
40 | + } | ||
41 | + | ||
42 | + public void setRepository (Collection<ObjectModel> objectModels) { | ||
43 | + this.repository = new LwM2mModelRepository(objectModels); | ||
44 | + } | ||
45 | + | ||
46 | + public LwM2mModelRepository getRepositoriesCommonTenant (String tenantID) { | ||
47 | + LwM2mModelRepository repository = new LwM2mModelRepository(); | ||
48 | + | ||
49 | + return repository; | ||
50 | + } | ||
51 | + | ||
52 | + @Override | ||
53 | + public LwM2mModel getObjectModel(Registration registration) { | ||
54 | + return new DynamicModel(registration, this.lwM2mClientContext.getProfile(registration).getTenantId()); | ||
55 | + } | ||
56 | + | ||
57 | + private class DynamicModel implements LwM2mModel { | ||
58 | + | ||
59 | + private final Registration registration; | ||
60 | + private final String tenantId; | ||
61 | + | ||
62 | + public DynamicModel(Registration registration, String tenantId) { | ||
63 | + this.registration = registration; | ||
64 | + this.tenantId = tenantId; | ||
65 | + } | ||
66 | + | ||
67 | + @Override | ||
68 | + public ResourceModel getResourceModel(int objectId, int resourceId) { | ||
69 | + ObjectModel objectModel = getObjectModel(objectId); | ||
70 | + if (objectModel != null) | ||
71 | + return objectModel.resources.get(resourceId); | ||
72 | + else | ||
73 | + return null; | ||
74 | + } | ||
75 | + | ||
76 | + @Override | ||
77 | + public ObjectModel getObjectModel(int objectId) { | ||
78 | + String version = registration.getSupportedVersion(objectId); | ||
79 | + if (version != null) { | ||
80 | + return repository.getObjectModel(objectId, version); | ||
81 | + } | ||
82 | + return null; | ||
83 | + } | ||
84 | + | ||
85 | + @Override | ||
86 | + public Collection<ObjectModel> getObjectModels() { | ||
87 | + Map<Integer, String> supportedObjects = registration.getSupportedObject(); | ||
88 | + Collection<ObjectModel> result = new ArrayList<>(supportedObjects.size()); | ||
89 | + for (Map.Entry<Integer, String> supportedObject : supportedObjects.entrySet()) { | ||
90 | + ObjectModel objectModel = repository.getObjectModel(supportedObject.getKey(), | ||
91 | + supportedObject.getValue()); | ||
92 | + if (objectModel != null) | ||
93 | + result.add(objectModel); | ||
94 | + } | ||
95 | + return result; | ||
96 | + } | ||
97 | + } | ||
98 | +} |
@@ -22,12 +22,14 @@ import lombok.Data; | @@ -22,12 +22,14 @@ import lombok.Data; | ||
22 | 22 | ||
23 | @Data | 23 | @Data |
24 | public class LwM2mClientProfile { | 24 | public class LwM2mClientProfile { |
25 | + | ||
26 | + private String tenantId; | ||
25 | /** | 27 | /** |
26 | * {"clientLwM2mSettings": { | 28 | * {"clientLwM2mSettings": { |
27 | * clientUpdateValueAfterConnect: false; | 29 | * clientUpdateValueAfterConnect: false; |
28 | * } | 30 | * } |
29 | **/ | 31 | **/ |
30 | - JsonObject postClientLwM2mSettings; | 32 | + private JsonObject postClientLwM2mSettings; |
31 | 33 | ||
32 | /** | 34 | /** |
33 | * {"keyName": { | 35 | * {"keyName": { |
@@ -36,22 +38,22 @@ public class LwM2mClientProfile { | @@ -36,22 +38,22 @@ public class LwM2mClientProfile { | ||
36 | * "/3/0/2": "serialNumber" | 38 | * "/3/0/2": "serialNumber" |
37 | * } | 39 | * } |
38 | **/ | 40 | **/ |
39 | - JsonObject postKeyNameProfile; | 41 | + private JsonObject postKeyNameProfile; |
40 | 42 | ||
41 | /** | 43 | /** |
42 | * [ "/2/0/0", "/2/0/1"] | 44 | * [ "/2/0/0", "/2/0/1"] |
43 | */ | 45 | */ |
44 | - JsonArray postAttributeProfile; | 46 | + private JsonArray postAttributeProfile; |
45 | 47 | ||
46 | /** | 48 | /** |
47 | * [ "/2/0/0", "/2/0/1"] | 49 | * [ "/2/0/0", "/2/0/1"] |
48 | */ | 50 | */ |
49 | - JsonArray postTelemetryProfile; | 51 | + private JsonArray postTelemetryProfile; |
50 | 52 | ||
51 | /** | 53 | /** |
52 | * [ "/2/0/0", "/2/0/1"] | 54 | * [ "/2/0/0", "/2/0/1"] |
53 | */ | 55 | */ |
54 | - JsonArray postObserveProfile; | 56 | + private JsonArray postObserveProfile; |
55 | 57 | ||
56 | public LwM2mClientProfile clone() { | 58 | public LwM2mClientProfile clone() { |
57 | LwM2mClientProfile lwM2mClientProfile = new LwM2mClientProfile(); | 59 | LwM2mClientProfile lwM2mClientProfile = new LwM2mClientProfile(); |
@@ -26,6 +26,7 @@ import org.eclipse.leshan.core.util.StringUtils; | @@ -26,6 +26,7 @@ import org.eclipse.leshan.core.util.StringUtils; | ||
26 | import javax.xml.datatype.DatatypeConfigurationException; | 26 | import javax.xml.datatype.DatatypeConfigurationException; |
27 | import javax.xml.datatype.DatatypeFactory; | 27 | import javax.xml.datatype.DatatypeFactory; |
28 | import javax.xml.datatype.XMLGregorianCalendar; | 28 | import javax.xml.datatype.XMLGregorianCalendar; |
29 | +import java.math.BigInteger; | ||
29 | import java.text.DateFormat; | 30 | import java.text.DateFormat; |
30 | import java.text.SimpleDateFormat; | 31 | import java.text.SimpleDateFormat; |
31 | import java.util.Date; | 32 | import java.util.Date; |
@@ -130,7 +131,13 @@ public class LwM2mValueConverterImpl implements LwM2mValueConverter { | @@ -130,7 +131,13 @@ public class LwM2mValueConverterImpl implements LwM2mValueConverter { | ||
130 | return String.valueOf(value); | 131 | return String.valueOf(value); |
131 | case TIME: | 132 | case TIME: |
132 | String DATE_FORMAT = "MMM d, yyyy HH:mm a"; | 133 | String DATE_FORMAT = "MMM d, yyyy HH:mm a"; |
133 | - Long timeValue = ((Date) value).getTime(); | 134 | + Long timeValue; |
135 | + try { | ||
136 | + timeValue = ((Date) value).getTime(); | ||
137 | + } | ||
138 | + catch (Exception e){ | ||
139 | + timeValue = new BigInteger((byte [])value).longValue(); | ||
140 | + } | ||
134 | DateFormat formatter = new SimpleDateFormat(DATE_FORMAT); | 141 | DateFormat formatter = new SimpleDateFormat(DATE_FORMAT); |
135 | return formatter.format(new Date(timeValue)); | 142 | return formatter.format(new Date(timeValue)); |
136 | default: | 143 | default: |
@@ -84,7 +84,11 @@ public class LwM2MTransportConfigServer { | @@ -84,7 +84,11 @@ public class LwM2MTransportConfigServer { | ||
84 | 84 | ||
85 | @Getter | 85 | @Getter |
86 | @Setter | 86 | @Setter |
87 | - private List<ObjectModel> modelsValue; | 87 | + private List<ObjectModel> modelsValueCommon; |
88 | + | ||
89 | + @Getter | ||
90 | + @Setter | ||
91 | + private List<ObjectModel> modelsValueServer; | ||
88 | 92 | ||
89 | @Getter | 93 | @Getter |
90 | @Value("${transport.lwm2m.timeout:}") | 94 | @Value("${transport.lwm2m.timeout:}") |
@@ -188,11 +192,13 @@ public class LwM2MTransportConfigServer { | @@ -188,11 +192,13 @@ public class LwM2MTransportConfigServer { | ||
188 | 192 | ||
189 | @PostConstruct | 193 | @PostConstruct |
190 | public void init() { | 194 | public void init() { |
191 | - modelsValue = ObjectLoader.loadDefault(); | 195 | + modelsValueServer = ObjectLoader.loadDefault(); |
196 | + modelsValueServer.remove(3); | ||
197 | + modelsValueCommon = ObjectLoader.loadDefault(); | ||
192 | File path = getPathModels(); | 198 | File path = getPathModels(); |
193 | if (path.isDirectory()) { | 199 | if (path.isDirectory()) { |
194 | try { | 200 | try { |
195 | - modelsValue.addAll(ObjectLoader.loadObjectsFromDir(path)); | 201 | + modelsValueCommon.addAll(ObjectLoader.loadObjectsFromDir(path)); |
196 | log.info(" [{}] Models directory is a directory", path.getAbsoluteFile()); | 202 | log.info(" [{}] Models directory is a directory", path.getAbsoluteFile()); |
197 | } catch (Exception e) { | 203 | } catch (Exception e) { |
198 | log.error(" [{}] Could not parse the resource definition file", e.toString()); | 204 | log.error(" [{}] Could not parse the resource definition file", e.toString()); |
@@ -255,9 +261,9 @@ public class LwM2MTransportConfigServer { | @@ -255,9 +261,9 @@ public class LwM2MTransportConfigServer { | ||
255 | public ResourceModel getResourceModel(Registration registration, LwM2mPath pathIds) { | 261 | public ResourceModel getResourceModel(Registration registration, LwM2mPath pathIds) { |
256 | String pathLink = "/" + pathIds.getObjectId() + "/" + pathIds.getObjectInstanceId(); | 262 | String pathLink = "/" + pathIds.getObjectId() + "/" + pathIds.getObjectInstanceId(); |
257 | return (Arrays.stream(registration.getObjectLinks()).filter(p-> p.getUrl().equals(pathLink)).findFirst().isPresent() && | 263 | return (Arrays.stream(registration.getObjectLinks()).filter(p-> p.getUrl().equals(pathLink)).findFirst().isPresent() && |
258 | - this.modelsValue.stream().filter(v -> v.id == pathIds.getObjectId()).collect(Collectors.toList()).size() > 0) && | ||
259 | - this.modelsValue.stream().filter(v -> v.id == pathIds.getObjectId()).collect(Collectors.toList()).get(0).resources.containsKey(pathIds.getResourceId()) ? | ||
260 | - this.modelsValue.stream().filter(v -> v.id == pathIds.getObjectId()).collect(Collectors.toList()).get(0).resources.get(pathIds.getResourceId()) : | 264 | + this.modelsValueCommon.stream().filter(v -> v.id == pathIds.getObjectId()).collect(Collectors.toList()).size() > 0) && |
265 | + this.modelsValueCommon.stream().filter(v -> v.id == pathIds.getObjectId()).collect(Collectors.toList()).get(0).resources.containsKey(pathIds.getResourceId()) ? | ||
266 | + this.modelsValueCommon.stream().filter(v -> v.id == pathIds.getObjectId()).collect(Collectors.toList()).get(0).resources.get(pathIds.getResourceId()) : | ||
261 | null; | 267 | null; |
262 | } | 268 | } |
263 | 269 |