From a1917179cda6a5b13b7de4550308d76bf27e04ff Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 00:19:20 -0400 Subject: [PATCH 01/12] Update README.md --- README.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ff858ff..924cfb2 100644 --- a/README.md +++ b/README.md @@ -1,11 +1,13 @@

               ReflectWork

-
               version: 0.0.1
+
               version: 0.0.2
-

¿Que es? +

What is it? -ReflectWork es un Framework desarrollado en Java usando la API de Reflection ¿Descriptivo no? +is a Framework, development with Java using the API of Reflection -Dejando el sentido del humor de lado, este trabajo se hizo con la finalidad de ahorrar trabajo repetitivo al desarrollador web, con la finalidad de que se dedique a hacer las funciones que necesita particularmente. ¿Como usarlo? el Framework trabaja estrictamente con Jsons enviados en forma de Raw. Plantea comunicaciones de esa forma

+What's the point? + +To manage an application using Jsons

From fcf4aa2f2334bca23749f9fea274a88f597e3920 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 00:27:05 -0400 Subject: [PATCH 02/12] Update README.md --- README.md | 88 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/README.md b/README.md index 924cfb2..dd7cd9a 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,94 @@ To manage an application using Jsons

+

How to uses this Framework

+ +

Requeriments

+ * Postman
+ * Apache Tomcat
+ * Java EE
+ * IDE with Java EE
+ * PostgreSQL
+ +

1. Create Database

+ + +This is a representation of the database + + +Please create a new database with some name in PostgreSQL, after this, please execute this commands in SQL: + +
Users
+ +```sql +CREATE TABLE users +( + id_users serial NOT NULL primary key, + name_users varchar, + surname_users varchar, + email_users varchar UNIQUE, + password_users char(64), + creationtime_users varchar +) +``` +
Profile
+ +```sql +CREATE TABLE profile +( + id_profile serial NOT NULL primary key, + username_profile varchar UNIQUE +) +``` + +
Profile Users
+ +```sql +CREATE TABLE users_profile +( + id_users_profile serial NOT NULL primary key, + id_profile integer NOT NULL, + id_users integer NOT NULL, + FOREIGN KEY (id_users) REFERENCES users(id_users) + FOREIGN KEY (id_profile) REFERENCES profile(id_profile) +) +``` +
Object
+ +```sql +CREATE TABLE object +( + id_object serial NOT NULL primary key, + name_object integer NOT NULL UNIQUE +) +``` + +
Method
+ +```sql +CREATE TABLE method +( + id_method serial NOT NULL primary key, + name_method integer NOT NULL, + id_object_method integer NOT NULL, + FOREIGN KEY (id_object_method) REFERENCES object(id_object) +) +``` + +
Permissions
+ +```sql +CREATE TABLE permissions +( + id_permissions serial NOT NULL primary key, + id_method_permissions integer NOT NULL, + id_profile_permissions integer NOT NULL, + FOREIGN KEY (id_method_permissions) REFERENCES method(id_method) + FOREIGN KEY (id_profile_permissions) REFERENCES profile(id_profile) +) +``` + +

