@Override public void process(Object annotation, OperationGenerator operationGenerator) { PatchMapping mappingAnnotation = (PatchMapping) annotation; Operation operation = operationGenerator.getOperation(); // path/value是等同的 this.processPath(mappingAnnotation.path(), operationGenerator); this.processPath(mappingAnnotation.value(), operationGenerator); this.processMethod(RequestMethod.PATCH, operationGenerator); this.processConsumes(mappingAnnotation.consumes(), operation); this.processProduces(mappingAnnotation.produces(), operation); if (StringUtils.isEmpty(operationGenerator.getHttpMethod()) && StringUtils.isEmpty(operationGenerator.getSwaggerGenerator().getHttpMethod())) { throw new Error("HttpMethod must not both be empty in class and method"); } }
@ApiOperation(value = "Start an existing workspace. Stop all other workspaces (only one workspace can be running at a time)") @PatchMapping("/workspace/{name}") public Workspace startExisting(@PathVariable String name, @RequestParam String masterUrl, @RequestParam String namespace, @ApiParam(value = "Keycloak token", required = true) @RequestHeader("Authorization") String keycloakToken) throws IOException, URISyntaxException, RouteNotFoundException, StackNotFoundException, GitHubOAthTokenException, ProjectCreationException, KeycloakException, WorkspaceNotFound { KeycloakTokenValidator.validate(keycloakToken); String openShiftToken = keycloakClient.getOpenShiftToken(keycloakToken); String gitHubToken = keycloakClient.getGitHubToken(keycloakToken); String cheServerURL = openShiftClientWrapper.getCheServerUrl(masterUrl, namespace, openShiftToken, keycloakToken); Workspace workspace = workspaceClient.startWorkspace(cheServerURL, name, masterUrl, namespace, openShiftToken, keycloakToken); setGitHubOAthTokenAndCommitterInfo(cheServerURL, gitHubToken, keycloakToken); return workspace; }
/** * @api {patch} /credentials/:name Update * @apiParam {String} name Credential name to update * * @apiParamExample {multipart} RSA-Multipart-Body: * the same as create * * @apiGroup Credenital */ @PatchMapping(path = "/{name}", consumes = MediaType.MULTIPART_FORM_DATA_VALUE) @WebSecurity(action = Actions.ADMIN_UPDATE) public Credential update(@PathVariable String name, @RequestParam(name = "detail") String detailJson, @RequestPart(name = "android-file", required = false) MultipartFile androidFile, @RequestPart(name = "p12-files", required = false) MultipartFile[] p12Files, @RequestPart(name = "pp-files", required = false) MultipartFile[] ppFiles) { // check name is existed if (!credentialService.existed(name)) { throw new IllegalParameterException("Credential name does not existed"); } CredentialDetail detail = jsonConverter.getGsonForReader().fromJson(detailJson, CredentialDetail.class); return createOrUpdate(name, detail, androidFile, p12Files, ppFiles); }
@PatchMapping public List<JSONDocument> processChanges( @PathVariable(PARAM_WindowId) final String windowIdStr // , @PathVariable(PARAM_ViewId) final String viewIdStr // , @PathVariable(PARAM_RowId) final String rowIdStr // , @RequestBody final List<JSONDocumentChangedEvent> events // ) { userSession.assertLoggedIn(); final ViewId viewId = ViewId.of(windowIdStr, viewIdStr); final DocumentId rowId = DocumentId.of(rowIdStr); return Execution.callInNewExecution("processChanges", () -> { viewsRepo.getView(viewId) .getById(rowId) .getAttributes() .processChanges(events); return JSONDocument.ofEvents(Execution.getCurrentDocumentChangesCollectorOrNull(), newJSONOptions()); }); }
@PatchMapping public JSONViewRow patchRow( @PathVariable(PARAM_WindowId) final String windowIdStr, @PathVariable(PARAM_ViewId) final String viewIdStr, @PathVariable(PARAM_RowId) final String rowIdStr, @RequestBody final List<JSONDocumentChangedEvent> fieldChangeRequests) { userSession.assertLoggedIn(); final ViewId viewId = ViewId.of(windowIdStr, viewIdStr); final DocumentId rowId = DocumentId.of(rowIdStr); final IEditableView view = getEditableView(viewId); final RowEditingContext editingCtx = createRowEditingContext(rowId); view.patchViewRow(editingCtx, fieldChangeRequests); final IViewRow row = view.getById(rowId); final IViewRowOverrides rowOverrides = ViewRowOverridesHelper.getViewRowOverrides(view); return JSONViewRow.ofRow(row, rowOverrides, userSession.getAD_Language()); }
/** * * @param windowIdStr * @param documentIdStr the string to identify the document to be returned. May also be {@link DocumentId#NEW_ID_STRING}, if a new record shall be created. * @param advanced * @param events * @return */ @PatchMapping("/{windowId}/{documentId}") public List<JSONDocument> patchRootDocument( @PathVariable("windowId") final String windowIdStr // , @PathVariable("documentId") final String documentIdStr // , @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced // , @RequestBody final List<JSONDocumentChangedEvent> events) { final DocumentPath documentPath = DocumentPath.builder() .setDocumentType(WindowId.fromJson(windowIdStr)) .setDocumentId(documentIdStr) .allowNewDocumentId() .build(); return patchDocument(documentPath, advanced, events); }
@PatchMapping("/{windowId}/{documentId}/{tabId}/{rowId}") public List<JSONDocument> patchIncludedDocument( @PathVariable("windowId") final String windowIdStr // , @PathVariable("documentId") final String documentIdStr // , @PathVariable("tabId") final String detailIdStr // , @PathVariable("rowId") final String rowIdStr // , @RequestParam(name = PARAM_Advanced, required = false, defaultValue = PARAM_Advanced_DefaultValue) final boolean advanced // , @RequestBody final List<JSONDocumentChangedEvent> events) { final DocumentPath documentPath = DocumentPath.builder() .setDocumentType(WindowId.fromJson(windowIdStr)) .setDocumentId(documentIdStr) .setDetailId(detailIdStr) .setRowId(rowIdStr) .allowNewRowId() .build(); return patchDocument(documentPath, advanced, events); }
@PatchMapping("/{asiDocId}") public List<JSONDocument> processChanges( @PathVariable("asiDocId") final String asiDocIdStr // , @RequestBody final List<JSONDocumentChangedEvent> events // ) { userSession.assertLoggedIn(); final DocumentId asiDocId = DocumentId.of(asiDocIdStr); return Execution.callInNewExecution("processChanges", () -> { final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull(); asiRepo.processASIDocumentChanges(asiDocId, events, changesCollector); return JSONDocument.ofEvents(changesCollector, newJsonOpts()); }); }
@PatchMapping("/node/{nodeId}") public List<JSONMenuNode> patchNode(@PathVariable(PARAM_NodeId) final String nodeId, @RequestBody List<JSONDocumentChangedEvent> events) { userSession.assertLoggedIn(); final JSONPatchMenuNodeRequest request = JSONPatchMenuNodeRequest.ofChangeEvents(events); final MenuTree menuTree = getMenuTree(); final MenuNode node = menuTree.getNodeById(nodeId); final LinkedHashMap<String, MenuNode> changedMenuNodesById = new LinkedHashMap<>(); if (request.getFavorite() != null) { menuTreeRepository.setFavorite(node, request.getFavorite()); menuTree.streamNodesByAD_Menu_ID(node.getAD_Menu_ID()) .forEach(changedNode -> changedMenuNodesById.put(changedNode.getId(), changedNode)); } return JSONMenuNode.ofList(changedMenuNodesById.values(), menuTreeRepository); }
@PatchMapping(value = { "/{cfInstanceId}/v2/service_instances/{instanceId}", "/v2/service_instances/{instanceId}" }) public ResponseEntity<?> updateServiceInstance(@PathVariable Map<String, String> pathVariables, @PathVariable("instanceId") String serviceInstanceId, @RequestParam(value = ASYNC_REQUEST_PARAMETER, required = false) boolean acceptsIncomplete, @RequestHeader(value = API_INFO_LOCATION_HEADER, required = false) String apiInfoLocation, @RequestHeader(value = ORIGINATING_IDENTITY_HEADER, required = false) String originatingIdentityString, @Valid @RequestBody UpdateServiceInstanceRequest request) { ServiceDefinition serviceDefinition = getServiceDefinition(request.getServiceDefinitionId()); request.setServiceInstanceId(serviceInstanceId); request.setServiceDefinition(serviceDefinition); setCommonRequestFields(request, pathVariables.get("cfInstanceId"), apiInfoLocation, originatingIdentityString, acceptsIncomplete); log.debug("Updating a service instance: request={}", request); UpdateServiceInstanceResponse response = service.updateServiceInstance(request); log.debug("Updating a service instance succeeded: serviceInstanceId={}, response={}", serviceInstanceId, response); return new ResponseEntity<>(response, response.isAsync() ? HttpStatus.ACCEPTED : HttpStatus.OK); }
Annotation findMappingAnnotation(AnnotatedElement element) { Annotation mappingAnnotation = element.getAnnotation(RequestMapping.class); if (mappingAnnotation == null) { mappingAnnotation = element.getAnnotation(GetMapping.class); if (mappingAnnotation == null) { mappingAnnotation = element.getAnnotation(PostMapping.class); if (mappingAnnotation == null) { mappingAnnotation = element.getAnnotation(PutMapping.class); if (mappingAnnotation == null) { mappingAnnotation = element.getAnnotation(DeleteMapping.class); if (mappingAnnotation == null) { mappingAnnotation = element.getAnnotation(PatchMapping.class); } } } } } if (mappingAnnotation == null) { if (element instanceof Method) { Method method = (Method) element; mappingAnnotation = AnnotationUtils.findAnnotation(method, RequestMapping.class); } else { Class<?> clazz = (Class<?>) element; mappingAnnotation = AnnotationUtils.findAnnotation(clazz, RequestMapping.class); } } return mappingAnnotation; }
@Override public boolean canProcess(Method method) { return method.getAnnotation(RequestMapping.class) != null || method.getAnnotation(GetMapping.class) != null || method.getAnnotation(PutMapping.class) != null || method.getAnnotation(PostMapping.class) != null || method.getAnnotation(PatchMapping.class) != null || method.getAnnotation(DeleteMapping.class) != null; }
@Override protected void initMethodAnnotationMgr() { super.initMethodAnnotationMgr(); methodAnnotationMgr.register(RequestMapping.class, new RequestMappingMethodAnnotationProcessor()); methodAnnotationMgr.register(GetMapping.class, new GetMappingMethodAnnotationProcessor()); methodAnnotationMgr.register(PutMapping.class, new PutMappingMethodAnnotationProcessor()); methodAnnotationMgr.register(PostMapping.class, new PostMappingMethodAnnotationProcessor()); methodAnnotationMgr.register(PatchMapping.class, new PatchMappingMethodAnnotationProcessor()); methodAnnotationMgr.register(DeleteMapping.class, new DeleteMappingMethodAnnotationProcessor()); }
@PatchMapping( path = "usingPatchMapping/{targetName}", consumes = {"text/plain", "application/*"}, produces = {"text/plain", "application/*"}) public String usingPatchMapping(@RequestBody User srcUser, @RequestHeader String header, @PathVariable String targetName, @RequestParam(name = "word") String word, @RequestAttribute String form) { return String.format("%s %s %s %s %s", srcUser.name, header, targetName, word, form); }
@ApiOperation(value = "Start Che Server") @PatchMapping("/server") public CheServerInfo startCheServer(@RequestParam String masterUrl, @RequestParam String namespace, @ApiParam(value = "Keycloak token", required = true) @RequestHeader("Authorization") String keycloakToken, HttpServletResponse response, HttpServletRequest request) throws Exception { KeycloakTokenValidator.validate(keycloakToken); String openShiftToken = keycloakClient.getOpenShiftToken(keycloakToken); CheServerInfo info = startServer(masterUrl, openShiftToken, keycloakToken, namespace, response, request); return info; }
@ApiOperation(value = "Start Che Server") @PatchMapping("/server/oso") public CheServerInfo startCheServerOnOpenShift(@RequestParam String masterUrl, @RequestParam String namespace, @ApiParam(value = "OpenShift token", required = true) @RequestHeader("Authorization") String openShiftToken, HttpServletResponse response, HttpServletRequest request) throws Exception { CheServerInfo info = startServer(masterUrl, openShiftToken, null, namespace, response, request); return info; }
@ApiOperation(value = "Start an existing workspace. Stop all other workspaces (only one workspace can be running at a time)") @PatchMapping("/workspace/oso/{name}") public Workspace startExistingOnOpenShift(@PathVariable String name, @RequestParam String masterUrl, @RequestParam String namespace, @ApiParam(value = "OpenShift token", required = true) @RequestHeader("Authorization") String openShiftToken) throws IOException, URISyntaxException, RouteNotFoundException, StackNotFoundException, GitHubOAthTokenException, ProjectCreationException, WorkspaceNotFound { String cheServerURL = openShiftClientWrapper.getCheServerUrl(masterUrl, namespace, openShiftToken, null); return workspaceClient.startWorkspace(cheServerURL, name, masterUrl, namespace, openShiftToken, null); }
@PatchMapping(path = "/{name}", consumes = MediaType.APPLICATION_JSON_VALUE) @WebSecurity(action = Actions.ADMIN_UPDATE) public Credential update(@PathVariable String name, @RequestBody CredentialDetail detail) { // check name is existed if (!credentialService.existed(name)) { throw new IllegalParameterException("Credential name does not existed"); } Credential credential = credentialService.createOrUpdate(name, detail); return credential; }
@Authorize(action = {Permission.ACTION_UPDATE, Permission.ACTION_ADD}, logical = Logical.AND) @PatchMapping @ApiOperation("新增或者修改") default ResponseMessage<PK> saveOrUpdate(@RequestBody M data) { E entity = getService().createEntity(); return ResponseMessage.ok(getService().saveOrUpdate(modelToEntity(data, entity))); }
@PatchMapping("/{boardId}/card/{cardId}") public JSONBoardCard patchCard(@PathVariable("boardId") final int boardId, @PathVariable("cardId") final int cardId, @RequestBody final List<JSONDocumentChangedEvent> changes) { userSession.assertLoggedIn(); final BoardCard card = boardsRepo.changeCard(boardId, cardId, createBoardCardChangeRequest(changes)); return JSONBoardCard.of(card, userSession.getAD_Language()); }
@PatchMapping("/{letterId}") @ApiOperation("Changes the letter") public JSONLetter changeLetter(@PathVariable("letterId") final String letterId, @RequestBody final List<JSONDocumentChangedEvent> events) { userSession.assertLoggedIn(); final WebuiLetterChangeResult result = changeLetter(letterId, letterOld -> changeLetter(letterOld, events)); return JSONLetter.of(result.getLetter()); }
@PatchMapping("/{emailId}") @ApiOperation("Changes the email") public JSONEmail changeEmail(@PathVariable("emailId") final String emailId, @RequestBody final List<JSONDocumentChangedEvent> events) { userSession.assertLoggedIn(); final WebuiEmailChangeResult result = changeEmail(emailId, emailOld -> changeEmail(emailOld, events)); return JSONEmail.of(result.getEmail()); }
@PatchMapping("/{quickInputId}") public List<JSONDocument> processChanges( @PathVariable("windowId") final String windowIdStr // , @PathVariable("documentId") final String documentIdStr // , @PathVariable("tabId") final String tabIdStr // , @PathVariable("quickInputId") final String quickInputIdStr // , @RequestBody final List<JSONDocumentChangedEvent> events) { userSession.assertLoggedIn(); final QuickInputPath quickInputPath = QuickInputPath.of(windowIdStr, documentIdStr, tabIdStr, quickInputIdStr); return Execution.callInNewExecution("quickInput-writable-" + quickInputPath, () -> { final IDocumentChangesCollector changesCollector = Execution.getCurrentDocumentChangesCollectorOrNull(); forQuickInputWritable(quickInputPath, changesCollector, quickInput -> { quickInput.processValueChanges(events); changesCollector.setPrimaryChange(quickInput.getDocumentPath()); return null; // void }); // Extract and send websocket events final List<JSONDocument> jsonDocumentEvents = JSONDocument.ofEvents(changesCollector, newJSONOptions()); websocketPublisher.convertAndPublish(jsonDocumentEvents); return jsonDocumentEvents; }); }
@PatchMapping("/{id}") public ResponseEntity patchUser(@PathVariable Long id, @RequestBody JsonPatch jsonPatch) { return this.userService .getUserByID(id) .map(existing -> { try { JsonNode patched = jsonPatch.apply(objectMapper.convertValue(existing, JsonNode.class)); UserDTO patchedUser = objectMapper.treeToValue(patched, UserDTO.class); // TODO add patched operations return ResponseEntity.ok(this.userService.update(patchedUser)); } catch (JsonPatchException | JsonProcessingException e) { return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body(e.getMessage()); } }) .orElse(ResponseEntity.notFound().build()); }
@Override public JAnnotationUse apply(ApiActionMetadata endpointMetadata, JMethod generatableType) { JAnnotationUse requestMappingAnnotation; switch (RequestMethod.valueOf(endpointMetadata.getActionType().name())) { case GET: requestMappingAnnotation = generatableType.annotate(GetMapping.class); break; case POST: requestMappingAnnotation = generatableType.annotate(PostMapping.class); break; case PUT: requestMappingAnnotation = generatableType.annotate(PutMapping.class); break; case PATCH: requestMappingAnnotation = generatableType.annotate(PatchMapping.class); break; case DELETE: requestMappingAnnotation = generatableType.annotate(DeleteMapping.class); break; default: requestMappingAnnotation = generatableType.annotate(RequestMapping.class); requestMappingAnnotation.param("method", RequestMethod.valueOf(endpointMetadata.getActionType().name())); } if (StringUtils.isNotBlank(endpointMetadata.getUrl())) { requestMappingAnnotation.param("value", endpointMetadata.getUrl()); } return requestMappingAnnotation; }
/** * Searches {@link org.springframework.web.bind.annotation.RequestMapping RequestMapping} * annotation on the given method argument and extracts * If RequestMapping annotation is not found, NoRequestMappingFoundException is thrown. * {@link org.springframework.http.HttpMethod HttpMethod} type equivalent to * {@link org.springframework.web.bind.annotation.RequestMethod RequestMethod} type * * @param element AnnotatedElement object to be examined. * @return Mapping object */ Mapping extractMapping(AnnotatedElement element) { Annotation annotation = findMappingAnnotation(element); String[] urls; RequestMethod requestMethod; String consumes; if (annotation instanceof RequestMapping) { RequestMapping requestMapping = (RequestMapping) annotation; requestMethod = requestMapping.method().length == 0 ? RequestMethod.GET : requestMapping.method()[0]; urls = requestMapping.value(); consumes = StringHelper.getFirstOrEmpty(requestMapping.consumes()); } else if (annotation instanceof GetMapping) { requestMethod = RequestMethod.GET; urls = ((GetMapping) annotation).value(); consumes = StringHelper.getFirstOrEmpty(((GetMapping) annotation).consumes()); } else if (annotation instanceof PostMapping) { requestMethod = RequestMethod.POST; urls = ((PostMapping) annotation).value(); consumes = StringHelper.getFirstOrEmpty(((PostMapping) annotation).consumes()); } else if (annotation instanceof PutMapping) { requestMethod = RequestMethod.PUT; urls = ((PutMapping) annotation).value(); consumes = StringHelper.getFirstOrEmpty(((PutMapping) annotation).consumes()); } else if (annotation instanceof DeleteMapping) { requestMethod = RequestMethod.DELETE; urls = ((DeleteMapping) annotation).value(); consumes = StringHelper.getFirstOrEmpty(((DeleteMapping) annotation).consumes()); } else if (annotation instanceof PatchMapping) { requestMethod = RequestMethod.PATCH; urls = ((PatchMapping) annotation).value(); consumes = StringHelper.getFirstOrEmpty(((PatchMapping) annotation).consumes()); } else { throw new NoRequestMappingFoundException(element); } HttpMethod httpMethod = HttpMethod.resolve(requestMethod.name()); String url = StringHelper.getFirstOrEmpty(urls); MediaType mediaType; try { mediaType = MediaType.valueOf(consumes); } catch (InvalidMediaTypeException exception) { mediaType = MediaType.APPLICATION_JSON_UTF8; } return new Mapping(httpMethod, url, mediaType); }
@PatchMapping ResponseEntity patchMapping();
@PatchMapping(path = "usingPatchMapping") public ResponseEntity<List<User>> usingPatchMapping() { return null; }
@PatchMapping(path = "usingPatchMapping") public void usingPatchMapping(int query) { }
@PatchMapping(path = "/groups/{group}/jobs/{name}/pause") public ResponseEntity<Void> pauseJob(@PathVariable String group, @PathVariable String name) { emailService.pauseJob(group, name); return ResponseEntity.noContent().build(); }
@PatchMapping(path = "/groups/{group}/jobs/{name}/resume") public ResponseEntity<Void> resumeJob(@PathVariable String group, @PathVariable String name) { emailService.resumeJob(group, name); return ResponseEntity.noContent().build(); }
@PatchMapping("/patch-mapping") public void patchMapping() { }
@PatchMapping(value = "/hello-patch") public void helloPatch() { logger.fine("hello PATCH"); }
@PatchMapping("{id}") @ResponseStatus(HttpStatus.NO_CONTENT) public void update(@PathVariable("id") long problemId, @RequestBody Problem p, @RequestParam(value = "locale", required = false) String requestLocale) { problemService.updateSelective(problemId, p, requestLocale); }
@PatchMapping("{userId}") @ResponseStatus(HttpStatus.NO_CONTENT) public void update(@PathVariable("userId") String userId, @RequestBody User user) { accountService.updateSelective(userId, user.toBuilder().password(null).build()); }
@PatchMapping("{userId}/password") @ResponseStatus(HttpStatus.NO_CONTENT) public void updatePassword(@PathVariable("userId") String userId, @RequestBody UserPasswordForm user) { accountService.updatePassword(userId, user.getPassword()); }
@PatchMapping("{id}") @ResponseStatus(HttpStatus.NO_CONTENT) public void update(@PathVariable("id") long id, @RequestBody Contest contest) { contestService.updateSelective(id, contest); }
@PatchMapping("") void methodWithPatchMappingAnnotation() throws ExceptionWithThrowableConstructorException;
@PatchMapping("/kpis/{itemId}") public JSONDashboardItem changeKPIItem(@PathVariable("itemId") final int itemId, @RequestBody final List<JSONPatchEvent<DashboardItemPatchPath>> events) { return changeDashboardItem(DashboardWidgetType.KPI, itemId, events); }
@PatchMapping("/targetIndicators/{itemId}") public JSONDashboardItem changeTargetIndicatorItem(@PathVariable("itemId") final int itemId, @RequestBody final List<JSONPatchEvent<DashboardItemPatchPath>> events) { return changeDashboardItem(DashboardWidgetType.TargetIndicator, itemId, events); }