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:com.hp.autonomy.frontend.find.core.beanconfiguration.AppConfiguration.java

@SuppressWarnings("ReturnOfInnerClass")
@Bean/*from  w  ww.  ja  va2  s .com*/
public EmbeddedServletContainerCustomizer containerCustomizer() {

    return new EmbeddedServletContainerCustomizer() {
        @Override
        public void customize(final ConfigurableEmbeddedServletContainer container) {

            final ErrorPage error401Page = new ErrorPage(HttpStatus.UNAUTHORIZED,
                    DispatcherServletConfiguration.AUTHENTICATION_ERROR_PATH);
            final ErrorPage error403Page = new ErrorPage(HttpStatus.FORBIDDEN,
                    DispatcherServletConfiguration.AUTHENTICATION_ERROR_PATH);
            final ErrorPage error404Page = new ErrorPage(HttpStatus.NOT_FOUND,
                    DispatcherServletConfiguration.NOT_FOUND_ERROR_PATH);
            final ErrorPage error500Page = new ErrorPage(HttpStatus.INTERNAL_SERVER_ERROR,
                    DispatcherServletConfiguration.SERVER_ERROR_PATH);

            container.addErrorPages(error401Page, error403Page, error404Page, error500Page);
        }
    };
}

From source file:org.apereo.openlrs.controllers.xapi.XAPIExceptionHandlerAdvice.java

@ExceptionHandler(NotFoundException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND)
@ResponseBody/*from   ww w  . j a  va 2  s  . c  om*/
public XAPIErrorInfo handleNotImplementedException(final HttpServletRequest request,
        final NotFoundException e) {
    final XAPIErrorInfo result = new XAPIErrorInfo(HttpStatus.NOT_FOUND, request, e.getLocalizedMessage());
    this.logException(e);
    this.logError(result);
    return result;
}

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

@RequestMapping(method = RequestMethod.GET)
public void invoke(HttpServletResponse response) throws IOException {
    if (!isAvailable()) {
        response.setStatus(HttpStatus.NOT_FOUND.value());
        return;/*  w  w w  .j a v a  2 s.  co m*/
    }

    Resource file = new FileSystemResource(logfile);
    response.setContentType(MediaType.TEXT_PLAIN_VALUE);
    response.setHeader("Content-Disposition", "attachment; filename=\"" + file.getFilename() + "\"");
    FileCopyUtils.copy(file.getInputStream(), response.getOutputStream());
}

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

@ApiMethod(description = "Update the User at the specified location. Passed User should contain updated fields")
@RequestMapping(value = "/user/{id}", method = RequestMethod.PUT)
public ResponseEntity<BGLUser> updateUser(@PathVariable("id") long id, @RequestBody BGLUser user) {
    BGLUser currentUser = userService.findUserById(id);
    if (currentUser == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    }//  ww w  .j  av  a 2 s.c  o  m

    currentUser.setUsername(user.getUsername());
    currentUser.setAvatarPath(user.getAvatarPath());
    currentUser.setEmail(user.getEmail());

    userService.updateUser(currentUser);
    return new ResponseEntity<>(currentUser, HttpStatus.OK);
}

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

@RequestMapping(value = "/product/{prod}/component/{comp}/property/{prop}/rule/{rule}", method = RequestMethod.DELETE)
@Transactional/*from  w  ww  .  j  a  v  a  2s  .  c  o  m*/
public ResponseEntity<PropertyResult> resticted(@PathVariable("prod") String product,
        @PathVariable("comp") String component, @PathVariable("prop") String property,
        @PathVariable("rule") String rule) {

    PropertyKey key = new PropertyKey(product, component, property, rule);
    Property fromRequest = new Property(key, null);

    List<String> errors = DomainValidator.checkForErrors(key);
    if (!errors.isEmpty()) {
        return new ResponseEntity<PropertyResult>(new PropertyResult(fromRequest, errors),
                HttpStatus.BAD_REQUEST);
    }

    if (!properties.exists(key)) {
        return new ResponseEntity<PropertyResult>(new PropertyResult(fromRequest, Property.NOT_FOUND),
                HttpStatus.NOT_FOUND);
    }
    properties.delete(key);
    return new ResponseEntity<PropertyResult>(HttpStatus.OK);
}

