Class UpdateHalMethodImplementor
- java.lang.Object
-
- io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
-
- io.quarkus.rest.data.panache.deployment.methods.hal.HalMethodImplementor
-
- io.quarkus.rest.data.panache.deployment.methods.hal.UpdateHalMethodImplementor
-
- All Implemented Interfaces:
MethodImplementor
public final class UpdateHalMethodImplementor extends HalMethodImplementor
-
-
Field Summary
-
Fields inherited from interface io.quarkus.rest.data.panache.deployment.methods.MethodImplementor
APPLICATION_HAL_JSON, APPLICATION_JSON
-
-
Constructor Summary
Constructors Constructor Description UpdateHalMethodImplementor(boolean withValidation, boolean isResteasyClassic)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected StringgetResourceMethodName()Get a name of a method which this controller uses to access data.protected voidimplementInternal(io.quarkus.gizmo.ClassCreator classCreator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.FieldDescriptor resourceField)ExposeRestDataResource.update(Object, Object)via HAL JAX-RS method.-
Methods inherited from class io.quarkus.rest.data.panache.deployment.methods.hal.HalMethodImplementor
implement, wrapHalEntities, wrapHalEntity
-
Methods inherited from class io.quarkus.rest.data.panache.deployment.methods.StandardMethodImplementor
addConsumesAnnotation, addContextAnnotation, addDefaultValueAnnotation, addDeleteAnnotation, addGetAnnotation, addLinksAnnotation, addPathAnnotation, addPathParamAnnotation, addPostAnnotation, addProducesAnnotation, addPutAnnotation, addQueryParamAnnotation, addSortQueryParamValidatorAnnotation, appendToPath, implementTryBlock
-
-
-
-
Method Detail
-
implementInternal
protected void implementInternal(io.quarkus.gizmo.ClassCreator classCreator, ResourceMetadata resourceMetadata, ResourceProperties resourceProperties, io.quarkus.gizmo.FieldDescriptor resourceField)ExposeRestDataResource.update(Object, Object)via HAL JAX-RS method. Generated code looks more or less like this:@PUT @Path("{id}") @Consumes({"application/json"}) @Produces({"application/hal+json"}) public Response updateHal(@PathParam("id") ID id, Entity entityToSave) { try { Object newEntity = updateExecutor.execute(() -> { if (resource.get(id) == null) { return resource.update(id, entityToSave); } else { resource.update(id, entityToSave); return null; } }); if (newEntity == null) { return Response.status(204).build(); } else { String location = new ResourceLinksProvider().getSelfLink(newEntity); if (location != null) { ResponseBuilder responseBuilder = Response.status(201); responseBuilder.entity(new HalEntityWrapper(newEntity)); responseBuilder.location(URI.create(location)); return responseBuilder.build(); } else { throw new RuntimeException("Could not extract a new entity URL") } } } catch (Throwable t) { throw new RestDataPanacheException(t); } }- Specified by:
implementInternalin classStandardMethodImplementor
-
getResourceMethodName
protected String getResourceMethodName()
Description copied from class:StandardMethodImplementorGet a name of a method which this controller uses to access data.- Specified by:
getResourceMethodNamein classStandardMethodImplementor
-
-