List of usage examples for javax.servlet.http HttpServletResponse SC_NOT_FOUND
int SC_NOT_FOUND
To view the source code for javax.servlet.http HttpServletResponse SC_NOT_FOUND.
Click Source Link
From source file:org.magnum.mobilecloud.video.VideoSvcCtrl.java
@PreAuthorize("hasRole(USER)") @RequestMapping(method = RequestMethod.POST, value = VideoSvcApi.VIDEO_SVC_PATH + "/{id}/like") public @ResponseBody void likeVideo(@PathVariable("id") long id, Principal principal, HttpServletResponse response) {//from ww w. j a v a2 s. c o m Video v = videoRepo.findOne(id); if (v != null) { HashSet<String> likers = v.getLikers(); if (likers.contains(principal.getName())) response.setStatus(HttpServletResponse.SC_BAD_REQUEST); else { likers.add(principal.getName()); videoRepo.save(v); response.setStatus(HttpServletResponse.SC_OK); } } else response.setStatus(HttpServletResponse.SC_NOT_FOUND); }
From source file:com.lyncode.oai.proxy.ProxyDataProvider.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { ProxyIdentify identify = new ProxyIdentify(req); ProxySetRepository listsets = new ProxySetRepository(); ProxyItemRepository itemRepository = new ProxyItemRepository(); try {//from ww w . ja va2 s . com XOAIManager.initialize("config" + File.separator + "xoai"); log.debug("Creating XOAI Data Provider Instance"); log.debug("Requested context: " + req.getPathInfo().replace("/", "")); OAIDataProvider dataprovider = new OAIDataProvider(req.getPathInfo().replace("/", ""), identify, listsets, itemRepository); log.debug("Reading parameters from request"); OutputStream out = resp.getOutputStream(); OAIRequestParameters parameters = new OAIRequestParameters(); parameters.setFrom(req.getParameter("from")); parameters.setUntil(req.getParameter("until")); parameters.setSet(req.getParameter("set")); parameters.setVerb(req.getParameter("verb")); parameters.setMetadataPrefix(req.getParameter("metadataPrefix")); parameters.setIdentifier(req.getParameter("identifier")); parameters.setResumptionToken(req.getParameter("resumptionToken")); resp.setContentType("application/xml"); dataprovider.handle(parameters, out); out.flush(); out.close(); } catch (InvalidContextException e) { resp.sendError(HttpServletResponse.SC_NOT_FOUND, "Requested OAI context \"" + req.getPathInfo().replace("/", "") + "\" does not exist"); } catch (OAIException e) { log.error(e.getMessage(), e); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occurred, please, contact the develop team development@lyncode.com"); } catch (com.lyncode.xoai.dataprovider.exceptions.ConfigurationException e) { log.error(e.getMessage(), e); resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "An error occurred, please, contact the develop team development@lyncode.com"); } }
From source file:info.magnolia.cms.filters.AggregatorFilter.java
@Override public void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException { boolean success; try {/*from w w w . j a v a2s. c o m*/ success = collect(); } catch (AccessDeniedException e) { // don't throw further, simply return error and break filter chain log.debug(e.getMessage(), e); if (!response.isCommitted()) { response.setStatus(HttpServletResponse.SC_FORBIDDEN); } // stop the chain return; } catch (RepositoryException e) { log.error(e.getMessage(), e); throw new ServletException(e.getMessage(), e); } if (!success) { log.debug("Resource not found, redirecting request for [{}] to 404 URI", request.getRequestURI()); if (!response.isCommitted()) { response.sendError(HttpServletResponse.SC_NOT_FOUND); } else { log.info("Unable to redirect to 404 page, response is already committed. URI was {}", request.getRequestURI()); } // stop the chain return; } chain.doFilter(request, response); }
From source file:io.wcm.caravan.io.http.impl.ResilientHttpImplTest.java
@Before public void setUp() { ArchaiusConfig.initialize();/*from w ww .j a v a2 s . co m*/ wireMockHost = "localhost:" + wireMock.port(); serviceConfig = context.registerInjectActivateService(new ResilientHttpServiceConfig(), getServiceConfigProperties(wireMockHost)); httpClientFactory = context.registerInjectActivateService(new HttpClientFactoryImpl()); underTest = context.registerInjectActivateService(new ResilientHttpImpl()); // setup wiremock wireMock.stubFor(get(urlEqualTo(HTTP_200_URI)).willReturn(aResponse() .withHeader("Content-Type", "text/plain;charset=" + CharEncoding.UTF_8).withBody(DUMMY_CONTENT))); wireMock.stubFor( get(urlEqualTo(HTTP_404_URI)).willReturn(aResponse().withStatus(HttpServletResponse.SC_NOT_FOUND))); wireMock.stubFor(get(urlEqualTo(HTTP_500_URI)) .willReturn(aResponse().withStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR))); wireMock.stubFor(get(urlEqualTo(CONNECT_TIMEOUT_URI)).willReturn(aResponse() .withHeader("Content-Type", "text/plain;charset=" + CharEncoding.UTF_8).withBody(DUMMY_CONTENT))); wireMock.stubFor(get(urlEqualTo(RESPONSE_TIMEOUT_URI)) .willReturn(aResponse().withHeader("Content-Type", "text/plain;charset=" + CharEncoding.UTF_8) .withBody(DUMMY_CONTENT).withFixedDelay(1000))); }
From source file:org.eclipse.virgo.apps.repository.web.RepositoryController.java
@RequestMapping(method = RequestMethod.GET, value = "/*/*/*/*") void getArtifact(HttpServletRequest request, HttpServletResponse response) throws IOException { String requestUri = request.getRequestURI(); String[] uriComponents = requestUri.split("/"); String repository = uriComponents[uriComponents.length - 4]; String type = uriComponents[uriComponents.length - 3]; String name = uriComponents[uriComponents.length - 2]; String version = uriComponents[uriComponents.length - 1]; InputStream artefact = this.repositoryManager.getArtifact(repository, type, name, version); if (artefact != null) { response.setContentType(ARTEFACT_CONTENT_TYPE); FileCopyUtils.copy(artefact, response.getOutputStream()); } else {/*from ww w . j a v a 2 s .co m*/ response.setStatus(HttpServletResponse.SC_NOT_FOUND); } }
From source file:io.wcm.caravan.io.http.impl.ribbon.RibbonHttpClientTest.java
@Before public void setUp() { ArchaiusConfig.initialize();//from ww w. java2s . com context.registerInjectActivateService(new SimpleLoadBalancerFactory()); context.registerInjectActivateService(new LoadBalancerCommandFactory()); context.registerInjectActivateService(new HttpClientFactoryImpl()); context.registerInjectActivateService(new ApacheHttpClient()); client = context.registerInjectActivateService(new RibbonHttpClient()); defectServer1Host = "localhost:" + defectServer1.port(); defectServer2Host = "localhost:" + defectServer2.port(); workingServerHost = "localhost:" + workingServer.port(); workingServer.stubFor(get(urlEqualTo(HTTP_200_URI)).willReturn(aResponse() .withHeader("Content-Type", "text/plain;charset=" + CharEncoding.UTF_8).withBody("success"))); workingServer.stubFor( get(urlEqualTo(HTTP_404_URI)).willReturn(aResponse().withStatus(HttpServletResponse.SC_NOT_FOUND))); defectServer1.stubFor(get(urlMatching(".*")) .willReturn(aResponse().withStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR))); defectServer2.stubFor(get(urlMatching(".*")) .willReturn(aResponse().withStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR))); }
From source file:com.jaspersoft.jasperserver.rest.services.RESTRole.java
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServiceException { WSRoleSearchCriteria criteria = restUtils.populateServiceObject(req.getPathInfo(), req.getParameterMap(), WSRoleSearchCriteria.class); WSRole[] roles = null;//from w w w .j a va 2 s .com try { // get the resources.... roles = userAndRoleManagementService.findRoles(criteria); } catch (AxisFault axisFault) { throw new ServiceException(HttpServletResponse.SC_NOT_FOUND, "could not locate roles in uri: " + criteria.getRoleName() + axisFault.getLocalizedMessage()); } if (log.isDebugEnabled()) { log.debug(roles.length + " roles were found"); } String marshal = generateSummeryReport(roles); if (log.isDebugEnabled()) { log.debug("Marshaling OK"); } restUtils.setStatusAndBody(HttpServletResponse.SC_OK, resp, marshal); }
From source file:de.mpg.escidoc.services.pidcache.web.MainServlet.java
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { logger.info("PID cache GET request"); try {/*from w w w . j a v a 2 s . c o m*/ if (!authenticate(req, resp)) { logger.warn("Unauthorized request from " + req.getRemoteHost()); return; } PidCacheService pidCacheService = new PidCacheService(); if (GwdgPidService.GWDG_PIDSERVICE_VIEW.equals(req.getPathInfo()) || GwdgPidService.GWDG_PIDSERVICE_VIEW.concat("/").equals(req.getPathInfo())) { if (req.getParameter("pid") == null) { resp.sendError(HttpServletResponse.SC_NO_CONTENT, "PID parameter failed."); } resp.getWriter().append(pidCacheService.retrieve(req.getParameter("pid"))); } else if ("/cache/size".equals(req.getPathInfo())) { resp.getWriter().append("There are " + pidCacheService.getCacheSize() + " PID stored in cache"); } else if ("/queue/size".equals(req.getPathInfo())) { resp.getWriter().append("There are " + pidCacheService.getQueueSize() + " PID actually in queue"); } else { resp.sendError(HttpServletResponse.SC_NOT_FOUND, req.getPathInfo()); } } catch (Exception e) { throw new ServletException("Error processing request", e); } }
From source file:org.piraso.server.spring.web.PirasoServletTest.java
@Test public void testStopNullService() throws Exception { request.addParameter("service", "stop"); request.addParameter("preferences", mapper.writeValueAsString(new Preferences())); doReturn(null).when(registry).getLogger(Matchers.<User>any()); servlet.handleRequest(request, response); assertEquals(HttpServletResponse.SC_NOT_FOUND, response.getStatus()); }
From source file:com.natpryce.piazza.BuildMonitorController.java
private ModelAndView showProject(String projectId, boolean showFeatureBranchBuildsOnly, HttpServletResponse response) throws IOException { SProject project = projectManager.findProjectByExternalId(projectId); if (project == null) { response.sendError(HttpServletResponse.SC_NOT_FOUND, "no project with id " + projectId); return null; }/*from w ww . jav a 2 s . c o m*/ PiazzaProjectSettings projectSettings = (PiazzaProjectSettings) projectSettingsManager .getSettings(projectId, PiazzaProjectSettings.PROJECT_SETTINGS_NAME); SUser associatedUser = getAssociatedUser(); String view = showFeatureBranchBuildsOnly ? "piazza-project-monitor-feature-branches.jsp" : "piazza-project-monitor.jsp"; return modelWithView(view).addObject("project", new ProjectMonitorViewState(project, piazza.userGroup(), piazza.getConfiguration(), projectSettings, associatedUser)); }