List of usage examples for org.springframework.http HttpStatus ACCEPTED
HttpStatus ACCEPTED
To view the source code for org.springframework.http HttpStatus ACCEPTED.
Click Source Link
From source file:github.priyatam.springrest.resource.PolicyResource.java
@RequestMapping(method = RequestMethod.GET, value = "/policy/future/{futureKey}") @ResponseBody// ww w . ja v a 2 s.c o m public ResponseEntity<Policy> poll(@PathVariable String futureKey) { logger.debug("Polling policy with future:" + futureKey); String location = resourceHelper.getPermLocation(futureKey); if (Strings.isNullOrEmpty(location)) { logger.warn("No Policy found for future. Is future expired?"); return new ResponseEntity<Policy>(null, new HttpHeaders(), HttpStatus.NOT_FOUND); } if (ResourceHelper.ProcessingStatus.PROCESSING.toString().equals(location)) { logger.debug("Policy is still processing."); return new ResponseEntity<Policy>(null, new HttpHeaders(), HttpStatus.ACCEPTED); } if (ResourceHelper.ProcessingStatus.ERROR.toString().equals(location)) { logger.debug("Policy was not created but resulted in an error."); throw new DataIntegrityViolationException("Unable to save Policy", new RuntimeException(resourceHelper.getError(futureKey))); } logger.debug("Received notification that policy creation is completed"); String policyNum = resourceHelper.parseKey(resourceHelper.getPermLocation(futureKey)); // Lookup Policy policy = persistenceHelper.loadPolicy(policyNum); if (policy == null) { logger.error("Can't read policy with key: " + policyNum); return new ResponseEntity<Policy>(null, new HttpHeaders(), HttpStatus.INTERNAL_SERVER_ERROR); } // Convert to Restful Resource with sparse objects responseBuilder.toPolicy(policy); return new ResponseEntity<Policy>(policy, HttpStatus.CREATED); }
From source file:com.netflix.genie.web.controllers.JobRestControllerUnitTests.java
/** * Makes sure we can successfully forward a job kill request. * * @throws IOException on error//from w w w . j a v a 2 s. com * @throws ServletException on error * @throws GenieException on error */ @Test public void canForwardJobKillRequest() throws IOException, ServletException, GenieException { this.jobsProperties.getForwarding().setEnabled(true); final String jobId = UUID.randomUUID().toString(); final String forwardedFrom = null; final HttpServletRequest request = Mockito.mock(HttpServletRequest.class); final HttpServletResponse response = Mockito.mock(HttpServletResponse.class); Mockito.when(request.getRequestURL()).thenReturn(new StringBuffer(UUID.randomUUID().toString())); Mockito.when(this.jobSearchService.getJobHost(jobId)).thenReturn(UUID.randomUUID().toString()); final StatusLine statusLine = Mockito.mock(StatusLine.class); Mockito.when(statusLine.getStatusCode()).thenReturn(HttpStatus.ACCEPTED.value()); final HttpResponse forwardResponse = Mockito.mock(HttpResponse.class); Mockito.when(forwardResponse.getStatusLine()).thenReturn(statusLine); Mockito.when(forwardResponse.getAllHeaders()).thenReturn(new Header[0]); Mockito.when(this.restTemplate.execute(Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyString())).thenReturn(null); this.controller.killJob(jobId, forwardedFrom, request, response); Mockito.verify(response, Mockito.never()).sendError(Mockito.anyInt(), Mockito.anyString()); Mockito.verify(this.jobSearchService, Mockito.times(1)).getJobHost(jobId); Mockito.verify(this.restTemplate, Mockito.times(1)).execute(Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.any(), Mockito.anyString()); }
From source file:org.fineract.module.stellar.controller.BridgeController.java
@RequestMapping(value = "/payments/", method = RequestMethod.POST, consumes = { "application/json" }, produces = { "application/json" }) public ResponseEntity<Void> sendStellarPayment(@RequestHeader(API_KEY_HEADER_LABEL) final String apiKey, @RequestHeader(TENANT_ID_HEADER_LABEL) final String mifosTenantId, @RequestHeader("X-Mifos-Entity") final String entity, @RequestHeader("X-Mifos-Action") final String action, @RequestBody final String payload) throws SecurityException { this.securityService.verifyApiKey(apiKey, mifosTenantId); if (entity.equalsIgnoreCase("JOURNALENTRY") && action.equalsIgnoreCase("CREATE")) { final JournalEntryData journalEntry = gson.fromJson(payload, JournalEntryData.class); final PaymentPersistency payment = journalEntryPaymentMapper.mapToPayment(mifosTenantId, journalEntry); if (!payment.isStellarPayment) { return new ResponseEntity<>(HttpStatus.NO_CONTENT); }//from www . j a v a 2 s.c o m this.bridgeService.sendPaymentToStellar(payment); } return new ResponseEntity<>(HttpStatus.ACCEPTED); }
From source file:com.acc.controller.CustomersController.java
/** * Client should pass old and new password in Body. Content-Type needs to be set to * application/x-www-form-urlencoded; charset=UTF-8 and sample body (urlencoded) is: old=1234&new=1111 * /*from w w w. j a v a2 s . c o m*/ * @param old * - old password * @param newPassword * - new password */ @Secured("ROLE_CUSTOMERGROUP") @RequestMapping(value = "/current/password", method = { RequestMethod.PUT, RequestMethod.POST }) @ResponseBody @ResponseStatus(value = HttpStatus.ACCEPTED, reason = "Password changed.") public void changePassword(@RequestParam final String old, @RequestParam(value = "new") final String newPassword) { customerFacade.changePassword(old, newPassword); }
From source file:com.sms.server.controller.AdminController.java
@RequestMapping(value = "/media/folder", method = RequestMethod.PUT, headers = { "Content-type=application/json" }) @ResponseBody/* w w w .jav a 2s . co m*/ public ResponseEntity<String> updateMediaFolder(@RequestBody MediaFolder update) { MediaFolder mediaFolder = settingsDao.getMediaFolderByID(update.getID()); if (mediaFolder == null) { return new ResponseEntity<>("Media folder does not exist.", HttpStatus.BAD_REQUEST); } if (update.getName() != null) { mediaFolder.setName(update.getName()); } if (update.getType() != null) { mediaFolder.setType(update.getType()); } if (update.getPath() != null) { // Check unique fields if (settingsDao.getMediaFolderByPath(update.getPath()) != null) { return new ResponseEntity<>("New media folder path already exists.", HttpStatus.NOT_ACCEPTABLE); } // Check path is readable if (!new File(update.getPath()).isDirectory()) { return new ResponseEntity<>("New media folder path does not exist or is not readable.", HttpStatus.FAILED_DEPENDENCY); } mediaFolder.setPath(update.getPath()); } if (update.getEnabled() != null) { mediaFolder.setEnabled(update.getEnabled()); } // Update database if (!settingsDao.updateMediaFolder(mediaFolder)) { LogService.getInstance().addLogEntry(Level.ERROR, CLASS_NAME, "Error updating media folder with ID '" + mediaFolder.getID() + "'.", null); return new ResponseEntity<>("Error updating media folder.", HttpStatus.INTERNAL_SERVER_ERROR); } LogService.getInstance().addLogEntry(Level.INFO, CLASS_NAME, "Media folder with ID '" + mediaFolder.getID() + "' updated successfully.", null); return new ResponseEntity<>("Media folder updated successfully.", HttpStatus.ACCEPTED); }
From source file:org.openbaton.nfvo.api.RestNetworkServiceDescriptor.java
@RequestMapping(value = "{idNsd}/vnfdependencies/{idVnf}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.ACCEPTED) public VNFDependency updateVNFDependency(@RequestBody @Valid VNFDependency vnfDependency, @PathVariable("idNsd") String idNsd, @PathVariable("idVnf") String idVnf, @RequestHeader(value = "project-id") String projectId) { networkServiceDescriptorManagement.saveVNFDependency(idNsd, vnfDependency, projectId); return vnfDependency; }
From source file:org.openbaton.nfvo.api.RestNetworkServiceDescriptor.java
/** * Edits the PhysicalNetworkFunctionDescriptor * * @param pDescriptor : The PhysicalNetworkFunctionDescriptor to be edited * @param id : The NSD id/* w ww . j a v a2s. com*/ * @return PhysicalNetworkFunctionDescriptor: The PhysicalNetworkFunctionDescriptor edited @ */ @RequestMapping(value = "{id}/pnfdescriptors/{idPnf}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.ACCEPTED) public PhysicalNetworkFunctionDescriptor updatePNFD( @RequestBody @Valid PhysicalNetworkFunctionDescriptor pDescriptor, @PathVariable("id") String id, @PathVariable("idPnf") String idPnf, @RequestHeader(value = "project-id") String projectId) { throw new UnsupportedOperationException("Not yet implemented"); }
From source file:org.openbaton.nfvo.api.RestNetworkServiceRecord.java
@RequestMapping(value = "{idNsr}/vnfrecords/{idVnf}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.ACCEPTED) public VirtualNetworkFunctionRecord updateVNF(@RequestBody @Valid VirtualNetworkFunctionRecord vnfRecord, @PathVariable("idNsr") String idNsr, @PathVariable("idVnf") String idVnf, @RequestHeader(value = "project-id") String projectId) throws NotFoundException { NetworkServiceRecord nsd = networkServiceRecordManagement.query(idNsr, projectId); nsd.getVnfr().add(vnfRecord);//from w w w. j av a 2 s .c o m networkServiceRecordManagement.update(nsd, idNsr, projectId); return vnfRecord; }
From source file:org.openbaton.nfvo.api.RestNetworkServiceDescriptor.java
@RequestMapping(value = "{id}/security/{id_s}", method = RequestMethod.PUT, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE) @ResponseStatus(HttpStatus.ACCEPTED) public Security updateSecurity(@RequestBody @Valid Security security, @PathVariable("id") String id, @PathVariable("id_s") String id_s, @RequestHeader(value = "project-id") String projectId) { throw new UnsupportedOperationException(); }