Example usage for org.springframework.http HttpStatus NOT_FOUND

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

Introduction

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

Prototype

HttpStatus NOT_FOUND

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

Click Source Link

Document

404 Not Found .

Usage

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

@ResponseBody
@ResponseStatus(HttpStatus.NOT_FOUND)
@ExceptionHandler(EntityNotFoundException.class)
public String entityNotFound(Exception e) throws IOException {
    return e.getMessage();
}

From source file:org.agatom.springatom.webmvc.controllers.wizard.SVWizardController.java

@ResponseBody
@ExceptionHandler(WizardProcessorNotFoundException.class)
public ResponseEntity<?> onWizardProcessorNotFoundException(final WizardProcessorNotFoundException exp) {
    if (LOGGER.isWarnEnabled()) {
        LOGGER.warn("onWizardProcessorNotFoundException(exp={}) kicked in...", exp);
    }/*from w w w . j a  v  a2 s .com*/
    return this.errorResponse(exp, HttpStatus.NOT_FOUND);
}

From source file:net.maritimecloud.identityregistry.controllers.LogoController.java

/**
 * Creates or updates a logo for an organization
 * @param request request to get servletPath
 * @param orgMrn resource location for organization
 * @param logo the log encoded as a MultipartFile
 * @throws McBasicRestException/*from  w  ww.ja  v  a  2  s .c  o  m*/
 */
@RequestMapping(value = "/api/org/{orgMrn}/logo", method = RequestMethod.POST)
@ResponseBody
@PreAuthorize("hasRole('ORG_ADMIN') and @accessControlUtil.hasAccessToOrg(#orgMrn)")
public ResponseEntity<?> createLogoPost(HttpServletRequest request, @PathVariable String orgMrn,
        @RequestParam("logo") MultipartFile logo) throws McBasicRestException {
    Organization org = this.organizationService.getOrganizationByMrn(orgMrn);
    if (org != null) {
        try {
            this.updateLogo(org, logo.getInputStream());
            organizationService.save(org);
            return new ResponseEntity<>(HttpStatus.CREATED);
        } catch (IOException e) {
            log.error("Unable to create logo", e);
            throw new McBasicRestException(HttpStatus.BAD_REQUEST, MCIdRegConstants.INVALID_IMAGE,
                    request.getServletPath());
        }
    } else {
        throw new McBasicRestException(HttpStatus.NOT_FOUND, MCIdRegConstants.ORG_NOT_FOUND,
                request.getServletPath());
    }
}

From source file:com._8x8.presentation.restController.UserRestController.java

@RequestMapping(value = "/user/{id}", method = RequestMethod.PUT)
public ResponseEntity<User> updateUser(@PathVariable("id") int id, @RequestBody User user) {

    System.out.println("Updating User " + id);
    User currentUser = _userService.GetUserById(id);//.findById(id);

    if (currentUser == null) {
        System.out.println("User with id " + id + " not found");
        return new ResponseEntity<User>(HttpStatus.NOT_FOUND);
    }//from w  w w.j  av  a2  s. com

    _userService.UpdateUserById(user);
    return new ResponseEntity<User>(currentUser, HttpStatus.OK);
}

From source file:de.codecentric.boot.admin.controller.RegistryController.java

/**
 * Unregister an application within this admin application.
 * /*from  w w  w.  j  ava 2s . co  m*/
 * @param id The application id.
 */
@RequestMapping(value = "/api/application/{id}", method = RequestMethod.DELETE)
public ResponseEntity<Application> unregister(@PathVariable String id) {
    LOGGER.debug("Unregister application with ID '{}'", id);
    Application app = registry.unregister(id);
    if (app != null) {
        return new ResponseEntity<Application>(app, HttpStatus.NO_CONTENT);
    } else {
        return new ResponseEntity<Application>(HttpStatus.NOT_FOUND);
    }
}

From source file:com.boot.pf.config.WebMvcConfig.java

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {

    return (container -> {
        ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED, "/401.html");
        ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND, "/404.html");
        ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR, "/500.html");

        container.addErrorPages(error401Page, error404Page, error500Page);
    });//  w  ww.j  av  a2s . c  om
}

From source file:org.ff4j.spring.boot.exceptions.FF4jExceptionHandler.java

@ExceptionHandler(value = FeatureStoreNotCached.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "feature store is not cached")
public void featureStoreNotCached() {
    // Not necessary to handle this exception
}

From source file:de.hska.ld.core.controller.RoleControllerIntegrationTest.java

@Test
public void testDeleteRoleUsesHttpNotFoundOnEntityLookupFailure() throws Exception {

    HttpResponse response = UserSession.admin().delete(RESOURCE_ROLE + "/" + -1, null);
    Assert.assertEquals(HttpStatus.NOT_FOUND, ResponseHelper.getStatusCode(response));
}

From source file:org.kuali.mobility.emergencyinfo.controllers.EmergencyInfoController.java

@RequestMapping(method = RequestMethod.PUT, headers = "Accept=application/json")
public ResponseEntity<String> put(@RequestBody String json) {
    if (emergencyInfoService
            .findEmergencyInfoById(emergencyInfoService.fromJsonToEntity(json).getEmergencyInfoId()) == null) {
        return new ResponseEntity<String>(HttpStatus.NOT_FOUND);
    } else {//from  w w  w  . j a v  a  2  s . com
        if (emergencyInfoService.saveEmergencyInfo(emergencyInfoService.fromJsonToEntity(json)) == null) {
            return new ResponseEntity<String>(HttpStatus.NOT_MODIFIED);
        }
    }
    return new ResponseEntity<String>(HttpStatus.OK);
}

From source file:ch.heigvd.gamification.api.ApplicationsEndpoint.java

@Override
@RequestMapping(value = "/{applicationName}", method = RequestMethod.PUT)
public ResponseEntity<Void> applicationsApplicationNamePut(
        @ApiParam(value = "applicationName", required = true) @PathVariable("applicationName") String applicationUsername,
        @ApiParam(value = "Modification of the application") @RequestBody Registration body) {

    Application app = apprepository.findByName(applicationUsername);

    if (app == null) {
        return new ResponseEntity(HttpStatus.NOT_FOUND);
    }// w ww. j  a  va2s  .  c  om

    if (body.getApplicationName() != null) {
        if (!body.getApplicationName().equals(" ")) {
            app.setName(body.getApplicationName());
        } else {
            body.setApplicationName(app.getName());
        }
    }

    if (body.getPassword() != null) {

        if (!body.getPassword().equals(" ")) {
            try {
                String password = Application.doHash(body.getPassword(), app.getSel());
                app.setPassword(password);
            } catch (UnsupportedEncodingException ex) {
                Logger.getLogger(ApplicationsEndpoint.class.getName()).log(Level.SEVERE, null, ex);
            } catch (NoSuchAlgorithmException ex) {
                Logger.getLogger(ApplicationsEndpoint.class.getName()).log(Level.SEVERE, null, ex);
            }

        }

    }

    apprepository.save(app);
    return new ResponseEntity(HttpStatus.OK);
}