Java Code Examples for org.springframework.http.HttpStatus#ACCEPTED

The following examples show how to use org.springframework.http.HttpStatus#ACCEPTED . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RestNetworkServiceRecord.java    From NFVO with Apache License 2.0 6 votes vote down vote up
@ApiOperation(
    value = "Updates a VNF Dependency in an NSR",
    notes = "Updates a VNF Dependency based on the id of the VNF it concerns")
@RequestMapping(
    value = "{id}/vnfdependencies/{id_vnfd}",
    method = RequestMethod.PUT,
    consumes = MediaType.APPLICATION_JSON_VALUE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public VNFRecordDependency updateVNFD(
    @RequestBody @Valid VNFRecordDependency vnfDependency,
    @PathVariable("id") String id,
    @PathVariable("id_vnfd") String id_vnfd,
    @RequestHeader(value = "project-id") String projectId)
    throws NotFoundException {
  NetworkServiceRecord nsr = networkServiceRecordManagement.query(id, projectId);
  nsr.getVnf_dependency().add(vnfDependency);
  networkServiceRecordManagement.update(nsr, id, projectId);
  return vnfDependency;
}
 
Example 2
Source File: JobRestController.java    From genie with Apache License 2.0 6 votes vote down vote up
/**
 * Submit a new job with attachments.
 *
 * @param jobRequest         The job request information
 * @param attachments        The attachments for the job
 * @param clientHost         client host sending the request
 * @param userAgent          The user agent string
 * @param httpServletRequest The http servlet request
 * @return The submitted job
 * @throws GenieException        For any error
 * @throws GenieCheckedException For V4 Agent Execution errors
 */
@PostMapping(consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public ResponseEntity<Void> submitJob(
    @Valid @RequestPart("request") final JobRequest jobRequest,
    @RequestPart("attachment") final MultipartFile[] attachments,
    @RequestHeader(value = FORWARDED_FOR_HEADER, required = false) @Nullable final String clientHost,
    @RequestHeader(value = HttpHeaders.USER_AGENT, required = false) @Nullable final String userAgent,
    final HttpServletRequest httpServletRequest
) throws GenieException, GenieCheckedException {
    log.info(
        "[submitJob] Called multipart method to submit job: {}, with {} attachments",
        jobRequest,
        attachments.length
    );
    this.submitJobWithAttachmentsRate.increment();
    return this.handleSubmitJob(jobRequest, attachments, clientHost, userAgent, httpServletRequest);
}
 
Example 3
Source File: ForceFocusCreditCalculator.java    From biliob_backend with MIT License 6 votes vote down vote up
@Override
ResponseEntity execute(Long id, ObjectId objectId) {

    BasicDBObject fieldsObject = new BasicDBObject();
    BasicDBObject dbObject = new BasicDBObject();
    dbObject.put("mid", id);
    fieldsObject.put("forceFocus", true);
    Author author =
            mongoTemplate.findOne(
                    new BasicQuery(dbObject.toJson(), fieldsObject.toJson()), Author.class);
    if (author == null) {
        mongoTemplate.remove(Query.query(Criteria.where("_id").is(objectId)), "user_record");
        return new ResponseEntity<>(new Result<>(ResultEnum.AUTHOR_NOT_FOUND), HttpStatus.ACCEPTED);
    } else if (author.getForceFocus() != null && author.getForceFocus()) {
        mongoTemplate.remove(Query.query(Criteria.where("_id").is(objectId)), "user_record");
        return new ResponseEntity<>(new Result<>(ResultEnum.ALREADY_FORCE_FOCUS), HttpStatus.ACCEPTED);
    }

    mongoTemplate.updateFirst(query(where("mid").is(id)), update("forceFocus", true), Author.class);
    super.setExecuted(objectId);
    upsertAuthorFreq(id, SECOND_OF_MINUTES * 60 * 12);
    return null;
}
 
Example 4
Source File: NotifyController.java    From botbuilder-java with MIT License 5 votes vote down vote up
@GetMapping("/api/notify")
public ResponseEntity<Object> proactiveMessage() {
    for (ConversationReference reference : conversationReferences.values()) {
        adapter.continueConversation(
            appId, reference, turnContext -> turnContext.sendActivity("proactive hello").thenApply(resourceResponse -> null)
        );
    }

    // Let the caller know proactive messages have been sent
    return new ResponseEntity<>(
        "<html><body><h1>Proactive messages have been sent.</h1></body></html>",
        HttpStatus.ACCEPTED
    );
}
 
Example 5
Source File: RestNetworkServiceDescriptor.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@ApiOperation(value = "", notes = "", hidden = true)
@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();
}
 
Example 6
Source File: BookingService.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
public HttpStatus deleteBooking(int bookingid, String token) throws SQLException {
    if(authRequests.postCheckAuth(token)){
        if(bookingDB.delete(bookingid)){
            return HttpStatus.ACCEPTED;
        } else {
            return HttpStatus.NOT_FOUND;
        }
    } else {
        return HttpStatus.FORBIDDEN;
    }
}
 
Example 7
Source File: CodeFirstSpringmvcBase.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public ResponseEntity<Date> responseEntity(InvocationContext c1, Date date) {
  HttpHeaders headers = new HttpHeaders();
  headers.add("h1", "h1v " + c1.getContext().toString());

  InvocationContext c2 = ContextUtils.getInvocationContext();
  headers.add("h2", "h2v " + c2.getContext().toString());

  return new ResponseEntity<Date>(date, headers, HttpStatus.ACCEPTED);
}
 
Example 8
Source File: RestNetworkServiceRecord.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
    value = "Upgrade a Virtual Network Function Record in a NSR",
    notes = "Specify the ids of the parent NSR and of the VNFR which will be upgraded")
