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:cn.edu.zjnu.acm.judge.service.MessageService.java

@Transactional
public void save(Long parentId, Long problemId, String userId, String title, String content) {
    long depth = 0;
    long orderNum = 0;

    final long nextId = messageMapper.nextId();
    final Message parent = parentId != null ? Optional.ofNullable(messageMapper.findOne(parentId))
            .orElseThrow(() -> new MessageException("No such parent message", HttpStatus.NOT_FOUND)) : null;
    if (parent != null) {
        orderNum = parent.getOrder();/*www .  j  a va 2  s  .co  m*/
        final long depth1 = parent.getDepth();

        List<Message> messages = messageMapper
                .findAllByThreadIdAndOrderNumGreaterThanOrderByOrderNum(parent.getThread(), parent.getOrder());
        for (Message m : messages) {
            depth = m.getDepth();
            if (depth <= depth1) {
                break;
            }
            orderNum = m.getOrder();
        }
        depth = depth1 + 1;
        messageMapper.updateOrderNumByThreadIdAndOrderNumGreaterThan(parent.getThread(), orderNum);
        ++orderNum;
    }
    messageMapper.save(nextId, parentId, orderNum, problemId, depth, userId, title, content);
    if (parent != null) {
        messageMapper.updateThreadIdByThreadId(nextId, parent.getThread());
    }
}

From source file:com.sms.server.controller.MediaController.java

@RequestMapping(value = "/folder", method = RequestMethod.GET)
public ResponseEntity<List<MediaFolder>> getMediaFolders() {
    List<MediaFolder> mediaFolders = settingsDao.getMediaFolders();

    if (mediaFolders == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }/*w w w  . java 2s  .  com*/

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

From source file:org.systemexception.springmongorest.Application.java

@Bean
public EmbeddedServletContainerCustomizer containerCustomizer() {

    return new EmbeddedServletContainerCustomizer() {
        @Override/*from w  ww  .j  a  va  2 s  .  c o m*/
        public void customize(ConfigurableEmbeddedServletContainer 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);
        }
    };
}

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

public static WebApiException asNotFound(String message) {
    return new WebApiException(HttpStatus.NOT_FOUND, message);
}

From source file:com.vgorcinschi.concordiafootballmanager.rest.PlayerRestController.java

@ExceptionHandler(PlayerNotFoundException.class)
@ResponseStatus(HttpStatus.NOT_FOUND)
public @ResponseBody Error playerNotFound(PlayerNotFoundException e) {
    String playerName = e.getLastName();
    return new Error(404, "Player [" + playerName + "] is not stored in our databse");
}

From source file:com.carlomicieli.jtrains.infrastructure.web.ResponsesTests.java

@Test
public void shouldCreateResponsesForNotFound() {
    ResponseEntity<VndErrors> notFound = Responses.notFound("details");
    assertThat(notFound).isNotNull();/*from  www .j  a v  a 2 s . com*/
    assertThat(notFound.getStatusCode()).isEqualTo(HttpStatus.NOT_FOUND);
    assertThat(notFound.getBody()).isEqualTo(new VndErrors("details", "Resource not found"));
}

From source file:com.sms.server.controller.JobController.java

@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ResponseEntity<Job> getJobByID(@PathVariable("id") Long id) {
    Job job = jobDao.getJobByID(id);/*from ww  w  .j  a  v a2  s.  com*/

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

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

From source file:io.lavagna.web.helper.GeneralHandlerExceptionResolver.java

public GeneralHandlerExceptionResolver() {
    // add the exceptions from the less generic to the more one
    statusCodeResolver.put(EmptyResultDataAccessException.class, HttpStatus.NOT_FOUND.value());
    statusCodeResolver.put(ValidationException.class, HttpStatus.UNPROCESSABLE_ENTITY.value());
}

From source file:com.tamnd2.basicwebapp.rest.mvc.BlogEntryController.java

@RequestMapping(value = "/{blogEntryId}", method = RequestMethod.GET)
public ResponseEntity<BlogEntryResource> getBlogEntry(@PathVariable Long blogEntryId) {
    BlogEntry entry = service.findBlogEntry(blogEntryId);
    if (entry != null) {
        BlogEntryResource res = (new BlogEntryResourceAsm()).toResource(entry);
        return new ResponseEntity<BlogEntryResource>(res, HttpStatus.OK);
    } else {//ww w.ja  va  2s  .c  o  m
        return new ResponseEntity<BlogEntryResource>(HttpStatus.NOT_FOUND);
    }
}

From source file:org.cloudfoundry.maven.Restart.java

@Override
protected void doExecute() throws MojoExecutionException {
    try {/* w ww . j  a v  a2  s  . c  om*/
        getLog().info(String.format("Restarting application '%s'", getAppname()));

        final StartingInfo startingInfo = getClient().restartApplication(getAppname());
        showStagingStatus(startingInfo);

        final CloudApplication application = getClient().getApplication(getAppname());
        showStartingStatus(application);
        showStartResults(application, getAllUris());
    } catch (CloudFoundryException e) {
        if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) {
            throw new MojoExecutionException(String.format("Application '%s' does not exist", getAppname()), e);
        }
    }
}