当前位置: 首页>>代码示例>>Java>>正文


Java HttpStatus.OK属性代码示例

本文整理汇总了Java中org.springframework.http.HttpStatus.OK属性的典型用法代码示例。如果您正苦于以下问题:Java HttpStatus.OK属性的具体用法?Java HttpStatus.OK怎么用?Java HttpStatus.OK使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在org.springframework.http.HttpStatus的用法示例。


在下文中一共展示了HttpStatus.OK属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: updateUser

@Secured(ADMIN)
@RequestMapping(value = "/user/{id}/update", method = RequestMethod.PUT)
public ResponseEntity<?> updateUser(@PathVariable("id") long id, @RequestBody UserUpdateDTO updateDTO) {
    Optional<ValidationErrors> errors = validators.validate(updateDTO);
    if (errors.isPresent()) {
        log.warn("User update data has field errors.");
        return new ResponseEntity<>(errors.get().getErrors(), HttpStatus.BAD_REQUEST);
    }
    UserDTO updatedUser = userService.updateUser(id, updateDTO);
    if (updatedUser == null) {
        log.error("No user found with given id({})",id);
        return new ResponseEntity<>("User not found with given id.", HttpStatus.INTERNAL_SERVER_ERROR);
    } else {
        log.debug("User({}) successfully updated by admin.",id);
        return new ResponseEntity<>(updatedUser, HttpStatus.OK);
    }
}
 
开发者ID:RFTDevGroup,项目名称:RFTBackend,代码行数:17,代码来源:UserController.java

示例2: getAdaptorConfiguration

@ApiOperation(value = "getAdaptorConfiguration", nickname = "getAdaptorConfiguration")
@RequestMapping(value = "/CISCore/getAdaptorConfiguration", method = RequestMethod.GET)
@ApiResponses(value = { 
           @ApiResponse(code = 200, message = "Success", response = AdaptorConfigurationImpl.class),
           @ApiResponse(code = 400, message = "Bad Request", response = AdaptorConfigurationImpl.class),
           @ApiResponse(code = 500, message = "Failure", response = AdaptorConfigurationImpl.class)}) 
public ResponseEntity<AdaptorConfigurationImpl> getAdaptorConfiguration() {
	log.info("--> getAdaptorConfiguration");
	
	AdaptorConfigurationImpl config = (AdaptorConfigurationImpl)cisCore.getAdaptorConfiguration();
	
	HttpHeaders responseHeaders = new HttpHeaders();
	
	log.info("getAdaptorConfiguration -->");
	return new ResponseEntity<AdaptorConfigurationImpl>(config, responseHeaders, HttpStatus.OK);
}
 
开发者ID:DRIVER-EU,项目名称:CommonInformationSpace,代码行数:16,代码来源:CISCoreConnectorRestController.java

示例3: exportCsv

/**
 * Export result to csv
 *
 * @param requestParams the query of the transfer timing search
 * @param pageable      the pagination information
 * @return downloadable csv
 */
@GetMapping(value = "/transfer-timings.csv", produces = CsvMediaType.TEXT_CSV_VALUE)
@Timed
public ResponseEntity<List<TransferTimingListingDTO>> exportCsv(@RequestParam Map<String, String> requestParams, @ApiParam Pageable pageable) {
    /* ==========================
     * In this example you might not understand as I did not put the other part of code but I have a AbstractHttpMessageConverter
     * that converts object or list of objects to a CSV
     * ==========================
     */
    final List<TransferTimingListingDTO> list;

    if (requestParams != null) {
        list = transferTimingPageService.searchWithoutPaging(requestParams, pageable);
    } else {
        list = transferTimingPageService.getAllWithoutPaging(pageable);
    }

    String filename = "visual-timings-" + Instant.now().getEpochSecond() + ".csv";

    HttpHeaders headers = new HttpHeaders();
    headers.add(HttpHeaders.CONTENT_DISPOSITION, "attachment;filename=" + filename);
    headers.add("X-Save-As", filename);

    return new ResponseEntity<>(list, headers, HttpStatus.OK);
}
 
开发者ID:Blackdread,项目名称:filter-sort-jooq-api,代码行数:31,代码来源:TransferTimingPageResource.java

示例4: getDeveloperTeams

@Override
public ResponseEntity<?> getDeveloperTeams() {
    List<Map<String, String>> developerTeams = new ArrayList<>();
    Map<String, String> developerTeam = new LinkedHashMap<>();
    developerTeam.put("版权所有", "米斯云平台");
    developerTeam.put("产品设计与研发团队", "Minsx Cloud Team");
    developerTeam.put("界面与用户体验团队", "Minsx Cloud Team");
    developerTeam.put("相关链接", "https://www.minsx.com/\thttps://github.com/MinsxCloud");
    developerTeam.forEach((key, value) -> {
        Map<String, String> item = new LinkedHashMap<>();
        item.put("key", key);
        item.put("value", value);
        developerTeams.add(item);
    });
    return new ResponseEntity<>(developerTeams, HttpStatus.OK);
}
 