@RequestMapping(
    value = "{idNsr}/vnfrecords/{idVnfr}/upgrade",
    method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void upgradeVnfr(
    @PathVariable("idNsr") String idNsr,
    @PathVariable("idVnfr") String idVnfr,
    @RequestHeader(value = "project-id") String projectId,
    @RequestBody @Valid JsonObject body)
    throws NotFoundException, BadFormatException, BadRequestException, ExecutionException,
        InterruptedException, IOException, VimException, PluginException, VimDriverException {
  NetworkServiceRecord nsr = networkServiceRecordManagement.query(idNsr, projectId);
  VirtualNetworkFunctionRecord vnfRecord =
      networkServiceRecordManagement.getVirtualNetworkFunctionRecord(idNsr, idVnfr, projectId);
  nsr.getVnfr().add(vnfRecord);

  String upgradeRequestEntityKey = "vnfdId";

  if (!body.has(upgradeRequestEntityKey)
      || !body.getAsJsonPrimitive(upgradeRequestEntityKey).isString())
    throw new BadRequestException(
        "The passed JSON is not correct. It should include a string field named: "
            + upgradeRequestEntityKey);

  // String vnfPackageId = body.getAsJsonPrimitive("vnfPackageId").getAsString();
  String upgradeVnfdId = body.getAsJsonPrimitive(upgradeRequestEntityKey).getAsString();

  log.info("Executing UPGRADE for VNFR: " + vnfRecord.getName());

  networkServiceRecordManagement.upgradeVnfr(idNsr, idVnfr, projectId, upgradeVnfdId);
}
 
Example 9
Source File: ControllerExceptionTest.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test get message_1.
 *
 * @throws Exception the exception
 */
@Test
public void testGetMessage_1()
	throws Exception {
	ControllerException fixture = new ControllerException(HttpStatus.ACCEPTED, "1", "message", new Throwable());

	String result = fixture.getMessage();

	assertEquals("message", result);
}
 
Example 10
Source File: RoomService.java    From restful-booker-platform with GNU General Public License v3.0 5 votes vote down vote up
public RoomResult updateRoom(int roomId, Room roomToUpdate, String token) throws SQLException {
    if(authRequests.postCheckAuth(token)){
        Room updatedRoom = roomDB.update(roomId, roomToUpdate);

        if(updatedRoom != null){
            return new RoomResult(HttpStatus.ACCEPTED, updatedRoom);
        } else {
            return new RoomResult(HttpStatus.NOT_FOUND);
        }
    } else {
        return new RoomResult(HttpStatus.FORBIDDEN);
    }
}
 
Example 11
Source File: RestUsers.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
    value = "Changing the current User's password",
    notes = "The current user can change his password by providing a new one")