From source file:org.magnum.dataup.VideoSvcUp.java

@RequestMapping(value = VideoSvcApi.VIDEO_DATA_PATH, method = RequestMethod.POST)
public @ResponseBody VideoStatus setVideoData(@PathVariable(VideoSvcApi.ID_PARAMETER) long id,
        @RequestParam(VideoSvcApi.DATA_PARAMETER) MultipartFile data, HttpServletResponse response)
        throws IOException {

    if (!videos.containsKey(id)) {
        System.out.println("ID Not found");
        response.setStatus(HttpStatus.NOT_FOUND.value());
    } else {/* ww w  . java  2 s .co m*/

        Video v = videos.get(id);
        //System.out.println("Vishal's video id: " + v.getId() + " url: " + v.getDataUrl()
        //      + " title:" + v.getTitle() + " Content type:" + v.getContentType() +
        //       " Subject:" + v.getSubject());
        videoDataMgr = VideoFileManager.get(); //singleton
        if (videoDataMgr.hasVideoData(v)) {
            System.out.println("Notice: Overwriting video at id: " + v.getId());
        }
        videoDataMgr.saveVideoData(v, data.getInputStream());
    }
    return new VideoStatus(VideoState.READY);
}

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

/**
 * Returns a list of rolemappings for this organization
 *
 * @return a reply...//from   w w  w.  j  a va  2s  .c  o  m
 */
@RequestMapping(value = "/api/org/{orgMrn}/roles", method = RequestMethod.GET, produces = "application/json;charset=UTF-8")
@ResponseBody
@PreAuthorize("hasRole('ORG_ADMIN') and @accessControlUtil.hasAccessToOrg(#orgMrn)")
public ResponseEntity<List<Role>> getRoles(HttpServletRequest request, @PathVariable String orgMrn)
        throws McBasicRestException {
    Organization org = this.organizationService.getOrganizationByMrn(orgMrn);
    if (org != null) {
        List<Role> roles = this.roleService.listFromOrg(org.getId());
        return new ResponseEntity<>(roles, HttpStatus.OK);
    } else {
        throw new McBasicRestException(HttpStatus.NOT_FOUND, MCIdRegConstants.ORG_NOT_FOUND,
                request.getServletPath());
    }
}

From source file:io.github.proxyprint.kitchen.controllers.notifications.NotificationsController.java

@Transactional
@ApiOperation(value = "Returns success/insuccess.", notes = "This method allows a consumer to subscribe the SSE.")
@RequestMapping(value = "/consumer/subscribe", produces = "text/event-stream")
public ResponseEntity<SseEmitter> subscribe(WebRequest request) {
    String username = request.getParameter("username");
    String password = request.getParameter("password");

    Consumer consumer = this.consumers.findByUsername(username);
    if (consumer == null) {
        return new ResponseEntity<>(HttpStatus.NOT_FOUND);
    } else if (consumer.getPassword().equals(password)) {
        return new ResponseEntity<>(this.notificationManager.subscribe(username), HttpStatus.OK);
    } else {/*from  w ww  .  j a  va 2 s  .  c  o  m*/
        return new ResponseEntity<>(HttpStatus.UNAUTHORIZED);
    }
}

From source file:com.bennavetta.appsite.webapi.AuthController.java

@RequestMapping(value = "/rule", method = DELETE)
public ResponseEntity<String> deleteRule(@RequestParam String pattern) {
    AccessRule rule = ofy().load().type(AccessRule.class).id(pattern).get();
    if (rule != null) {
        ofy().delete().entity(rule).now();
        return new ResponseEntity<String>(pattern, HttpStatus.OK);
    } else {//  w  w  w. j a va2s . c om
        return new ResponseEntity<String>("Rule '" + pattern + "' not found", HttpStatus.NOT_FOUND);
    }
}

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

