下面列出了怎么用javax.ws.rs.PATCH的API类实例代码及写法,或者点击链接到github查看源代码。
@PATCH
@Path("/{id}")
@Consumes({RestConstants.MEDIA_TYPE_YAML, MediaType.APPLICATION_JSON})
@Operation(summary = "Update the experiment in the submarine server with spec",
tags = {"experiment"},
responses = {
@ApiResponse(description = "successful operation", content = @Content(
schema = @Schema(implementation = JsonResponse.class))),
@ApiResponse(responseCode = "404", description = "Experiment not found")})
public Response patchExperiment(@PathParam(RestConstants.ID) String id, ExperimentSpec spec) {
try {
Experiment experiment = experimentManager.patchExperiment(id, spec);
return new JsonResponse.Builder<Experiment>(Response.Status.OK).success(true)
.result(experiment).build();
} catch (SubmarineRuntimeException e) {
return parseExperimentServiceException(e);
}
}
@Path("/update")
@PATCH
@Consumes(MediaType.TEXT_PLAIN)
public Response updateSheet(@QueryParam("spreadsheetId") String spreadsheetId, String title) {
BatchUpdateSpreadsheetRequest request = new BatchUpdateSpreadsheetRequest()
.setIncludeSpreadsheetInResponse(true)
.setRequests(Collections
.singletonList(new Request().setUpdateSpreadsheetProperties(new UpdateSpreadsheetPropertiesRequest()
.setProperties(new SpreadsheetProperties().setTitle(title))
.setFields("title"))));
final Map<String, Object> headers = new HashMap<>();
headers.put("CamelGoogleSheets.spreadsheetId", spreadsheetId);
headers.put("CamelGoogleSheets.batchUpdateSpreadsheetRequest", request);
producerTemplate.requestBodyAndHeaders("google-sheets://spreadsheets/batchUpdate", null, headers);
return Response.ok().build();
}
@PATCH
@Path("passphrase")
public Response enterPassphrase(
@Context Request request,
String jsonData
)
{
return requestHelper.doInScope(ApiConsts.API_ENTER_CRYPT_PASS, request, () ->
{
String passPhrase = objectMapper.readValue(jsonData, String.class);
ApiCallRc apiCallRc = ctrlApiCallHandler.enterPassphrase(passPhrase);
return ApiCallRcRestUtils.toResponse(apiCallRc, Response.Status.OK);
}, true);
}
/**
* Perform a PATCH operation on an LDP Resource.
*
* @param uriInfo the URI info
* @param secContext the security context
* @param headers the HTTP headers
* @param request the request
* @param body the body
* @return the async response
*/
@PATCH
@Timed
@Operation(summary = "Update a linked data resource")
public CompletionStage<Response> updateResource(@Context final Request request, @Context final UriInfo uriInfo,
@Context final HttpHeaders headers, @Context final SecurityContext secContext,
@RequestBody(description = "The update request for RDF resources, typically as SPARQL-Update",
required = true,
content = @Content(mediaType = "application/sparql-update")) final String body) {
final TrellisRequest req = new TrellisRequest(request, uriInfo, headers, secContext);
final String urlBase = getBaseUrl(req);
final IRI identifier = buildTrellisIdentifier(req.getPath());
final PatchHandler patchHandler = new PatchHandler(req, body, trellis, extensions, supportsCreateOnPatch,
defaultJsonLdProfile, urlBase);
return getParent(identifier).thenCombine(trellis.getResourceService().get(identifier), patchHandler::initialize)
.thenCompose(patchHandler::updateResource).thenCompose(patchHandler::updateMemento)
.thenApply(ResponseBuilder::build).exceptionally(this::handleException);
}
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value PV_ID}
* @param productVersion
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ProductVersion.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
ProductVersion patchSpecific(
@Parameter(description = PV_ID) @PathParam("id") String id,
@NotNull ProductVersion productVersion);
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value PM_ID}
* @param productMilestone
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ProductMilestone.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
ProductMilestone patchSpecific(
@Parameter(description = PM_ID) @PathParam("id") String id,
@NotNull ProductMilestone productMilestone);
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value PR_ID}
* @param productRelease
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ProductRelease.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
ProductRelease patchSpecific(
@Parameter(description = PR_ID) @PathParam("id") String id,
@NotNull ProductRelease productRelease);
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value GC_ID}
* @param groupConfig
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = GroupConfiguration.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
GroupConfiguration patchSpecific(
@Parameter(description = GC_ID) @PathParam("id") String id,
@NotNull GroupConfiguration groupConfig);
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value P_ID}
* @param project
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = Project.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
Project patchSpecific(@Parameter(description = P_ID) @PathParam("id") String id, @NotNull Project project);
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value BC_ID}
* @param buildConfig
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = BuildConfiguration.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
BuildConfiguration patchSpecific(
@Parameter(description = BC_ID) @PathParam("id") String id,
BuildConfiguration buildConfig);
/**
* {@value PATCH_SPECIFIC_DESC}
*
* @param id {@value P_ID}
* @param product
* @return
*/
@Operation(
summary = PATCH_SPECIFIC_DESC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = Product.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
Product patchSpecific(@Parameter(description = P_ID) @PathParam("id") String id, @NotNull Product product);
/**
* {@value PATCH_SPECIFIC}
*
* @param id {@value SCM_ID}
* @param scmRepository
* @return
*/
@Operation(
summary = PATCH_SPECIFIC,
responses = {
@ApiResponse(
responseCode = SUCCESS_CODE,
description = SUCCESS_DESCRIPTION,
content = @Content(schema = @Schema(implementation = SCMRepository.class))),
@ApiResponse(
responseCode = INVALID_CODE,
description = INVALID_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))),
@ApiResponse(responseCode = NOT_FOUND_CODE, description = NOT_FOUND_DESCRIPTION),
@ApiResponse(
responseCode = SERVER_ERROR_CODE,
description = SERVER_ERROR_DESCRIPTION,
content = @Content(schema = @Schema(implementation = ErrorResponse.class))) })
@PATCH
@Path("/{id}")
@Consumes(MediaType.APPLICATION_JSON_PATCH_JSON)
SCMRepository patchSpecific(
@Parameter(description = SCM_ID) @PathParam("id") String id,
@NotNull SCMRepository scmRepository);
@PATCH
@Path("/schemas/{schemaid}")
@Consumes({"application/json"})
@Produces({"application/json"})
public Response apiSchemasSchemaidPatch(@PathParam("schemaid") String schemaid, @NotNull @Valid List<AnyOfStateModificationEnabledModification> anyOfStateModificationEnabledModification)
throws ArtifactNotFoundException {
return service.apiSchemasSchemaidPatch(schemaid, anyOfStateModificationEnabledModification);
}
@PATCH
@Path("/schemas/{schemaid}/versions/{versionnum}")
@Consumes({"application/json"})
@Produces({"application/json"})
public Response apiSchemasSchemaidVersionsVersionnumPatch(@PathParam("schemaid") String schemaid, @PathParam("versionnum") int versionnum, @NotNull @Valid List<AnyOfStateModificationEnabledModification> anyOfStateModificationEnabledModification)
throws ArtifactNotFoundException {
return service.apiSchemasSchemaidVersionsVersionnumPatch(schemaid, versionnum, anyOfStateModificationEnabledModification);
}
@Override
public void initMethodAnnotationProcessor() {
super.initMethodAnnotationProcessor();
methodAnnotationMap.put(Path.class, new PathMethodAnnotationProcessor());
HttpMethodAnnotationProcessor httpMethodAnnotationProcessor = new HttpMethodAnnotationProcessor();
methodAnnotationMap.put(GET.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(POST.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(DELETE.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(PATCH.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(PUT.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(OPTIONS.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(HEAD.class, httpMethodAnnotationProcessor);
methodAnnotationMap.put(Consumes.class, new ConsumesAnnotationProcessor());
}
@Path("/update")
@PATCH
@Consumes(MediaType.APPLICATION_JSON)
public Response update(@QueryParam("sessionId") String sessionId, String json) {
HttpStatusCode status = producerTemplate.requestBody(
"olingo4://update/People('lewisblack')?serviceUri=" + getServiceURL(sessionId), json, HttpStatusCode.class);
return Response
.status(status.getStatusCode())
.build();
}
@Path("/blob/update")
@PATCH
@Consumes(MediaType.TEXT_PLAIN)
public Response updateBlob(String message) throws Exception {
producerTemplate.sendBody(
"azure-blob://devstoreaccount1/camel-test/test?operation=updateBlockBlob&azureBlobClient=#azureBlobClient&validateClientURI=false",
message);
return Response.ok().build();
}
@Path("/update/event")
@PATCH
public Response updateCalendarEvent(@QueryParam("calendarId") String calendarId, @QueryParam("eventId") String eventId) {
Map<String, Object> headers = new HashMap<>();
headers.put("CamelGoogleCalendar.calendarId", calendarId);
headers.put("CamelGoogleCalendar.eventId", eventId);
try {
Event response = producerTemplate.requestBodyAndHeaders("google-calendar://events/get", null, headers,
Event.class);
if (response == null) {
return Response.status(Response.Status.NOT_FOUND).build();
}
response.setSummary(response.getSummary() + " Updated");
headers = new HashMap<>();
headers.put("CamelGoogleCalendar.calendarId", calendarId);
headers.put("CamelGoogleCalendar.eventId", eventId);
headers.put("CamelGoogleCalendar.content", response);
producerTemplate.requestBodyAndHeaders("google-calendar://events/update", null, headers);
return Response.ok().build();
} catch (CamelExecutionException e) {
Exception exchangeException = e.getExchange().getException();
if (exchangeException != null && exchangeException.getCause() instanceof GoogleJsonResponseException) {
GoogleJsonResponseException originalException = (GoogleJsonResponseException) exchangeException.getCause();
return Response.status(originalException.getStatusCode()).build();
}
throw e;
}
}
@Path("/update")
@PATCH
@Produces(MediaType.TEXT_PLAIN)
public Response updateData(@QueryParam("indexId") String indexId, String indexValue) throws Exception {
Map<String, String> data = createIndexedData(indexValue);
Map<String, Object> headers = new HashMap<>();
headers.put(ElasticsearchConstants.PARAM_INDEX_ID, indexId);
producerTemplate.requestBodyAndHeaders("elasticsearch-rest://elasticsearch?operation=Update&indexName=test", data,
headers);
return Response.ok().build();
}
@PATCH
@Consumes(MediaType.TEXT_PLAIN)
@Tags({
@Tag, @Tag
})
public void patchValue(String value) {
}
/**
* Add tags to an integration for release to target environments.
*/
@PATCH
@Path("integrations/{id}")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Map<String, ContinuousDeliveryEnvironment> patchTagsForRelease(@NotNull @PathParam("id") @Parameter(required = true) String integrationId, @NotNull @Parameter(required = true) List<String> environments) {
return tagForRelease(integrationId, environments, false);
}
/**
* Add tags to an integration for release to target environments.
*/
@PATCH
@Path("integrations/{id}/tags")
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public Map<String, ContinuousDeliveryEnvironment> patchTagsForRelease(@NotNull @PathParam("id") @Parameter(required = true) String integrationId,
@NotNull @Parameter(required = true) List<String> environments) {
return environmentHandler.patchTagsForRelease(integrationId, environments);
}
@PATCH
@Path("/it")
@RequestReader(DummyBodyReader.class)
@ResponseWriter(TestDummyWriter.class)
@RouteOrder(20)
public Dummy echoJsonPatch(Dummy postParam) {
postParam.name = "Received-" + postParam.name;
postParam.value = "Received-" + postParam.value;
return postParam;
}
@PATCH
@Path("/{idA2A}/{idPendenza}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response updatePendenza(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, @PathParam("idA2A") String idA2A, @PathParam("idPendenza") String idPendenza, java.io.InputStream is){
this.buildContext();
return this.controller.pendenzeIdA2AIdPendenzaPATCH(this.getUser(), uriInfo, httpHeaders, idA2A, idPendenza, is);
}
@PATCH
@Path("/{idA2A}/{idPendenza}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response updatePendenza(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, @PathParam("idA2A") String idA2A, @PathParam("idPendenza") String idPendenza, java.io.InputStream is){
this.buildContext();
return this.controller.pendenzeIdA2AIdPendenzaPATCH(this.getUser(), uriInfo, httpHeaders, idA2A, idPendenza, is);
}
@PATCH
@Path("/{principal}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response updateOperatore(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is, @PathParam("principal") String principal){
this.buildContext();
return this.controller.updateOperatore(this.getUser(), uriInfo, httpHeaders, is, principal);
}
@PATCH
@Path("/{idDominio}/{iuv}/{ccp}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response updateRpp(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is, @PathParam("idDominio") String idDominio, @PathParam("iuv") String iuv, @PathParam("ccp") String ccp){
this.buildContext();
return this.controller.updateRpp(this.getUser(), uriInfo, httpHeaders, is, idDominio, iuv, ccp);
}
@PATCH
@Path("/{idDominio}/{iuv}/n/a")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response updateRpp(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is, @PathParam("idDominio") String idDominio, @PathParam("iuv") String iuv){
this.buildContext();
return this.controller.updateRpp(this.getUser(), uriInfo, httpHeaders, is, idDominio, iuv, "n/a");
}
@PATCH
@Path("/{idRuolo}")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response updateRuolo(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is, @PathParam("idRuolo") String idRuolo){
this.buildContext();
return this.controller.updateRuolo(this.getUser(), uriInfo, httpHeaders, is, idRuolo);
}
@PATCH
@Path("/")
@Consumes({ "application/json" })
@Produces({ "application/json" })
public Response aggiornaConfigurazioni(@Context UriInfo uriInfo, @Context HttpHeaders httpHeaders, java.io.InputStream is){
this.buildContext();
return this.controller.aggiornaConfigurazioni(this.getUser(), uriInfo, httpHeaders, is);
}