@Override public ApplicationDto getApplicationByApplicationToken(String applicationToken) throws ControlServiceException { return applicationService.findAppByApplicationToken(applicationToken); }
@Override public String compute(String key) { LOG.debug("Fetching result for token id"); ApplicationDto appDto = applicationService.findAppByApplicationToken(key); return appDto != null ? appDto.getTenantId() : null; }
@Override public String compute(String key) { LOG.debug("Fetching result for token id"); ApplicationDto appDto = applicationService.findAppByApplicationToken(key); return appDto != null ? appDto.getId() : null; } });
@Override @Cacheable("defaultGroups") public EndpointGroupDto getDefaultGroup(String applicationToken) { return defaultGroupMemorizer.compute(applicationToken, applicationToken1 -> { LOG.debug("Fetching result for token id"); ApplicationDto appDto = applicationService.findAppByApplicationToken(applicationToken1); return endpointService.findDefaultGroup(appDto.getId()); }); }
@Override public ConfigurationSchemaDto compute(AppVersionKey key) { LOG.debug("Fetching result for getConfSchemaByAppAndVersion"); ApplicationDto appDto = applicationService.findAppByApplicationToken( key.getApplicationToken()); ConfigurationSchemaDto value = configurationService.findConfSchemaByAppIdAndVersion( appDto.getId(), key.getVersion()); return value; } });
@Override public EndpointProfileSchemaDto compute(AppVersionKey key) { LOG.debug("Fetching result for getProfileSchemaByAppAndVersion"); ApplicationDto appDto = applicationService.findAppByApplicationToken( key.getApplicationToken()); EndpointProfileSchemaDto value = profileService.findProfileSchemaByAppIdAndVersion( appDto.getId(), key.getVersion()); return value; } });
@Override public ServerProfileSchemaDto compute(AppVersionKey key) { LOG.debug("Fetching result for getServerProfileSchemaByAppAndVersion"); ApplicationDto appDto = applicationService.findAppByApplicationToken( key.getApplicationToken()); ServerProfileSchemaDto value = serverProfileService.findServerProfileSchemaByAppIdAndVersion(appDto.getId(), key.getVersion()); return value; } });
@Override public AppSeqNumber compute(String key) { LOG.debug("Fetching result for getAppSeqNumber"); ApplicationDto appDto = applicationService.findAppByApplicationToken(key); AppSeqNumber appSeqNumber = new AppSeqNumber( appDto.getTenantId(), appDto.getId(), appDto.getApplicationToken(), appDto.getSequenceNumber()); return appSeqNumber; } });
@Override public List<ProfileFilterDto> compute(AppProfileVersionsKey key) { LOG.debug("Fetching result for getFilters"); ApplicationDto appDto = applicationService.findAppByApplicationToken( key.getApplicationToken()); List<ProfileFilterDto> value = profileService.findProfileFiltersByAppIdAndVersionsCombination(appDto.getId(), key.getEndpointProfileSchemaVersion(), key.getServerProfileSchemaVersion()); return value; } });
/** * Create a new instance of ApplicationLogActorMessageProcessor. * * @param context the akka context * @param applicationToken the application token */ public ApplicationLogActorMessageProcessor(AkkaContext context, String applicationToken) { super(); this.logAppenderService = context.getLogAppenderService(); this.cacheService = context.getCacheService(); this.ctlService = context.getCtlService(); this.applicationToken = applicationToken; this.applicationId = context.getApplicationService() .findAppByApplicationToken(applicationToken) .getId(); this.logAppenders = new HashMap<>(); this.logAppendersCache = new HashMap<>(); this.logSchemas = new HashMap<>(); this.clientProfileSchemas = new HashMap<>(); this.serverProfileSchemas = new HashMap<>(); this.voidCallback = new VoidCallback(); for (LogAppender appender : logAppenderService.getApplicationAppenders(applicationId)) { logAppenders.put(appender.getAppenderId(), appender); } }
/** * Instantiates a new application log actor. * * @param context the context * @param applicationToken the application token */ private ApplicationUserVerifierActor(AkkaContext context, String applicationToken) { this.applicationId = context.getApplicationService() .findAppByApplicationToken(applicationToken) .getId(); this.messageProcessor = new ApplicationUserVerifierActorMessageProcessor( context.getEndpointUserService(), applicationId ); }
@Override public EndpointUserConfigurationDto saveUserConfiguration(EndpointUserConfigurationDto userConfig) { EndpointUserConfigurationDto userConfigurationDto = null; if (userConfig != null) { String userConfigBody = userConfig.getBody(); if (isNotBlank(userConfigBody)) { String appToken = userConfig.getAppToken(); ApplicationDto applicationDto = applicationService.findAppByApplicationToken(appToken); if (applicationDto != null) { int schemaVersion = userConfig.getSchemaVersion(); userConfig.setBody(configurationService.normalizeAccordingToOverrideConfigurationSchema(applicationDto.getId(), schemaVersion, userConfigBody)); userConfigurationDto = getDto(endpointUserConfigurationDao.save(userConfig)); } else { LOG.warn("Can't find application with token {} for endpoint user configuration.", appToken); throw new IncorrectParameterException("Can't find application for specified token."); } } else { LOG.warn("Invalid endpoint user configuration. Configuration body is empty"); throw new IncorrectParameterException("Configuration body is empty."); } } return userConfigurationDto; }
List<HistoryDto> relatedChanges = new ArrayList<HistoryDto>(); ApplicationDto appDto = applicationService.findAppByApplicationToken(key.getAppToken()); List<HistoryDto> fullHistoryList = historyService.findHistoriesBySeqNumberRange( appDto.getId(), key.getOldSeqNumber(),
@Override public ApplicationDto editApplication(ApplicationDto application) throws ControlServiceException { ApplicationDto storedApplication = applicationService .findAppByApplicationToken(application.getApplicationToken()); if (storedApplication != null) { application.setId(storedApplication.getId()); } boolean update = !isEmpty(application.getId()); ApplicationDto appDto = applicationService.saveApp(application); if (update) { LOG.info("[{}] Broadcasting notification about application {} update.", application.getId(), application.getApplicationToken()); Notification thriftNotification = new Notification(); thriftNotification.setAppId(appDto.getId()); thriftNotification.setAppSeqNumber(appDto.getSequenceNumber()); thriftNotification.setOp(Operation.APP_UPDATE); controlZkService.sendEndpointNotification(thriftNotification); } return appDto; }
@Test public void findAppByApplicationTokenTest() { ApplicationDto application = generateApplicationDto(); ApplicationDto foundApp = applicationService.findAppByApplicationToken(application.getApplicationToken()); Assert.assertNotNull(foundApp); Assert.assertEquals(application.getId(), foundApp.getId()); }
@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()); } }