@RequestMapping(
    value = "changepwd",
    method = RequestMethod.PUT,
    consumes = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public void changePassword(@RequestBody /*@Valid*/ JsonObject newPwd)
    throws UnauthorizedUserException, PasswordWeakException {
  log.debug("Changing password");
  JsonObject jsonObject = gson.fromJson(newPwd, JsonObject.class);
  userManagement.changePassword(
      jsonObject.get("old_pwd").getAsString(), jsonObject.get("new_pwd").getAsString());
}
 
Example 12
Source File: FluxRestApplicationTests.java    From spring-cloud-function with Apache License 2.0 5 votes vote down vote up
@PostMapping("/updates")
@ResponseStatus(HttpStatus.ACCEPTED)
public Flux<?> updates(@RequestBody List<String> list) {
	Flux<String> flux = Flux.fromIterable(list).cache();
	flux.subscribe(value -> this.list.add(value));
	return flux;
}
 
Example 13
Source File: ProfessorshipController.java    From fenixedu-academic with GNU Lesser General Public License v3.0 5 votes vote down vote up
@RequestMapping(method = DELETE, value = "{professorship}")
@ResponseBody
public ResponseEntity<String> deleteProfessorship(@PathVariable Professorship professorship) {
    try {
        professorshipService.deleteProfessorship(professorship);
        return new ResponseEntity<String>(HttpStatus.ACCEPTED);
    } catch (Exception e) {
        return new ResponseEntity<String>(e.getLocalizedMessage(), HttpStatus.PRECONDITION_FAILED);
    }
}
 
Example 14
Source File: VnfmReceiverRest.java    From NFVO with Apache License 2.0 5 votes vote down vote up
@RequestMapping(
    value = "vnfm-core-allocate",
    method = RequestMethod.POST,
    consumes = MediaType.APPLICATION_JSON_VALUE,
    produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.ACCEPTED)
public NFVMessage allocate(@RequestBody VnfmOrAllocateResourcesMessage message)
    throws ExecutionException, InterruptedException {

  return vnfStateHandler.executeAction(message).get();
}
 
Example 15
Source File: AbstractCreditCalculator.java    From biliob_backend with MIT License 5 votes vote down vote up
private ResponseEntity<Result> checkCredit(User user, Double value) {
    if (user == null) {
        return new ResponseEntity<>(
                new Result(ResultEnum.HAS_NOT_LOGGED_IN), HttpStatus.UNAUTHORIZED);
    } else if (value < 0 && user.getCredit() < (-value)) {
        AbstractCreditCalculator.logger.info("用户:{},积分不足,当前积分:{}", user.getName(), user.getCredit());
        return new ResponseEntity<>(new Result(ResultEnum.CREDIT_NOT_ENOUGH), HttpStatus.ACCEPTED);
    } else {
        return null;
    }
}
 
Example 16
Source File: ControllerExceptionTest.java    From ankush with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Test get status_1.
 *
 * @throws Exception the exception
 */
@Test
public void testGetStatus_1()
	throws Exception {
	ControllerException fixture = new ControllerException(HttpStatus.ACCEPTED, "1", "message", new Throwable());

	HttpStatus result = fixture.getStatus();

	assertNotNull(result);
	assertEquals(202, result.value());
	assertEquals("202", result.toString());
	assertEquals("Accepted", result.getReasonPhrase());
	assertEquals("ACCEPTED", result.name());
	assertEquals(6, result.ordinal());
}
 
Example 17
Source File: MeController.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@RequestMapping( value = "/changePassword", method = RequestMethod.PUT, consumes = { "text/*", "application/*" } )
@ResponseStatus( HttpStatus.ACCEPTED )
public void changePassword( @RequestBody Map<String, String> body, HttpServletResponse response )
    throws WebMessageException, NotAuthenticatedException, IOException
{
    User currentUser = currentUserService.getCurrentUser();

    if ( currentUser == null )
    {
        throw new NotAuthenticatedException();
    }

    String oldPassword = body.get( "oldPassword" );
    String newPassword = body.get( "newPassword" );

    if ( StringUtils.isEmpty( oldPassword ) || StringUtils.isEmpty( newPassword ) )
    {
        throw new WebMessageException( WebMessageUtils.conflict( "OldPassword and newPassword must be provided" ) );
    }

    boolean valid = passwordManager.matches( oldPassword, currentUser.getUserCredentials().getPassword() );

    if ( !valid )
    {
        throw new WebMessageException( WebMessageUtils.conflict( "OldPassword is incorrect" ) );
    }

    updatePassword( currentUser, newPassword );
    manager.update( currentUser );

    currentUserService.expireUserSessions();
}
 
Example 18
Source File: CartsController.java    From carts with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(HttpStatus.ACCEPTED)
@RequestMapping(value = "/{customerId}", method = RequestMethod.DELETE)
public void delete(@PathVariable String customerId) {
    new CartResource(cartDAO, customerId).destroy().run();
}
 
Example 19
Source File: RequestMappingHandlerAdapterIntegrationTests.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@ResponseStatus(code = HttpStatus.ACCEPTED)
@ResponseBody
public String handleAndValidateRequestBody(@Valid TestBean modelAttr, Errors errors) throws Exception {
	return "Error count [" + errors.getErrorCount() + "]";
}
 
Example 20
Source File: ServiceBrokerExceptionHandler.java    From spring-cloud-open-service-broker with Apache License 2.0 2 votes vote down vote up
/**
 * Handle a {@link ServiceBrokerUpdateOperationInProgressException}
 *
 * @param ex the exception
 * @return an operation in progress message
 */
@ExceptionHandler(ServiceBrokerUpdateOperationInProgressException.class)
@ResponseStatus(HttpStatus.ACCEPTED)
public OperationInProgressMessage handleException(ServiceBrokerUpdateOperationInProgressException ex) {
	return getOperationInProgressMessage(ex);
}