use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class IdmIdentityControllerRestTest method testPatchProfile.
@Test
public void testPatchProfile() throws UnsupportedEncodingException, IOException, Exception {
IdmIdentityDto owner = getHelper().createIdentity((GuardedString) null);
//
// create + patch profile
String response = getMockMvc().perform(MockMvcRequestBuilders.patch(getDetailUrl(owner.getId()) + "/profile").with(authentication(getAdminAuthentication())).content(// PATCH => lookout, mappar cannot be used (maps even null attrs).
"{ \"preferredLanguage\": \"en\" }").contentType(TestHelper.HAL_CONTENT_TYPE)).andExpect(status().isOk()).andExpect(content().contentType(TestHelper.HAL_CONTENT_TYPE)).andReturn().getResponse().getContentAsString();
IdmProfileDto createdProfile = (IdmProfileDto) getMapper().readValue(response, IdmProfileDto.class);
Assert.assertEquals(owner.getId(), createdProfile.getIdentity());
Assert.assertEquals("en", createdProfile.getPreferredLanguage());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmProfileService method findOrCreateByIdentity.
@Override
@Transactional
public IdmProfileDto findOrCreateByIdentity(Serializable identityIdentifier, BasePermission... permission) {
Assert.notNull(identityIdentifier, "Identity identifier is required.");
IdmIdentityDto identity = (IdmIdentityDto) lookupService.lookupDto(IdmIdentityDto.class, identityIdentifier);
if (identity == null) {
return null;
}
//
IdmProfileDto profile = this.findOneByIdentity(identity, permission);
//
if (profile != null) {
return profile;
}
// TODO: two profiles can be created in multi thread access (lock by identity before the get)
profile = new IdmProfileDto();
profile.setIdentity(identity.getId());
//
return save(profile, permission);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmProfileService method findOneByIdentity.
private IdmProfileDto findOneByIdentity(IdmIdentityDto identity, BasePermission... permission) {
Assert.notNull(identity, "Identity is required.");
//
IdmProfileFilter filter = new IdmProfileFilter();
filter.setIdentityId(identity.getId());
List<IdmProfileDto> profiles = find(filter, null, permission).getContent();
//
return profiles.isEmpty() ? null : profiles.get(0);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class ProfileDeleteProcessor method process.
@Override
public EventResult<IdmProfileDto> process(EntityEvent<IdmProfileDto> event) {
IdmProfileDto profile = event.getContent();
Assert.notNull(profile.getId(), "Profile id is required!");
//
// remove image attachment for this identity
attachmentManager.deleteAttachments(profile);
//
service.deleteInternal(profile);
//
return new DefaultEventResult<>(event, this);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class ProfileSaveProcessor method process.
@Override
public EventResult<IdmProfileDto> process(EntityEvent<IdmProfileDto> event) {
IdmProfileDto profile = event.getContent();
profile = service.saveInternal(profile);
event.setContent(profile);
//
return new DefaultEventResult<>(event, this);
}
Aggregations