@JsonIgnore public String getEndpointProfileSchemaId() { return activeStructureDto != null ? activeStructureDto.getEndpointProfileSchemaId() : inactiveStructureDto.getEndpointProfileSchemaId(); }
/** * Create new instance of <code>ProfileFilter</code>. * @param dto data transfer object contain body, * endpoint profile schema id, server profile * schema id. Assign these values on corresponding * fields of new instance */ public ProfileFilter(ProfileFilterDto dto) { super(dto); this.body = dto.getBody(); String endpointSchemaId = dto.getEndpointProfileSchemaId(); if (isNotBlank(endpointSchemaId)) { this.endpointProfileSchema = new EndpointProfileSchema(getLongId(endpointSchemaId)); } String serverSchemaId = dto.getServerProfileSchemaId(); if (isNotBlank(serverSchemaId)) { this.serverProfileSchema = new ServerProfileSchema(getLongId(serverSchemaId)); } }
/** * All-args constructor. */ public static List<ProfileFilterRecordDto> convertToProfileFilterRecords( Collection<ProfileFilterDto> profileFilters) { Map<ProfileVersionPairDto, ProfileFilterRecordDto> profileFiltterRecordsMap = new HashMap<>(); for (ProfileFilterDto profileFilter : profileFilters) { ProfileVersionPairDto versionPair = new ProfileVersionPairDto( profileFilter.getEndpointProfileSchemaId(), profileFilter.getEndpointProfileSchemaVersion(), profileFilter.getServerProfileSchemaId(), profileFilter.getServerProfileSchemaVersion()); ProfileFilterRecordDto profileFilterRecord = profileFiltterRecordsMap.get(versionPair); if (profileFilterRecord == null) { profileFilterRecord = new ProfileFilterRecordDto(); profileFiltterRecordsMap.put(versionPair, profileFilterRecord); } if (profileFilter.getStatus() == UpdateStatus.ACTIVE) { profileFilterRecord.setActiveStructureDto(profileFilter); } else if (profileFilter.getStatus() == UpdateStatus.INACTIVE) { profileFilterRecord.setInactiveStructureDto(profileFilter); } } return new ArrayList<>(profileFiltterRecordsMap.values()); }
private void validateFilter(ProfileFilterDto dto) { if (dto == null) { throw new IncorrectParameterException("Can't save profile filter. Incorrect object."); } if (dto.getEndpointProfileSchemaId() == null && dto.getServerProfileSchemaId() == null) { throw new IncorrectParameterException( "Profile Filter object invalid. Both schemas are empty."); } if (StringUtils.isBlank(dto.getEndpointGroupId())) { throw new IncorrectParameterException( "Profile Filter object invalid. Endpoint Group id invalid:" + dto.getEndpointGroupId()); } } }
ProfileFilterDto filterDto = cacheService.getFilter(notification.getProfileFilterId()); LOG.debug("Processing filter {}", filterDto); if (filterDto.getEndpointProfileSchemaId() != null && filterDto.getServerProfileSchemaId() != null) { cacheService.resetFilters(new AppProfileVersionsKey(
@Test public void saveMoreFiltersTest() { List<EndpointProfileSchemaDto> schemas = generateProfSchemaDto(null, null, 1); EndpointProfileSchemaDto schema = schemas.get(0); ApplicationDto app = applicationService.findAppById(schema.getApplicationId()); ServerProfileSchemaDto serverSchema = generateServerProfileSchema(app.getId(), app.getTenantId(), 1); generateFilterDto(schema.getId(), serverSchema.getId(), null, 10, true); List<ProfileFilterDto> filters = profileService.findProfileFiltersByAppIdAndVersionsCombination(schema.getApplicationId(), schema.getVersion(), serverSchema.getVersion()); Assert.assertFalse(filters.isEmpty()); Assert.assertEquals(filters.get(0).getStatus(), UpdateStatus.ACTIVE); Assert.assertEquals(schema.getId(), filters.get(0).getEndpointProfileSchemaId()); Assert.assertEquals(serverSchema.getId(), filters.get(0).getServerProfileSchemaId()); }
String endProfSchemaId = profileFilterDto.getEndpointProfileSchemaId(); String srvProfSchemaId = profileFilterDto.getServerProfileSchemaId(); String groupId = profileFilterDto.getEndpointGroupId();
@Override public ProfileFilterDto editProfileFilter(ProfileFilterDto profileFilter) throws KaaAdminServiceException { checkAuthority(KaaAuthorityDto.TENANT_DEVELOPER, KaaAuthorityDto.TENANT_USER); try { String username = getCurrentUser().getUsername(); if (isEmpty(profileFilter.getId())) { profileFilter.setCreatedUsername(username); checkEndpointGroupId(profileFilter.getEndpointGroupId()); } else { profileFilter.setModifiedUsername(username); ProfileFilterDto storedProfileFilter = controlService.getProfileFilter( profileFilter.getId()); Utils.checkNotNull(storedProfileFilter); checkEndpointGroupId(storedProfileFilter.getEndpointGroupId()); } validateProfileFilterBody(profileFilter.getEndpointProfileSchemaId(), profileFilter.getServerProfileSchemaId(), profileFilter.getBody()); return controlService.editProfileFilter(profileFilter); } catch (Exception ex) { throw Utils.handleException(ex); } }