org.springframework.web.bind.annotation.RequestMethod#PATCH源码实例Demo

下面列出了org.springframework.web.bind.annotation.RequestMethod#PATCH 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: Moss   文件: InstancesProxyController.java
@RequestMapping(path = REQUEST_MAPPING_PATH, method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.POST, RequestMethod.PUT, RequestMethod.PATCH, RequestMethod.DELETE, RequestMethod.OPTIONS})
public Mono<Void> endpointProxy(@PathVariable("instanceId") String instanceId,
                                ServerHttpRequest request,
                                ServerHttpResponse response) {
    String endpointLocalPath = getEndpointLocalPath(request.getPath().pathWithinApplication().value());
    URI uri = UriComponentsBuilder.fromPath(endpointLocalPath)
                                  .query(request.getURI().getRawQuery())
                                  .build(true)
                                  .toUri();

    return super.forward(instanceId, uri, request.getMethod(), request.getHeaders(),
        () -> BodyInserters.fromDataBuffers(request.getBody())).flatMap(clientResponse -> {
        response.setStatusCode(clientResponse.statusCode());
        response.getHeaders().addAll(filterHeaders(clientResponse.headers().asHttpHeaders()));
        return response.writeAndFlushWith(clientResponse.body(BodyExtractors.toDataBuffers()).window(1));
    });
}
 
源代码2 项目: openapi-generator   文件: AnotherFakeApi.java
/**
 * PATCH /another-fake/dummy : To test special tags
 * To test special tags and operation ID starting with number
 *
 * @param body client model (required)
 * @return successful operation (status code 200)
 */
@ApiOperation(value = "To test special tags", nickname = "call123testSpecialTags", notes = "To test special tags and operation ID starting with number", response = Client.class, tags={ "$another-fake?", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = Client.class) })
@RequestMapping(value = "/another-fake/dummy",
    produces = { "application/json" }, 
    consumes = { "application/json" },
    method = RequestMethod.PATCH)
default ResponseEntity<Client> call123testSpecialTags(@ApiParam(value = "client model" ,required=true )  @Valid @RequestBody Client body) {
    getRequest().ifPresent(request -> {
        for (MediaType mediaType: MediaType.parseMediaTypes(request.getHeader("Accept"))) {
            if (mediaType.isCompatibleWith(MediaType.valueOf("application/json"))) {
                String exampleString = "{ \"client\" : \"client\" }";
                ApiUtil.setExampleResponse(request, "application/json", exampleString);
                break;
            }
        }
    });
    return new ResponseEntity<>(HttpStatus.NOT_IMPLEMENTED);

}
 
源代码3 项目: entando-core   文件: DataObjectModelController.java
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{dataModelId}", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_VALUE, consumes="application/json-patch+json")
public ResponseEntity<SimpleRestResponse<DataModelDto>> patchDataObjectModel(@PathVariable Long dataModelId,
                                                                             @RequestBody JsonNode jsonPatch,
                                                                             BindingResult bindingResult) throws JsonProcessingException {
    logger.debug("Patching data object model -> {}", dataModelId);

    this.getDataObjectModelValidator().validateDataObjectModelJsonPatch(jsonPatch, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }

    DataModelDto patchedDataModelDto = this.getDataObjectModelService().getPatchedDataObjectModel(dataModelId, jsonPatch);
    DataObjectModelRequest dataObjectModelRequest = this.dataModelDtoToRequestConverter.convert(patchedDataModelDto);

    return this.updateDataObjectModel(Long.toString(dataModelId), dataObjectModelRequest, bindingResult);

}
 
源代码4 项目: metron   文件: UpdateController.java
@ApiOperation(value = "Update a document with a patch")
@ApiResponse(message = "Returns the complete patched document.", code = 200)
@RequestMapping(value = "/patch", method = RequestMethod.PATCH)
ResponseEntity<Document> patch(
        final @ApiParam(name = "request", value = "Patch request", required = true)
              @RequestBody
        PatchRequest request
) throws RestException {
  try {
    return new ResponseEntity<>(service.patch(request), HttpStatus.OK);
  } catch (OriginalNotFoundException e) {
    return new ResponseEntity<>(HttpStatus.NOT_FOUND);
  }
}
 
源代码5 项目: entando-core   文件: RoleController.java
@RestAccessControl(permission = Permission.SUPERUSER)
@RequestMapping(value = "/{roleCode}", method = RequestMethod.PATCH, produces = MediaType.APPLICATION_JSON_VALUE, consumes="application/json-patch+json")
public ResponseEntity<SimpleRestResponse<RoleDto>> updateRole(@PathVariable String roleCode, @RequestBody JsonNode patchRequest, BindingResult bindingResult) {
    logger.debug("update role {} with jsonpatch-request {}", roleCode, patchRequest);

    this.getRoleValidator().validateJsonPatch(patchRequest, bindingResult);
    if (bindingResult.hasErrors()) {
        throw new ValidationGenericException(bindingResult);
    }

    RoleDto patchedRoleDto = this.getRoleService().getPatchedRole(roleCode, patchRequest);
    RoleRequest patchedRoleRequest = this.roleDtotoRoleRequestConverter.convert(patchedRoleDto);

    return this.updateRole(roleCode, patchedRoleRequest, bindingResult);
}
 
源代码6 项目: openapi-generator   文件: FakeClassnameTestApi.java
/**
 * PATCH /fake_classname_test : To test class name in snake case
 * To test class name in snake case
 *
 * @param body client model (required)
 * @return successful operation (status code 200)
 */
@ApiOperation(value = "To test class name in snake case", nickname = "testClassname", notes = "To test class name in snake case", response = Client.class, authorizations = {
    @Authorization(value = "api_key_query")
}, tags={ "fake_classname_tags 123#$%^", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = Client.class) })
@RequestMapping(value = "/fake_classname_test",
    produces = { "application/json" }, 
    consumes = { "application/json" },
    method = RequestMethod.PATCH)
default ResponseEntity<Client> testClassname(@ApiParam(value = "client model" ,required=true )  @Valid @RequestBody Client body) {
    return getDelegate().testClassname(body);
}
 
源代码7 项目: openapi-generator   文件: FakeApi.java
/**
 * PATCH /fake : To test \&quot;client\&quot; model
 * To test \&quot;client\&quot; model
 *
 * @param body client model (required)
 * @return successful operation (status code 200)
 */
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = Client.class) })
@RequestMapping(value = "/fake",
    produces = { "application/json" }, 
    consumes = { "application/json" },
    method = RequestMethod.PATCH)
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true )  @Valid @RequestBody Client body);
 
源代码8 项目: restdocs-raml   文件: NotesController.java
@RequestMapping(value = "/{id}", method = RequestMethod.PATCH)
@ResponseStatus(HttpStatus.NO_CONTENT)
void updateNote(@PathVariable("id") long id, @RequestBody NotePatchInput noteInput) {
	Note note = findNoteById(id);
	if (noteInput.getTagUris() != null) {
		note.setTags(getTags(noteInput.getTagUris()));
	}
	if (noteInput.getTitle() != null) {
		note.setTitle(noteInput.getTitle());
	}
	if (noteInput.getBody() != null) {
		note.setBody(noteInput.getBody());
	}
	this.noteRepository.save(note);
}
 
源代码9 项目: JiwhizBlogWeb   文件: AuthorBlogRestController.java
@RequestMapping(method = RequestMethod.PATCH, value = ApiUrls.URL_AUTHOR_BLOGS_BLOG)
public HttpEntity<AuthorBlogResource> patchBlogPost(
        @PathVariable("blogId") String blogId, 
        @RequestBody Map<String, String> updateMap) throws ResourceNotFoundException {
    BlogPost blogPost = getBlogByIdAndCheckAuthor(blogId);
    String content = updateMap.get("content");
    if (content != null) {
        blogPost.setContent(content);
    }
    String title = updateMap.get("title");
    if (title != null) {
        blogPost.setTitle(title);
    }
    String tagString = updateMap.get("tagString");
    if (tagString != null) {
        blogPost.parseAndSetTags(tagString);
    }
    String published = updateMap.get("published");
    if (published != null) {
        blogPost.setPublished(published.equals("true"));
    }
    
    blogPost = blogPostRepository.save(blogPost);

    AuthorBlogResource resource = authorBlogResourceAssembler.toResource(blogPost);
    return new ResponseEntity<>(resource, HttpStatus.OK);

}
 
源代码10 项目: openapi-generator   文件: FakeApi.java
/**
 * PATCH /fake : To test \&quot;client\&quot; model
 * To test \&quot;client\&quot; model
 *
 * @param body client model (required)
 * @return successful operation (status code 200)
 */
@ApiOperation(value = "To test \"client\" model", nickname = "testClientModel", notes = "To test \"client\" model", response = Client.class, tags={ "fake", })
@ApiResponses(value = { 
    @ApiResponse(code = 200, message = "successful operation", response = Client.class) })
@RequestMapping(value = "/fake",
    produces = { "application/json" }, 
    consumes = { "application/json" },
    method = RequestMethod.PATCH)
