public CassandraEndpointNotification(String id) { parseStringId(id); }
private ByteBuffer[] getEndpointKeyHash(List<CassandraEpByAppId> filter) { ByteBuffer[] endpointKeyHash = new ByteBuffer[filter.size()]; int pos = 0; for (CassandraEpByAppId ep : filter) { endpointKeyHash[pos++] = ep.getEndpointKeyHash(); } return endpointKeyHash; }
private ByteBuffer[] getEndpointKeyHash(List<CassandraEpByEndpointGroupId> filter) { ByteBuffer[] endpointKeyHash = new ByteBuffer[filter.size()]; int pos = 0; for (CassandraEpByEndpointGroupId ep : filter) { endpointKeyHash[pos++] = ep.getEndpointKeyHash(); } return endpointKeyHash; }
@Override public void removeById(String id) { LOG.debug("Try to remove endpoint user by id {}", id); CassandraEndpointUser endpointUser = new CassandraEndpointUser(id); removeByExternalIdAndTenantId(endpointUser.getExternalId(), endpointUser.getTenantId()); }
@Override public EndpointSpecificConfigurationDto toDto() { EndpointSpecificConfigurationDto dto = new EndpointSpecificConfigurationDto(); dto.setEndpointKeyHash(getBytes(this.getEndpointKeyHash())); dto.setConfiguration(this.getConfiguration()); dto.setConfigurationSchemaVersion(this.getConfigurationVersion()); dto.setVersion(this.getVersion()); return dto; }
@Override public void run() { try { CassandraEndpointProfile ep = new CassandraEndpointProfile(endpointProfile); ep.setEndpointUserId("Ololo " + id); endpointProfileDao.save(ep.toDto()); } catch (KaaOptimisticLockingFailureException ex) { LOG.error("Catch optimistic exception."); throw ex; } } }));
protected EndpointUserDto generateEndpointUser(List<String> endpointIds) { EndpointUserDto endpointUserDto = new EndpointUserDto(); endpointUserDto.setExternalId(UUID.randomUUID().toString()); endpointUserDto.setUsername("Test username"); endpointUserDto.setTenantId(UUID.randomUUID().toString()); endpointUserDto.setEndpointIds(endpointIds); return endpointUserDao.save(new CassandraEndpointUser(endpointUserDto)).toDto(); }
@Override public CassandraEndpointProfile save(EndpointProfileDto dto) { CassandraEndpointProfile endpointProfile = new CassandraEndpointProfile(dto); return save(endpointProfile); }
@Override public CassandraNotification save(NotificationDto notification) { return save(new CassandraNotification(notification)); }
@Override public CassandraEndpointUser save(EndpointUserDto dto) { return save(new CassandraEndpointUser(dto)); }
@Override public CassandraEndpointConfiguration save(EndpointConfigurationDto dto) { LOG.debug("Save endpoint configuration [{}] ", dto); return save(new CassandraEndpointConfiguration(dto)); }
/** * Get value of field <code>id</code>, if it is blank than generate this field by method * <code>generateId()</code> and return. * * @return id */ public String getStringId() { if (isBlank(id)) { generateId(); } return id; }
public ByteBuffer getCassandraCredentialsBody() { return ByteBuffer.wrap(this.getCredentialsBody()); }
@Override public CassandraEndpointUserConfiguration save(EndpointUserConfigurationDto dto) { LOG.debug("Saving user specific configuration {}", dto); CassandraEndpointUserConfiguration userConfiguration = save( new CassandraEndpointUserConfiguration(dto)); if (LOG.isTraceEnabled()) { LOG.trace("Saving result: {}", userConfiguration); } else { LOG.debug("Saving result: {}", userConfiguration != null); } return userConfiguration; }
@Override public CassandraTopicListEntry save(TopicListEntryDto dto) { LOG.debug("Save topic list entry [{}] ", dto); return save(new CassandraTopicListEntry(dto)); }
/** * Get endpoints ids by access token. * * @param accessToken is endpoint key hash * @return endpoint key hash */ public ByteBuffer findEpIdByAccessToken(String accessToken) { LOG.debug("Try to find endpoint key hash by access token {}", accessToken); ByteBuffer endpointKeyHash = null; CassandraEpByAccessToken result = findById(accessToken); if (result != null) { endpointKeyHash = result.getEndpointKeyHash(); } return endpointKeyHash; } }
@Override public CassandraEndpointProfile save(CassandraEndpointProfile object) { if (object.getVersion() == null) { return saveProfile(object); } else { return updateProfile(object); } }
/** * Create new instance of <code>CassandraEpRegistrationByEndpointId</code>. * * @param endpointRegistration contains endpoint id and credentials id, we use them to create * instance of <code>CassandraEpRegistrationByEndpointId</code> */ public static CassandraEpRegistrationByEndpointId fromEndpointRegistration( EndpointRegistration endpointRegistration) { String endpointId = endpointRegistration.getEndpointId(); String credentialsId = endpointRegistration.getCredentialsId(); return new CassandraEpRegistrationByEndpointId(endpointId, credentialsId); }
protected EndpointRegistrationDto generateEndpointRegistration( String applicationId, String endpointId, String credentialsId, Integer serverProfileVersion, String serverProfileBody) { EndpointRegistrationDto endpointRegistration = new EndpointRegistrationDto(); endpointRegistration.setApplicationId(applicationId); endpointRegistration.setEndpointId(endpointId); endpointRegistration.setCredentialsId(credentialsId); endpointRegistration.setServerProfileVersion(serverProfileVersion); endpointRegistration.setServerProfileBody(serverProfileBody); return this.endpointRegistrationDao.save(endpointRegistration).toDto(); }
@Override public CassandraEndpointUser findById(String id) { LOG.debug("Try to find endpoint user by id {}", id); CassandraEndpointUser endpointUser = new CassandraEndpointUser(id); endpointUser = findByExternalIdAndTenantId( endpointUser.getExternalId(), endpointUser.getTenantId() ); LOG.trace("Found endpoint user {} by id {}", endpointUser, id); return endpointUser; }