Dear people, please, could someone help me, I made these changes and now the submit is being carried out but it is not being inserted into the database, which is where I am going wrong. insert the route put the swagger.json file.
@PUT
public Event updateEvent(@PathParam("id") long id, Event updatedEvent) throws StorageException {
Event existingEvent = storage.getObject(Event.class, new Request(
new Columns.All(), new Condition.Equals("id", id)));
if (existingEvent == null) {
throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build());
}
permissionsService.checkPermission(Device.class, getUserId(), existingEvent.getDeviceId());
existingEvent.setAttributes(updatedEvent.getAttributes());
storage.update(existingEvent);
return existingEvent;
}
"summary": "Update a Events",
"tags": [
"Events"
],
"parameters": [
{
"name": "id",
"in": "path",
"required": true,
"schema": {
"type": "integer"
}
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Event"
}
}
},
"required": true
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/Event"
}
}
}
}
},
"x-codegen-request-body-name": "body"
}
I would like to know if it is possible to create the put verb to edit the attributes column of tc_events, if it is possible, could someone help by informing which files I need to change? EventResorce. I did this but I was not successful, I don't know what the route files would be.
@Path("{id}") @PUT public Event updateEvent(@PathParam("id") long id, Event updatedEvent) throws StorageException { Event existingEvent = storage.getObject(Event.class, new Request( new Columns.All(), new Condition.Equals("id", id))); if (existingEvent == null) { throw new WebApplicationException(Response.status(Response.Status.NOT_FOUND).build()); } permissionsService.checkPermission(Device.class, getUserId(), existingEvent.getDeviceId()); existingEvent.setAttributes(updatedEvent.getAttributes()); storage.update(existingEvent); return existingEvent; }