... objName, methodName, params, types ??? Bienvenido al esquema de trabajo, como es un FrameWork desarrollado en Java, gracias a la API de reflection cuando necesites un metodo en especifico, lo puedes llamar dinamicamente desde un solo endpoint... Por ejemplo ! From f66ee69174b56772dba008e090346189f89f6c57 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 00:32:24 -0400 Subject: [PATCH 03/12] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index dd7cd9a..1ae6fb6 100644 --- a/README.md +++ b/README.md @@ -98,7 +98,11 @@ CREATE TABLE permissions FOREIGN KEY (id_profile_permissions) REFERENCES profile(id_profile) ) ``` +

2. Download Project

+Download this as a zip or clone in your IDE workspace, if you download please unzip this in your IDE workspace. After, open your IDE and import project of projects existing in your workspace + +

3. Configure Project

... objName, methodName, params, types ??? From 7dd76bce2e45f7d769b452e0efa87d089642777b Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:08:46 -0400 Subject: [PATCH 04/12] Update README.md --- README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/README.md b/README.md index 1ae6fb6..6911307 100644 --- a/README.md +++ b/README.md @@ -104,6 +104,18 @@ Download this as a zip or clone in your IDE workspace, if you download please un

3. Configure Project

+Enter in the folder Config and create the .properties files for config_db and config_pool, you need to create this files:

+config_pool.properties
+maxconnections={number};
+hops={number};

+config_db.properties
+db.driver=org.postgresql.Driver; // to use PostgreSQL
+db.url=jdbc:postgresql://localhost:5432/{YourNameDB};
+db.username={YourUsernameDB};
+db.password={PassofUsernameDB};

+ + +

... objName, methodName, params, types ??? Bienvenido al esquema de trabajo, como es un FrameWork desarrollado en Java, gracias a la API de reflection cuando necesites un metodo en especifico, lo puedes llamar dinamicamente desde un solo endpoint... Por ejemplo ! From 96b182537e7a3393f9db90c0f3abfa7c3e319969 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:19:12 -0400 Subject: [PATCH 05/12] Update README.md --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 6911307..5b5c315 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,16 @@ db.password={PassofUsernameDB};

+ +Very important: The database needs the previous tables + +

4. Runs a Server

+ +In your IDE with Java EE, open the project and create a server in servers tab. Use a apache tomcat 8.0 or higher, and add the dynamic web project in server. + + + +

... objName, methodName, params, types ??? Bienvenido al esquema de trabajo, como es un FrameWork desarrollado en Java, gracias a la API de reflection cuando necesites un metodo en especifico, lo puedes llamar dinamicamente desde un solo endpoint... Por ejemplo ! From 7f5272871a3d66d082c07a828872c9a283271f82 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:30:44 -0400 Subject: [PATCH 06/12] Update README.md --- README.md | 196 +++--------------------------------------------------- 1 file changed, 11 insertions(+), 185 deletions(-) diff --git a/README.md b/README.md index 5b5c315..e203938 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ To manage an application using Jsons

-

How to uses this Framework

+

               How to uses this Framework

Requeriments

* Postman
@@ -121,60 +121,23 @@ db.password={PassofUsernameDB};

4. Runs a Server

-In your IDE with Java EE, open the project and create a server in servers tab. Use a apache tomcat 8.0 or higher, and add the dynamic web project in server. +In your IDE with Java EE, open the project and create a server in servers tab. Use a apache tomcat 8.0 or higher, and add the dynamic web project in server. after, start the server. + -

... objName, methodName, params, types ??? - -Bienvenido al esquema de trabajo, como es un FrameWork desarrollado en Java, gracias a la API de reflection cuando necesites un metodo en especifico, lo puedes llamar dinamicamente desde un solo endpoint... Por ejemplo ! - -Metodo registerUser:

- -```java - private JSONManage json_manage = new JSONManage(); - - public JsonObject registerUser(String name, String surname, String email, String password) { - HashPassword hashing = new HashPassword(); - try - { - String hash = hashing.toHashPassword(password); - DBComponent database = Pool.getDBInstance(); - if( database != null) { - Calendar c = new GregorianCalendar(); - String creationtime = "Fecha: " + c.get(Calendar.DAY_OF_MONTH) + "/" - + c.get(Calendar.MONTH) + "/" + c.get(Calendar.YEAR)+ " Hora: " - + Calendar.HOUR_OF_DAY + ":" + Calendar.MINUTE + ":" + Calendar.SECOND; - if( email.contains("@")) { - database.exeSimple(new Query("insert.users", new Object[] {name, surname, email, hash, creationtime})); - Pool.returnDBInstance(database); - return json_manage.ReportSuccessMessage("Welcome "+name+" "+surname+" You're registered !"); - } - else { - Pool.returnDBInstance(database); - return json_manage.ReportErrorMessage("Verify your email address"); - } - } - else { - return json_manage.ReportErrorMessage("Error in database consults"); - } - } catch (NoSuchAlgorithmException | SQLException e) - { - e.printStackTrace(); - return json_manage.ReportErrorMessage(e.getMessage()); - } - } -``` -

Vemos que es un metodo que recibe los datos de un usuario en string, se encarga de verificarlos y meterlos en una base de datos, sencillo... Lo interesante esta, que simplemente no hay que llamarlo en ninguna parte del codigo ¿Y entonces como se ejecuta diras? Pues...

+

5. Test Server

- +Open postman and create new request in POST method to this endpoint: localhost:8080/TeamBackendJava/Dispatcher or localhost:8080/backend_java/Dispatcher, next go to body raw, and write Json, click in send and wait responses.

-

Tu despreocupate de como va a ser llamado el codigo, gracias al Framework esto es posible, simplemente tienes que poner el nombre de tu Clase, el nombre del metodo, los parametros y los tipos... +If the response is a JSON. You're using the Framework
+Else if the response is a status 500 with html, servers finds a big bug
+Else the response is a status 404, server is turn off or isn't the endpoint

-En el ejemplo anterior tenemos el metodo registerUser que se encuentra en la clase Register, y tiene 4 parametros de tipo String

- -

Tipos de Parametros soportados:

+ +The default response with json empty is it

+

               Some Examples

string
byte
double
@@ -187,143 +150,6 @@ Integer
float
-

Adaptando el proyecto a tu PC

-

Creando la base de datos

- -

Para el manejo de los objetos y metodos, necesitamos plantear ese esquema para modo de que el sistema pueda funcionar, el funcionamiento es simple. Al momento de que el servidor arranca, automaticamente carga todos los objetos y metodos que no estan guardados en la base de datos. El objeto de seguridad relaciona un perfil con permisos, donde esos permisos dicen a fin de cuentas que metodos puede manejar y cuales no. - -Nota: Por el momento, como no existen roles, se tienen que agregar los permisos para cada perfil manualmente. -Nota 2: Si el servidor se reinicia y hubo metodos borrados, quedaran registrados en la base de datos. - -Esperamos corregir eso para una proxima version. Siguiendo con el framework, estas son las tablas que necesitamos:

- -

Users

- -```sql -CREATE TABLE users -( - id_users serial NOT NULL primary key, - name_users varchar, - surname_users varchar, - email_users varchar UNIQUE, - password_users char(64), - creationtime_users varchar -) -``` -

Profile

- -```sql -CREATE TABLE profile -( - id_profile serial NOT NULL primary key, - username_profile varchar UNIQUE -) -``` - -

Profile Users

- -```sql -CREATE TABLE users_profile -( - id_users_profile serial NOT NULL primary key, - id_profile integer NOT NULL, - id_users integer NOT NULL, - FOREIGN KEY (id_users) REFERENCES users(id_users) - FOREIGN KEY (id_profile) REFERENCES profile(id_profile) -) -``` -

Object

- -```sql -CREATE TABLE object -( - id_object serial NOT NULL primary key, - name_object integer NOT NULL UNIQUE -) -``` - -

Method

- -```sql -CREATE TABLE method -( - id_method serial NOT NULL primary key, - name_method integer NOT NULL, - id_object_method integer NOT NULL, - FOREIGN KEY (id_object_method) REFERENCES object(id_object) -) -``` - -

Permissions

- -```sql -CREATE TABLE permissions -( - id_permissions serial NOT NULL primary key, - id_method_permissions integer NOT NULL, - id_profile_permissions integer NOT NULL, - FOREIGN KEY (id_method_permissions) REFERENCES method(id_method) - FOREIGN KEY (id_profile_permissions) REFERENCES profile(id_profile) -) -``` - -(!) Algo muy importante: Hay que anexar un perfil Guest, que sera el default de cualquier persona, que usualmente nada mas tendra permiso a metodos de login y register. En la tabla perfil se inserta un perfil llamado GUEST con el ID 1, y a ese perfil le añadiremos permisos mas adelante - -

Cabe destacar de antemano que se necesita tener Java EE y algun IDE de desarrollo... Despues de eso, deberas ir a tu carpeta de proyectos del IDE (en el caso de eclipse el workspace) y Clonar este repositorio, una vez abierto se verá algo asi:

- - -

(!) Es importante que modifiques la URI y coloques donde esta colocado tu proyecto en el workspace.. Ejemplo en windows seria C:/Users/Desktop/eclipse_workspace/backend_java Por ejemplo... de esa URI depende todos los demas archivos. - -Tambien es importante que crees esos 3 archivos de configuracion, segun eso se regiran muchas cosas de la aplicacion

- -

Entendiendo y configurando archivos

- -

config_db.properties

- -```properties -db.driver= (tu driver) -db.url= (url de tu base de datos) -db.username= (username de la base de datos) -db.password= (password de la base de datos) -``` - -

config_querys.properties

- -```properties -insert.object= INSERT INTO object (name_object) VALUES (?); -insert.method= INSERT INTO method (name_method, id_object_method) VALUES (?, ?); -insert.users = INSERT INTO users (name_users, surname_users, email_users, password_users, creationtime_users) VALUES (?, ?, ?, ?, ?); -select.where.name_object=SELECT *FROM object WHERE name_object=?; -select.where.name_method=SELECT *FROM method WHERE name_method=?; -select.where.id_profile=SELECT *FROM profile WHERE id_profile=?; -select.profile=SELECT *FROM profile; -select.permissions=SELECT *FROM permissions; -select.where.id_profile_permissions=SELECT *FROM permissions WHERE id_profile_permissions=?; -select.where.id_method=SELECT *FROM method WHERE id_method=?; -select.where.id_object=SELECT *FROM object WHERE id_object=?; -innerjoin.object.method=SELECT method.id_method, method.name_method, object.name_object FROM method INNER JOIN object ON method.id_object_method = object.id_object; -``` - -

Usualmente esos son los querys que se usan hasta ahora, puedes anexar esos y otros si prefieres.

- - -

config_pool.properties

- -```properties -maxconnections= (maximas conexiones al mismo tiempo para la base de datos) -hops= (instancias creadas al mismo tiempo "mordiscos") -``` - - -

Agregando Permisos

- -

Cuando inicies el servidor por primera vez, si no hay errores, te cargara automaticamente los objetos y metodos en la base de datos... ¿Te acuerdas del usuario GUEST? si no, chequea arriba, si ya lo has hecho. Tienes que agarrar las ID de los metodos que quieras darle permiso al usuario GUEST e insertarlo en la tabla Permisos

- -

Listo!

- -

Ya puedes usarlo enviando y recibiendo jsons, probando creando metodos nuevos que hagan otras cosas. Si llegaste hasta aqui, gracias por apoyarnos. Estaremos avanzando y actualizando mas cosas con el tiempo !!

- -


From 7cbc366e645e64654c204ffe7c3112790ad28f63 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:39:37 -0400 Subject: [PATCH 07/12] Update README.md --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e203938..4c6896a 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@

What is it? -is a Framework, development with Java using the API of Reflection +is a Framework, development with Java using the API of Reflection. You can create classes and methods in one package, and methods and objects has been called dynamically What's the point? @@ -138,6 +138,9 @@ Else the response is a status 404, server is turn off or isn't the endpoint
The default response with json empty is it

               Some Examples

+First, you needs register and login to uses dynamic objs and methods + + string
byte
double
From 484552ff2517070a0ee8ee56469dd4afc8d191f6 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:51:20 -0400 Subject: [PATCH 08/12] Update README.md --- README.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4c6896a..502acd3 100644 --- a/README.md +++ b/README.md @@ -138,9 +138,16 @@ Else the response is a status 404, server is turn off or isn't the endpoint
The default response with json empty is it

               Some Examples

-First, you needs register and login to uses dynamic objs and methods +First, you needs register and login to uses dynamic objs and methods
+ + + +Next, you have session. The servlet needs this params:
+ +Oh well ! Let's try, make a obj and method and restart the server
+ string
byte
double
From 75aa5482e23a56f67767ede12d131066444519a2 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 02:57:41 -0400 Subject: [PATCH 09/12] Update README.md --- README.md | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 502acd3..97ad3b1 100644 --- a/README.md +++ b/README.md @@ -138,16 +138,21 @@ Else the response is a status 404, server is turn off or isn't the endpoint
The default response with json empty is it

               Some Examples

-First, you needs register and login to uses dynamic objs and methods
+

      First, you needs register and login to uses dynamic objs and methods
-Next, you have session. The servlet needs this params:
+

      Next, you have session. The servlet needs this params:

-Oh well ! Let's try, make a obj and method and restart the server
+

      Oh well ! Let's try, make a obj and method and restart the server

+

      But... If you try to uses this method, server says this:

+ +

      You need give permissions in SQL, like this:

+ +

      Note: The objects and methods refresh in DB with server restart

string
byte
double
From 7855f56ce6ed611af7140ca238ff981b23baa687 Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 03:02:55 -0400 Subject: [PATCH 10/12] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 97ad3b1..0361c29 100644 --- a/README.md +++ b/README.md @@ -151,8 +151,10 @@ The default response with json empty is it



      But... If you try to uses this method, server says this:



      You need give permissions in SQL, like this:

- +

      Note: The objects and methods refresh in DB with server restart

+ + string
byte
double
From 659f35456a9dd8234cff8f7b2cfb529da9d9a14e Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 03:05:11 -0400 Subject: [PATCH 11/12] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0361c29..b80aa9c 100644 --- a/README.md +++ b/README.md @@ -154,7 +154,8 @@ The default response with json empty is it



      Note: The objects and methods refresh in DB with server restart

- + +

      And repeat process for method

string
byte
double
From db853dcd19f5b12ea5764b175e5993a74a3216de Mon Sep 17 00:00:00 2001 From: Marcos Fuenmayor <56895143+mdjfs@users.noreply.github.com> Date: Wed, 8 Apr 2020 03:11:43 -0400 Subject: [PATCH 12/12] Update README.md --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b80aa9c..9adae30 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ The default response with json empty is it



      Next, you have session. The servlet needs this params:



      Oh well ! Let's try, make a obj and method and restart the server

- +

      But... If you try to uses this method, server says this:



      You need give permissions in SQL, like this:

@@ -155,7 +155,12 @@ The default response with json empty is it



      Note: The objects and methods refresh in DB with server restart

-

      And repeat process for method

+

      And repeat process for method, next, restart the server

+ +

      Ok, now you have permissions, good !

+

+ +

Types of paramateres supported:

string
byte
double