Example usage for org.springframework.http HttpStatus BAD_REQUEST

List of usage examples for org.springframework.http HttpStatus BAD_REQUEST

Introduction

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

Prototype

HttpStatus BAD_REQUEST

To view the source code for org.springframework.http HttpStatus BAD_REQUEST.

Click Source Link

Document

400 Bad Request .

Usage

From source file:org.cloudfoundry.identity.uaa.codestore.CodeStoreEndpointsTests.java

@Test
public void testGenerateCodeWithNullExpiresAt() throws Exception {
    String data = "{}";
    ExpiringCode expiringCode = new ExpiringCode(null, null, data);

    try {//from w  w  w  .ja v  a  2 s  .  co m
        codeStoreEndpoints.generateCode(expiringCode);

        fail("expiresAt is null, should throw CodeStoreException.");
    } catch (CodeStoreException e) {
        assertEquals(e.getStatus(), HttpStatus.BAD_REQUEST);
    }
}

From source file:net.oneandone.stool.overview.IndexController.java

@RequestMapping(value = "feedback", method = RequestMethod.POST)
public ResponseEntity sendFeedback(@ModelAttribute("message") String message, ServletRequest request)
        throws MessagingException {
    String subject;/*from w  ww.j  av  a 2s .  c o m*/
    if (message.isEmpty()) {
        return new ResponseEntity(HttpStatus.BAD_REQUEST);
    }
    subject = "[Stool] Feedback from " + SecurityContextHolder.getContext().getAuthentication().getName();
    new Mailer(session.configuration.mailHost, session.configuration.mailUsername,
            session.configuration.mailPassword).send(session.configuration.contactAdmin,
                    new String[] { session.configuration.contactAdmin }, subject, message);
    return new ResponseEntity(HttpStatus.ACCEPTED);
}

From source file:org.apigw.authserver.web.controller.TrustedController.java

@ExceptionHandler(IllegalArgumentException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody/*from w ww . ja  v  a2  s. c o  m*/
public String handleIllegalArgument() {
    return "Resident identification numbers must match yyyymmddnnnn.";
}

From source file:nu.yona.server.subscriptions.rest.UserPhotoController.java

@ExceptionHandler(MultipartException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ResponseBody//  w w w .  j  av a2s.  c  o m
public ErrorResponseDto handleMultipartException(Exception exception, HttpServletRequest request) {
    return globalExceptionMapping.handleOtherException(exception, request);
}

From source file:edu.eci.arsw.pacm.controllers.PacmRESTController.java

@RequestMapping(path = "/{salanum}/protectores", method = RequestMethod.GET)
public ResponseEntity<?> getProtectores(@PathVariable(name = "salanum") String salanum) {

    try {/*from   ww w. j  a  v a2s .c  o  m*/
        return new ResponseEntity<>(services.getProtectores(Integer.parseInt(salanum)), HttpStatus.ACCEPTED);
    } catch (ServicesException ex) {
        Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>(ex.getLocalizedMessage(), HttpStatus.NOT_FOUND);
    } catch (NumberFormatException ex) {
        Logger.getLogger(PacmRESTController.class.getName()).log(Level.SEVERE, null, ex);
        return new ResponseEntity<>("/{salanum}/ must be an integer value.", HttpStatus.BAD_REQUEST);
    }
}

From source file:org.trustedanalytics.user.invite.RestErrorHandler.java

@ResponseBody
@ResponseStatus(HttpStatus.BAD_REQUEST)
@ExceptionHandler(WrongEmailAddressException.class)
public String wrongEmailAddress(Exception e) throws IOException {
    return e.getMessage();
}

From source file:edu.chalmers.dat076.moviefinder.controller.AdminController.java

@RequestMapping(value = "/removePath/{id}", method = RequestMethod.DELETE)
public ResponseEntity<String> removePath(@PathVariable long id) {
    ListeningPath lp = listeningPathRepository.findOne(id);
    if (lp != null) {
        File f = new File(lp.getListeningPath());
        try {//from   ww w .  j  a va  2  s . c  om
            databaseHelper.removePath(f.toPath());
            fileThreadService.removeListeningPath(f.toPath());
            movieDatabaseHelper.removeFile(f.toPath());
            return new ResponseEntity<>(HttpStatus.OK);
        } catch (NullPointerException e) {
            return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
        }
    } else {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.gazbert.bxbot.rest.api.StrategyConfigController.java

/**
 * Updates a given Strategy configuration.
 *
 * @param user the authenticated user./*from w w w. j  a va 2s . c o m*/
 * @param strategyId id of the Strategy config to update.
 * @param config the updated Strategy config.
 * @return 204 'No Content' HTTP status code if update successful, 404 'Not Found' HTTP status code if Strategy config not found.
 */
@RequestMapping(value = "/strategy/{strategyId}", method = RequestMethod.PUT)
ResponseEntity<?> updateStrategy(@AuthenticationPrincipal User user, @PathVariable String strategyId,
        @RequestBody StrategyConfig config) {

    if (config == null || config.getId() == null || !strategyId.equals(config.getId())) {
        return new ResponseEntity<>(HttpStatus.BAD_REQUEST);
    }

    final StrategyConfig updatedConfig = strategyConfigService.updateStrategy(config);
    return updatedConfig.getId() != null ? new ResponseEntity<>(HttpStatus.NO_CONTENT)
            : new ResponseEntity<>(HttpStatus.NOT_FOUND);
}

From source file:com.hp.autonomy.frontend.find.idol.view.IdolViewController.java

@ExceptionHandler(ReferenceFieldBlankException.class)
@ResponseStatus(HttpStatus.BAD_REQUEST)
public ModelAndView handleReferenceFieldBlankException(final HttpServletRequest request,
        final ServletResponse response) {
    response.reset();/*from w w  w  .ja  v  a  2 s .  c o m*/

    log.info(Markers.AUDIT, "TRIED TO VIEW A DOCUMENT USING A BLANK REFERENCE FIELD");

    return controllerUtils.buildErrorModelAndView(new ErrorModelAndViewInfo.Builder().setRequest(request)
            .setMainMessageCode("error.referenceFieldBlankMain")
            .setSubMessageCode("error.referenceFieldBlankSub").setStatusCode(HttpStatus.BAD_REQUEST.value())
            .setContactSupport(true).build());
}