@RequestMapping( value = "/user/{LOCALID}/delete", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public ResponseEntity<DeleteUserIdResponseDTO> deleteUser(@PathVariable("LOCALID") String localID) throws ApplicationNotFoundException, LocalIdMissingException { log.debug("REST DELETE_ID START. localid [{}]", localID); String currentLogin = SecurityUtils.getCurrentLogin(); Application application = applicationRepository.findOneByApplicationID(currentLogin); if (application == null) { throw new ApplicationNotFoundException(currentLogin); } Person person = personRepository.findOneByLocalID(localID); if (person == null) { throw new LocalIdMissingException(); } orcidService.deleteUser(person); DeleteUserIdResponseDTO response = new DeleteUserIdResponseDTO(); response.setResultCode(ResultCode.SUCCESS.getCode()); return new ResponseEntity<DeleteUserIdResponseDTO>(response, HttpStatus.OK); }
private void checkGetTicketInput(String localID, GetTicketRequestDTO jsonGetTicket) throws LocalIDDifferentException, LocalIdMissingException, ApplicationIdMissingException, ApplicationlIDDifferentException { String currentLogin = SecurityUtils.getCurrentLogin(); if (!currentLogin.equals(jsonGetTicket.getAppId())) { throw new ApplicationlIDDifferentException(currentLogin, jsonGetTicket.getAppId()); } if (!localID.equals(jsonGetTicket.getLocalID())) throw new LocalIDDifferentException(jsonGetTicket.getLocalID(), localID); if (jsonGetTicket.getLocalID() == null || jsonGetTicket.getLocalID().isEmpty()) throw new LocalIdMissingException(); if (jsonGetTicket.getAppId() == null || jsonGetTicket.getAppId().isEmpty()) throw new ApplicationIdMissingException(); }
@RequestMapping( value = "/user/id/{TOKEN}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE) @Timed public GetUserIdResponseDTO getUserId(@PathVariable("TOKEN") String tokenString) throws TokenNotFoundException, OrcidForUserMissingException, ApplicationlIDDifferentException, OrcidDeniedForApplicationException { log.debug("REST GET-USER-ID START. token [{}]", tokenString); Token token = tokenRepository.findOneByOtt(tokenString); if (token == null) { throw new TokenNotFoundException(tokenString); } String currentLogin = SecurityUtils.getCurrentLogin(); if (!currentLogin.equals(token.getApplication().getApplicationID())) { throw new ApplicationlIDDifferentException( currentLogin, token.getApplication().getApplicationID()); } RelPersonApplication relPersonApplication = relPersonApplicationRepository.findOneByPersonIsAndApplicationIsAndTokenIs( token.getPerson(), token.getApplication(), token); if (token.getPerson().getOrcid() == null) { if (relPersonApplication == null) { throw new OrcidForUserMissingException(token.getPerson().getLocalID()); } else if (relPersonApplication.getDenied()) { throw new OrcidDeniedForApplicationException(token.getPerson().getLocalID()); } else if (!relPersonApplication.getValid()) { throw new OrcidForUserMissingException(token.getPerson().getLocalID()); } } GetUserIdResponseDTO response = new GetUserIdResponseDTO(); if (relPersonApplication != null) response.setOrcidAccessToken(relPersonApplication.getOauthAccessToken()); response.setOrcid(token.getPerson().getOrcid()); response.setResultCode("001"); log.debug( "REST GET-USER-ID END. token [{}], orcid [{}]", tokenString, token.getPerson().getOrcid()); return response; }