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.zalando.github.spring.MembersTemplate.java

@Override
public boolean isPublicMemberOfOrganization(String organization, String username) {
    Map<String, Object> uriVariables = new HashMap<>();
    uriVariables.put("organization", organization);
    uriVariables.put("username", username);
    HttpStatus status = HttpStatus.NOT_FOUND;
    try {//from   w w  w  .  j a v a  2s. com

        ResponseEntity<Void> responseEntity = getRestOperations().getForEntity(
                buildUri("/orgs/{organization}/public_members/{username}", uriVariables), Void.class);
        status = responseEntity.getStatusCode();
    } catch (HttpClientErrorException e) {
        // skip
    }
    return HttpStatus.NO_CONTENT.equals(status) ? true : false;
}

From source file:cn.edu.zjnu.acm.judge.controller.MailController.java

@PostMapping("/send")
@SuppressWarnings("AssignmentToMethodParameter")
public String send(@RequestParam("title") String title, @RequestParam("to") String to,
        @RequestParam("content") String content, Authentication authentication) {
    String userId = authentication != null ? authentication.getName() : null;
    if (StringUtils.isEmptyOrWhitespace(title)) {
        title = "No Topic";
    }/*w w  w.  j av  a 2  s  .c  o m*/
    if (content.length() > 40000) {
        throw new MessageException("Sorry, content too long", HttpStatus.PAYLOAD_TOO_LARGE);
    }
    if (userMapper.findOne(to) == null) {
        throw new MessageException("Sorry, no such user:" + to, HttpStatus.NOT_FOUND);
    }

    mailMapper.save(Mail.builder().from(userId).to(to).title(title).content(content).build());
    return "mails/sendsuccess";
}

From source file:ca.qhrtech.controllers.UserController.java

@ApiMethod(description = "Deletes the User at the specified location")
@RequestMapping(value = "/user/{id}", method = RequestMethod.DELETE)
public ResponseEntity<BGLUser> deleteUser(@PathVariable("id") long id) {
    if (userService.findUserById(id) == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);

    }/*from   ww  w .j  a va 2 s.  c om*/
    userService.deleteUser(id);
    return new ResponseEntity<>(HttpStatus.NO_CONTENT);
}

From source file:com.envision.envservice.rest.UserResource.java

@GET
@Path("/detail/{id}")
@Produces(MediaType.APPLICATION_JSON)// w  ww .  java 2s.  c o m
public Response queryUserDetail(@PathParam("id") String id) throws Exception {
    HttpStatus status = HttpStatus.OK;
    String repsonse = null;

    paramCheck(id);

    UserDetailVo userDetail = userDetailService.queryUserDetail(id);
    if (userDetail != null) {
        repsonse = JSONObject.toJSONString(userDetail, JSONFilter.NULLFILTER);
    } else {
        status = HttpStatus.NOT_FOUND;
        repsonse = FailResult.toJson(Code.USER_NOT_FOUND, "");
    }

    return Response.status(status.value()).entity(repsonse).build();
}

From source file:de.codecentric.boot.admin.actuate.LogfileMvcEndpoint.java

@RequestMapping(method = RequestMethod.HEAD)
@ResponseBody//  w  w  w  .jav  a 2s . c  om
public ResponseEntity<Object> available() {
    if (isAvailable()) {
        return new ResponseEntity<Object>(HttpStatus.OK);
    } else {
        return new ResponseEntity<Object>(HttpStatus.NOT_FOUND);
    }
}

From source file:org.osiam.resources.exception.OsiamExceptionHandler.java

@ExceptionHandler({ ResourceNotFoundException.class, NoSuchElementException.class })
@ResponseStatus(HttpStatus.NOT_FOUND)
@ResponseBody/* w w w  . j a v a  2  s. c o  m*/
public ErrorResponse handleResourceNotFoundException(Exception e) {
    return produceErrorResponse(e.getMessage(), HttpStatus.NOT_FOUND);
}

From source file:org.createnet.raptor.auth.service.controller.DevicePermissionController.java

@RequestMapping(value = "/{deviceUuid}/permission/{userUuid}", method = RequestMethod.GET)
@ApiOperation(value = "List user permissions on a device", notes = "", response = String.class, responseContainer = "List", nickname = "getUserPermissions")
public ResponseEntity<?> listPermissions(@PathVariable("deviceUuid") String deviceUuid,
        @PathVariable("userUuid") String userUuid) {

    Device device = deviceService.getByUuid(deviceUuid);
    if (device == null) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("Device not found");
    }//from w  w  w  .j  a va  2 s.  c o  m

    User user = userService.getByUuid(userUuid);
    if (user == null) {
        return ResponseEntity.status(HttpStatus.NOT_FOUND).body("User not found");
    }

    List<String> permissions = RaptorPermission.toLabel(aclDeviceService.list(device, user));
    return ResponseEntity.status(HttpStatus.ACCEPTED).body(permissions);
}

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

@Test
public void unregister() {
    Application app = new Application("http://localhost", "FOO");
    app = controller.register(app).getBody();

    ResponseEntity<?> response = controller.unregister(app.getId());
    assertEquals(HttpStatus.NO_CONTENT, response.getStatusCode());
    assertEquals(app, response.getBody());

    assertEquals(HttpStatus.NOT_FOUND, controller.get(app.getId()).getStatusCode());
}

From source file:com.nebhale.buildmonitor.web.WebHookController.java

private ResponseEntity<?> webHook(Project project, Map<String, ?> payload, PayloadParser payloadParser)
        throws JsonProcessingException {
    if (this.logger.isDebugEnabled()) {
        this.logger.debug(this.objectMapper.writeValueAsString(payload));
    }//w  w  w  . j a v a  2s.c om

    if (project == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }

    String uri = payloadParser.getUri(payload);
    Build.State state = payloadParser.getState(payload);

    this.logger.info("Received {} webhook for {} with status {}", project.getKey(), uri, state);
    if (Build.State.UNKNOWN == state) {
        this.logger.warn(this.objectMapper.writeValueAsString(payload));
    }

    if (payloadParser.shouldProcess(payload)) {
        Build build = this.repository.findByUri(uri);
        if (build == null) {
            build = new Build(project, uri, state);
        } else {
            build.setState(state);
        }

        this.repository.saveAndFlush(build);
        this.buildsChangedNotifier.buildsChanged(project);
    } else {
        this.logger.info("Payload ignored");
    }

    return new ResponseEntity<>(HttpStatus.OK);
}

From source file:org.energyos.espi.datacustodian.oauth.OauthAdminController.java

@RequestMapping(value = "custodian/oauth/tokens/{token}/retailcustomers/{userId}", method = RequestMethod.DELETE)
public ResponseEntity<Void> revokeToken(@PathVariable String userId, @PathVariable String token,
        Principal principal) throws Exception {
    checkResourceOwner(userId, principal);
    if (tokenServices.revokeToken(token)) {
        return new ResponseEntity<Void>(HttpStatus.NO_CONTENT);
    } else {/*from ww w.  j  a va 2s .  co m*/
        return new ResponseEntity<Void>(HttpStatus.NOT_FOUND);
    }
}