Commit c3efbd4015beab9639c398f49bb051bcb843cebd

Authored by Andrii Shvaika
1 parent d0928e4d

Minor refactoring

@@ -74,7 +74,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore { @@ -74,7 +74,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
74 public SecurityInfo getByEndpoint(String endPoint) { 74 public SecurityInfo getByEndpoint(String endPoint) {
75 readLock.lock(); 75 readLock.lock();
76 try { 76 try {
77 - String registrationId = this.getByRegistrationId(endPoint, null); 77 + String registrationId = this.getRegistrationId(endPoint, null);
78 return (registrationId != null && sessions.size() > 0 && sessions.get(registrationId) != null) ? 78 return (registrationId != null && sessions.size() > 0 && sessions.get(registrationId) != null) ?
79 sessions.get(registrationId).getSecurityInfo() : this.addLwM2MClientToSession(endPoint); 79 sessions.get(registrationId).getSecurityInfo() : this.addLwM2MClientToSession(endPoint);
80 } finally { 80 } finally {
@@ -91,7 +91,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore { @@ -91,7 +91,7 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
91 public SecurityInfo getByIdentity(String identity) { 91 public SecurityInfo getByIdentity(String identity) {
92 readLock.lock(); 92 readLock.lock();
93 try { 93 try {
94 - String integrationId = this.getByRegistrationId(null, identity); 94 + String integrationId = this.getRegistrationId(null, identity);
95 return (integrationId != null) ? sessions.get(integrationId).getSecurityInfo() : this.addLwM2MClientToSession(identity); 95 return (integrationId != null) ? sessions.get(integrationId).getSecurityInfo() : this.addLwM2MClientToSession(identity);
96 } finally { 96 } finally {
97 readLock.unlock(); 97 readLock.unlock();
@@ -177,10 +177,10 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore { @@ -177,10 +177,10 @@ public class LwM2mInMemorySecurityStore extends InMemorySecurityStore {
177 } 177 }
178 } 178 }
179 179
180 - private String getByRegistrationId(String endPoint, String identity) { 180 + private String getRegistrationId(String endPoint, String identity) {
181 List<String> registrationIds = (endPoint != null) ? 181 List<String> registrationIds = (endPoint != null) ?
182 - this.sessions.entrySet().stream().filter(model -> endPoint.equals(model.getValue().getEndPoint())).map(model -> model.getKey()).collect(Collectors.toList()) :  
183 - this.sessions.entrySet().stream().filter(model -> identity.equals(model.getValue().getIdentity())).map(model -> model.getKey()).collect(Collectors.toList()); 182 + this.sessions.entrySet().stream().filter(model -> endPoint.equals(model.getValue().getEndPoint())).map(Map.Entry::getKey).collect(Collectors.toList()) :
  183 + this.sessions.entrySet().stream().filter(model -> identity.equals(model.getValue().getIdentity())).map(Map.Entry::getKey).collect(Collectors.toList());
184 return (registrationIds != null && registrationIds.size() > 0) ? registrationIds.get(0) : null; 184 return (registrationIds != null && registrationIds.size() > 0) ? registrationIds.get(0) : null;
185 } 185 }
186 186