From 205f8471bfb56f41acf90b814ae4fcb842bbf37f Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 15 Apr 2022 21:34:45 +0200 Subject: [PATCH] Re-organisation des packages --- .../ApplicationLifeCycle.java | 9 ++++++--- .../covas/{Users.java => Entity/UsersEntity.java} | 15 +++++++-------- src/main/java/com/covas/Enums/Roles.java | 9 +++++++++ src/main/java/com/covas/{ => Json}/Hello.java | 2 +- src/main/java/com/covas/{ => Json}/Jwt2.java | 2 +- src/main/java/com/covas/{ => Json}/Token.java | 2 +- .../covas/{ => Resources}/GreetingResource.java | 2 +- .../com/covas/{ => Resources}/HelloRessource.java | 4 +++- .../com/covas/{ => Resources}/TokenRessource.java | 10 ++++------ 9 files changed, 33 insertions(+), 22 deletions(-) rename src/main/java/com/covas/{ => ApplicationScoped}/ApplicationLifeCycle.java (91%) rename src/main/java/com/covas/{Users.java => Entity/UsersEntity.java} (77%) create mode 100644 src/main/java/com/covas/Enums/Roles.java rename src/main/java/com/covas/{ => Json}/Hello.java (91%) rename src/main/java/com/covas/{ => Json}/Jwt2.java (96%) rename src/main/java/com/covas/{ => Json}/Token.java (96%) rename src/main/java/com/covas/{ => Resources}/GreetingResource.java (90%) rename src/main/java/com/covas/{ => Resources}/HelloRessource.java (91%) rename src/main/java/com/covas/{ => Resources}/TokenRessource.java (94%) diff --git a/src/main/java/com/covas/ApplicationLifeCycle.java b/src/main/java/com/covas/ApplicationScoped/ApplicationLifeCycle.java similarity index 91% rename from src/main/java/com/covas/ApplicationLifeCycle.java rename to src/main/java/com/covas/ApplicationScoped/ApplicationLifeCycle.java index ac09d0e..adac74c 100644 --- a/src/main/java/com/covas/ApplicationLifeCycle.java +++ b/src/main/java/com/covas/ApplicationScoped/ApplicationLifeCycle.java @@ -1,4 +1,4 @@ -package com.covas; +package com.covas.ApplicationScoped; import org.jboss.logging.Logger; @@ -14,6 +14,9 @@ import javax.enterprise.event.Observes; import javax.inject.Inject; import javax.transaction.Transactional; +import com.covas.Entity.UsersEntity; +import com.covas.Enums.Roles; + import org.eclipse.microprofile.config.inject.ConfigProperty; @@ -29,8 +32,8 @@ public class ApplicationLifeCycle { void onStart(@Observes StartupEvent ev) { LOGGER.info("The application has started"); if (schemaCreate){ - Users users = new Users(); - Users users2 = new Users(); + UsersEntity users = new UsersEntity(); + UsersEntity users2 = new UsersEntity(); if(users.findByPseudo("Peter") == null){ diff --git a/src/main/java/com/covas/Users.java b/src/main/java/com/covas/Entity/UsersEntity.java similarity index 77% rename from src/main/java/com/covas/Users.java rename to src/main/java/com/covas/Entity/UsersEntity.java index ab12b47..3f01c85 100644 --- a/src/main/java/com/covas/Users.java +++ b/src/main/java/com/covas/Entity/UsersEntity.java @@ -1,21 +1,20 @@ -package com.covas; +package com.covas.Entity; import java.time.LocalDate; import javax.persistence.Column; import javax.persistence.Entity; +import javax.persistence.Table; + +import com.covas.Enums.Roles; import org.hibernate.annotations.ColumnDefault; import io.quarkus.hibernate.orm.panache.PanacheEntity; -enum Roles { - User, - Admin -} - @Entity -public class Users extends PanacheEntity { +@Table(name = "users") +public class UsersEntity extends PanacheEntity { @Column(nullable = false, unique = true) public String pseudo; @@ -34,7 +33,7 @@ public class Users extends PanacheEntity { public Roles roles; - public static Users findByPseudo(String pseudo){ + public static UsersEntity findByPseudo(String pseudo){ return find("pseudo", pseudo).firstResult(); } diff --git a/src/main/java/com/covas/Enums/Roles.java b/src/main/java/com/covas/Enums/Roles.java new file mode 100644 index 0000000..8185ec4 --- /dev/null +++ b/src/main/java/com/covas/Enums/Roles.java @@ -0,0 +1,9 @@ +package com.covas; + +public enum Roles { + User, + Admin; + Roles(){ + + } +} \ No newline at end of file diff --git a/src/main/java/com/covas/Hello.java b/src/main/java/com/covas/Json/Hello.java similarity index 91% rename from src/main/java/com/covas/Hello.java rename to src/main/java/com/covas/Json/Hello.java index 1250c08..6a5a749 100644 --- a/src/main/java/com/covas/Hello.java +++ b/src/main/java/com/covas/Json/Hello.java @@ -1,4 +1,4 @@ -package com.covas; +package com.covas.Json; import io.quarkus.runtime.annotations.RegisterForReflection; diff --git a/src/main/java/com/covas/Jwt2.java b/src/main/java/com/covas/Json/Jwt2.java similarity index 96% rename from src/main/java/com/covas/Jwt2.java rename to src/main/java/com/covas/Json/Jwt2.java index 7e98745..d20a02d 100644 --- a/src/main/java/com/covas/Jwt2.java +++ b/src/main/java/com/covas/Json/Jwt2.java @@ -1,4 +1,4 @@ -package com.covas; +package com.covas.Json; import io.quarkus.runtime.annotations.RegisterForReflection; diff --git a/src/main/java/com/covas/Token.java b/src/main/java/com/covas/Json/Token.java similarity index 96% rename from src/main/java/com/covas/Token.java rename to src/main/java/com/covas/Json/Token.java index fe6eec7..3efa5c2 100644 --- a/src/main/java/com/covas/Token.java +++ b/src/main/java/com/covas/Json/Token.java @@ -1,4 +1,4 @@ -package com.covas; +package com.covas.Json; import io.quarkus.runtime.annotations.RegisterForReflection; diff --git a/src/main/java/com/covas/GreetingResource.java b/src/main/java/com/covas/Resources/GreetingResource.java similarity index 90% rename from src/main/java/com/covas/GreetingResource.java rename to src/main/java/com/covas/Resources/GreetingResource.java index e40ba8f..312ddc1 100644 --- a/src/main/java/com/covas/GreetingResource.java +++ b/src/main/java/com/covas/Resources/GreetingResource.java @@ -1,4 +1,4 @@ -package com.covas; +package com.covas.Resources; import javax.ws.rs.GET; import javax.ws.rs.Path; diff --git a/src/main/java/com/covas/HelloRessource.java b/src/main/java/com/covas/Resources/HelloRessource.java similarity index 91% rename from src/main/java/com/covas/HelloRessource.java rename to src/main/java/com/covas/Resources/HelloRessource.java index 4b7e99b..87f637e 100644 --- a/src/main/java/com/covas/HelloRessource.java +++ b/src/main/java/com/covas/Resources/HelloRessource.java @@ -1,4 +1,4 @@ -package com.covas; +package com.covas.Resources; import java.util.Collections; import java.util.LinkedHashSet; @@ -11,6 +11,8 @@ import javax.ws.rs.Produces; import javax.ws.rs.core.MediaType; import javax.ws.rs.core.Response; +import com.covas.Json.Hello; + @Consumes(MediaType.APPLICATION_JSON) @Produces(MediaType.APPLICATION_JSON) @Path("/json") diff --git a/src/main/java/com/covas/TokenRessource.java b/src/main/java/com/covas/Resources/TokenRessource.java similarity index 94% rename from src/main/java/com/covas/TokenRessource.java rename to src/main/java/com/covas/Resources/TokenRessource.java index e4142bc..84acce6 100644 --- a/src/main/java/com/covas/TokenRessource.java +++ b/src/main/java/com/covas/Resources/TokenRessource.java @@ -1,16 +1,11 @@ -package com.covas; +package com.covas.Resources; -import java.time.LocalDate; -import java.time.Month; import java.util.Arrays; import java.util.HashSet; -import javax.annotation.PostConstruct; import javax.annotation.security.PermitAll; import javax.annotation.security.RolesAllowed; import javax.inject.Inject; -import javax.transaction.TransactionScoped; -import javax.transaction.Transactional; import javax.ws.rs.CookieParam; import javax.ws.rs.GET; import javax.ws.rs.InternalServerErrorException; @@ -22,6 +17,9 @@ import javax.ws.rs.core.NewCookie; import javax.ws.rs.core.Response; import javax.ws.rs.core.SecurityContext; +import com.covas.Json.Jwt2; +import com.covas.Json.Token; + import io.smallrye.jwt.auth.principal.JWTParser; import io.smallrye.jwt.auth.principal.ParseException; import io.smallrye.jwt.build.Jwt;