@Override
protected void doExecute() throws MojoExecutionException {

    //Assert.configurationNotNull(this.getUrl(), "url", SystemProperties.URL);

    final java.util.List<String> uris = new ArrayList<String>(1);

    if (this.getUrl() != null) {
        uris.add(this.getUrl());
    }/*from   www  . ja va  2 s  .c  o m*/

    final String appname = this.getAppname();
    final String command = this.getCommand();
    final Map<String, String> env = this.getEnv();
    final String framework = this.getFramework();
    final Integer instances = this.getInstances();
    final Integer memory = this.getMemory();
    final File path = this.getPath();
    final String runtime = this.getRuntime();
    final List<String> services = this.getServices();

    super.getLog().debug(String.format(
            "Pushing App - Appname: %s," + " Command: %s," + " Env: %s," + " Framework: %s," + " Instances: %s,"
                    + " Memory: %s," + " Path: %s," + " Runtime: %s," + " Services: %s," + " Uris: %s,",

            appname, command, env, framework, instances, memory, path, runtime, services, uris));

    super.getLog().debug("Create Application...");

    validateMemoryChoice(this.getClient(), memory);
    validateFrameworkChoice(this.getClient().getCloudInfo().getFrameworks(), framework);

    boolean found = true;

    try {
        this.getClient().getApplication(appname);
    } catch (CloudFoundryException e) {
        if (HttpStatus.NOT_FOUND.equals(e.getStatusCode())) {
            found = false;
        } else {
            throw new MojoExecutionException(String.format(
                    "Error while checking for existing application '%s'. Error message: '%s'. Description: '%s'",
                    appname, e.getMessage(), e.getDescription()), e);
        }

    }

    if (found) {
        throw new MojoExecutionException(String.format("The application '%s' is already deployed.", appname));
    }

    try {
        final Staging staging = new Staging(framework);

        staging.setCommand(command);
        staging.setRuntime(runtime);

        this.getClient().createApplication(appname, staging, memory, uris, services);
    } catch (CloudFoundryException e) {
        throw new MojoExecutionException(
                String.format("Error while creating application '%s'. Error message: '%s'. Description: '%s'",
                        this.getAppname(), e.getMessage(), e.getDescription()),
                e);
    }

    super.getLog().debug("Updating Application env...");

    try {
        this.getClient().updateApplicationEnv(appname, env);
    } catch (CloudFoundryException e) {
        throw new MojoExecutionException(String.format(
                "Error while updating application env '%s'. Error message: '%s'. Description: '%s'",
                this.getAppname(), e.getMessage(), e.getDescription()), e);
    }

    super.getLog().debug("Deploy Application...");

    validatePath(path);

    try {
        uploadApplication(this.getClient(), path, appname);
    } catch (CloudFoundryException e) {
        throw new MojoExecutionException(
                String.format("Error while creating application '%s'. Error message: '%s'. Description: '%s'",
                        this.getAppname(), e.getMessage(), e.getDescription()),
                e);
    }

    if (instances != null) {
        super.getLog().debug("Set the number of instances to " + instances);

        try {
            this.getClient().updateApplicationInstances(appname, instances);
        } catch (CloudFoundryException e) {
            throw new MojoExecutionException(String.format(
                    "Error while setting number of instances for application '%s'. Error message: '%s'. Description: '%s'",
                    this.getAppname(), e.getMessage(), e.getDescription()), e);
        }
    }

    if (!isNoStart()) {

        super.getLog().debug("Start Application..." + appname);

        try {
            this.getClient().startApplication(appname);
        } catch (CloudFoundryException e) {
            throw new MojoExecutionException(String.format(
                    "Error while creating application '%s'. Error message: '%s'. Description: '%s'",
                    this.getAppname(), e.getMessage(), e.getDescription()), e);
        }

    } else {
        super.getLog().debug("Not Starting Application.");
    }

    if (this.getUrl() != null) {
        super.getLog().info(String.format("'%s' was successfully deployed to: '%s'.", appname, this.getUrl()));
    } else {
        super.getLog().info(String.format("'%s' was successfully deployed.", appname, this.getUrl()));
    }

}