use of eu.bcvsolutions.idm.core.api.dto.filter.IdmProfileFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method expandPanel.
/**
* Expand panel on frontend - persist updated identity profile setting.
*
* @param backendId identity codeable identifier
* @param panelId panel identitfier ~ uiKey
* @return updated profile
* @since 11.2.0
*/
@RequestMapping(value = "/{backendId}/profile/panels/{panelId}/expand", method = RequestMethod.PATCH)
@ResponseBody
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_UPDATE + "')")
@ApiOperation(value = "Expand panel", nickname = "expandPanel", tags = { IdmIdentityController.TAG }, notes = "Expand panel - persist updated identity profile setting.", 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<?> expandPanel(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable @NotNull String backendId, @ApiParam(value = "Panel identifier - uiKey.", required = true) @PathVariable @NotNull String panelId) {
IdmIdentityDto identity = getDto(backendId);
if (identity == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
IdmProfileDto profile = profileService.expandPanel(backendId, panelId, 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.filter.IdmProfileFilter in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method uploadProfileImage.
/**
* Upload new profile picture
*
* @param backendId
* @param fileName
* @param data
* @return
* @throws IOException
* @since 9.0.0
*/
@ResponseBody
@RequestMapping(value = "/{backendId}/profile/image", method = RequestMethod.POST)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.PROFILE_UPDATE + "')")
@ApiOperation(value = "Update profile picture", nickname = "postProfilePicture", tags = { IdmProfileController.TAG }, notes = "Upload new profile image", 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<?> uploadProfileImage(@ApiParam(value = "Identity's uuid identifier or username.", required = false) @PathVariable String backendId, @RequestParam(required = true, name = "fileName") @NotNull String fileName, @RequestParam(required = true, name = "data") MultipartFile data) {
IdmProfileDto profile = profileService.findOrCreateByIdentity(backendId, IdmBasePermission.READ, IdmBasePermission.CREATE);
//
profile = profileService.uploadImage(profile, data, fileName, 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.filter.IdmProfileFilter 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);
}
Aggregations