Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
Adrian
/
EjemploDAE2020Cliente
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
71cd62a9
authored
Dec 21, 2020
by
Adrian
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
Añadido edición de detalles de usuario, falta comprobaciones de datos
parent
52348f94
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
8 deletions
nbactions.xml
src/main/java/es/ujaen/dae/ujacoinconsoleclient/client/InterfazAPIRest.java
src/main/java/es/ujaen/dae/ujacoinconsoleclient/client/UjaCoinClient.java
src/main/java/es/ujaen/dae/ujacoinconsoleclient/entidades/DTO/ClienteDTO.java
src/main/java/es/ujaen/dae/ujacoinconsoleclient/util/ErrorInterfaz.java
nbactions.xml
0 → 100644
View file @
71cd62a9
<?xml version="1.0" encoding="UTF-8"?>
<actions>
<action>
<actionName>
run
</actionName>
<packagings>
<packaging>
jar
</packaging>
</packagings>
<goals>
<goal>
process-classes
</goal>
<goal>
org.codehaus.mojo:exec-maven-plugin:1.5.0:exec
</goal>
</goals>
<properties>
<exec.args>
-classpath %classpath es.ujaen.dae.ujacoinconsoleclient.client.Launcher
</exec.args>
<exec.executable>
java
</exec.executable>
</properties>
</action>
</actions>
src/main/java/es/ujaen/dae/ujacoinconsoleclient/client/InterfazAPIRest.java
View file @
71cd62a9
...
...
@@ -13,7 +13,6 @@ import org.apache.http.auth.UsernamePasswordCredentials;
import
org.apache.http.client.CredentialsProvider
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.impl.client.BasicCredentialsProvider
;
import
org.apache.http.impl.client.DefaultHttpClient
;
import
org.apache.http.impl.client.HttpClientBuilder
;
import
org.springframework.http.ResponseEntity
;
import
org.springframework.http.client.ClientHttpRequestFactory
;
...
...
@@ -73,4 +72,25 @@ public class InterfazAPIRest {
return
new
Pair
<>(
ErrorInterfaz
.
OK
,
response
.
getBody
());
}
public
Pair
<
ErrorInterfaz
,
ClienteDTO
>
actualizarCliente
(
ClienteDTO
cliente
)
{
String
url
=
"https://localhost:8080/ujacoin/clientes/{dni}"
;
ResponseEntity
<
ClienteDTO
>
response
=
null
;
try
{
restTemplate
.
put
(
url
,
cliente
,
dni
);
response
=
restTemplate
.
getForEntity
(
url
,
ClienteDTO
.
class
,
dni
);
}
catch
(
Exception
ex
)
{
if
(
ex
instanceof
org
.
springframework
.
web
.
client
.
HttpClientErrorException
&&
ex
.
getMessage
().
startsWith
(
"404"
))
{
return
new
Pair
<>(
ErrorInterfaz
.
ErrorCredenciales
,
null
);
}
else
{
return
new
Pair
<>(
ErrorInterfaz
.
ErrorConexion
,
null
);
}
}
return
new
Pair
<>(
ErrorInterfaz
.
OK
,
response
.
getBody
());
}
}
src/main/java/es/ujaen/dae/ujacoinconsoleclient/client/UjaCoinClient.java
View file @
71cd62a9
...
...
@@ -71,9 +71,9 @@ public class UjaCoinClient {
}
}
while
(
respuesta
.
first
!=
ErrorInterfaz
.
OK
);
usuario
=
respuesta
.
second
;
System
.
out
.
println
(
"Login correcto"
);
menuUsuario
();
...
...
@@ -83,9 +83,9 @@ public class UjaCoinClient {
private
void
menuUsuario
()
{
int
opcion
=
0
;
limpiarConsola
();
do
{
limpiarConsola
();
System
.
out
.
println
(
"Usuario "
+
usuario
.
getNombre
());
System
.
out
.
println
(
"Acciones:"
);
System
.
out
.
println
(
"1->Detalles de usuario."
);
...
...
@@ -127,7 +127,7 @@ public class UjaCoinClient {
}
private
void
menuDetalleUsuario
()
{
int
opcion
=
0
;
limpiarConsola
();
...
...
@@ -151,7 +151,7 @@ public class UjaCoinClient {
switch
(
opcion
)
{
case
1
:
System
.
out
.
println
(
"Opción no implementada, cliente en desarrollo"
);
menuEditarDatos
(
);
break
;
case
2
:
break
;
...
...
@@ -162,7 +162,27 @@ public class UjaCoinClient {
}
}
while
(
opcion
!=
2
);
}
private
void
menuEditarDatos
()
{
System
.
out
.
println
(
"Nueva dirección:"
);
usuario
.
setDireccion
(
scanner
.
nextLine
());
System
.
out
.
println
(
"Nuevo email:"
);
usuario
.
setEmail
(
scanner
.
nextLine
());
System
.
out
.
println
(
"Nuevo teléfono:"
);
usuario
.
setTelefono
(
scanner
.
nextLine
());
//Comprobar datos introducidos antes de enviarlos al servidor
Pair
<
ErrorInterfaz
,
ClienteDTO
>
respuesta
=
interfaz
.
actualizarCliente
(
usuario
);
if
(
respuesta
.
first
==
ErrorInterfaz
.
OK
)
{
usuario
=
respuesta
.
second
;
}
}
private
void
menuCuentas
()
{
...
...
src/main/java/es/ujaen/dae/ujacoinconsoleclient/entidades/DTO/ClienteDTO.java
View file @
71cd62a9
...
...
@@ -87,4 +87,18 @@ public class ClienteDTO {
cuentasAsociadas
.
add
(
tarjeta
);
}
public
void
setDireccion
(
String
direccion
)
{
this
.
direccion
=
direccion
;
}
public
void
setTelefono
(
String
telefono
)
{
this
.
telefono
=
telefono
;
}
public
void
setEmail
(
String
email
)
{
this
.
email
=
email
;
}
}
src/main/java/es/ujaen/dae/ujacoinconsoleclient/util/ErrorInterfaz.java
View file @
71cd62a9
...
...
@@ -12,5 +12,6 @@ package es.ujaen.dae.ujacoinconsoleclient.util;
public
enum
ErrorInterfaz
{
OK
,
ErrorConexion
,
ErrorCredenciales
ErrorCredenciales
,
ErrorFormatoDatos
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment