Remove function useless

This commit is contained in:
Valentin CZERYBA 2023-01-08 11:59:29 +01:00
parent e97a50b635
commit a71d6562ca

View File

@ -267,30 +267,9 @@ public class PublisherRessources {
}
// Delete
@DELETE
@RolesAllowed("User")
@Transactional
public Response changeStatusToDelete(@Context SecurityContext ctx, @CookieParam("user") String userCookie) {
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
UsersEntity user = UsersEntity.findById(kid);
Response.Status status = getResponseCheck(ctx, userCookie, user);
if (status.equals(Response.Status.OK)) {
user.status = -1;
user.updated_at = LocalDateTime.now();
user.deleted_at = LocalDateTime.now();
user.persist();
if (!user.isPersistent()) {
status = Response.Status.NOT_MODIFIED;
}
}
return Response.status(status).build();
}
@DELETE
@Path("{id}")
@RolesAllowed("Admin")
@RolesAllowed({"Admin", "User"})
@Transactional
public Response changeStatusSinglePublisherToDelete(@Context SecurityContext ctx, @CookieParam("user") String userCookie,
@PathParam("id") String id) {
@ -314,33 +293,9 @@ public class PublisherRessources {
return Response.status(status).build();
}
@DELETE
@RolesAllowed("User")
@Transactional
@Path("disable")
public Response changeStatusToDisable(@Context SecurityContext ctx, @CookieParam("user") String userCookie) {
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
UsersEntity user = UsersEntity.findById(kid);
Response.Status status = getResponseCheck(ctx, userCookie, user);
if (status.equals(Response.Status.OK)) {
user.status = -1;
user.updated_at = LocalDateTime.now();
user.deleted_at = LocalDateTime.now();
user.persist();
if (!user.isPersistent()) {
status = Response.Status.NOT_MODIFIED;
}
}
return Response.status(status).build();
}
@DELETE
@Path("/disable/{id}")
@RolesAllowed("Admin")
@RolesAllowed({"Admin", "User"})
@Transactional
public Response changeStatusSinglePublisherToDisable(@Context SecurityContext ctx, @CookieParam("user") String userCookie,
@PathParam("id") String id) {
@ -366,7 +321,7 @@ public class PublisherRessources {
// PATCH
@PATCH
@RolesAllowed("Admin")
@RolesAllowed({"Admin", "User"})
@Consumes(MediaType.APPLICATION_JSON)
@Transactional
@Path("{id}")
@ -404,7 +359,7 @@ public class PublisherRessources {
@PATCH
@RolesAllowed("Admin")
@RolesAllowed({"Admin", "User"})
@Consumes(MediaType.APPLICATION_JSON)
@Transactional
@Path("enable/{id}")
@ -428,30 +383,4 @@ public class PublisherRessources {
return Response.status(status).build();
}
@PATCH
@RolesAllowed("User")
@Consumes(MediaType.APPLICATION_JSON)
@Transactional
public Response updateSingleUser(@Context SecurityContext ctx, @CookieParam("user") String userCookie,
UsersEntity users) {
UUID kid = UUID.fromString(jwt.getClaim(Claims.kid));
UsersEntity user = UsersEntity.findById(kid);
Response.Status status = getResponseCheck(ctx, userCookie, user);
if (status.equals(Response.Status.OK)) {
user.name = users.name;
user.firstName = users.firstName;
user.email = users.email;
user.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(),
users.birth.getDayOfMonth());
user.updated_at = LocalDateTime.now();
user.password = Hash.encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8)));
user.persist();
if (!user.isPersistent()) {
status = Response.Status.NOT_MODIFIED;
}
}
return Response.status(status).build();
}
}