@Override public List<ApplicationEventFamilyMapDto> findApplicationEventFamilyMapsByIds(List<String> ids) { LOG.debug("Find application event family maps by ids [{}]", ids); List<ApplicationEventFamilyMapDto> eventFamilies = Collections.emptyList(); if (ids != null && !ids.isEmpty()) { eventFamilies = convertDtoList(applicationEventFamilyMapDao.findByIds(ids)); } return eventFamilies; }
@Override public ApplicationDto findAppByApplicationToken(String applicationToken) { ApplicationDto applicationDto = null; if (isNotBlank(applicationToken)) { applicationDto = getDto(applicationDao.findByApplicationToken(applicationToken)); } return applicationDto; }
public void setUserConfigurationHash(byte[] userConfigurationHash) { this.userConfigurationHash = getArrayCopy(userConfigurationHash); }
@Override public ChangeConfigurationNotification deleteConfigurationRecord( String schemaId, String groupId, String deactivatedUsername) { ChangeConfigurationNotification configurationNotification = null; validateSqlId(schemaId, "Incorrect configuration schema id " + schemaId + "."); validateSqlId(groupId, "Incorrect group id " + groupId + "."); ConfigurationDto configurationDto = getDto(configurationDao.deactivateOldConfiguration( schemaId, groupId, deactivatedUsername)); if (configurationDto != null) { HistoryDto historyDto = addHistory(configurationDto, ChangeType.REMOVE_CONF); ChangeNotificationDto changeNotificationDto = createNotification( configurationDto, historyDto); configurationNotification = new ChangeConfigurationNotification(); configurationNotification.setConfigurationDto(configurationDto); configurationNotification.setChangeNotificationDto(changeNotificationDto); } Configuration configuration = configurationDao.findInactiveBySchemaIdAndGroupId( schemaId, groupId); if (configuration != null) { configurationDao.removeById(idToString(configuration)); } return configurationNotification; }
@Override public void removeConfSchemasByAppId(String appId) { validateSqlId(appId, "Incorrect application id " + appId + ". Can't remove configuration schema."); LOG.debug("Removing configuration schemas and correspond configuration by application id"); List<ConfigurationSchema> configurationSchemaList = configurationSchemaDao.findByApplicationId(appId); for (ConfigurationSchema configurationSchema : configurationSchemaList) { if (configurationSchema != null) { removeCascadeConfigurationSchema(idToString(configurationSchema)); } } }
@Override public CTLSchemaDto getOrCreateEmptySystemSchema(String createdUsername) { CTLSchemaDto ctlSchema = findCtlSchemaByFqnAndVerAndTenantIdAndApplicationId( DEFAULT_SYSTEM_EMPTY_SCHEMA_FQN, DEFAULT_SYSTEM_EMPTY_SCHEMA_VERSION, null, null); if (ctlSchema == null) { ctlSchema = new CTLSchemaDto(); CtlSchemaMetaInfoDto metaInfo = new CtlSchemaMetaInfoDto(DEFAULT_SYSTEM_EMPTY_SCHEMA_FQN); ctlSchema.setMetaInfo(metaInfo); ctlSchema.setVersion(DEFAULT_SYSTEM_EMPTY_SCHEMA_VERSION); ctlSchema.setCreatedUsername(createdUsername); ctlSchema.setDependencySet(new HashSet<CTLSchemaDto>()); String body = getStringFromFile(DEFAULT_SYSTEM_EMPTY_SCHEMA_FILE, CtlServiceImpl.class); if (!body.isEmpty()) { ctlSchema.setBody(body); } else { throw new RuntimeException("Can't read default system schema."); // NOSONAR } ctlSchema = saveCtlSchema(ctlSchema); } return ctlSchema; }
@Override public CTLSchemaDto toDto() { CTLSchemaDto ctlSchemaDto = createDto(); ctlSchemaDto.setId(getStringId()); ctlSchemaDto.setMetaInfo(metaInfo.toDto()); ctlSchemaDto.setVersion(version); ctlSchemaDto.setCreatedTime(createdTime); ctlSchemaDto.setCreatedUsername(createdUsername); ctlSchemaDto.setBody(body); ctlSchemaDto.setDefaultRecord(defaultRecord); ctlSchemaDto.setDependencySet(DaoUtil.convertDtoSet(dependencySet)); return ctlSchemaDto; }
schemaId, groupId); if (oldInactiveConfiguration != null) { configurationDto.setId(idToString(oldInactiveConfiguration.getId())); configurationDto.setSequenceNumber(oldInactiveConfiguration.getSequenceNumber()); } else if (oldActiveConfiguration != null) { return getDto(configurationDao.save(new Configuration(configurationDto)));
@Override public ConfigurationSchemaDto saveConfSchema(ConfigurationSchemaDto configurationSchema) { ConfigurationSchemaDto savedConfigSchema = null; if (configurationSchema != null) { String appId = configurationSchema.getApplicationId(); if (isValidId(appId)) { LOG.debug("Finding default endpoint group for application id [{}]", appId); EndpointGroup endpointGroup = endpointGroupDao.findByAppIdAndWeight(appId, 0); if (endpointGroup != null) { savedConfigSchema = saveConfSchema(configurationSchema, idToString(endpointGroup)); } else { LOG.warn("Can't find default group for application [{}]", appId); } } else { LOG.warn("Can't find endpoint group. Invalid application id [{}]", appId); } } else { LOG.warn("Configuration schema object is null"); } return savedConfigSchema; }
@Override public List<UserVerifierDto> findUserVerifiersByAppId(String appId) { LOG.debug("Find user verifiers by application id [{}]", appId); return convertDtoList(userVerifierDao.findByAppId(appId)); }
@Override public LogAppenderDto findLogAppenderById(String id) { LOG.debug("Find log appender by id [{}]", id); return getDto(logAppenderDao.findById(id)); }
public void setEndpointKeyHash(byte[] endpointKeyHash) { this.endpointKeyHash = getArrayCopy(endpointKeyHash); }
@Override public List<VersionDto> findVacantSchemasByEndpointGroupId(String endpointGroupId) { validateId(endpointGroupId, "Can't find vacant schemas. Invalid endpoint group id: " + endpointGroupId); EndpointGroup group = endpointGroupDao.findById(endpointGroupId); List<Configuration> configurations = configurationDao.findActualByEndpointGroupId( endpointGroupId); List<String> usedSchemaIds = new ArrayList<>(); for (Configuration configuration : configurations) { ConfigurationSchema schema = configuration.getConfigurationSchema(); if (schema != null) { usedSchemaIds.add(idToString(schema.getId())); } } List<ConfigurationSchema> schemas = configurationSchemaDao.findVacantSchemas( group.getApplicationId(), usedSchemaIds); List<VersionDto> schemaDtoList = new ArrayList<>(); for (ConfigurationSchema schema : schemas) { schemaDtoList.add(schema.toVersionDto()); } return schemaDtoList; }
@Override public List<LogAppenderDto> findAllAppendersByAppId(String appId) { LOG.debug("Find vacant log appenders by application id [{}]", appId); return convertDtoList(logAppenderDao.findByAppId(appId)); }
@Override public UserVerifierDto findUserVerifiersByAppIdAndVerifierToken( String appId, String verifierToken) { LOG.debug("Find user verifier by application id [{}] and verifier token [{}]", appId, verifierToken); return getDto(userVerifierDao.findByAppIdAndVerifierToken(appId, verifierToken)); }
public void setTopicHash(byte[] topicHash) { this.topicHash = getArrayCopy(topicHash); }
private ChangeNotificationDto createNotification(ConfigurationDto configurationDto, HistoryDto historyDto) { LOG.debug("Create notification after configuration update."); ChangeNotificationDto changeNotificationDto = null; if (historyDto != null) { changeNotificationDto = new ChangeNotificationDto(); changeNotificationDto.setAppId(configurationDto.getApplicationId()); changeNotificationDto.setAppSeqNumber(historyDto.getSequenceNumber()); String endpointGroupId = configurationDto.getEndpointGroupId(); if (isValidId(endpointGroupId)) { EndpointGroup group = endpointGroupDao.findById(endpointGroupId); if (group != null) { changeNotificationDto.setGroupId(idToString(group)); changeNotificationDto.setGroupSeqNumber(group.getSequenceNumber()); } else { LOG.debug("Can't find endpoint group by id [{}].", endpointGroupId); } } else { LOG.debug("Incorrect endpoint group id [{}].", endpointGroupId); } } else { LOG.debug("Can't save history information."); } return changeNotificationDto; }
@Override public List<CTLSchemaDto> findCtlSchemas() { LOG.debug("Find all ctl schemas"); return convertDtoList(ctlSchemaDao.find()); }
@Override public NotificationDto findNotificationById(String id) { NotificationDto dto = null; LOG.debug("Find notification by id [{}] ", id); if (StringUtils.isNotBlank(id)) { dto = getDto(notificationDao.findById(id)); } LOG.trace("Found notification object {} by id [{}] ", dto, id); return dto; }
public void setProfileHash(byte[] profileHash) { this.profileHash = getArrayCopy(profileHash); }