/** * Check schema. * * @param schemaDto the schema dto * @param file the file * @throws NotFoundException the control service exception */ private void checkSchema(VersionDto schemaDto, RecordFiles file) throws NotFoundException { if (schemaDto == null) { throw new NotFoundException("Schema " + file + " not found!"); } }
private ServerProfileSchemaDto getServerProfileSchema(String applicationId, Integer serverProfileVersion) throws Exception { ServerProfileSchemaDto serverProfileSchema = this.controlService.getServerProfileSchemaByApplicationIdAndVersion( applicationId, serverProfileVersion); if (serverProfileSchema == null) { throw new NotFoundException("No server-side endpoint profile schema found!"); } return serverProfileSchema; }
@Override public CTLSchemaDto getCtlSchemaById(String schemaId) throws ControlServiceException { CTLSchemaDto ctlSchemaDto = ctlService.findCtlSchemaById(schemaId); if (ctlSchemaDto == null) { LOG.error("CTL schema with Id [{}] not found!", schemaId); throw new NotFoundException("CTL schema not found!"); } return ctlSchemaDto; }
@Override public EndpointSpecificConfigurationDto findEndpointSpecificConfiguration(byte[] endpointKeyHash, Integer confSchemaVersion) { Optional<EndpointSpecificConfigurationDto> result; if (confSchemaVersion == null) { result = endpointSpecificConfigurationService.findActiveConfigurationByEndpointKeyHash(endpointKeyHash); } else { result = endpointSpecificConfigurationService.findByEndpointKeyHashAndConfSchemaVersion(endpointKeyHash, confSchemaVersion); } return result.orElseThrow(() -> new NotFoundException("Endpoint specific configuration not found")); }
@Override public EndpointSpecificConfigurationDto deleteEndpointSpecificConfiguration(byte[] endpointKeyHash, Integer confSchemaVersion) { Optional<EndpointSpecificConfigurationDto> result; if (confSchemaVersion == null) { result = endpointSpecificConfigurationService.deleteActiveConfigurationByEndpointKeyHash(endpointKeyHash); } else { result = endpointSpecificConfigurationService.deleteByEndpointKeyHashAndConfSchemaVersion(endpointKeyHash, confSchemaVersion); } EndpointSpecificConfigurationDto configuration = result .orElseThrow(() -> new NotFoundException("Endpoint specific configuration not found")); sendEndpointConfigurationRefreshMessage(configuration); return configuration; }
@Override public FileData getRecordStructureSchema(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService .findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } Schema recordWrapperSchema = null; try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(logCtlSchema.getBody()); } catch (IOException ex) { LOG.error("Unable to get Record Structure Schema", ex); throw new ControlServiceException(ex); } String libraryFileName = MessageFormatter .arrayFormat(SCHEMA_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); String schemaInJson = recordWrapperSchema.toString(true); byte[] schemaData = schemaInJson.getBytes(StandardCharsets.UTF_8); FileData schema = new FileData(); schema.setFileName(libraryFileName); schema.setFileData(schemaData); return schema; }
@Override public FileData generateRecordStructureLibrary(String applicationId, int logSchemaVersion) throws ControlServiceException { ApplicationDto application = applicationService.findAppById(applicationId); if (application == null) { throw new NotFoundException("Application not found!"); } LogSchemaDto logSchema = logSchemaService.findLogSchemaByAppIdAndVersion(applicationId, logSchemaVersion); if (logSchema == null) { throw new NotFoundException("Log schema not found!"); } try { CTLSchemaDto logCtlSchema = getCtlSchemaById(logSchema.getCtlSchemaId()); Schema recordWrapperSchema = RecordWrapperSchemaGenerator .generateRecordWrapperSchema(getFlatSchemaByCtlSchemaId(logCtlSchema.getId())); String fileName = MessageFormatter.arrayFormat(LOG_SCHEMA_LIBRARY_NAME_PATTERN, new Object[] {logSchemaVersion}).getMessage(); return SchemaLibraryGenerator.generateSchemaLibrary(recordWrapperSchema, fileName); } catch (Exception ex) { LOG.error("Unable to generate Record Structure Library", ex); throw new ControlServiceException(ex); } }
ApplicationDto application = applicationService.findAppById(key.getApplicationId()); if (application == null) { throw new NotFoundException("Application not found!");
@Override public SdkProfileDto createSdkProfile(SdkProfileDto sdkProfile) throws KaaAdminServiceException { this.checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { this.checkApplicationId(sdkProfile.getApplicationId()); sdkProfile.setCreatedUsername(getCurrentUser().getUsername()); sdkProfile.setCreatedTime(System.currentTimeMillis()); ApplicationDto application = controlService.getApplication(sdkProfile.getApplicationId()); if (application == null) { throw new NotFoundException("Application not found!"); } sdkProfile.setApplicationToken(application.getApplicationToken()); return controlService.saveSdkProfile(sdkProfile); } catch (Exception cause) { throw Utils.handleException(cause); } }
@Override public ConfigurationRecordDto findConfigurationRecordBySchemaIdAndEndpointGroupId( String schemaId, String endpointGroupId) { ConfigurationRecordDto record = new ConfigurationRecordDto(); Collection<ConfigurationDto> configurations = convertDtoList( configurationDao.findActualBySchemaIdAndGroupId(schemaId, endpointGroupId)); if (configurations != null) { for (ConfigurationDto configuration : configurations) { if (configuration.getStatus() == UpdateStatus.ACTIVE) { record.setActiveStructureDto(configuration); } else if (configuration.getStatus() == UpdateStatus.INACTIVE) { record.setInactiveStructureDto(configuration); } } } if (!record.hasActive()) { ConfigurationDto deprecatedConfiguration = getDto( configurationDao.findLatestDeprecated(schemaId, endpointGroupId)); if (deprecatedConfiguration != null) { record.setActiveStructureDto(deprecatedConfiguration); } } if (record.isEmpty()) { LOG.debug("Can't find related Configuration record."); throw new NotFoundException("Configuration record not found, schemaId: " + schemaId + ", endpointGroupId: " + endpointGroupId); // NOSONAR } return record; }
+ "server schema {} and group {}.", endpointProfileSchemaId, serverProfileSchemaId, endpointGroupId); throw new NotFoundException("Profile filter record not found, endpointProfileSchemaId: " + endpointProfileSchemaId + ", serverProfileSchemaId: " + serverProfileSchemaId + " endpointGroupId: " + endpointGroupId);
@Override public void editUserConfiguration(EndpointUserConfigurationDto configuration) throws ControlServiceException { ApplicationDto appDto = applicationService.findAppByApplicationToken( configuration.getAppToken()); EndpointUserDto userDto = endpointService.findEndpointUserByExternalIdAndTenantId( configuration.getUserId(), appDto.getTenantId()); if (userDto == null) { throw new NotFoundException("Specified user not found!"); } configuration.setUserId(userDto.getId()); configuration = userConfigurationService.saveUserConfiguration(configuration); EndpointObjectHash hash = EndpointObjectHash.fromString(configuration.getBody()); checkNeighbors(); OperationsNodeInfo server = resolve(configuration.getUserId()); if (server != null) { UserConfigurationUpdate msg = new UserConfigurationUpdate(appDto.getTenantId(), configuration.getUserId(), configuration.getAppToken(), configuration.getSchemaVersion(), hash.getDataBuf()); if (LOG.isTraceEnabled()) { LOG.trace("Sending message {} to [{}]", msg, Neighbors.getServerId( server.getConnectionInfo())); } neighbors.sendMessage(server.getConnectionInfo(), OperationsServiceMsg.fromUpdate(msg)); } else { LOG.warn("Can't find server for user [{}]", configuration.getUserId()); } }
sdkProfile.getProfileSchemaVersion()); if (profileSchema == null) { throw new NotFoundException("Profile schema not found!"); sdkProfile.getConfigurationSchemaVersion()); if (configurationSchema == null) { throw new NotFoundException("Configuration schema not found!"); throw new NotFoundException("Default configuration not found!"); NotificationTypeDto.USER, sdkProfile.getNotificationSchemaVersion()); if (notificationSchema == null) { throw new NotFoundException("Notification schema not found!"); throw new NotFoundException("Log schema not found!");