下面列出了javax.ws.rs.NotSupportedException#com.codahale.metrics.annotation.Timed 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* GET /users/:login : get the "login" user.
*
* @param login the login of the user to find
* @return the ResponseEntity with status 200 (OK) and with body the "login" user, or with status 404 (Not Found)
*/
@GetMapping("/users/{login:" + Constants.LOGIN_REGEX + "}")
@Timed
public ResponseEntity<UserDTO> getUser(HttpServletRequest httpServletRequest,
@PathVariable String login) {
log.debug("REST request to get User : {}", login);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
String userRoles = JwtUtil.getUserRoles(httpServletRequest);
if (null == userLogin || !(userLogin.equals(login) || userLogin.equals("system") || (userRoles != null && userRoles.contains("ROLE_ADMIN")))) {
// 只能由申请者自己或者ROLE_ADMIN查询用户信息
return ResponseEntity.status(403).build(); // 403 Forbidden
}
return ResponseUtil.wrapOrNotFound(
userService.getUserWithAuthoritiesByLogin(login)
.map(UserDTO::new));
}
/**
* GET /solution-favorites : get pageable solution-favorites.
*
* @return the ResponseEntity with status 200 (OK) and the list of solution-favorites in body
*/
@GetMapping("/solution-favorites")
@Timed
public ResponseEntity<List<SolutionFavorite>> getAllSolutionFavorite(@RequestParam(value = "userLogin") String userLogin,
@RequestParam(value = "solutionUuid", required = false) String solutionUuid,
Pageable pageable) {
log.debug("REST request to get all solution-favorites");
Page<SolutionFavorite> page;
if (null != solutionUuid) {
page = solutionFavoriteRepository.findAllByUserLoginAndSolutionUuid(userLogin, solutionUuid, pageable);
} else {
page = solutionFavoriteRepository.findAllByUserLogin(userLogin, pageable);
}
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/solution-favorites");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
/**
* PUT /users : Updates an existing User.
*
* @param userDTO the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user
* @throws EmailAlreadyUsedException 400 (Bad Request) if the email is already in use
* @throws LoginAlreadyUsedException 400 (Bad Request) if the login is already in use
*/
@PutMapping("/users")
@Timed
@Secured({AuthoritiesConstants.ADMIN})
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody UserDTO userDTO) {
log.debug("REST request to update User : {}", userDTO);
Optional<User> existingUser = userRepository.findOneByEmailIgnoreCase(userDTO.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
throw new EmailAlreadyUsedException();
}
existingUser = userRepository.findOneByLogin(userDTO.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(userDTO.getId()))) {
throw new LoginAlreadyUsedException();
}
Optional<UserDTO> updatedUser = userService.updateUser(userDTO);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("A user is updated with identifier " + userDTO.getLogin(), userDTO.getLogin()));
}
/**
* DELETE /solution-favorites/:id : delete the "id" solutionFavorite.
*
* @param id the id of the solutionFavorite to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/solution-favorites/{id}")
@Timed
public ResponseEntity<Void> deleteSolutionFavorite(HttpServletRequest httpServletRequest,
@PathVariable Long id) {
log.debug("REST request to delete SolutionFavorite : {}", id);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
SolutionFavorite solutionFavorite = solutionFavoriteRepository.findOne(id);
if (null == userLogin || !userLogin.equals(solutionFavorite.getUserLogin())) {
return ResponseEntity.status(403).build(); // 403 Forbidden
}
solutionFavoriteRepository.delete(id);
return ResponseEntity.ok().build();
}
/**
* DELETE /artifacts/:id : delete the "id" artifact.
* @param id the id of the artifact to delete
* @return the ResponseEntity with status 200 (OK) or 403 Forbidden
*/
@DeleteMapping("/artifacts/{id}")
@Timed
public ResponseEntity<Void> deleteArtifact(HttpServletRequest httpServletRequest,
@PathVariable Long id) {
log.debug("REST request to delete Artifact : {}", id);
Artifact artifact = artifactRepository.findOne(id);
Solution solution = solutionRepository.findAllByUuid(artifact.getSolutionUuid()).get(0);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null == userLogin || !(userLogin.equals(solution.getAuthorLogin()) || userLogin.equals("system"))) {
// 只能由作者自己删除,或者由umu微服务中的onboardService异步服务删除
return ResponseEntity.status(403).build(); // 403 Forbidden
}
artifactRepository.delete(id);
return ResponseEntity.ok().build();
}
/**
* POST /account : update the current user information.
*
* @param userDTO the current user information
* @return the ResponseEntity with status 200 (OK), or status 400 (Bad Request) or 500 (Internal Server Error) if the user couldn't be updated
*/
@PostMapping("/account")
@Timed
public ResponseEntity saveAccount(@Valid @RequestBody UserDTO userDTO) {
final String userLogin = SecurityUtils.getCurrentUserLogin();
Optional<User> existingUser = userRepository.findOneByEmail(userDTO.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getLogin().equalsIgnoreCase(userLogin))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert("user-management", "emailexists", "Email already in use")).body(null);
}
return userRepository
.findOneByLogin(userLogin)
.map(u -> {
userService.updateUser(userDTO.getFirstName(), userDTO.getLastName(), userDTO.getEmail(),
userDTO.getLangKey(), userDTO.getImageUrl());
return new ResponseEntity(HttpStatus.OK);
})
.orElseGet(() -> new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR));
}
/**
* POST /users : Creates a new user.
* <p>
* Creates a new user if the login and email are not already used, and sends an
* mail with an activation link.
* The user needs to be activated on creation.
*
* @param userDTO the user to create
* @return the ResponseEntity with status 201 (Created) and with body the new user, or with status 400 (Bad Request) if the login or email is already in use
* @throws URISyntaxException if the Location URI syntax is incorrect
* @throws BadRequestAlertException 400 (Bad Request) if the login or email is already in use
*/
@PostMapping("/users")
@Timed
@Secured({AuthoritiesConstants.ADMIN})
public ResponseEntity<User> createUser(@Valid @RequestBody UserDTO userDTO) throws URISyntaxException {
log.debug("REST request to save User : {}", userDTO);
if (userDTO.getId() != null) {
throw new BadRequestAlertException("A new user cannot already have an ID", "userManagement", "idexists");
// Lowercase the user login before comparing with database
} else if (userRepository.findOneByLogin(userDTO.getLogin().toLowerCase()).isPresent()) {
throw new LoginAlreadyUsedException();
} else if (userRepository.findOneByEmailIgnoreCase(userDTO.getEmail()).isPresent()) {
throw new EmailAlreadyUsedException();
} else {
User newUser = userService.createUser(userDTO);
// mailService.sendCreationEmail(newUser); // huolongshe: 创建用户不发邮件通知
return ResponseEntity.created(new URI("/api/users/" + newUser.getLogin()))
.headers(HeaderUtil.createAlert( "A user is created with identifier " + newUser.getLogin(), newUser.getLogin()))
.body(newUser);
}
}
/**
* DELETE /articles/:id : delete the "id" article.
* @param id the id of the article to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/articles/{id}")
@Timed
@Secured({"ROLE_CONTENT"})
public ResponseEntity<Void> deleteArticle(HttpServletRequest httpServletRequest,
@PathVariable Long id) {
log.debug("REST request to delete Article : {}", id);
Article article = articleRepository.findOne(id);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null == userLogin || !userLogin.equals(article.getAuthorLogin())) {
return ResponseEntity.status(403).build(); // 403 Forbidden
}
articleRepository.delete(id);
return ResponseEntity.ok().build();
}
/**
* PUT /messages/viewed : Updates an existing message' viewed.
*
* @param id the message id to update
* @param viewed the message viewed to update
* @return the ResponseEntity with status 200 (OK) or 400 (badRequest)
*/
@PutMapping("/messages/viewed")
@Timed
public ResponseEntity<Message> updateMessageViewed(HttpServletRequest httpServletRequest,
@RequestParam(value = "id") Long id,
@RequestParam(value = "viewed") Boolean viewed) throws URISyntaxException {
log.debug("REST request to update Message viewed: {}", id);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
Message message = messageRepository.findOne(id);
if (null != userLogin && message.getReceiver().equals(userLogin)) {
message.setViewed(viewed);
messageRepository.save(message);
return ResponseEntity.ok().build();
} else {
return ResponseEntity.badRequest().build();
}
}
/**
* PUT /users : Updates an existing User.
*
* @param managedUserVM the user to update
* @return the ResponseEntity with status 200 (OK) and with body the updated user,
* or with status 400 (Bad Request) if the login or email is already in use,
* or with status 500 (Internal Server Error) if the user couldn't be updated
*/
@PutMapping("/users")
@Timed
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<UserDTO> updateUser(@Valid @RequestBody ManagedUserVM managedUserVM) {
log.debug("REST request to update User : {}", managedUserVM);
Optional<User> existingUser = userRepository.findOneByEmail(managedUserVM.getEmail());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "emailexists", "Email already in use")).body(null);
}
existingUser = userRepository.findOneByLogin(managedUserVM.getLogin().toLowerCase());
if (existingUser.isPresent() && (!existingUser.get().getId().equals(managedUserVM.getId()))) {
return ResponseEntity.badRequest().headers(HeaderUtil.createFailureAlert(ENTITY_NAME, "userexists", "Login already in use")).body(null);
}
Optional<UserDTO> updatedUser = userService.updateUser(managedUserVM);
return ResponseUtil.wrapOrNotFound(updatedUser,
HeaderUtil.createAlert("A user is updated with identifier " + managedUserVM.getLogin(), managedUserVM.getLogin()));
}
/**
* GET /ability : get deployments by uuid.
*
* @return the ResponseEntity with status 200 (OK) and the list of deployments in body
*/
@GetMapping("/ability")
@Timed
public List<Deployment> getAllDeployments(@RequestParam(value = "uuid") String uuid) {
log.debug("REST request to get all Deployments by uuid");
List<Deployment> deploymentList = this.deploymentRepository.findAllByUuid(uuid);
if (!deploymentList.isEmpty()) {
// 该接口只有在用户调用AI能力时才会被调用,所以选择在这里递加能力的接口调用次数
Deployment deployment = deploymentList.get(0);
deployment.setCallCount(deployment.getCallCount() + 1);
this.deploymentRepository.save(deployment);
}
return deploymentList;
}
/**
* DELETE /documents/:id : delete the "id" document.
* @param id the id of the document to delete
* @return the ResponseEntity with status 200 (OK) or 403 Forbidden
*/
@DeleteMapping("/documents/{id}")
@Timed
public ResponseEntity<Void> deleteDocument(HttpServletRequest httpServletRequest,
@PathVariable Long id) {
log.debug("REST request to delete Document : {}", id);
Document document = documentRepository.findOne(id);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null == userLogin || !userLogin.equals(document.getAuthorLogin())) {
return ResponseEntity.status(403).build(); // 403 Forbidden
}
documentRepository.delete(id);
return ResponseEntity.ok().build();
}
/**
* GET /tasks : get pageable tasks.
*
* @return the ResponseEntity with status 200 (OK) and the list of tasks in body
*/
@GetMapping("/tasks")
@Timed
public ResponseEntity<List<Task>> getTasks(@RequestParam(value = "uuid", required = false) String uuid,
@RequestParam(value = "userLogin", required = false) String userLogin,
@RequestParam(value = "taskStatus", required = false) String taskStatus,
Pageable pageable) {
log.debug("REST request to get all tasks");
Page<Task> page;
if (null != uuid) {
page = taskRepository.findAllByUuid(uuid, pageable);
} else if (null != userLogin) {
if (null != taskStatus) {
page = taskRepository.findAllByUserLoginAndTaskStatus(userLogin, taskStatus, pageable);
} else {
page = taskRepository.findAllByUserLogin(userLogin, pageable);
}
} else {
page = taskRepository.findAll(pageable);
}
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/tasks");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
/**
* PUT /solutions/subjects : 更新Solution对象中的subjectdeng诸字段
* @param jsonObject the JSONObject with subjects to be updated
* @return the ResponseEntity with status 200 (OK) and with body the updated solution, or status 400 (Bad Request)
*/
@PutMapping("/solutions/subjects")
@Timed
@Secured({"ROLE_MANAGER"}) // subject字段只能由平台管理员更新
public ResponseEntity<Solution> updateSolutionSubjects(@Valid @RequestBody JSONObject jsonObject) {
log.debug("REST request to update Solution subjects: {}", jsonObject);
Solution solution = solutionRepository.findOne(jsonObject.getLong("id"));
solution.setSubject1(jsonObject.getString("subject1"));
solution.setSubject2(jsonObject.getString("subject2"));
solution.setSubject3(jsonObject.getString("subject3"));
solution.setDisplayOrder(jsonObject.getLong("displayOrder"));
solution.setModifiedDate(Instant.now());
Solution result = solutionRepository.save(solution);
return ResponseEntity.ok().body(result);
}
@CrossOrigin
@PostMapping("/{deploymentUuid}/{modelMethod}")
@Timed
public ResponseEntity<String> openAbility(@PathVariable String deploymentUuid,
@PathVariable String modelMethod,
@Valid @RequestBody String requestBody,
@RequestHeader MultiValueMap<String,String> requestHeader) {
log.debug("REST request to access AI open ability");
List<Deployment> deploymentList = this.ummClient.getDeployment(deploymentUuid);
if(deploymentList.isEmpty()) {
return ResponseEntity.status(404).body("Cannot find deployment: " + deploymentUuid);
}
List<Solution> solutions = ummClient.getSolutionsByUuid(deploymentList.get(0).getSolutionUuid());
if (!solutions.isEmpty()) {
if (solutions.get(0).getToolkitType().equals("模型组合")) {
return abilityService.callComposer(solutions.get(0).getUuid(), modelMethod, requestBody, requestHeader);
}
}
Integer k8sPort = deploymentList.get(0).getk8sPort();
if(k8sPort == null) {
return ResponseEntity.status(404).body("Deployment: " + deploymentUuid + " is not running");
}
String url = "http://" + internalIP + ":" + k8sPort + "/model/methods/" + modelMethod;
return abilityService.apiGateway(url, requestBody, requestHeader);
}
/**
* Authenticates a user setting the access and refresh token cookies.
*
* @param request the HttpServletRequest holding - among others - the headers passed from the client.
* @param response the HttpServletResponse getting the cookies set upon successful authentication.
* @param params the login params (username, password, rememberMe).
* @return the access token of the authenticated user. Will return an error code if it fails to authenticate the user.
*/
@RequestMapping(value = "/login", method = RequestMethod.POST, consumes = MediaType
.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Timed
public ResponseEntity<OAuth2AccessToken> authenticate(HttpServletRequest request, HttpServletResponse response, @RequestBody
Map<String, String> params) {
if (params.get("username").equals("system")) {
return ResponseEntity.badRequest().build();
}
int verifyResult = this.uaaClient.validateVerifyCode(params);
if (1 == verifyResult) {
return authenticationService.authenticate(request, response, params);
} else {
return ResponseEntity.badRequest().build();
}
}
/**
* DELETE /solutions/:id : delete the "id" solution.
* @param id the id of the solution to delete
* @return the ResponseEntity with status 200 (OK)
*/
@DeleteMapping("/solutions/{id}")
@Timed
public ResponseEntity<Void> deleteSolution(HttpServletRequest httpServletRequest,
@PathVariable Long id) {
log.debug("REST request to delete Solution : {}", id);
Solution solution = solutionRepository.findOne(id);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null == userLogin || !(userLogin.equals(solution.getAuthorLogin()) || userLogin.equals("system"))) {
// solution只能由作者自己删除,或者由umu微服务中的onboardService异步服务删除
return ResponseEntity.status(403).build(); // 403 Forbidden
}
solutionRepository.delete(id);
return ResponseEntity.ok().build();
}
/**
* GET /publish-requests : get pageable publishRequests.
* @return the ResponseEntity with status 200 (OK) and the list of publishRequests in body
*/
@GetMapping("/publish-requests")
@Timed
public ResponseEntity<List<PublishRequest>> getPublishRequests(@RequestParam(value = "reviewed", required = false) Boolean reviewed,
@RequestParam(value = "requestType", required = false) String requestType,
@RequestParam(value = "solutionUuid", required = false) String solutionUuid,
Pageable pageable) {
log.debug("REST request to get all PublishRequests");
Page<PublishRequest> page;
if (null != reviewed) {
if (null != requestType) {
page = publishRequestRepository.findAllByReviewedAndRequestType(reviewed, requestType, pageable);
} else {
page = publishRequestRepository.findAllByReviewed(reviewed, pageable);
}
} else if (null != solutionUuid) {
page = publishRequestRepository.findAllBySolutionUuid(solutionUuid, pageable);
} else {
page = publishRequestRepository.findAll(pageable);
}
HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/api/publish-requests");
return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
@RequestMapping(value = "/ueditor", method = RequestMethod.GET)
@Timed
public String getConfig(@RequestParam(value = "action") String action) {
log.debug("REST request to get config json string");
Ueditor ueditor = new Ueditor();
if (action.equals("config")) {
try {
ClassPathResource classPathResource = new ClassPathResource("ueditor/config.json");
InputStream stream = classPathResource.getInputStream();
String config = IOUtils.toString(stream, "UTF-8");
stream.close();
return config;
} catch (Exception e) {
ueditor.setState("找不到配置文件!");
return JSONObject.toJSONString(ueditor);
}
} else {
ueditor.setState("不支持操作!");
return JSONObject.toJSONString(ueditor);
}
}
@RequestMapping(value = "/download", method = RequestMethod.GET)
@Timed
public void downloadArtifact(@RequestParam(value = "url") String url, HttpServletResponse response) {
log.debug("REST request to download artifact/document file");
// 暂时不在HTTP响应头中传递文件名,因为文件名可能是中文
// String fileName = url.substring(artifactUrl.lastIndexOf("/") + 1);
response.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", "0");
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
// response.setHeader("x-filename", fileName);
// response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
response.setHeader("Content-Disposition", "attachment");
response.setStatus(HttpServletResponse.SC_OK);
try {
ByteArrayOutputStream byteArrayOutputStream = nexusArtifactClient.getArtifact(url);
byteArrayOutputStream.writeTo(response.getOutputStream());
response.flushBuffer();
if (null != byteArrayOutputStream) {
byteArrayOutputStream.close();
}
} catch (Exception e) {
}
}
/**
* PUT /solution-ratings/score : Updates an existing solutionRating's score.
* @param jsonObject JSONObject with fields to be updated
* @return the ResponseEntity with status 200 (OK) and with body the updated solutionRating, or with status 403 Forbidden
*/
@PutMapping("/solution-ratings/score")
@Timed
public ResponseEntity<SolutionRating> updateSolutionRatingScore(HttpServletRequest httpServletRequest,
@Valid @RequestBody JSONObject jsonObject) {
log.debug("REST request to update SolutionRating : {}", jsonObject);
SolutionRating solutionRating = solutionRatingRepository.findOne(jsonObject.getLong("id"));
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null == userLogin || !userLogin.equals(solutionRating.getUserLogin())) {
return ResponseEntity.status(403).build(); // 403 Forbidden
}
solutionRating.setRatingScore(jsonObject.getInteger("score"));
SolutionRating result = solutionRatingRepository.save(solutionRating);
return ResponseEntity.ok().body(result);
}
/**
* PUT /messages/deleted : Updates an existing message' deleted.
*
* @param id the message id to update
* @param deleted the message deleted to update
* @return the ResponseEntity with status 200 (OK) or 400 (badRequest)
*/
@PutMapping("/messages/deleted")
@Timed
public ResponseEntity<Message> updateMessageDeleted(HttpServletRequest httpServletRequest,
@RequestParam(value = "id") Long id,
@RequestParam(value = "deleted") Boolean deleted) throws URISyntaxException {
log.debug("REST request to update Message deleted: {}", id);
Message message = messageRepository.findOne(id);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null != userLogin && message.getReceiver().equals(userLogin)) {
message.setDeleted(deleted);
messageRepository.save(message);
return ResponseEntity.ok().build();
} else {
return ResponseEntity.badRequest().build();
}
}
/**
* POST /messages : Send a new message.
*
* @param message the message to create
* @return the ResponseEntity with status 200 OK
*/
@PostMapping("/messages/send")
@Timed
public ResponseEntity<Void> sendMessage(HttpServletRequest httpServletRequest, @Valid @RequestBody Message message) {
log.debug("REST request to send Message : {}", message);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
if (null != userLogin) {
message.setSender(userLogin);
message.setId(null);
message.setViewed(false);
message.setDeleted(false);
message.setCreatedDate(Instant.now());
message.setModifiedDate(Instant.now());
messageRepository.save(message);
return ResponseEntity.ok().build();
} else {
return ResponseEntity.badRequest().build();
}
}
/**
* PUT /tasks : Updates an existing task.
* @param task the task to update
* @return the ResponseEntity with status 200 (OK) or 403 Forbidden
*/
@PutMapping("/tasks")
@Timed
public ResponseEntity<Task> updateTask(HttpServletRequest httpServletRequest,
@Valid @RequestBody Task task) {
log.debug("REST request to update Task : {}", task);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
// updateTask只能由umu微服务中的异步任务OnBoardingServie调用,不能由前端用户调用
if (null == userLogin || !userLogin.equals("system")) {
return ResponseEntity.status(403).build();
}
Task result = taskRepository.save(task);
return ResponseEntity.ok().body(result);
}
/**
* GET /authenticate : check if the user is authenticated, and return its login.
*
* @param request the HTTP request
* @return the login if the user is authenticated
*/
@GetMapping("/authenticate")
@Timed
public String isAuthenticated(HttpServletRequest request) {
log.debug("REST request to check if the current user is authenticated");
return request.getRemoteUser();
}
/**
* POST /solution-shareds : Create a new solutionShared.
* @param solutionShared the solutionShared to create
* @return the ResponseEntity with status 201 (Created) or 401 Unauthorized
*/
@PostMapping("/solution-shareds")
@Timed
public ResponseEntity<SolutionShared> createSolutionShared(HttpServletRequest httpServletRequest,
@Valid @RequestBody SolutionShared solutionShared) {
log.debug("REST request to save SolutionShared : {}", solutionShared);
String userLogin = JwtUtil.getUserLogin(httpServletRequest);
solutionShared.setFromUserLogin(userLogin);
solutionShared.shareDate(Instant.now());
SolutionShared result = solutionSharedRepository.save(solutionShared);
return ResponseEntity.status(201).body(result);
}
@PutMapping("/logs")
@ResponseStatus(HttpStatus.NO_CONTENT)
@Timed
public void changeLevel(@RequestBody LoggerVM jsonLogger) {
LoggerContext context = (LoggerContext) LoggerFactory.getILoggerFactory();
context.getLogger(jsonLogger.getName()).setLevel(Level.valueOf(jsonLogger.getLevel()));
}
/**
* @return create a new authority if not exist
*/
@PostMapping("/users/authorities/{authority}")
@Timed
@Secured({AuthoritiesConstants.ADMIN})
public ResponseEntity<Void> createAuthority(@PathVariable String authority) {
userService.createAuthority(authority);
return ResponseEntity.ok().build();
}
/**
* GET / : get the SSH public key
* @return entity
*/
@GetMapping(value = "/ssh/public_key", produces = MediaType.TEXT_PLAIN_VALUE)
@Timed
public ResponseEntity<String> eureka() {
try {
String publicKey = getPublicKey();
if(publicKey != null) return new ResponseEntity<>(publicKey, HttpStatus.OK);
} catch (IOException e) {
log.warn("SSH public key could not be loaded: {}", e.getMessage());
}
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
}
/**
* GET /documents/:id : get the "id" document.
* @param id the id of the document to retrieve
* @return the ResponseEntity with status 200 (OK) and with body the document, or with status 404 (Not Found)
*/
@GetMapping("/documents/{id}")
@Timed
public ResponseEntity<Document> getDocument(@PathVariable Long id) {
log.debug("REST request to get Document : {}", id);
Document document = documentRepository.findOne(id);
return ResponseUtil.wrapOrNotFound(Optional.ofNullable(document));
}