use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class XmEntityResource method updateSelfAvatar.
// TODO remove this method after deal with hasPermission check for self
@Timed
@PutMapping(path = "/xm-entities/self/avatar", consumes = "image/*")
@PreAuthorize("hasPermission({'fileName':#fileName, 'request':#request}, 'XMENTITY.SELF.AVATAR.UPDATE')")
@PrivilegeDescription("Privilege to update avatar of current user")
public ResponseEntity<Void> updateSelfAvatar(@RequestHeader(value = XM_HEADER_CONTENT_NAME, required = false) String fileName, HttpServletRequest request) throws IOException {
HttpEntity<Resource> avatarEntity = XmHttpEntityUtils.buildAvatarHttpEntity(request, fileName);
URI uri = xmEntityService.updateAvatar(IdOrKey.SELF, avatarEntity);
return buildAvatarUpdateResponse(uri);
}
use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class XmEntityResource method searchXmEntitiesToLink.
@Timed
@GetMapping("/xm-entities/{entityTypeKey}/{idOrKey}/links/{linkTypeKey}/search")
@PreAuthorize("hasPermission({'query': #query}, 'XMENTITY.SEARCH.TO_LINK.QUERY')")
@PrivilegeDescription("Privilege to search candidates for link with specified XmEntity")
public ResponseEntity<List<XmEntity>> searchXmEntitiesToLink(@PathVariable String idOrKey, @PathVariable String entityTypeKey, @PathVariable String linkTypeKey, @RequestParam String query, @ApiParam Pageable pageable) {
Page<XmEntity> page = xmEntityService.searchXmEntitiesToLink(IdOrKey.of(idOrKey), entityTypeKey, linkTypeKey, query, pageable, null);
HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, String.format("/api/xm-entities/%s/%s/links/%s/search", entityTypeKey, idOrKey, linkTypeKey));
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class XmEntityResource method searchXmEntitiesV2.
@GetMapping("/_search/v2/xm-entities")
@Timed
@PreAuthorize("hasPermission({'query': #query}, 'XMENTITY.SEARCH.QUERY')")
@PrivilegeDescription("Privilege to search for the xmEntity corresponding to the query")
public ResponseEntity<List<XmEntity>> searchXmEntitiesV2(@RequestParam String query, @ApiParam Pageable pageable, @ApiParam ElasticFetchSourceFilterDto fetchSourceFilterDto) {
SearchDto searchDto = SearchDto.builder().query(query).pageable(pageable).entityClass(XmEntity.class).fetchSourceFilter(new FetchSourceFilter(fetchSourceFilterDto.getIncludes(), fetchSourceFilterDto.getExcludes())).build();
Page<XmEntity> page = xmEntityService.searchV2(searchDto, null);
HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/xm-entities");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class XmEntityResource method updateAvatar.
/**
* Multipart update avatar.
*
* @param idOrKey id or key of XmEntity
* @param multipartFile multipart file with avatar
* @return HTTP response
* @throws IOException when IO error
*/
@Timed
@PostMapping("/xm-entities/{idOrKey}/avatar")
@PreAuthorize("hasPermission({'idOrKey':#idOrKey, 'multipartFile':#multipartFile}, 'XMENTITY.AVATAR.UPDATE')")
@PrivilegeDescription("Privilege to update avatar")
public ResponseEntity<Void> updateAvatar(@PathVariable String idOrKey, @RequestParam("file") MultipartFile multipartFile) throws IOException {
HttpEntity<Resource> avatarEntity = XmHttpEntityUtils.buildAvatarHttpEntity(multipartFile);
URI uri = xmEntityService.updateAvatar(IdOrKey.of(idOrKey), avatarEntity);
return buildAvatarUpdateResponse(uri);
}
use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class XmEntityResource method searchXmEntities.
@GetMapping("/_search-with-template/xm-entities")
@Timed
@PreAuthorize("hasPermission({'template': #template}, 'XMENTITY.SEARCH.TEMPLATE')")
@PrivilegeDescription("Privilege to search for the xmEntity by query template")
public ResponseEntity<List<XmEntity>> searchXmEntities(@RequestParam String template, @ApiParam TemplateParamsHolder templateParamsHolder, @ApiParam Pageable pageable) {
Page<XmEntity> page = xmEntityService.search(template, templateParamsHolder, pageable, null);
HttpHeaders headers = PaginationUtil.generateSearchWithTemplatePaginationHttpHeaders(template, templateParamsHolder, page, "/api/_search-with-template/xm-entities");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Aggregations