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:gt.dakaik.rest.impl.SchoolImpl.java

@Override
public ResponseEntity<School> findAll(int idUsuario, String token) throws EntidadNoEncontradaException {
    return new ResponseEntity(repoSchool.findAll(), HttpStatus.OK);
}

From source file:com.intel.databackend.handlers.ErrorHandler.java

@ExceptionHandler(DataInquiryException.class)
public ResponseEntity handleError(DataInquiryException ex) {
    return new ResponseEntity<ErrorResponse>(ex.getResponse(), ex.getHttpErrorStatus());
}

From source file:reconf.server.services.property.RealAllPropertiesService.java

@RequestMapping(value = "/product/{prod}/component/{comp}/property", method = RequestMethod.GET)
@Transactional(readOnly = true)// w ww  .  j  av a  2  s  .c o  m
public ResponseEntity<AllPropertiesResult> global(@PathVariable("prod") String product,
        @PathVariable("comp") String component, HttpServletRequest request, Authentication auth) {

    ComponentKey key = new ComponentKey(product, component);

    if (!products.exists(key.getProduct())) {
        return new ResponseEntity<AllPropertiesResult>(new AllPropertiesResult(key, Product.NOT_FOUND),
                HttpStatus.NOT_FOUND);
    }
    if (!components.exists(new ComponentKey(key.getProduct(), key.getName()))) {
        return new ResponseEntity<AllPropertiesResult>(new AllPropertiesResult(key, Component.NOT_FOUND),
                HttpStatus.NOT_FOUND);
    }

    List<PropertyRuleResult> result = new ArrayList<>();
    for (Property dbProperty : properties.findByKeyProductAndKeyComponent(key.getProduct(), key.getName())) {
        PropertyRuleResult toAdd = new PropertyRuleResult(dbProperty, CrudServiceUtils.getBaseUrl(request));
        if (StringUtils.equalsIgnoreCase(dbProperty.getKey().getRuleName(), Property.DEFAULT_RULE_NAME)) {
            toAdd.clearRule();
        }
        toAdd.addSelfUri(CrudServiceUtils.getBaseUrl(request));
        result.add(toAdd);
    }

    return new ResponseEntity<AllPropertiesResult>(
            new AllPropertiesResult(key, result, CrudServiceUtils.getBaseUrl(request)), HttpStatus.OK);
}

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

@Override
public ResponseEntity<Menu> findById(int idUsuario, String token, Long id) throws EntidadNoEncontradaException {
    Menu m = repoMenu.findOne(id);

    if (m != null) {
        return new ResponseEntity(m, HttpStatus.OK);
    } else {//from w w w  .ja v  a2  s .com
        throw new EntidadNoEncontradaException("Entity Menu");
    }
}

From source file:net.eusashead.hateoas.conditional.interceptor.SyncTestController.java

@RequestMapping(method = RequestMethod.PUT)
public ResponseEntity<Void> put() {
    HttpHeaders headers = new HttpHeaders();
    headers.setETag("\"123456\"");
    return new ResponseEntity<Void>(headers, HttpStatus.NO_CONTENT);
}

From source file:com.htmlhifive.resourcefw.sample.ctrl.OtherController.java

@RequestMapping("other1")
public ResponseEntity<Map<String, String>> other1(
        @RequestParam(value = "q", required = false, defaultValue = "defaultQ") final String q)
        throws Exception {

    @SuppressWarnings("serial")
    HashMap<String, String> body = new HashMap<String, String>() {
        {/*from ww  w  .j av  a 2  s .com*/
            put("q", q);
        }
    };

    return new ResponseEntity<Map<String, String>>(body, HttpStatus.OK);
}

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

/**
 * ?/*from www  .  j  a v a 2  s.c  o  m*/
 * 
 * @param projectId
 * @param storyIds
 * @return
 */
@RequestMapping(value = "/project/{projectId}/statistics", method = RequestMethod.GET)
@ResponseBody
public ResponseEntity<Map<String, Object>> queryStatistics(@PathVariable long projectId, String storyIds) {
    String[] idStrs = storyIds.split(",");
    List<Long> ids = new ArrayList<Long>();
    for (String id : idStrs) {
        ids.add(new Long(id));
    }
    Map<String, Object> resultMap = statisticsService.queryStatistics(ids, projectId);
    return new ResponseEntity<Map<String, Object>>(resultMap, HttpStatus.OK);
}

From source file:br.eti.danielcamargo.backend.common.rest.handlers.GlobalExceptionHandler.java

@ExceptionHandler({ BusinessException.class })
public ResponseEntity<List<Mensagem>> handleBadRequest(final BusinessException ex, final WebRequest request) {
    List<ValidationOccurrence> ocorrencias = ex.getOccurrences();
    List<Mensagem> mensagens = new ArrayList<>();
    for (ValidationOccurrence validationOccurrence : ocorrencias) {
        if (validationOccurrence.isConstraintViolation()) {
            mensagens.add(MessageUtils.criarMensagemErroValidacao(ex.getModulo(), validationOccurrence));
        } else {//  w  ww. ja va2  s . c  om
            mensagens.add(MessageUtils.criarMensagemErro(ex.getModulo(), validationOccurrence));
        }
    }

    ResponseEntity<List<Mensagem>> responseEntity = new ResponseEntity<>(mensagens, HttpStatus.BAD_REQUEST);
    return responseEntity;
}

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

@Override
public ResponseEntity<Profile> findById(int idUsuario, String token, Long id)
        throws EntidadNoEncontradaException {
    Profile p = repoProfile.findOne(id);

    if (p != null) {
        return new ResponseEntity(p, HttpStatus.OK);
    } else {//from w ww.j  a  v  a2  s  .co  m
        throw new EntidadNoEncontradaException("Entity User");
    }
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.TestResource.java

@RequestMapping(value = "/internalservererror", method = RequestMethod.GET)
@Timed//  w  ww.j a  va  2  s.c om
public ResponseEntity<Map<String, String>> return500Error() {
    return new ResponseEntity<>(ImmutableMap.of("message", "error"), HttpStatus.INTERNAL_SERVER_ERROR);
}