diff --git a/src/main/java/com/covas/Resources/PublisherRessources.java b/src/main/java/com/covas/Resources/PublisherRessources.java index 07756c7..cbb5164 100644 --- a/src/main/java/com/covas/Resources/PublisherRessources.java +++ b/src/main/java/com/covas/Resources/PublisherRessources.java @@ -372,35 +372,30 @@ public class PublisherRessources { @Consumes(MediaType.APPLICATION_JSON) @Transactional @Path("{id}") - public Response updateUserAdmin(@Context SecurityContext ctx, @CookieParam("user") String userCookie, - UsersEntity users, @PathParam("id") String id) { + public Response updatePublisherAdmin(@Context SecurityContext ctx, @CookieParam("user") String userCookie, + PublisherEntity publishers, @PathParam("id") String id) { 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)) { - UsersEntity usersOrig = UsersEntity.findById(UUID.fromString(id)); - if (usersOrig == null) { + PublisherEntity publishersOrig = PublisherEntity.findById(UUID.fromString(id)); + if (publishersOrig == null) { status = Response.Status.NOT_FOUND; } else { - usersOrig.name = users.name; - usersOrig.firstName = users.firstName; - usersOrig.email = users.email; - usersOrig.birth = LocalDate.of(users.birth.getYear(), users.birth.getMonth(), - users.birth.getDayOfMonth()); - usersOrig.updated_at = LocalDateTime.now(); - if(users.password.length() > 0){ - usersOrig.password = Hash - .encryptSHA512(Base64.toBase64String(users.password.getBytes(StandardCharsets.UTF_8))); + publishersOrig.description = publishers.description; + publishersOrig.url = publishers.url; + publishersOrig.type = publishers.type; + + publishersOrig.updated_at = LocalDateTime.now(); + + if(publishers.status == 1){ + publishersOrig.deleted_at = null; + publishersOrig.status = 1; } - usersOrig.roles = users.roles; - if(users.status == 1){ - usersOrig.deleted_at = null; - usersOrig.status = 1; - } - usersOrig.persist(); - if (!usersOrig.isPersistent()) { + publishersOrig.persist(); + if (!publishersOrig.isPersistent()) { status = Response.Status.NOT_MODIFIED; } } @@ -421,13 +416,13 @@ public class PublisherRessources { Response.Status status = getResponseCheck(ctx, userCookie, user); if (status.equals(Response.Status.OK)) { - UsersEntity usersOrig = UsersEntity.findById(UUID.fromString(id)); - if (usersOrig == null) { + PublisherEntity publishersOrig = PublisherEntity.findById(UUID.fromString(id)); + if (publishersOrig == null) { status = Response.Status.NOT_FOUND; } else { - usersOrig.status = 1; - usersOrig.persist(); - if (!usersOrig.isPersistent()) { + publishersOrig.status = 1; + publishersOrig.persist(); + if (!publishersOrig.isPersistent()) { status = Response.Status.NOT_MODIFIED; } }