@Override public void init(EndpointProfileDto profile, String profileSchemaBody, String serverProfileSchemaBody) { GenericAvroConverter<GenericRecord> endpointProfileConverter = new GenericAvroConverter<>( new Schema.Parser().parse(profileSchemaBody)); GenericAvroConverter<GenericRecord> serverProfileConverter = new GenericAvroConverter<>( new Schema.Parser().parse(serverProfileSchemaBody)); this.epKey = Base64Util.encode(profile.getEndpointKeyHash()); try { if (profile.getServerProfileBody() != null) { serverProfileGenericRecord = serverProfileConverter.decodeJson( profile.getServerProfileBody()); } if (profile.getClientProfileBody() != null) { clientProfileGenericRecord = endpointProfileConverter.decodeJson( profile.getClientProfileBody()); } } catch (IOException ioe) { LOG.error("Error decoding avro object from Json string", ioe); } }
json = profile.getClientProfileBody(); } else { json = profile.getServerProfileBody();
private EndpointProfileDataDto convert(EndpointProfileDto profileDto) { return new EndpointProfileDataDto( profileDto.getId(), endpointKey, profileDto.getClientProfileVersion(), profileDto.getClientProfileBody(), profileDto.getServerProfileVersion(), profileDto.getServerProfileBody()); }
@Override public EndpointProfileBodyDto findBodyByKeyHash(byte[] endpointKeyHash) { LOG.debug("Find endpoint profile body by endpoint key hash [{}] ", endpointKeyHash); EndpointProfileBodyDto endpointProfileBodyDto = null; Query query = Query.query(where(EP_ENDPOINT_KEY_HASH).is(endpointKeyHash)); query.fields() .include(DaoConstants.PROFILE) .include(EP_SERVER_PROFILE_PROPERTY) .include(EP_APPLICATION_ID) .include(EP_PROFILE_VERSION) .include(EP_SERVER_PROFILE_VERSION_PROPERTY) .include(EP_USE_RAW_SCHEMA); EndpointProfileDto pf = mongoTemplate.findOne(query, getDocumentClass()).toDto(); if (pf != null) { endpointProfileBodyDto = new EndpointProfileBodyDto( endpointKeyHash, pf.getClientProfileBody(), pf.getServerProfileBody(), pf.getClientProfileVersion(), pf.getServerProfileVersion(), pf.getApplicationId()); } LOG.debug("[{}] Found client-side endpoint profile body {} with client-side endpoint " + "profile version {} and server-side endpoint profile body {} " + "with server-side endpoint profile version {} and application id {}", endpointKeyHash, pf.getClientProfileBody(), pf.getServerProfileBody(), pf.getClientProfileVersion(), pf.getServerProfileVersion(), pf.getApplicationId()); return endpointProfileBodyDto; }
@Test public void findEndpointProfileBodyByEndpointGroupIdTest() { EndpointGroupDto group = generateEndpointGroupDto(null); String endpointGroupId = group.getId(); PageLinkDto pageLinkDto = new PageLinkDto(endpointGroupId, DEFAULT_LIMIT, DEFAULT_OFFSET); EndpointProfileDto savedEndpointProfileDto = generateEndpointProfileWithGroupIdDto(endpointGroupId); EndpointProfilesBodyDto endpointProfilesPage = endpointService.findEndpointProfileBodyByEndpointGroupId(pageLinkDto); EndpointProfileBodyDto endpointProfileBodyDto = endpointProfilesPage.getEndpointProfilesBody().get(0); Assert.assertEquals(savedEndpointProfileDto.getClientProfileBody(), endpointProfileBodyDto.getClientSideProfile()); }
@Test public void findEndpointProfileBodyByKeyHashTest() { String endpointGroupId = "124"; EndpointProfileDto savedEndpointProfileDto = generateEndpointProfileWithGroupIdDto(endpointGroupId); EndpointProfileBodyDto endpointProfileBodyDto = endpointService.findEndpointProfileBodyByKeyHash(savedEndpointProfileDto.getEndpointKeyHash()); Assert.assertEquals(savedEndpointProfileDto.getClientProfileBody(), endpointProfileBodyDto.getClientSideProfile()); }
EndpointProfileBodyDto endpointProfileBodyDto = new EndpointProfileBodyDto( ep.getEndpointKeyHash(), ep.getClientProfileBody(), ep.getServerProfileBody(), ep.getClientProfileVersion(),
@Test public void testFindBodyByKeyHash() throws Exception { EndpointProfileDto expected = generateEndpointProfileWithEndpointGroupId(null); EndpointProfileBodyDto found = endpointProfileDao.findBodyByKeyHash(expected.getEndpointKeyHash()); Assert.assertFalse(found.getClientSideProfile().isEmpty()); Assert.assertFalse(found.getServerSideProfile().isEmpty()); Assert.assertEquals(expected.getClientProfileBody(), found.getClientSideProfile()); Assert.assertEquals(expected.getServerProfileBody(), found.getServerSideProfile()); }
@Test public void findBodyByKeyHashTest() { EndpointProfileDto endpointProfile = generateEndpointProfileDto(null, null); Assert.assertNotNull(endpointProfile); EndpointProfileBodyDto found = endpointProfileDao.findBodyByKeyHash(endpointProfile.getEndpointKeyHash()); Assert.assertNotNull(found); Assert.assertEquals(endpointProfile.getClientProfileBody(), found.getClientSideProfile()); Assert.assertEquals(endpointProfile.getServerProfileBody(), found.getServerSideProfile()); }
endpointProfileView.setProfileRecord(createRecordFieldFromCtlSchemaAndBody( clientProfileSchema.getCtlSchemaId(), endpointProfile.getClientProfileBody())); endpointProfileView.setServerProfileRecord(createRecordFieldFromCtlSchemaAndBody( serverProfileSchema.getCtlSchemaId(),
this.groupStates = convertDtoToModelList(dto.getGroupState()); this.sequenceNumber = dto.getSequenceNumber(); this.profile = dto.getClientProfileBody(); this.profileHash = getByteBuffer(dto.getProfileHash()); this.profileVersion = dto.getClientProfileVersion();
this.epsConfigurationHash = dto.getEpsConfigurationHash(); this.profile = MongoDaoUtil.encodeReservedCharacteres( (DBObject) JSON.parse(dto.getClientProfileBody())); this.profileHash = dto.getProfileHash(); this.profileVersion = dto.getClientProfileVersion();