开发者ID:MinsxCloud,项目名称:minsx-framework,代码行数:16,代码来源:SystemServiceImpl.java

示例5: ready

@RequestMapping("/ready")
ResponseEntity<String> ready() {
	
	HttpHeaders responseHeaders = new HttpHeaders();
	HttpStatus httpStatus;
	String ret;
	if (ready)
	{
		httpStatus = HttpStatus.OK;
		ret = "ready";
	}
	else
	{
		httpStatus = HttpStatus.SERVICE_UNAVAILABLE;
		ret = "Service unavailable";
	}
	ResponseEntity<String> responseEntity = new ResponseEntity<String>(ret, responseHeaders, httpStatus);
	return responseEntity;
   }
 
开发者ID:SeldonIO,项目名称:seldon-core,代码行数:19,代码来源:RestClientController.java

示例6: create

/**
 * Function to create a user
 * Only a system administrator can create an User
 *
 * @param user
 * @return DtoUser
 */
@RequestMapping(value = "", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<DtoUser> create(@RequestBody final DtoUser user) {
    LOGGER.debug(() -> "Creating User " + user.getEmail());
    if (!this.getLoggedInUser().isAdmin()) {
        LOGGER.error(() -> "Users can only be created by system administrators");
        return new ResponseEntity<>(HttpStatus.FORBIDDEN);
    }
    user.setPassword(ENCODER.encode(user.getPassword()));
    return new ResponseEntity<>(getDtoUser(serviceUser.addUser(user)), HttpStatus.OK);
}
 
开发者ID:howma03,项目名称:sporticus,代码行数:17,代码来源:RestControllerAdminUser.java

示例7: findByName

/**
 * Fetch restaurants with the specified name. A partial case-insensitive
 * match is supported. So <code>http://.../restaurants/rest</code> will find
 * any restaurants with upper or lower case 'rest' in their name.
 *
 * @param name
 * @return A non-null, non-empty collection of restaurants.
 */
@HystrixCommand(fallbackMethod = "defaultRestaurants")
@RequestMapping(method = RequestMethod.GET)
public ResponseEntity<Collection<Restaurant>> findByName(@RequestParam("name") String name) {
    logger.info(String.format("restaurant-service findByName() invoked:{} for {} ", restaurantService.getClass().getName(), name));
    name = name.trim().toLowerCase();
    Collection<Restaurant> restaurants;
    try {
        restaurants = restaurantService.findByName(name);
    } catch (Exception ex) {
        logger.log(Level.SEVERE, "Exception raised findByName REST Call", ex);
        return new ResponseEntity<>(HttpStatus.INTERNAL_SERVER_ERROR);
    }
    return restaurants.size() > 0 ? new ResponseEntity<>(restaurants, HttpStatus.OK)
            : new ResponseEntity<>(HttpStatus.NO_CONTENT);
}
 
开发者ID:PacktPublishing,项目名称:Mastering-Microservices-with-Java-9-Second-Edition,代码行数:23,代码来源:RestaurantController.java

示例8: getJobConfig

public ResponseEntity<String> getJobConfig(@ApiParam(value = "Name of the job",required=true ) @PathVariable("name") String name,
    @RequestHeader(value = "Accept", required = false) String accept) throws Exception {
    // do some magic!

    if (accept != null && accept.contains("")) {
        return new ResponseEntity<String>(objectMapper.readValue("", String.class), HttpStatus.OK);
    }

    return new ResponseEntity<String>(HttpStatus.OK);
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:10,代码来源:JobApiController.java

示例9: searchVotes

/**
 * SEARCH  /_search/votes?query=:query : search for the vote corresponding
 * to the query.
 *
 * @param query the query of the vote search
 * @param pageable the pagination information
 * @return the result of the search
 */
@GetMapping("/_search/votes")
@Timed
public ResponseEntity<List<Vote>> searchVotes(@RequestParam String query, @ApiParam Pageable pageable) {
    log.debug("REST request to search for a page of Votes for query {}", query);
    Page<Vote> page = voteSearchRepository.search(queryStringQuery(query), pageable);
    HttpHeaders headers = PaginationUtil.generateSearchPaginationHttpHeaders(query, page, "/api/_search/votes");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
 
开发者ID:xm-online,项目名称:xm-ms-entity,代码行数:16,代码来源:VoteResource.java

示例10: query

@ApiOperation("Query product from catalog")
@ApiResponses({
        @ApiResponse(code = 201, message = "Product has been query from catalog"),
        @ApiResponse(code = 404, message = "Product not found")})
@ResponseStatus(HttpStatus.OK)
@GetMapping("/query")
public ProductDto query(@RequestParam long id) {
    return productService.get(id);
}
 
开发者ID:rozidan,项目名称:project-template,代码行数:9,代码来源:ProductController.java

示例11: showProjectsDetails

@JsonView(JsonViews.Project.class)
@ResponseStatus(HttpStatus.OK)
@RequestMapping(value = "/api/project/details", method = {RequestMethod.GET, RequestMethod.POST}, produces = "application/json")
public List<Project> showProjectsDetails()
{
    LOGGER.debug("ApiController - showProjectsDetails");
    return projectService.findAllWithAll();
}
 
开发者ID:scrumtracker,项目名称:scrumtracker2017,代码行数:8,代码来源:ApiProjectController.java

示例12: getParticipantFromCGOR

@ApiOperation(value = "getParticipantFromCGOR", nickname = "getParticipantFromCGOR")
@RequestMapping(value = "/CISConnector/getParticipantFromCGOR/{cgorName}", method = RequestMethod.GET)
@ApiImplicitParams({
       @ApiImplicitParam(name = "cgorName", value = "the CGOR name", required = true, dataType = "String", paramType = "path"),
       @ApiImplicitParam(name = "organisation", value = "the Organisation name", required = true, dataType = "String", paramType = "query")
     })
@ApiResponses(value = { 
           @ApiResponse(code = 200, message = "Success", response = Participant.class),
           @ApiResponse(code = 400, message = "Bad Request", response = Participant.class),
           @ApiResponse(code = 500, message = "Failure", response = Participant.class)})
public ResponseEntity<Participant> getParticipantFromCGOR(@PathVariable String cgorName, @QueryParam("organisation") String organisation) {
	log.info("--> getParticipantFromCGOR: " + cgorName);
	
	Participant participant;
	
	try {
		participant = connector.getParticipantFromCGOR(cgorName, organisation);
	} catch (CISCommunicationException e) {
		log.error("Error executing the request: Communication Error" , e);
		participant = null;
	}
	
	HttpHeaders responseHeaders = new HttpHeaders();
	
	log.info("getParticipantFromCGOR -->");
	return new ResponseEntity<Participant>(participant, responseHeaders, HttpStatus.OK);
}
 
开发者ID:DRIVER-EU,项目名称:CommonInformationSpace,代码行数:27,代码来源:CISAdaptorConnectorRestController.java

示例13: getByDates

/**
 * GET  /audits : get a page of AuditEvents between the fromDate and toDate.
 *
 * @param fromDate the start of the time period of AuditEvents to get
 * @param toDate the end of the time period of AuditEvents to get
 * @param pageable the pagination information
 * @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
 */
@GetMapping(params = {"fromDate", "toDate"})
public ResponseEntity<List<AuditEvent>> getByDates(
    @RequestParam(value = "fromDate") LocalDate fromDate,
    @RequestParam(value = "toDate") LocalDate toDate,
    Pageable pageable) {

    Page<AuditEvent> page = auditEventService.findByDates(
        fromDate.atStartOfDay(ZoneId.systemDefault()).toInstant(),
        toDate.atStartOfDay(ZoneId.systemDefault()).plusDays(1).toInstant(),
        pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
 
开发者ID:torgcrm,项目名称:TorgCRM-Server,代码行数:21,代码来源:AuditResource.java

示例14: getByDates

/**
 * GET  /audits : get a page of AuditEvents between the fromDate and toDate.
 *
 * @param fromDate the start of the time period of AuditEvents to get
 * @param toDate the end of the time period of AuditEvents to get
 * @param pageable the pagination information
 * @return the ResponseEntity with status 200 (OK) and the list of AuditEvents in body
 * @throws URISyntaxException if there is an error to generate the pagination HTTP headers
 */

@GetMapping(params = {"fromDate", "toDate"})
@Secured(AuthoritiesConstants.ADMIN)
public ResponseEntity<List<AuditEvent>> getByDates(
    @RequestParam(value = "fromDate") LocalDate fromDate,
    @RequestParam(value = "toDate") LocalDate toDate,
    @ApiParam Pageable pageable) throws URISyntaxException {

    Page<AuditEvent> page = auditEventService.findByDates(fromDate.atTime(0, 0), toDate.atTime(23, 59), pageable);
    HttpHeaders headers = PaginationUtil.generatePaginationHttpHeaders(page, "/management/audits");
    return new ResponseEntity<>(page.getContent(), headers, HttpStatus.OK);
}
 
开发者ID:quanticc,项目名称:sentry,代码行数:21,代码来源:AuditResource.java

示例15: getOrderById

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<?> getOrderById(@PathVariable("id") long id) {
    LOGGER.info("Start getOrderById with id: {}", id);
    Order order = orderService.getById(id);

    if (order == null) {
        LOGGER.info("order with id: {} is NULL", id);
        return new ResponseEntity<>("Order not found", HttpStatus.NOT_FOUND);
    }

    OrderDto orderDto = OrderDto.toDto(order);
    return new ResponseEntity<>(orderDto, HttpStatus.OK);
}
 
开发者ID:atereshkov,项目名称:Diber-backend,代码行数:14,代码来源:OrderController.java


注:本文中的org.springframework.http.HttpStatus.OK属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。