diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/EndpointProfileCassandraDao.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/EndpointProfileCassandraDao.java index e724240dd0..12b4393478 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/EndpointProfileCassandraDao.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/EndpointProfileCassandraDao.java @@ -86,18 +86,20 @@ import static org.kaaproject.kaa.server.common.nosql.cassandra.dao.model.CassandraModelConstants.EP_SERVER_PROFILE_VERSION_PROPERTY; @Repository(value = "endpointProfileDao") -public class EndpointProfileCassandraDao extends AbstractVersionableCassandraDao implements EndpointProfileDao { +public class EndpointProfileCassandraDao + extends AbstractVersionableCassandraDao + implements EndpointProfileDao { private static final Logger LOG = LoggerFactory.getLogger(EndpointProfileCassandraDao.class); @Autowired - private CassandraEpbyAppIdDao cassandraEPByAppIdDao; + private CassandraEpbyAppIdDao cassandraEpByAppIdDao; @Autowired - private CassandraEpByAccessTokenDao cassandraEPByAccessTokenDao; + private CassandraEpByAccessTokenDao cassandraEpByAccessTokenDao; @Autowired - private CassandraEpBySdkTokenDao cassandraEPBySdkTokenDao; + private CassandraEpBySdkTokenDao cassandraEpBySdkTokenDao; @Autowired - private CassandraEpByEndpointGroupIdDao cassandraEPByEndpointGroupIdDao; + private CassandraEpByEndpointGroupIdDao cassandraEpByEndpointGroupIdDao; private EndpointUserCassandraDao endpointUserDao; @@ -132,17 +134,23 @@ private CassandraEndpointProfile saveProfile(CassandraEndpointProfile profile) { profile = super.save(profile); ByteBuffer epKeyHash = profile.getEndpointKeyHash(); List statementList = new ArrayList<>(); - statementList.add(cassandraEPByAppIdDao.getSaveQuery(new CassandraEPByAppId(profile.getApplicationId(), epKeyHash))); + statementList.add(cassandraEpByAppIdDao.getSaveQuery( + new CassandraEPByAppId(profile.getApplicationId(), epKeyHash))); String accessToken = profile.getAccessToken(); if (accessToken != null) { - statementList.add(cassandraEPByAccessTokenDao.getSaveQuery(new CassandraEPByAccessToken(accessToken, epKeyHash))); + statementList.add( + cassandraEpByAccessTokenDao.getSaveQuery( + new CassandraEPByAccessToken(accessToken, epKeyHash))); } statementList.add(getSaveQuery(profile)); - Statement saveBySdkTokenId = cassandraEPBySdkTokenDao.getSaveQuery(new CassandraEpBySdkToken(profile.getSdkToken(), epKeyHash)); + Statement saveBySdkTokenId = cassandraEpBySdkTokenDao.getSaveQuery( + new CassandraEpBySdkToken(profile.getSdkToken(), epKeyHash)); statementList.add(saveBySdkTokenId); Set groupIdSet = getEndpointProfilesGroupIdSet(profile); for (String groupId : groupIdSet) { - statementList.add(cassandraEPByEndpointGroupIdDao.getSaveQuery(new CassandraEPByEndpointGroupId(groupId, epKeyHash))); + statementList.add( + cassandraEpByEndpointGroupIdDao.getSaveQuery( + new CassandraEPByEndpointGroupId(groupId, epKeyHash))); } executeBatch(statementList.toArray(new Statement[statementList.size()])); LOG.debug("[{}] Endpoint profile saved", profile.getId()); @@ -161,37 +169,51 @@ private CassandraEndpointProfile updateProfile(CassandraEndpointProfile profile) Set oldEndpointGroupIds = getEndpointProfilesGroupIdSet(storedProfile); Set newEndpointGroupIds = getEndpointProfilesGroupIdSet(profile); - Set removeEndpointGroupIds = Sets.filter(oldEndpointGroupIds, Predicates.not(Predicates.in(newEndpointGroupIds))); - Set addEndpointGroupIds = Sets.filter(newEndpointGroupIds, Predicates.not(Predicates.in(oldEndpointGroupIds))); + Set removeEndpointGroupIds = Sets.filter( + oldEndpointGroupIds, Predicates.not(Predicates.in(newEndpointGroupIds))); + + Set addEndpointGroupIds = Sets.filter( + newEndpointGroupIds, Predicates.not(Predicates.in(oldEndpointGroupIds))); if (addEndpointGroupIds != null) { for (String id : addEndpointGroupIds) { - statementList.add(cassandraEPByEndpointGroupIdDao.getSaveQuery(new CassandraEPByEndpointGroupId(id, epKeyHash))); + statementList.add(cassandraEpByEndpointGroupIdDao.getSaveQuery( + new CassandraEPByEndpointGroupId(id, epKeyHash))); } + if (removeEndpointGroupIds != null) { for (String id : removeEndpointGroupIds) { - statementList.add(delete().from(EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME) - .where(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_GROUP_ID_PROPERTY, id)) - .and(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY, epKeyHash))); + statementList.add(delete() + .from(EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME) + .where(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_GROUP_ID_PROPERTY, id)) + .and(eq( + EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY, epKeyHash))); } } executeBatch(statementList.toArray(new Statement[statementList.size()])); } else { - LOG.error("[{}] Can't update endpoint profile with version {}. Endpoint profile already changed!", profile.getId(), profile.getVersion()); - throw new KaaOptimisticLockingFailureException("Can't update endpoint profile with version . Endpoint profile already changed!"); + LOG.error("[{}] Can't update endpoint profile with version {}. " + + "Endpoint profile already changed!", + profile.getId(), profile.getVersion()); + throw new KaaOptimisticLockingFailureException("Can't update endpoint profile with" + + " version . Endpoint profile already changed!"); } String accessToken = profile.getAccessToken(); - if (storedProfile.getAccessToken() != null && !storedProfile.getAccessToken().equals(accessToken)) { - cassandraEPByAccessTokenDao.removeById(storedProfile.getAccessToken()); + if (storedProfile.getAccessToken() != null + && !storedProfile.getAccessToken().equals(accessToken)) { + cassandraEpByAccessTokenDao.removeById(storedProfile.getAccessToken()); } if (accessToken != null) { - statementList.add(cassandraEPByAccessTokenDao.getSaveQuery(new CassandraEPByAccessToken(accessToken, epKeyHash))); + statementList.add(cassandraEpByAccessTokenDao.getSaveQuery( + new CassandraEPByAccessToken(accessToken, epKeyHash))); } executeBatch(statementList.toArray(new Statement[statementList.size()])); LOG.debug("[{}] Endpoint profile updated", profile.getId()); } else { - LOG.error("[{}] Stored profile is null. Can't update endpoint profile.", profile.getId()); - throw new DatabaseProcessingException("Stored profile is null. Can't update endpoint profile."); + LOG.error("[{}] Stored profile is null. Can't update endpoint profile.", + profile.getId()); + throw new DatabaseProcessingException("Stored profile is null. " + + "Can't update endpoint profile."); } return profile; } @@ -199,7 +221,7 @@ private CassandraEndpointProfile updateProfile(CassandraEndpointProfile profile) @Override public CassandraEndpointProfile findByKeyHash(byte[] endpointKeyHash) { LOG.debug("Try to find endpoint profile by key hash [{}]", endpointKeyHash); - CassandraEndpointProfile endpointProfile = (CassandraEndpointProfile) getMapper().get(getByteBuffer(endpointKeyHash)); + CassandraEndpointProfile endpointProfile = getMapper().get(getByteBuffer(endpointKeyHash)); LOG.debug("[{}] Found endpoint profile {}", endpointKeyHash, endpointProfile); return endpointProfile; } @@ -212,9 +234,14 @@ public EndpointProfileBodyDto findBodyByKeyHash(byte[] endpointKeyHash) { String appId = null; int clientSideProfileVersion = 0; int serverSideProfileVersion = 0; - ResultSet resultSet = execute(select(EP_PROFILE_PROPERTY, EP_SERVER_PROFILE_PROPERTY, EP_APP_ID_PROPERTY, EP_PROFILE_VERSION_PROPERTY, - EP_SERVER_PROFILE_VERSION_PROPERTY).from(getColumnFamilyName()) - .where(eq(EP_EP_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash)))); + ResultSet resultSet = execute(select( + EP_PROFILE_PROPERTY, + EP_SERVER_PROFILE_PROPERTY, + EP_APP_ID_PROPERTY, + EP_PROFILE_VERSION_PROPERTY, + EP_SERVER_PROFILE_VERSION_PROPERTY) + .from(getColumnFamilyName()) + .where(eq(EP_EP_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash)))); Row row = resultSet.one(); if (row != null) { profile = row.getString(EP_PROFILE_PROPERTY); @@ -223,10 +250,15 @@ public EndpointProfileBodyDto findBodyByKeyHash(byte[] endpointKeyHash) { clientSideProfileVersion = row.getInt(EP_PROFILE_VERSION_PROPERTY); serverSideProfileVersion = row.getInt(EP_SERVER_PROFILE_VERSION_PROPERTY); } - LOG.debug("[{}] Found client-side endpoint profile body {} with client-side endpoint profile version {} and server-side endpoint profile body {} " + - "with server-side endpoint profile version {} and application id {}", endpointKeyHash, profile, clientSideProfileVersion, serverSideProfile, - serverSideProfileVersion, appId); - return new EndpointProfileBodyDto(endpointKeyHash, profile, serverSideProfile, clientSideProfileVersion, serverSideProfileVersion, appId); + LOG.debug("[{}] Found client-side endpoint profile body {} " + + "with client-side endpoint profile version {} " + + "and server-side endpoint profile body {} " + + "with server-side endpoint profile version {} and application id {}", + endpointKeyHash, profile, clientSideProfileVersion, serverSideProfile, + serverSideProfileVersion, appId); + return new EndpointProfileBodyDto( + endpointKeyHash, profile, serverSideProfile, + clientSideProfileVersion, serverSideProfileVersion, appId); } @Override @@ -259,9 +291,12 @@ private void removeByKeyHashFromEpByEndpointGroupId(byte[] endpointKeyHash) { } if (endpointGroupIds != null) { for (String id : endpointGroupIds) { - statementList.add(delete().from(EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME) - .where(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_GROUP_ID_PROPERTY, id)) - .and(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash)))); + statementList.add(delete() + .from(EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME) + .where(eq(EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_GROUP_ID_PROPERTY, id)) + .and(eq( + EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY, + getByteBuffer(endpointKeyHash)))); } } Statement[] st = new Statement[statementList.size()]; @@ -276,8 +311,10 @@ public void removeByKeyHash(byte[] endpointKeyHash) { removeByKeyHashFromEpByEndpointGroupId(endpointKeyHash); String appId = storedProfile.getApplicationId(); if (!appId.isEmpty()) { - Statement deleteEp = delete().from(EP_BY_APP_ID_COLUMN_FAMILY_NAME).where(eq(EP_BY_APP_ID_APPLICATION_ID_PROPERTY, appId)) - .and(eq(EP_BY_APP_ID_ENDPOINT_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash))); + Statement deleteEp = delete() + .from(EP_BY_APP_ID_COLUMN_FAMILY_NAME) + .where(eq(EP_BY_APP_ID_APPLICATION_ID_PROPERTY, appId)) + .and(eq(EP_BY_APP_ID_ENDPOINT_KEY_HASH_PROPERTY, getByteBuffer(endpointKeyHash))); executeBatch(deleteEp); } getMapper().delete(getByteBuffer(endpointKeyHash)); @@ -286,14 +323,16 @@ public void removeByKeyHash(byte[] endpointKeyHash) { @Override public void removeByAppId(String appId) { LOG.debug("Remove endpoint profile by application id [{}]", appId); - Statement deleteEps = delete().from(getColumnFamilyName()).where(in(EP_EP_KEY_HASH_PROPERTY, cassandraEPByAppIdDao.getEpIdsListByAppId(appId))); - ByteBuffer[] epKeyHashList = cassandraEPByAppIdDao.getEpIdsListByAppId(appId); + Statement deleteEps = delete().from(getColumnFamilyName()) + .where(in(EP_EP_KEY_HASH_PROPERTY, cassandraEpByAppIdDao.getEpIdsListByAppId(appId))); + ByteBuffer[] epKeyHashList = cassandraEpByAppIdDao.getEpIdsListByAppId(appId); if (epKeyHashList != null) { for (ByteBuffer epKeyHash : epKeyHashList) { removeByKeyHashFromEpByEndpointGroupId(getBytes(epKeyHash)); } } - Statement deleteEpsByAppId = delete().from(EP_BY_APP_ID_COLUMN_FAMILY_NAME).where(eq(EP_BY_APP_ID_APPLICATION_ID_PROPERTY, appId)); + Statement deleteEpsByAppId = delete().from(EP_BY_APP_ID_COLUMN_FAMILY_NAME) + .where(eq(EP_BY_APP_ID_APPLICATION_ID_PROPERTY, appId)); executeBatch(deleteEps, deleteEpsByAppId); LOG.trace("Execute statements {}, {} like batch", deleteEps, deleteEpsByAppId); } @@ -302,17 +341,22 @@ public void removeByAppId(String appId) { public CassandraEndpointProfile findByAccessToken(String endpointAccessToken) { LOG.debug("Try to find endpoint profile by access token id [{}]", endpointAccessToken); CassandraEndpointProfile endpointProfile = null; - ByteBuffer epKeyHash = cassandraEPByAccessTokenDao.findEPIdByAccessToken(endpointAccessToken); + ByteBuffer epKeyHash = cassandraEpByAccessTokenDao.findEpIdByAccessToken( + endpointAccessToken); + if (epKeyHash != null) { endpointProfile = (CassandraEndpointProfile) getMapper().get(epKeyHash); } - LOG.trace("Found endpoint profile {} by access token [{}]", endpointProfile, endpointAccessToken); + LOG.trace("Found endpoint profile {} by access token [{}]", + endpointProfile, endpointAccessToken); return endpointProfile; } - private List findEndpointProfilesList(ByteBuffer[] keyHashList, String endpointGroupId) { + private List findEndpointProfilesList(ByteBuffer[] keyHashList, + String endpointGroupId) { List cassandraEndpointProfileList = new ArrayList<>(); - LOG.debug("Found {} endpoint profiles by group id {}", keyHashList != null ? keyHashList.length : 0, endpointGroupId); + LOG.debug("Found {} endpoint profiles by group id {}", + keyHashList != null ? keyHashList.length : 0, endpointGroupId); for (ByteBuffer keyHash : keyHashList) { CassandraEndpointProfile profile = findByKeyHash(getBytes(keyHash)); if (profile != null) { @@ -324,9 +368,12 @@ private List findEndpointProfilesList(ByteBuffer[] keyHashLi return cassandraEndpointProfileList; } - private List findEndpointProfilesBodyList(ByteBuffer[] keyHashList, String endpointGroupId) { - List endpointProfilesBodyDto = new ArrayList<>(); - LOG.debug("Found {} endpoint profiles body by group id {}", keyHashList != null ? keyHashList.length : 0, endpointGroupId); + private List findEndpointProfilesBodyList(ByteBuffer[] keyHashList, + String endpointGroupId) { + final List endpointProfilesBodyDto = new ArrayList<>(); + LOG.debug("Found {} endpoint profiles body by group id {}", + keyHashList != null ? keyHashList.length : 0, endpointGroupId); + for (ByteBuffer keyHash : keyHashList) { EndpointProfileBodyDto endpointProfileBodyDto = findBodyByKeyHash(getBytes(keyHash)); if (endpointProfileBodyDto != null) { @@ -341,36 +388,43 @@ private List findEndpointProfilesBodyList(ByteBuffer[] k @Override public EndpointProfilesPageDto findByEndpointGroupId(PageLinkDto pageLink) { - LOG.debug("Try to find endpoint profile by endpoint group id [{}]", pageLink.getEndpointGroupId()); + LOG.debug("Try to find endpoint profile by endpoint group id [{}]", + pageLink.getEndpointGroupId()); EndpointProfilesPageDto endpointProfilesPageDto; List cassandraEndpointProfileList; ByteBuffer[] keyHashList; if (pageLink.getApplicationId() != null) { - keyHashList = cassandraEPByAppIdDao.findEpByAppId(pageLink, pageLink.getApplicationId()); + keyHashList = cassandraEpByAppIdDao.findEpByAppId( + pageLink, pageLink.getApplicationId()); } else { - keyHashList = cassandraEPByEndpointGroupIdDao.findEpByEndpointGroupId(pageLink); + keyHashList = cassandraEpByEndpointGroupIdDao.findEpByEndpointGroupId(pageLink); } - cassandraEndpointProfileList = findEndpointProfilesList(keyHashList, pageLink.getEndpointGroupId()); - endpointProfilesPageDto = createNextPage(cassandraEndpointProfileList, pageLink.getEndpointGroupId(), pageLink.getLimit()); + cassandraEndpointProfileList = findEndpointProfilesList( + keyHashList, pageLink.getEndpointGroupId()); + endpointProfilesPageDto = createNextPage( + cassandraEndpointProfileList, pageLink.getEndpointGroupId(), pageLink.getLimit()); return endpointProfilesPageDto; } @Override public EndpointProfilesBodyDto findBodyByEndpointGroupId(PageLinkDto pageLink) { - LOG.debug("Try to find endpoint profile body by endpoint group id [{}]", pageLink.getEndpointGroupId()); + LOG.debug("Try to find endpoint profile body by endpoint group id [{}]", + pageLink.getEndpointGroupId()); EndpointProfilesBodyDto endpointProfilesBodyDto; List profilesBodyDto; ByteBuffer[] keyHashList; if (pageLink.getApplicationId() != null) { - keyHashList = cassandraEPByAppIdDao.findEpByAppId(pageLink, pageLink.getApplicationId()); + keyHashList = cassandraEpByAppIdDao.findEpByAppId( + pageLink, pageLink.getApplicationId()); } else { - keyHashList = cassandraEPByEndpointGroupIdDao.findEpByEndpointGroupId(pageLink); + keyHashList = cassandraEpByEndpointGroupIdDao.findEpByEndpointGroupId(pageLink); } profilesBodyDto = findEndpointProfilesBodyList(keyHashList, pageLink.getEndpointGroupId()); if(profilesBodyDto == null) { profilesBodyDto = Collections.emptyList(); } - endpointProfilesBodyDto = createNextBodyPage(profilesBodyDto, pageLink.getEndpointGroupId(), pageLink.getLimit()); + endpointProfilesBodyDto = createNextBodyPage( + profilesBodyDto, pageLink.getEndpointGroupId(), pageLink.getLimit()); return endpointProfilesBodyDto; } @@ -382,7 +436,8 @@ public List findByEndpointUserId(String endpointUserId if (endpointUser != null) { List ids = endpointUser.getEndpointIds(); if (ids != null && !ids.isEmpty()) { - Statement select = select().from(getColumnFamilyName()).where(in(EP_EP_KEY_HASH_PROPERTY, convertStringIds(ids))); + Statement select = select().from(getColumnFamilyName()) + .where(in(EP_EP_KEY_HASH_PROPERTY, convertStringIds(ids))); LOG.trace("Execute statements {}", select); profileList = findListByStatement(select); } @@ -423,8 +478,12 @@ public boolean checkSdkToken(String sdkToken) { } @Override - public CassandraEndpointProfile updateServerProfile(byte[] keyHash, int version, String serverProfile) { - LOG.debug("Updating server profile for endpoint profile with key hash [{}] with schema version [{}]", keyHash, version); + public CassandraEndpointProfile updateServerProfile(byte[] keyHash, + int version, + String serverProfile) { + LOG.debug("Updating server profile for endpoint profile with key hash [{}] " + + "with schema version [{}]", + keyHash, version); ByteBuffer key = ByteBuffer.wrap(keyHash); Statement update = QueryBuilder.update(EP_COLUMN_FAMILY_NAME) .with(set(EP_SERVER_PROFILE_PROPERTY, serverProfile)) @@ -457,7 +516,9 @@ private ByteBuffer[] convertStringIds(List ids) { return keyHashArray; } - private EndpointProfilesPageDto createNextPage(List cassandraEndpointProfileList, String endpointGroupId, String limit) { + private EndpointProfilesPageDto createNextPage(List cassandraEndpointProfileList, + String endpointGroupId, + String limit) { EndpointProfilesPageDto endpointProfilesPageDto = new EndpointProfilesPageDto(); PageLinkDto pageLinkDto = new PageLinkDto(); String next; @@ -465,7 +526,8 @@ private EndpointProfilesPageDto createNextPage(List cassandr if (cassandraEndpointProfileList.size() == (lim + 1)) { pageLinkDto.setEndpointGroupId(endpointGroupId); pageLinkDto.setLimit(limit); - pageLinkDto.setOffset(Base64.encodeBase64URLSafeString(cassandraEndpointProfileList.get(lim).getEndpointKeyHash())); + pageLinkDto.setOffset(Base64.encodeBase64URLSafeString( + cassandraEndpointProfileList.get(lim).getEndpointKeyHash())); cassandraEndpointProfileList.remove(lim); next = null; } else { @@ -477,7 +539,9 @@ private EndpointProfilesPageDto createNextPage(List cassandr return endpointProfilesPageDto; } - private EndpointProfilesBodyDto createNextBodyPage(List profilesBodyDto, String endpointGroupId, String limit) { + private EndpointProfilesBodyDto createNextBodyPage(List profilesBodyDto, + String endpointGroupId, + String limit) { EndpointProfilesBodyDto endpointProfilesBodyDto = new EndpointProfilesBodyDto(); PageLinkDto pageLinkDto = new PageLinkDto(); String next; @@ -485,7 +549,8 @@ private EndpointProfilesBodyDto createNextBodyPage(List if (profilesBodyDto.size() == (lim + 1)) { pageLinkDto.setEndpointGroupId(endpointGroupId); pageLinkDto.setLimit(limit); - pageLinkDto.setOffset(Base64.encodeBase64URLSafeString(profilesBodyDto.get(lim).getEndpointKeyHash())); + pageLinkDto.setOffset( + Base64.encodeBase64URLSafeString(profilesBodyDto.get(lim).getEndpointKeyHash())); profilesBodyDto.remove(lim); next = null; } else { diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/filter/CassandraEpByAccessTokenDao.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/filter/CassandraEpByAccessTokenDao.java index 01dade33dc..e76335b147 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/filter/CassandraEpByAccessTokenDao.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/filter/CassandraEpByAccessTokenDao.java @@ -40,7 +40,7 @@ protected String getColumnFamilyName() { return CassandraModelConstants.EP_BY_ACCESS_TOKEN_COLUMN_FAMILY_NAME; } - public ByteBuffer findEPIdByAccessToken(String accessToken) { + public ByteBuffer findEpIdByAccessToken(String accessToken) { LOG.debug("Try to find endpoint key hash by access token {}", accessToken); ByteBuffer endpointKeyHash = null; CassandraEPByAccessToken result = findById(accessToken); diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointNotification.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointNotification.java index d16a3f2ebb..86cc7b97fd 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointNotification.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointNotification.java @@ -50,7 +50,8 @@ public final class CassandraEndpointNotification implements EndpointNotification private Integer seqNum; @Column(name = CassandraModelConstants.ET_NF_ID_PROPERTY) private String id; - @Column(name = CassandraModelConstants.ET_NF_NOTIFICATION_TYPE_PROPERTY, codec = NotificationTypeCodec.class) + @Column(name = CassandraModelConstants.ET_NF_NOTIFICATION_TYPE_PROPERTY, + codec = NotificationTypeCodec.class) private NotificationTypeDto type; @Column(name = CassandraModelConstants.ET_NF_APPLICATION_ID_PROPERTY) private String applicationId; @@ -201,26 +202,62 @@ public void setTopicId(String topicId) { } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + public boolean equals(Object object) { + if (this == object) { + return true; + } + + if (object == null || getClass() != object.getClass()) { + return false; + } - CassandraEndpointNotification that = (CassandraEndpointNotification) o; + CassandraEndpointNotification that = (CassandraEndpointNotification) object; - if (nfVersion != that.nfVersion) return false; - if (applicationId != null ? !applicationId.equals(that.applicationId) : that.applicationId != null) + if (nfVersion != that.nfVersion) { return false; - if (body != null ? !body.equals(that.body) : that.body != null) return false; - if (endpointKeyHash != null ? !endpointKeyHash.equals(that.endpointKeyHash) : that.endpointKeyHash != null) + } + + if (applicationId != null + ? !applicationId.equals(that.applicationId) + : that.applicationId != null) { return false; - if (expiredAt != null ? !expiredAt.equals(that.expiredAt) : that.expiredAt != null) + } + + if (body != null ? !body.equals(that.body) : that.body != null) { return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (lastModifyTime != null ? !lastModifyTime.equals(that.lastModifyTime) : that.lastModifyTime != null) + } + + if (endpointKeyHash != null + ? !endpointKeyHash.equals(that.endpointKeyHash) + : that.endpointKeyHash != null) { return false; - if (schemaId != null ? !schemaId.equals(that.schemaId) : that.schemaId != null) return false; - if (seqNum != null ? !seqNum.equals(that.seqNum) : that.seqNum != null) return false; - if (type != that.type) return false; + } + + if (expiredAt != null ? !expiredAt.equals(that.expiredAt) : that.expiredAt != null) { + return false; + } + + if (id != null ? !id.equals(that.id) : that.id != null) { + return false; + } + + if (lastModifyTime != null + ? !lastModifyTime.equals(that.lastModifyTime) + : that.lastModifyTime != null) { + return false; + } + + if (schemaId != null ? !schemaId.equals(that.schemaId) : that.schemaId != null) { + return false; + } + + if (seqNum != null ? !seqNum.equals(that.seqNum) : that.seqNum != null) { + return false; + } + + if (type != that.type) { + return false; + } return true; } @@ -242,18 +279,18 @@ public int hashCode() { @Override public String toString() { - return "CassandraEndpointNotification{" + - "endpointKeyHash=" + endpointKeyHash + - ", seqNum=" + seqNum + - ", id='" + id + '\'' + - ", type=" + type + - ", applicationId='" + applicationId + '\'' + - ", schemaId='" + schemaId + '\'' + - ", nfVersion=" + nfVersion + - ", lastModifyTime=" + lastModifyTime + - ", body=" + body + - ", expiredAt=" + expiredAt + - '}'; + return "CassandraEndpointNotification{" + + "endpointKeyHash=" + endpointKeyHash + + ", seqNum=" + seqNum + + ", id='" + id + '\'' + + ", type=" + type + + ", applicationId='" + applicationId + '\'' + + ", schemaId='" + schemaId + '\'' + + ", nfVersion=" + nfVersion + + ", lastModifyTime=" + lastModifyTime + + ", body=" + body + + ", expiredAt=" + expiredAt + + '}'; } @Override diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointProfile.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointProfile.java index f0633d99dc..a766b253d4 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointProfile.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointProfile.java @@ -375,42 +375,151 @@ public void setVersion(Long version) { } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - CassandraEndpointProfile that = (CassandraEndpointProfile) o; - - if (sequenceNumber != that.sequenceNumber) return false; - if (profileVersion != that.profileVersion) return false; - if (serverProfileVersion != that.serverProfileVersion) return false; - if (configurationVersion != that.configurationVersion) return false; - if (notificationVersion != that.notificationVersion) return false; - if (systemNfVersion != that.systemNfVersion) return false; - if (userNfVersion != that.userNfVersion) return false; - if (logSchemaVersion != that.logSchemaVersion) return false; - if (endpointKeyHash != null ? !endpointKeyHash.equals(that.endpointKeyHash) : that.endpointKeyHash != null) return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (endpointProfileKey != null ? !endpointProfileKey.equals(that.endpointProfileKey) : that.endpointProfileKey != null) + public boolean equals(Object object) { + if (this == object) { + return true; + } + + if (object == null || getClass() != object.getClass()) { + return false; + } + + CassandraEndpointProfile that = (CassandraEndpointProfile) object; + + if (sequenceNumber != that.sequenceNumber) { + return false; + } + + if (profileVersion != that.profileVersion) { + return false; + } + + if (serverProfileVersion != that.serverProfileVersion) { + return false; + } + + if (configurationVersion != that.configurationVersion) { + return false; + } + + if (notificationVersion != that.notificationVersion) { + return false; + } + + if (systemNfVersion != that.systemNfVersion) { + return false; + } + + if (userNfVersion != that.userNfVersion) { + return false; + } + + if (logSchemaVersion != that.logSchemaVersion) { + return false; + } + + if (endpointKeyHash != null + ? !endpointKeyHash.equals(that.endpointKeyHash) + : that.endpointKeyHash != null) { + return false; + } + if (id != null ? !id.equals(that.id) : that.id != null) { + return false; + } + + if (endpointProfileKey != null + ? !endpointProfileKey.equals(that.endpointProfileKey) + : that.endpointProfileKey != null) { + return false; + } + + if (applicationId != null + ? !applicationId.equals(that.applicationId) + : that.applicationId != null) { return false; - if (applicationId != null ? !applicationId.equals(that.applicationId) : that.applicationId != null) return false; - if (endpointUserId != null ? !endpointUserId.equals(that.endpointUserId) : that.endpointUserId != null) return false; - if (accessToken != null ? !accessToken.equals(that.accessToken) : that.accessToken != null) return false; - if (groupStates != null ? !groupStates.equals(that.groupStates) : that.groupStates != null) return false; - if (profile != null ? !profile.equals(that.profile) : that.profile != null) return false; - if (profileHash != null ? !profileHash.equals(that.profileHash) : that.profileHash != null) return false; - if (configurationHash != null ? !configurationHash.equals(that.configurationHash) : that.configurationHash != null) return false; - if (userConfigurationHash != null ? !userConfigurationHash.equals(that.userConfigurationHash) : that.userConfigurationHash != null) + } + + if (endpointUserId != null + ? !endpointUserId.equals(that.endpointUserId) + : that.endpointUserId != null) { + return false; + } + + if (accessToken != null + ? !accessToken.equals(that.accessToken) + : that.accessToken != null) { + return false; + } + + if (groupStates != null + ? !groupStates.equals(that.groupStates) + : that.groupStates != null) { + return false; + } + + if (profile != null + ? !profile.equals(that.profile) + : that.profile != null) { + return false; + } + + if (profileHash != null + ? !profileHash.equals(that.profileHash) + : that.profileHash != null) { + return false; + } + + if (configurationHash != null + ? !configurationHash.equals(that.configurationHash) + : that.configurationHash != null) { + return false; + } + + if (userConfigurationHash != null + ? !userConfigurationHash.equals(that.userConfigurationHash) + : that.userConfigurationHash != null) { + return false; + } + + if (subscriptions != null + ? !subscriptions.equals(that.subscriptions) + : that.subscriptions != null) { + return false; + } + + if (topicHash != null + ? !topicHash.equals(that.topicHash) + : that.topicHash != null) { return false; - if (subscriptions != null ? !subscriptions.equals(that.subscriptions) : that.subscriptions != null) return false; - if (topicHash != null ? !topicHash.equals(that.topicHash) : that.topicHash != null) return false; - if (ecfVersionStates != null ? !ecfVersionStates.equals(that.ecfVersionStates) : that.ecfVersionStates != null) return false; - if (serverHash != null ? !serverHash.equals(that.serverHash) : that.serverHash != null) return false; - if (sdkToken != null ? !sdkToken.equals(that.sdkToken) : that.sdkToken != null) return false; - if (useConfigurationRawSchema != null ? !useConfigurationRawSchema.equals(that.useConfigurationRawSchema) : that.useConfigurationRawSchema != null) { + } + + if (ecfVersionStates != null + ? !ecfVersionStates.equals(that.ecfVersionStates) + : that.ecfVersionStates != null) { return false; } - return serverProfile != null ? serverProfile.equals(that.serverProfile) : that.serverProfile == null; + + if (serverHash != null + ? !serverHash.equals(that.serverHash) + : that.serverHash != null) { + return false; + } + + if (sdkToken != null + ? !sdkToken.equals(that.sdkToken) + : that.sdkToken != null) { + return false; + } + + if (useConfigurationRawSchema != null + ? !useConfigurationRawSchema.equals(that.useConfigurationRawSchema) + : that.useConfigurationRawSchema != null) { + return false; + } + + return serverProfile != null + ? serverProfile.equals(that.serverProfile) + : that.serverProfile == null; } @@ -429,7 +538,8 @@ public int hashCode() { result = 31 * result + profileVersion; result = 31 * result + serverProfileVersion; result = 31 * result + (configurationHash != null ? configurationHash.hashCode() : 0); - result = 31 * result + (userConfigurationHash != null ? userConfigurationHash.hashCode() : 0); + result = 31 * result + + (userConfigurationHash != null ? userConfigurationHash.hashCode() : 0); result = 31 * result + configurationVersion; result = 31 * result + notificationVersion; result = 31 * result + (subscriptions != null ? subscriptions.hashCode() : 0); @@ -440,42 +550,43 @@ public int hashCode() { result = 31 * result + (ecfVersionStates != null ? ecfVersionStates.hashCode() : 0); result = 31 * result + (serverHash != null ? serverHash.hashCode() : 0); result = 31 * result + (sdkToken != null ? sdkToken.hashCode() : 0); - result = 31 * result + (useConfigurationRawSchema != null ? useConfigurationRawSchema.hashCode() : 0); + result = 31 * result + + (useConfigurationRawSchema != null ? useConfigurationRawSchema.hashCode() : 0); result = 31 * result + (serverProfile != null ? serverProfile.hashCode() : 0); return result; } @Override public String toString() { - return "CassandraEndpointProfile{" + - "endpointKeyHash=" + endpointKeyHash + - ", id='" + id + '\'' + - ", endpointProfileKey=" + endpointProfileKey + - ", applicationId='" + applicationId + '\'' + - ", endpointUserId='" + endpointUserId + '\'' + - ", accessToken='" + accessToken + '\'' + - ", groupStates=" + groupStates + - ", sequenceNumber=" + sequenceNumber + - ", profile='" + profile + '\'' + - ", profileHash=" + profileHash + - ", profileVersion=" + profileVersion + - ", serverProfileVersion=" + serverProfileVersion + - ", configurationHash=" + configurationHash + - ", userConfigurationHash=" + userConfigurationHash + - ", configurationVersion=" + configurationVersion + - ", notificationVersion=" + notificationVersion + - ", subscriptions=" + subscriptions + - ", topicHash=" + topicHash + - ", simpleTopicHash=" + simpleTopicHash + - ", systemNfVersion=" + systemNfVersion + - ", userNfVersion=" + userNfVersion + - ", logSchemaVersion=" + logSchemaVersion + - ", ecfVersionStates=" + ecfVersionStates + - ", serverHash='" + serverHash + '\'' + - ", sdkToken='" + sdkToken + '\'' + - ", useRawSchema=" + useConfigurationRawSchema + - ", serverProfile='" + serverProfile + '\'' + - '}'; + return "CassandraEndpointProfile{" + + "endpointKeyHash=" + endpointKeyHash + + ", id='" + id + '\'' + + ", endpointProfileKey=" + endpointProfileKey + + ", applicationId='" + applicationId + '\'' + + ", endpointUserId='" + endpointUserId + '\'' + + ", accessToken='" + accessToken + '\'' + + ", groupStates=" + groupStates + + ", sequenceNumber=" + sequenceNumber + + ", profile='" + profile + '\'' + + ", profileHash=" + profileHash + + ", profileVersion=" + profileVersion + + ", serverProfileVersion=" + serverProfileVersion + + ", configurationHash=" + configurationHash + + ", userConfigurationHash=" + userConfigurationHash + + ", configurationVersion=" + configurationVersion + + ", notificationVersion=" + notificationVersion + + ", subscriptions=" + subscriptions + + ", topicHash=" + topicHash + + ", simpleTopicHash=" + simpleTopicHash + + ", systemNfVersion=" + systemNfVersion + + ", userNfVersion=" + userNfVersion + + ", logSchemaVersion=" + logSchemaVersion + + ", ecfVersionStates=" + ecfVersionStates + + ", serverHash='" + serverHash + '\'' + + ", sdkToken='" + sdkToken + '\'' + + ", useRawSchema=" + useConfigurationRawSchema + + ", serverProfile='" + serverProfile + '\'' + + '}'; } @Override diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointRegistration.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointRegistration.java index 3c2901e1e1..7d80f68730 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointRegistration.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointRegistration.java @@ -149,7 +149,8 @@ public int hashCode() { @Override public boolean equals(Object other) { - return EqualsBuilder.reflectionEquals(this, other, CassandraEndpointRegistration.EXCLUDE_FIELDS); + return EqualsBuilder.reflectionEquals( + this, other, CassandraEndpointRegistration.EXCLUDE_FIELDS); } @Override diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointUser.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointUser.java index d0a2c6a5bc..3f4d2774f2 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointUser.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEndpointUser.java @@ -185,7 +185,8 @@ public boolean equals(Object obj) { @Override public String toString() { - return "EndpointUser [id=" + id + ", username=" + username + ", externalId=" + externalId + ", tenantId=" + tenantId + ", accessToken=" + accessToken + return "EndpointUser [id=" + id + ", username=" + username + ", externalId=" + + externalId + ", tenantId=" + tenantId + ", accessToken=" + accessToken + ", endpointIds=" + endpointIds + "]"; } diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEpBySdkToken.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEpBySdkToken.java index 0a8d060872..d715061c7e 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEpBySdkToken.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraEpBySdkToken.java @@ -83,20 +83,20 @@ public int hashCode() { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object object) { + if (this == object) { return true; } - if (o == null) { + if (object == null) { return false; } - if (!(o instanceof CassandraEpBySdkToken)) { + if (!(object instanceof CassandraEpBySdkToken)) { return false; } - CassandraEpBySdkToken other = (CassandraEpBySdkToken) o; + CassandraEpBySdkToken other = (CassandraEpBySdkToken) object; if (endpointKeyHash == null) { if (other.endpointKeyHash != null) { diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraModelConstants.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraModelConstants.java index aecb62c6fe..a6d25ae8c7 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraModelConstants.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraModelConstants.java @@ -76,7 +76,8 @@ private CassandraModelConstants() { * Cassandra endpoint configuration constants. */ public static final String ENDPOINT_CONFIGURATION_COLUMN_FAMILY_NAME = "ep_conf"; - public static final String ENDPOINT_CONFIGURATION_CONF_HASH_PROPERTY = CONFIGURATION_HASH_PROPERTY; + public static final String ENDPOINT_CONFIGURATION_CONF_HASH_PROPERTY = + CONFIGURATION_HASH_PROPERTY; public static final String ENDPOINT_CONFIGURATION_CONF_PROPERTY = "cf"; public static final String ENDPOINT_CONFIGURATION_CONF_ID_PROPERTY = "cf_id"; @@ -127,46 +128,52 @@ private CassandraModelConstants() { * CassandraEPByAccessToken constants. */ public static final String EP_BY_ACCESS_TOKEN_COLUMN_FAMILY_NAME = "access_token_eps"; - public static final String EP_BY_ACCESS_TOKEN_ACCESS_TOKEN_PROPERTY = ACCESS_TOKEN_PROPERTY; - public static final String EP_BY_ACCESS_TOKEN_ENDPOINT_KEY_HASH_PROPERTY = ENDPOINT_KEY_HASH_PROPERTY; + public static final String EP_BY_ACCESS_TOKEN_ACCESS_TOKEN_PROPERTY = + ACCESS_TOKEN_PROPERTY; + public static final String EP_BY_ACCESS_TOKEN_ENDPOINT_KEY_HASH_PROPERTY = + ENDPOINT_KEY_HASH_PROPERTY; /** - * CassandraEPByAppId constants + * CassandraEPByAppId constants. */ public static final String EP_BY_APP_ID_COLUMN_FAMILY_NAME = "app_eps"; public static final String EP_BY_APP_ID_APPLICATION_ID_PROPERTY = APPLICATION_ID_PROPERTY; - public static final String EP_BY_APP_ID_ENDPOINT_KEY_HASH_PROPERTY = ENDPOINT_KEY_HASH_PROPERTY; + public static final String EP_BY_APP_ID_ENDPOINT_KEY_HASH_PROPERTY = + ENDPOINT_KEY_HASH_PROPERTY; /** * CassandraEpBySdkToken constants. */ public static final String EP_BY_SDK_TOKEN_COLUMN_FAMILY_NAME = "sdk_token_eps"; public static final String EP_BY_SDK_TOKEN_SDK_TOKEN_PROPERTY = SDK_TOKEN_PROPERTY; - public static final String EP_BY_SDK_TOKEN_ENDPOINT_KEY_HASH_PROPERTY = ENDPOINT_KEY_HASH_PROPERTY; + public static final String EP_BY_SDK_TOKEN_ENDPOINT_KEY_HASH_PROPERTY = + ENDPOINT_KEY_HASH_PROPERTY; /** - * CassandraEPByEndpointGroupId constants + * CassandraEPByEndpointGroupId constants. */ - public static final String EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME = "endpoint_group_id_eps"; + public static final String EP_BY_ENDPOINT_GROUP_ID_COLUMN_FAMILY_NAME = + "endpoint_group_id_eps"; public static final String EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_GROUP_ID_PROPERTY = "ep_group_id"; - public static final String EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY = ENDPOINT_KEY_HASH_PROPERTY; + public static final String EP_BY_ENDPOINT_GROUP_ID_ENDPOINT_KEY_HASH_PROPERTY = + ENDPOINT_KEY_HASH_PROPERTY; /** - * CassandraTopicLastSecNum constants + * CassandraTopicLastSecNum constants. */ public static final String TOPIC_ID_SEQ_NUMBER_COLUMN_FAMILY_NAME = "topic_seq"; public static final String TOPIC_ID_SEQ_NUMBER_TOPIC_ID_PROPERTY = TOPIC_ID_PROPERTY; public static final String TOPIC_ID_SEQ_NUMBER_SEQUENCE_NUMBER_PROPERTY = "seq_num"; /** - * CassandraTopicLastSecNum constants + * CassandraTopicLastSecNum constants. */ public static final String TOPIC_IDS_COLUMN_FAMILY_NAME = "topics"; public static final String TOPIC_IDS_TOPIC_ID_PROPERTY = TOPIC_ID_PROPERTY; public static final String TOPIC_IDS_VER_TYPE_PROPERTY = "schema_ver"; /** - * CassandraEndpointUserConfiguration constants + * CassandraEndpointUserConfiguration constants. */ public static final String EP_USER_CONF_COLUMN_FAMILY_NAME = "user_conf"; public static final String EP_USER_CONF_USER_ID_PROPERTY = "user_id"; @@ -205,18 +212,23 @@ private CassandraModelConstants() { public static final String EP_REGISTRATION_APPLICATION_ID_PROPERTY = EP_APP_ID_PROPERTY; public static final String EP_REGISTRATION_ENDPOINT_ID_PROPERTY = "ep_id"; public static final String EP_REGISTRATION_CREDENTIALS_ID_PROPERTY = "creds_id"; - public static final String EP_REGISTRATION_SERVER_PROFILE_VERSION_PROPERTY = EP_SERVER_PROFILE_VERSION_PROPERTY; - public static final String EP_REGISTRATION_SERVER_PROFILE_BODY_PROPERTY = EP_SERVER_PROFILE_PROPERTY; + public static final String EP_REGISTRATION_SERVER_PROFILE_VERSION_PROPERTY = + EP_SERVER_PROFILE_VERSION_PROPERTY; + public static final String EP_REGISTRATION_SERVER_PROFILE_BODY_PROPERTY = + EP_SERVER_PROFILE_PROPERTY; /** * {@link CassandraEpRegistrationByEndpointId} */ - public static final String EP_REGISTRATIONS_BY_ENDPOINT_ID_COLUMN_FAMILY_NAME = "creds_id_ep_registration"; - public static final String EP_REGISTRATION_BY_ENDPOINT_ID_CREDENTIALS_ID_PROPERTY = EP_REGISTRATION_CREDENTIALS_ID_PROPERTY; - public static final String EP_REGISTRATION_BY_ENDPOINT_ID_ENDPOINT_ID_PROPERTY = EP_REGISTRATION_ENDPOINT_ID_PROPERTY; + public static final String EP_REGISTRATIONS_BY_ENDPOINT_ID_COLUMN_FAMILY_NAME = + "creds_id_ep_registration"; + public static final String EP_REGISTRATION_BY_ENDPOINT_ID_CREDENTIALS_ID_PROPERTY = + EP_REGISTRATION_CREDENTIALS_ID_PROPERTY; + public static final String EP_REGISTRATION_BY_ENDPOINT_ID_ENDPOINT_ID_PROPERTY = + EP_REGISTRATION_ENDPOINT_ID_PROPERTY; /** - * Cassandra Credentials constants + * Cassandra Credentials constants. */ public static final String CREDENTIALS_COLUMN_FAMILY_NAME = "credentials"; public static final String CREDENTIALS_APPLICATION_ID_PROPERTY = "creds_application_id"; diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraNotification.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraNotification.java index ed8d0c2487..b8b5c6508c 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraNotification.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraNotification.java @@ -197,25 +197,60 @@ public void setExpiredAt(Date expiredAt) { } @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + public boolean equals(Object object) { + if (this == object) { + return true; + } + + if (object == null || getClass() != object.getClass()) { + return false; + } + + CassandraNotification that = (CassandraNotification) object; + + if (seqNum != that.seqNum) { + return false; + } + + if (nfVersion != that.nfVersion) { + return false; + } + + if (applicationId != null + ? !applicationId.equals(that.applicationId) + : that.applicationId != null) { + return false; + } + + if (body != null ? !body.equals(that.body) : that.body != null) { + return false; + } - CassandraNotification that = (CassandraNotification) o; + if (expiredAt != null ? !expiredAt.equals(that.expiredAt) : that.expiredAt != null) { + return false; + } - if (seqNum != that.seqNum) return false; - if (nfVersion != that.nfVersion) return false; - if (applicationId != null ? !applicationId.equals(that.applicationId) : that.applicationId != null) + if (id != null ? !id.equals(that.id) : that.id != null) { return false; - if (body != null ? !body.equals(that.body) : that.body != null) return false; - if (expiredAt != null ? !expiredAt.equals(that.expiredAt) : that.expiredAt != null) + } + + if (lastModifyTime != null + ? !lastModifyTime.equals(that.lastModifyTime) + : that.lastModifyTime != null) { return false; - if (id != null ? !id.equals(that.id) : that.id != null) return false; - if (lastModifyTime != null ? !lastModifyTime.equals(that.lastModifyTime) : that.lastModifyTime != null) + } + + if (schemaId != null ? !schemaId.equals(that.schemaId) : that.schemaId != null) { return false; - if (schemaId != null ? !schemaId.equals(that.schemaId) : that.schemaId != null) return false; - if (topicId != null ? !topicId.equals(that.topicId) : that.topicId != null) return false; - if (type != that.type) return false; + } + + if (topicId != null ? !topicId.equals(that.topicId) : that.topicId != null) { + return false; + } + + if (type != that.type) { + return false; + } return true; } @@ -223,17 +258,17 @@ public boolean equals(Object o) { @Override public String toString() { return "CassandraNotification{" + - "topicId='" + topicId + '\'' + - ", type=" + type + - ", id='" + id + '\'' + - ", applicationId='" + applicationId + '\'' + - ", schemaId='" + schemaId + '\'' + - ", nfVersion=" + nfVersion + - ", seqNum=" + seqNum + - ", lastModifyTime=" + lastModifyTime + - ", body=" + body + - ", expiredAt=" + expiredAt + - '}'; + "topicId='" + topicId + '\'' + + ", type=" + type + + ", id='" + id + '\'' + + ", applicationId='" + applicationId + '\'' + + ", schemaId='" + schemaId + '\'' + + ", nfVersion=" + nfVersion + + ", seqNum=" + seqNum + + ", lastModifyTime=" + lastModifyTime + + ", body=" + body + + ", expiredAt=" + expiredAt + + '}'; } @Override diff --git a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraTopicListEntry.java b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraTopicListEntry.java index 63ee5212ac..057398e708 100644 --- a/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraTopicListEntry.java +++ b/server/common/nosql/cassandra-dao/src/main/java/org/kaaproject/kaa/server/common/nosql/cassandra/dao/model/CassandraTopicListEntry.java @@ -89,15 +89,15 @@ public void setTopicIds(List topicIds) { } @Override - public boolean equals(Object o) { - if (this == o) { + public boolean equals(Object object) { + if (this == object) { return true; } - if (!(o instanceof CassandraTopicListEntry)) { + if (!(object instanceof CassandraTopicListEntry)) { return false; } - CassandraTopicListEntry that = (CassandraTopicListEntry) o; + CassandraTopicListEntry that = (CassandraTopicListEntry) object; if (simpleHash != that.simpleHash) { return false;