ResponseEntity<Client> testClientModel(@ApiParam(value = "client model" ,required=true )  @Valid @RequestBody Client body);
 
源代码11 项目: dhis2-core   文件: ChartFacadeController.java
@RequestMapping( value = "/{uid}", method = RequestMethod.PATCH )
@ResponseStatus( value = HttpStatus.NO_CONTENT )
public void partialUpdateObject(
    @PathVariable( "uid" ) String pvUid, @RequestParam Map<String, String> rpParameters,
    HttpServletRequest request, HttpServletResponse response ) throws Exception
{
    WebOptions options = new WebOptions( rpParameters );
    List<Visualization> entities = getEntity( pvUid, options );

    if ( entities.isEmpty() )
    {
        throw new WebMessageException( WebMessageUtils.notFound( Chart.class, pvUid ) );
    }

    Visualization persistedObject = entities.get( 0 );

    User user = currentUserService.getCurrentUser();

    if ( !aclService.canUpdate( user, persistedObject ) )
    {
        throw new UpdateAccessDeniedException( "You don't have the proper permissions to update this object." );
    }

    Patch patch = null;

    if ( isJson( request ) )
    {
        patch = patchService.diff(
            new PatchParams( jsonMapper.readTree( request.getInputStream() ) )
        );
    }
    else if ( isXml( request ) )
    {
        patch = patchService.diff(
            new PatchParams( xmlMapper.readTree( request.getInputStream() ) )
        );
    }

    patchService.apply( patch, persistedObject );
    manager.update( persistedObject );
}
 
源代码12 项目: SO   文件: ContextModelController.java
/**
 * response for request "/cm, HTTP-method:PATCH(update)".<BR/>
 * @param cm ContextModelForMQ
 * @return updated ContextModelForMQ id
 */
@RequestMapping(method=RequestMethod.PATCH)
public String updateContextModel(ContextModelForDB cm) {
    //implements...
    return null;
}
 
@RequestMapping(value = "/request-mapping-patch", method = RequestMethod.PATCH)
public void requestMappingPatch() {
}
 
@RequestMapping(value = "/something", method = RequestMethod.PATCH)
@ResponseBody
public String handlePartialUpdate(@RequestBody String content) throws IOException {
	return content;
}
 
源代码15 项目: tutorials   文件: HeavyResourceController.java
@RequestMapping(value = "/heavyresource2/{id}", method = RequestMethod.PATCH, consumes = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<?> partialUpdateGeneric(@RequestBody Map<String, Object> updates,
                                              @PathVariable("id") String id) {
    heavyResourceRepository.save(updates, id);
    return ResponseEntity.ok("resource updated");
}
 
源代码16 项目: SO   文件: OrchestrationServiceController.java
/**
 * response for request "/os, HTTP-method:PATCH(update)".<BR/>
 * @param os OrchestrationServiceForDB
 * @return updated OrchestrationServiceForDB id
 */
@RequestMapping(method=RequestMethod.PATCH)
public String updateOrchestrationService(OrchestrationServiceForDB os) {
    //implements...
    return null;
}
 
源代码17 项目: SO   文件: CompositeVirtualObjectController.java
/**
 * response for request "/cvo, HTTP-method:PATCH(update)".<BR/>
 * @param cvo CompositeVirtualObjectForDB
 * @return updated profile id
 */
@RequestMapping(method=RequestMethod.PATCH)
public String updateCompositeVirtualObject(CompositeVirtualObjectForDB cvo) {
    //implements...
    return null;
}
 
源代码18 项目: SO   文件: FixedDeviceController.java
/**
 * response for request "/fd, HTTP-method:PATCH(update)".<BR/>
 * @param fd FixedDeviceForDB
 * @return updated FixedDeviceForDB id
 */
@RequestMapping(method=RequestMethod.PATCH)
public String updateFixedDevice(FixedDeviceForDB fd) {
    //implements...
    return null;
}
 
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/responseEntity", method = RequestMethod.PATCH)
public ResponseEntity<Date> responseEntityPATCH(InvocationContext c1, @RequestAttribute("date") Date date) {
  return responseEntity(c1, date);
}
 
/**
 * Mapping to several HTTP request methods is not OK if it's a mix of unprotected and protected HTTP request methods.
 */
@RequestMapping(value = "/request-mapping-all-unprotected-methods-and-one-protected-method",
        method = {RequestMethod.GET, RequestMethod.HEAD, RequestMethod.TRACE, RequestMethod.OPTIONS, RequestMethod.PATCH})
public void requestMappingAllUnprotectedMethodsAndOneProtectedMethod() {
}