use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method deleteProfileImage.
/**
* Deletes image attachment from identity
*
* @return
* @since 9.0.0
*/
@RequestMapping(value = "/{backendId}/profile/image", method = RequestMethod.DELETE)
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_UPDATE + "')")
@ApiOperation(value = "Profile picture", nickname = "deleteProfilePicure", tags = { IdmIdentityController.TAG }, notes = "Deletes profile picture from identity.", authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.PROFILE_UPDATE, description = "") }) })
public ResponseEntity<?> deleteProfileImage(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable String backendId) {
IdmProfileDto profile = profileService.findOneByIdentity(backendId, IdmBasePermission.READ, IdmBasePermission.UPDATE);
//
profile = profileService.deleteImage(profile, IdmBasePermission.UPDATE);
// refresh with permissions are needed
IdmProfileFilter context = new IdmProfileFilter();
context.setAddPermissions(true);
profile = profileController.getService().get(profile, context, IdmBasePermission.READ);
//
return new ResponseEntity<>(profileController.toResource(profile), HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmProfileDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmProfileServiceIntegrationTest method testReferentialIntegrity.
@Test
public void testReferentialIntegrity() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmProfileDto profile = getHelper().createProfile(identity);
//
IdmAttachmentDto attachment = new IdmAttachmentDto();
attachment.setName("something");
attachment.setInputData(IOUtils.toInputStream("data"));
attachment.setMimetype("text/plain");
attachment = attachmentManager.saveAttachment(profile, attachment);
//
Assert.assertNotNull(attachmentManager.get(attachment.getId()));
//
service.delete(profile);
//
Assert.assertNull(attachmentManager.get(attachment.getId()));
}
Aggregations