Example usage for org.springframework.http ResponseEntity ResponseEntity

List of usage examples for org.springframework.http ResponseEntity ResponseEntity

Introduction

In this page you can find the example usage for org.springframework.http ResponseEntity ResponseEntity.

Prototype

public ResponseEntity(MultiValueMap<String, String> headers, HttpStatus status) 

Source Link

Document

Create a new HttpEntity with the given headers and status code, and no body.

Usage

From source file:springfox.documentation.spring.web.dummy.controllers.EnumService.java

@RequestMapping(value = "/entity", method = RequestMethod.GET)
@ApiOperation(value = "Example with response entity single value")
public ResponseEntity<EnumType> getResponseEntityValue() {
    return new ResponseEntity<EnumType>(EnumType.ONE, HttpStatus.OK);
}

From source file:com.ogaclejapan.dotapk.WebApiException.java

private WebApiException(HttpStatus status, WebApiErrorReturns errorReturns) {
    super(errorReturns.getError().getMessage());
    this.responseEntity = new ResponseEntity<WebApiErrorReturns>(errorReturns, status);
}

From source file:net.eusashead.hateoas.response.impl.OptionsResponseBuilderImpl.java

@Override
public ResponseEntity<T> build() {
    ResponseEntity<T> responseEntity;
    if (entity == null) {
        responseEntity = new ResponseEntity<T>(headers, HttpStatus.OK);
    } else {//from w w w.  j  a va 2 s .co  m
        responseEntity = new ResponseEntity<T>(entity, headers, HttpStatus.OK);
    }
    return responseEntity;
}

From source file:br.com.hyperclass.snackbar.restapi.CashierController.java

@RequestMapping(value = "/cashier", method = RequestMethod.GET)
public ResponseEntity<ProductsWrapper> orderItemProducts() {
    return new ResponseEntity<ProductsWrapper>(new ProductsWrapper(cashier.productsInCashier()), HttpStatus.OK);
}

From source file:com.chevres.rss.restapi.controller.RegisterController.java

@CrossOrigin
@RequestMapping(path = "/register", method = RequestMethod.POST)
@ResponseBody// www  . j a  v a  2 s  .c  om
public HttpEntity<String> register(@RequestBody User user, BindingResult bindingResult) {

    ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring.xml");

    userValidator.validate(user, bindingResult);

    if (bindingResult.hasErrors()) {
        context.close();
        return new ResponseEntity(new ErrorMessageResponse("bad_params"), HttpStatus.BAD_REQUEST);
    }

    UserDAO userDAO = context.getBean(UserDAO.class);

    if (userDAO.doesExist(user.getUsername())) {
        context.close();
        return new ResponseEntity(new ErrorMessageResponse("already_exist"), HttpStatus.BAD_REQUEST);
    }

    PasswordEncoder passwordEncoder = new BCryptPasswordEncoder();
    String hashedPassword = passwordEncoder.encode(user.getPassword());
    user.setPassword(hashedPassword);
    user.setType(User.USER_TYPE_LABEL);
    userDAO.create(user);

    context.close();

    return new ResponseEntity(new SuccessMessageResponse("success"), HttpStatus.OK);
}

From source file:com.tribuo.backend.controllers.ProductosController.java

/**
 *
 * @param code/*from  w ww. j  a v  a  2  s  . com*/
 * @return
 */
@RequestMapping(value = "/codigo/{code}", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Productos> getOPriductoByCode(@PathVariable("code") String code) {
    Productos p = se.getProductoByCode(code);
    return new ResponseEntity<>(p, HttpStatus.OK);
}

From source file:gt.dakaik.rest.impl.ForumImpl.java

@Override
public ResponseEntity<Forum> findByUser(int idUsuario, String token, int page, int idUserProfile)
        throws EntidadNoEncontradaException {
    Pageable p = new PageRequest(page, 40);

    return new ResponseEntity(repoForum.findByUser(idUserProfile, p), HttpStatus.OK);
}

From source file:com.seguriboxltv.ws.AlgorithmHashRest.java

@RequestMapping(value = "/sdhash", method = RequestMethod.GET, headers = "Accept=application/json")
@ResponseBody//from   w  w  w . java  2s  . c  o m
public ResponseEntity<List<HashAlgs>> getAllSDHash() {
    List<HashAlgs> list = null;
    try {
        list = algorithmCryptModuleService.GetSDAlgorithmHash();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return new ResponseEntity<>(list, HttpStatus.OK);
}

From source file:com.jiwhiz.rest.author.AuthorAccountRestController.java

@RequestMapping(method = RequestMethod.GET, value = URL_AUTHOR)
@Transactional(readOnly = true)/*from  w ww.ja  va  2  s.c o m*/
public HttpEntity<AuthorAccountResource> getCurrentAuthorAccount() {
    UserAccount currentUser = getCurrentAuthenticatedAuthor();
    return new ResponseEntity<>(authorAccountResourceAssembler.toResource(currentUser), HttpStatus.OK);
}

From source file:com.baidu.stqa.signet.web.action.PropertyAction.java

/**
 * ??// w w w  .  j  a  va2  s .  c  om
 * 
 * @param projectId
 * @param key
 * @return
 */
@RequestMapping(value = "/project/{projectId}/property", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Map<String, Object>> queryProperty(@PathVariable long projectId, String key) {

    doLog(projectId);

    Map<String, Object> propertyMap = new HashMap<String, Object>();
    if (key == null) {
        propertyMap = propertyService.queryProperty(projectId);
    } else {
        String value = propertyService.queryProperty(projectId, key);
        propertyMap.put(key, value);
    }
    return new ResponseEntity<Map<String, Object>>(propertyMap, HttpStatus.OK);
}