@GetMapping(value = "/login") public ModelAndView login( @RequestParam(value = "error", required = false) String error, @RequestParam(value = "logout", required = false) String logout) { logger.info("******login(error): {} ***************************************", error); logger.info("******login(logout): {} ***************************************", logout); ModelAndView model = new ModelAndView(); if (error != null) { model.addObject("error", "Invalid username and password!"); } if (logout != null) { model.addObject("message", "You've been logged out successfully."); } model.setViewName("login"); return model; }
/** * 在线显示文件 * @param id * @return */ @GetMapping("/view/{id}") @ResponseBody public ResponseEntity<Object> serveFileOnline(@PathVariable String id) { File file = fileService.getFileById(id); if (file != null) { return ResponseEntity .ok() .header(HttpHeaders.CONTENT_DISPOSITION, "fileName=\"" + file.getName() + "\"") .header(HttpHeaders.CONTENT_TYPE, file.getContentType() ) .header(HttpHeaders.CONTENT_LENGTH, file.getSize()+"") .header("Connection", "close") .body( file.getContent()); } else { return ResponseEntity.status(HttpStatus.NOT_FOUND).body("File was not fount"); } }
@GetMapping(value = BASE_PATH + "/" + FILENAME + "/raw", produces = MediaType.IMAGE_JPEG_VALUE) @ResponseBody public Mono<ResponseEntity<?>> oneRawImage( @PathVariable String filename) { // tag::try-catch[] return imageService.findOneImage(filename) .map(resource -> { try { return ResponseEntity.ok() .contentLength(resource.contentLength()) .body(new InputStreamResource( resource.getInputStream())); } catch (IOException e) { return ResponseEntity.badRequest() .body("Couldn't find " + filename + " => " + e.getMessage()); } }); // end::try-catch[] }
/** * Handle federation request. * * @param response the response * @param request the request * @throws Exception the exception */ @GetMapping(path = WSFederationConstants.ENDPOINT_FEDERATION_REQUEST) protected void handleFederationRequest(final HttpServletResponse response, final HttpServletRequest request) throws Exception { final WSFederationRequest fedRequest = WSFederationRequest.of(request); switch (fedRequest.getWa().toLowerCase()) { case WSFederationConstants.WSIGNOUT10: case WSFederationConstants.WSIGNOUT_CLEANUP10: handleLogoutRequest(fedRequest, request, response); break; case WSFederationConstants.WSIGNIN10: handleInitialAuthenticationRequest(fedRequest, response, request); break; default: throw new UnauthorizedAuthenticationException("The authentication request is not recognized", Collections.emptyMap()); } }
@GetMapping("/articulo/{id}") public String verArticulo (Model model, @PathVariable long id,HttpServletRequest request){ Articulo articulo = articulo_repository.findOne(id); model.addAttribute("articulo", articulo); model.addAttribute("comentarios",comentario_repository.findByArticulo(articulo)); model.addAttribute("admin",request.isUserInRole("ADMIN")); return "ver_articulo"; }
/** * Get all available links. * * @return list of links. */ @ApiOperation(value = "Get all available switches", response = SwitchDto.class) @ApiResponses(value = { @ApiResponse(code = 200, response = FlowPayload.class, message = "Operation is successful"), @ApiResponse(code = 400, response = MessageError.class, message = "Invalid input data"), @ApiResponse(code = 401, response = MessageError.class, message = "Unauthorized"), @ApiResponse(code = 403, response = MessageError.class, message = "Forbidden"), @ApiResponse(code = 404, response = MessageError.class, message = "Not found"), @ApiResponse(code = 500, response = MessageError.class, message = "General error"), @ApiResponse(code = 503, response = MessageError.class, message = "Service unavailable")}) @GetMapping(path = "/switches") @ResponseStatus(HttpStatus.OK) public List<SwitchDto> getSwitches() { return switchService.getSwitches(); }
@GetMapping(value = "/tweet/{year}/{month}/{day}/{title}") public String tweetSingle(@PathVariable("year") Integer year,@PathVariable("month") Integer month,@PathVariable("day") Integer day,@PathVariable("title") String title, Model model) { model.addAttribute("tweet","selected"); Article article = articleService.getArticleByTitle(title); model.addAttribute("article",article); List<String> tagsList = articleService.getArticleTagsByArticleId(article.getId()); model.addAttribute("tagsList",tagsList.toString()); return "front/theme/effe/tweetSingle"; }
@GetMapping(value = "get_class_file") public void getClassFile(@RequestParam List<String> tableNames, @RequestParam String url, @RequestParam String userName, @RequestParam String password, @RequestParam(required = false) String pkgName, HttpServletResponse response) throws SQLException, IOException { Connection conn = getConn(url, userName, password); Map<String, List<String>> nameWithJavaMap = getStringListMap(tableNames, conn, pkgName); conn.close(); ServletOutputStream outputStream = response.getOutputStream(); ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream); for (Map.Entry<String, List<String>> stringListEntry : nameWithJavaMap.entrySet()) { zipOutputStream.putNextEntry( new ZipEntry( getJavaClassName(stringListEntry.getKey()) + ".java" ) ); for (String line : stringListEntry.getValue()) { zipOutputStream.write(line.getBytes()); zipOutputStream.write('\n'); } } response.setContentType("application/zip;charset=utf-8"); response.setHeader("Content-disposition", "attachment;filename= " + LocalDateTime.now().format(DateTimeFormatter.BASIC_ISO_DATE) + ".zip"); zipOutputStream.close(); }
/** * 编辑用户页 * * @param id * @param model * @return */ @GetMapping("/editPage") public String editPage(Model model, Long id) { UserVo userVo = userService.selectVoById(id); List<Role> rolesList = userVo.getRolesList(); List<Long> ids = new ArrayList<Long>(); for (Role role : rolesList) { ids.add(role.getId()); } model.addAttribute("roleIds", ids); model.addAttribute("user", userVo); return "admin/user/userEdit"; }
@GetMapping("/default") public String defaultAfterLogin(HttpServletRequest request) { if (request.isUserInRole("ROLE_ADMIN")) { return "redirect:/events/"; } return "redirect:/"; }
/** * Receive non-password protected message. */ @GetMapping("/confirm/{id:[a-f0-9]{64}}") public String confirm( @PathVariable("id") final String id, @ModelAttribute("linkSecret") final String linkSecret, final Model model, final HttpSession session) { prepareMessage(id, linkSecret, null, model, session); return FORM_MSG_DISPLAY; }
@GetMapping("/") ResponseEntity<String> showCodeCouple(){ HttpHeaders headers = new HttpHeaders(); headers.set("Accept", MediaType.APPLICATION_JSON_VALUE); HttpEntity<?> entity = new HttpEntity<>(headers); return restTemplate.exchange( "http://producer-service/", HttpMethod.GET, entity, String.class); }
@GetMapping("/users") public ResponseEntity<String> users() { ParameterizedTypeReference<String> reference = new ParameterizedTypeReference<String>() { }; return restTemplate.exchange(SERVICE, HttpMethod.GET, authenticationService.addAuthenticationHeader(), reference); }
@GetMapping("/{token:.+}") public ResponseEntity validateToken(@CookieValue("time") String time, @RequestHeader("Authorization") String[] authorization, @PathVariable String token, @RequestParam String url) { String temp = tokens.get(token); String auth = authorization[0]; if (auth.equals("dummy")) { auth = authorization[1]; } if (temp.equals(time) && auth.equals(token + time + url)) { return ResponseEntity.ok().build(); } else { return ResponseEntity.badRequest().build(); } }
/** * Download attached file. */ @GetMapping("/file/{id:[a-f0-9]{64}}/{key:[a-f0-9]{64}}") public ResponseEntity<StreamingResponseBody> file(@PathVariable("id") final String id, @PathVariable("key") final String keyHex, final HttpSession session) { final KeyIv keyIv = new KeyIv(BaseEncoding.base16().lowerCase().decode(keyHex), resolveFileIv(id, session)); final DecryptedFile decryptedFile = messageService.resolveStoredFile(id, keyIv); final HttpHeaders headers = new HttpHeaders(); // Set application/octet-stream instead of the original mime type to force download headers.setContentType(MediaType.APPLICATION_OCTET_STREAM); if (decryptedFile.getName() != null) { headers.setContentDispositionFormData("attachment", decryptedFile.getName(), StandardCharsets.UTF_8); } headers.setContentLength(decryptedFile.getOriginalFileSize()); final StreamingResponseBody body = out -> { try (final InputStream in = messageService.getStoredFileInputStream(id, keyIv)) { ByteStreams.copy(in, out); out.flush(); } messageService.burnFile(id); }; return new ResponseEntity<>(body, headers, HttpStatus.OK); }
@GetMapping(path = "/feed.xml", produces = MediaType.APPLICATION_ATOM_XML) public void feed(HttpServletRequest req, Writer writer) { try { new SyndFeedOutput().output(getFeed(), writer); } catch (Exception ex) { logger.error("Could not generate feed", ex); } }
/** * 没有事务,手动指定数据源使用主库 */ @GetMapping("/get/slave/{code}/{officeAddress}") public ResponseEntity<List<BaseCode>> listSlave(@PathVariable String code, @PathVariable Integer officeAddress) { EnumBaseCode type = EnumBaseCode.getByCode(code); Optional<List<BaseCode>> optional = baseCodeService.getListByCity(type, officeAddress); return ResponseEntity.ok(optional.orElseThrow(IllegalArgumentException::new)); }
/** * Get Metadata. * * @param request the request * @param response the response * @throws Exception the exception */ @GetMapping(path = WSFederationConstants.ENDPOINT_FEDERATION_METADATA) public void doGet(final HttpServletRequest request, final HttpServletResponse response) throws Exception { try { response.setContentType(MediaType.TEXT_HTML_VALUE); final PrintWriter out = response.getWriter(); final WSFederationMetadataWriter mw = new WSFederationMetadataWriter(); final Document metadata = mw.produceMetadataDocument(casProperties); out.write(DOM2Writer.nodeToString(metadata)); } catch (final Exception ex) { LOGGER.error("Failed to get metadata document", ex); response.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); } }
/** * GET / : get the SSH public key */ @GetMapping(value = "/ssh/public_key", produces = MediaType.TEXT_PLAIN_VALUE) @Timed public ResponseEntity<String> eureka() { try { String publicKey = new String(Files.readAllBytes( Paths.get(System.getProperty("user.home") + "/.ssh/id_rsa.pub"))); 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); } }
/** * Handle request for jwk set. * * @param request the request * @param response the response * @param model the model * @return the jwk set * @throws Exception the exception */ @GetMapping(value = '/' + OidcConstants.BASE_OIDC_URL + '/' + OidcConstants.JWKS_URL, produces = MediaType.APPLICATION_JSON_VALUE) public ResponseEntity<String> handleRequestInternal(final HttpServletRequest request, final HttpServletResponse response, final Model model) throws Exception { Assert.notNull(this.jwksFile, "JWKS file cannot be undefined or null."); try { final String jsonJwks = IOUtils.toString(this.jwksFile.getInputStream(), StandardCharsets.UTF_8); final JsonWebKeySet jsonWebKeySet = new JsonWebKeySet(jsonJwks); this.servicesManager.getAllServices() .stream() .filter(s -> s instanceof OidcRegisteredService && StringUtils.isNotBlank(((OidcRegisteredService) s).getJwks())) .forEach( Unchecked.consumer(s -> { final OidcRegisteredService service = (OidcRegisteredService) s; final Resource resource = this.resourceLoader.getResource(service.getJwks()); final JsonWebKeySet set = new JsonWebKeySet(IOUtils.toString(resource.getInputStream(), StandardCharsets.UTF_8)); set.getJsonWebKeys().forEach(jsonWebKeySet::addJsonWebKey); })); final String body = jsonWebKeySet.toJson(JsonWebKey.OutputControlLevel.PUBLIC_ONLY); response.setContentType(MediaType.APPLICATION_JSON_VALUE); return new ResponseEntity<>(body, HttpStatus.OK); } catch (final Exception e) { LOGGER.error(e.getMessage(), e); return new ResponseEntity<>(e.getMessage(), HttpStatus.BAD_REQUEST); } }
/** * Gets services. * * @param response the response */ @GetMapping(value = "/getServices") public void getServices(final HttpServletResponse response) { ensureDefaultServiceExists(); final Map<String, Object> model = new HashMap<>(); final List<RegisteredServiceViewBean> serviceBeans = new ArrayList<>(); final List<RegisteredService> services = new ArrayList<>(this.servicesManager.getAllServices()); serviceBeans.addAll(services.stream().map(this.registeredServiceFactory::createServiceViewBean).collect(Collectors.toList())); model.put("services", serviceBeans); model.put(STATUS, HttpServletResponse.SC_OK); JsonUtils.render(model, response); }
/** * 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(); }
@GetMapping(path="/updateUser") // Map ONLY GET Requests @ResponseBody public ResponseEntity<Object> updateUser (@RequestParam String email , @RequestParam String password , @RequestParam String password2 , @RequestParam String height , @RequestParam String weight , @RequestParam String age , @RequestParam String gender) { UserVO userVO = new UserVO(email, password, password2, height, weight, age, gender, userRepository); ArrayList<ValidationRule> rules = new ArrayList<>(); rules.add(new UpdateEmailValidationRule()); rules.add(new PasswordValidationRule()); rules.add(new HeightValidationRule()); rules.add(new WeightValidationRule()); rules.add(new AgeValidationRule()); rules.add(new GenderValidationRule()); ValidationResponse validationResponse; for(ValidationRule rule: rules){ validationResponse = rule.validate(userVO); LOG.info(validationResponse.toString()); if(!validationResponse.getStatus().is2xxSuccessful()){ LOG.info("Status failure: " + validationResponse.getStatus()); return new ResponseEntity<>(validationResponse.getResponseBody(), validationResponse.getStatus()); } } User user = userRepository.findByEmail(email); user.setPassword(password); user.setHeight(Integer.parseInt(height)); user.setWeight(Integer.parseInt(weight)); user.setAge(Integer.parseInt(age)); user.setGender(gender); userRepository.save(user); return new ResponseEntity<>("User Updated", HttpStatus.OK); }
@GetMapping("/") public String index(Model model) { List<Article> articles = this.articleRepository.findAll(); model.addAttribute("view", "home/index"); model.addAttribute("articles", articles); return "base-layout"; }
/** * 官网首页数据展示 * * @return */ @GetMapping("/index") public String index(HttpServletRequest request, Model model, HttpSession session) { Integer newpv = (Integer) session.getAttribute("is_new"); if (newpv == null) { TzPv pv = new TzPv(); pv.setUserip(Utils.getIpAddress(request)); pv.setUseragent(request.getHeader("User-Agent")); pv.setVisittime(new Timestamp(System.currentTimeMillis())); pv.setModule(3); this.tzPvService.insert(pv); session.setAttribute("is_new", 1); } //获取导航菜单资源 List<OfficialResouce> menus = officialResouceService.findResourceByCid(1, 0, 4); //轮播图获取 List<OfficialResouce> carousels = officialResouceService.findResourceByCid(2, 0, 4); //公司展示图片获取 List<OfficialResouce> companyPic = officialResouceService.findResourceByCid(3, 0, 3); //新闻中心截图获取 List<OfficalNews> news = officalNewsService.findNewsByCid(13, 0, 5); //视频 List<OfficalNews> videos = officalNewsService.findNewsByCid(14, 0, 6); List<OfficalNews> notices = officalNewsService.findNewsByCid(15, 0, 3); List<OfficialResouce> lovePics = officialResouceService.findResourceByCid(10, 0, 6); session.setAttribute("menu", menus); model.addAttribute("carousels", carousels); model.addAttribute("companyPic", companyPic); model.addAttribute("lovePics", lovePics); model.addAttribute("videos", videos); model.addAttribute("news", news); model.addAttribute("notices", notices); return "index"; }
@GetMapping(path = "/users/{name}/todos/{id}") public Resource<Todo> retrieveTodo(@PathVariable String name, @PathVariable int id) { Todo todo = todoService.retrieveTodo(id); if (todo == null) { throw new TodoNotFoundException("Todo Not Found"); } Resource<com.mastering.spring.springboot.bean.Todo> todoResource = new Resource<com.mastering.spring.springboot.bean.Todo>(todo); ControllerLinkBuilder linkTo = linkTo(methodOn(this.getClass()).retrieveTodos(name)); todoResource.add(linkTo.withRel("parent")); return todoResource; }
/** * 获取用户信息 */ @GetMapping("userInfo") @ApiOperation(value = "获取用户信息") @ApiImplicitParam(paramType = "header", name = "token", value = "token", required = true) public R userInfo(@LoginUser UserEntity user){ return R.ok().put("user", user); }
@GetMapping("/") public String home(Model model) { if (userAccountService.isNoUserFound()) { model.addAttribute("userAccount", new UserAccount()); return "signUp"; } else { return "redirect:/admin/"; } }
/** * GET /eureka/applications : get Eureka applications information */ @GetMapping("/eureka/applications") @Timed public ResponseEntity<EurekaDTO> eureka() { EurekaDTO eurekaDTO = new EurekaDTO(); eurekaDTO.setApplications(getApplications()); return new ResponseEntity<>(eurekaDTO, HttpStatus.OK); }
@GetMapping(path = "/users/{id}") public Mono<Person> get(@PathVariable("id") String uuid) { return this.client .get().uri(getReadURL() + "/api/users/", uuid) .accept(MediaType.APPLICATION_JSON) .exchange() .flatMap(resp -> resp.bodyToMono(Person.class)); }
@GetMapping(path = "/events", produces = { // MediaType.APPLICATION_STREAM_JSON_VALUE, // MediaType.TEXT_EVENT_STREAM_VALUE // }) Flux<Event> streamEvents() { return eventRepository.findPeopleBy(); }
@GetMapping("/consulta") public ModelAndView consulta(@RequestParam("titulo") String titulo, @RequestParam("desc") String desc, @RequestParam("ano") Integer ano) { ModelAndView mav = new ModelAndView("/consulta"); mav.addObject("listaFilmes", filmes.getSearchFilmes(titulo, desc, ano)); System.out.println("Passando por consulta"); return mav; }
/** * Return json-information about all users in database. */ @GetMapping @ResponseStatus(HttpStatus.OK) public List<UserDto> loadAllUsers() { log.info("Start loadAllUsers"); return userService.findAll().stream() .map(user -> mapper.map(user, UserDto.class)) .collect(toList()); }
@GetMapping(value="/doctor", produces="application/json") public DoctorInfo findAll(ModelMap model) { List<Doctor> doctors = docService.findAll(); if(doctors == null) { return new DoctorInfo("No Doctors found!", null); } return new DoctorInfo("Doctors found", doctors); }
@Override @GetMapping({"tenants/{tenantKey}"}) Tenant getTenant(@PathVariable("tenantKey") String tenantKey);
@GetMapping("/byResource/{resource}") List<Booking> bookingsByResource(@PathVariable UUID resource) { return view.currentBookings() .filter(b -> b.getResourceId().equals(resource)) .collect(toList()); }
@GetMapping(path = "/authentication-error-via-configuration", produces = {APPLICATION_JSON_VALUE, APPLICATION_XML_VALUE}) public void throwAuthenticationExceptionViaConfiguration() { }