Я обнаружил исключение при запуске curl -d '{"DTYPE": "3", "id": 3, "version": 1, "email": "ajj@example.com", "firstName ":" Didier "," lastName ":" Ben "," password ":" Fatoumata7899 "," username ": fatou79"} '-H' Тип содержимого: приложение / json 'http://localhost: 8080 / api / users
Мой класс конечной точки
@ApplicationScoped
public class UsersResource {
@Context
private UriInfo uriInfo;
@Inject
private UserRepository users;
/*@Crypto(Type.BCRYPT)*/
/* @Inject
@Context
private PasswordEncoder passwordEncoder;*/
@GET
public User getUserById(@PathParam ("id")Long id) {
return users.findById(id);
}
@GET
public Response allUsers() {
return ok(users.findAll()).build();
}
@GET
@Path("/count")
public Response count() {
return ok(Count.builder().count(users.stream().count()).build()).build();
}
@GET
@Path("/exists")
public Response exists(@QueryParam("username") String username, @QueryParam("email") String email) {
if (username != null && username.length() > 0) {
return ok(Existed.builder().existed(users.findByUsername(username).isPresent()).build()).build();
}
if (email != null && email.length() > 0) {
return ok(Existed.builder().existed(users.findByEmail(email).isPresent()).build()).build();
}
return Response.status(Response.Status.BAD_REQUEST).entity("username or email query params is required")
.build();
}
@POST
public Response create(User user, @PathParam("user") Long userId) {
User u = users.findUserById(userId);
users.createUser(u);
return Response.status(201).build();
}
@PUT
@Path("/{id}")
public Response update(@PathParam ("id")Long id, User user) {
if(!id.equals(user.getId())) {
throw new BadRequestException("id in path and in Body must be the same");
}
users.updateUser(user);
return Response.status(204).build();
}
@DELETE
@Path("/{id}")
public Response delete(@PathParam("id") Long userId) {
users.deleteById(userId);
return Response.status(204).build();
}
}
второй класс конечной точки:
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ApplicationScoped
public class UserResource {
@Context
UriInfo uriInfo;
@Inject
UserRepository users;
@Context
SecurityContext securityContext;
@PathParam("username")
String username;
@GET
public Response getUserByUsername() {
return users.findByUsername(username)
.map(u -> Response.ok(u)
.link(uriInfo.getBaseUriBuilder().path("/users/{username}").build(username), "self").build())
.orElse(Response.status(Response.Status.NOT_FOUND).build());
}
@PUT
public Response updateUser(UserForm form) {
if (securityContext.getUserPrincipal() != null
&& securityContext.getUserPrincipal().getName().equals(username)) {
return users.findByUsername(username).map(u -> {
u.setFirstName(form.getFirstName());
u.setLastName(form.getLastName());
u.setEmail(form.getEmail());
users.save(u);
return Response.noContent().build();
}).orElse(Response.status(Response.Status.NOT_FOUND).build());
}
return Response.status(Response.Status.UNAUTHORIZED).build();
}
@DELETE
public Response deleteUser() {
return users.findByUsername(username).map(u -> {
users.delete(u);
return Response.noContent().build();
}).orElse(Response.status(Response.Status.NOT_FOUND).build());
}
}
Это консоль возвращение журнала: RESTEASY003880: невозможно найти контекстные данные типа: io.vertx.core.http.HttpServerRequest в org.jboss.resteasy.core.ContextParameterInjector $ GenericDelegatingProxy.invoke (ContextParameterInjector. java: 120): 120) proxy. $ Proxy70.remoteAddress (неизвестный источник) по адресу com.ciwara.kalanSowApp.web.filter.LoggingFilter.filter (LoggingFilter. java: 27) по адресу org.jboss.resteasy.core.interception.jaxrs.PreMatchContainer.filterxtte PreMatchContainerRequestContext. java: 311) в org.jboss.resteasy.core.ResourceMethodInvoker.invokeOnTarget (ResourceMethodInvoker. java: 423) в org.jboss.rest easy.core.ResourceMethodInvoker.invoke (ResourceMethodInvoker. java: 391) по адресу org.jboss.resteasy.core.ResourceMethodInvoker.lambda $ invoke $ 1 (ResourceMethodInvoker. java: 365) в классе * 1029. .uniComposeStage (CompletableFuture. java: 995) в java .util.concurrent.CompletableFuture.thenCompose (CompletableFuture. java: 2137) в java .util.concurrent.CompletableFuture.then *ompose (CompletableFuture. : 110) в org.jboss.resteasy.core.ResourceMethodInvoker.invoke (ResourceMethodInvoker. java: 365) в org.jboss.resteasy.core.SynchronousDispatcher.invoke (SynchronousDispatcher. java: 47ss. At. 477). resteasy.core.SynchronousDispatcher.lambda $ invoke $ 4 (SynchronousDispatcher. java: 252) в org.jboss.resteasy.core.SynchronousDispatcher.lambda $ препроцесс $ 0 (SynchronousDispatcher. java: 153) в org.j. core.interception.jaxrs.PreMatchContainerRequestContext.filter (PreMatchContainerRequestContext. java: 363) в org.jboss.resteasy.core.SynchronousDispatcher.prepr ocess (SynchronousDispatcher. java: 156) в org.jboss.resteasy.core.SynchronousDispatcher.invoke (SynchronousDispatcher. java: 238) в org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher java: 249) в io.quarkus.resteasy.runtime.ResteasyFilter.doFilter (ResteasyFilter. java: 30) в io.undertow.servlet.core.ManagedFilter.doFilter (ManagedFilter. java: 61) в io .undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter (FilterHandler. java: 131) в com.ciwara.kalanSowApp.security.cors.CORSFilter.doFilter (CORSFilter. java: 62) в io.undertow. .core.ManagedFilter.doFilter (ManagedFilter. java: 61) в io.undertow.servlet.handlers.FilterHandler $ FilterChainImpl.doFilter (FilterHandler. java: 131) в io.undertow.servlet.estlers.FilterHquler. (FilterHandler. java: 84) в io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest (ServletSecurityRoleHandler. java: 63) в io.undertow.servlet.handlers.Servl etChain $ 1.handleRequest (ServletChain. java: 68) в io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest (ServletDispatchingHandler. java: 36) в io.undertow.servlet.handler.Inssoc. . java: 133) в io.undertow.servlet.handlers.security.ServletAuthenticationCallHandler.handleRequest (ServletAuthenticationCallHandler. java: 57) в io.undertow.server.handlers.PredicateHandler.handleRequest: 43. * )
Большое спасибо за помощь.