use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class FunctionResource method callUploadFunction.
@Timed
@PostMapping(value = "/functions/**" + UPLOAD, consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@PreAuthorize("hasPermission({'functionKey': #functionKey}, 'FUNCTION.UPLOAD.CALL')")
@SneakyThrows
@PrivilegeDescription("Privilege to call upload function")
public ResponseEntity<Object> callUploadFunction(HttpServletRequest request, @RequestParam(value = "file", required = false) List<MultipartFile> files, HttpServletRequest httpServletRequest) {
Map<String, Object> functionInput = of("httpServletRequest", httpServletRequest, "files", files);
String functionKey = getFunctionKey(request);
functionKey = functionKey.substring(0, functionKey.length() - UPLOAD.length());
FunctionContext result = functionService.execute(functionKey, functionInput, "POST");
return ResponseEntity.ok().body(result.functionResult());
}
use of com.icthh.xm.commons.permission.annotation.PrivilegeDescription in project xm-ms-entity by xm-online.
the class CalendarResource method getCalendarEvents.
/**
* GET /calendars/{id}/events : get events for specific calendar.
*
* @param calendarId the id of the calendar to retrieve events
* @return the ResponseEntity with status 200 (OK) and with body events
*/
@GetMapping("/calendars/{calendarId}/events")
@Timed
@PreAuthorize("hasPermission({'calendarId': #calendarId}, 'calendar', 'CALENDAR.GET_LIST.ITEM.EVENTS')")
@PrivilegeDescription("Privilege to get events for specific calendar")
public ResponseEntity<List<Event>> getCalendarEvents(@PathVariable Long calendarId, EventFilter filter, Pageable pageable) {
Page<Event> page = calendarService.findEvents(calendarId, filter, pageable);
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/calendars/{id}/events");
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 updateSelfAvatar.
// TODO remove this method after deal with hasPermission check for self
@Timed
@PostMapping("/xm-entities/self/avatar")
@PreAuthorize("hasPermission({'multipartFile': #multipartFile}, 'XMENTITY.SELF.AVATAR.UPDATE')")
@PrivilegeDescription("Privilege to update avatar of current user")
public ResponseEntity<Void> updateSelfAvatar(@RequestParam("file") MultipartFile multipartFile) throws IOException {
HttpEntity<Resource> avatarEntity = XmHttpEntityUtils.buildAvatarHttpEntity(multipartFile);
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 searchXmEntities.
/**
* SEARCH /_search/xm-entities?query=:query : search for the xmEntity corresponding to the query.
*
* @param query the query of the xmEntity search
* @param pageable the pagination information
* @return the result of the search
*/
@GetMapping("/_search/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>> searchXmEntities(@RequestParam String query, @ApiParam Pageable pageable) {
Page<XmEntity> page = xmEntityService.search(query, pageable, 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 searchByTypeKeyAndQuery.
@GetMapping("/_search-with-typekey/xm-entities")
@Timed
@PreAuthorize("hasPermission({'typeKey': #typeKey, 'query': #query}, 'XMENTITY.SEARCH.TYPEKEY.QUERY')")
@PrivilegeDescription("Privilege to search for the xmEntity corresponding to the query(not required) and typeKey")
public ResponseEntity<List<XmEntity>> searchByTypeKeyAndQuery(@RequestParam String typeKey, @RequestParam(required = false) String query, @ApiParam Pageable pageable) {
Page<XmEntity> page = xmEntityService.searchByQueryAndTypeKey(query, typeKey, pageable, null);
HttpHeaders headers = PaginationUtil.generateSearchByTypeKeyPaginationHttpHeaders(typeKey, query, page, "/api/_search-with-typekey/xm-entities");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
Aggregations