Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
api-e004
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Pedro Rolon
api-e004
Commits
fbec7745
Commit
fbec7745
authored
Dec 17, 2018
by
Pedro Rolon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
se agregó api key
parent
ba4ae0de
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
35 additions
and
70 deletions
+35
-70
Api-e004/WebContent/vista/js/borrarPunto.js
+3
-0
Api-e004/WebContent/vista/js/buscarPunto.js
+3
-0
Api-e004/WebContent/vista/js/buscarPuntosCercanos.js
+3
-0
Api-e004/WebContent/vista/js/guardarPunto.js
+3
-0
Api-e004/build/classes/controlador/GeoConexion.class
+0
-0
Api-e004/build/classes/controlador/Prueba.class
+0
-0
Api-e004/src/api/GeoApi.java
+16
-0
Api-e004/src/controlador/GeoConexion.java
+4
-8
Api-e004/src/controlador/Prueba.java
+0
-60
README.md
+3
-2
No files found.
Api-e004/WebContent/vista/js/borrarPunto.js
View file @
fbec7745
...
@@ -6,6 +6,9 @@ jQuery(function($){
...
@@ -6,6 +6,9 @@ jQuery(function($){
//url: 'http://192.168.67.126:8095/ApiGeolocalizacion/punto/81', //URL de Albaro
//url: 'http://192.168.67.126:8095/ApiGeolocalizacion/punto/81', //URL de Albaro
url
:
'http://localhost:8080/Api-e004/punto/'
+
$
(
"#idBaja"
).
val
(),
url
:
'http://localhost:8080/Api-e004/punto/'
+
$
(
"#idBaja"
).
val
(),
type
:
"DELETE"
,
type
:
"DELETE"
,
headers
:{
apiKey
:
"pqntslc"
},
//dataType:"json",
//dataType:"json",
success
:
function
(
result
,
textStatus
,
jqXHR
)
{
success
:
function
(
result
,
textStatus
,
jqXHR
)
{
//En result se guarda lo que retorna el servlet
//En result se guarda lo que retorna el servlet
...
...
Api-e004/WebContent/vista/js/buscarPunto.js
View file @
fbec7745
...
@@ -5,6 +5,9 @@ jQuery(function($){
...
@@ -5,6 +5,9 @@ jQuery(function($){
$
.
ajax
({
$
.
ajax
({
url
:
'http://localhost:8080/Api-e004/punto/'
+
$
(
"#idConsulta"
).
val
(),
url
:
'http://localhost:8080/Api-e004/punto/'
+
$
(
"#idConsulta"
).
val
(),
type
:
'GET'
,
type
:
'GET'
,
headers
:{
apiKey
:
"pqntslc"
},
success
:
function
(
result
){
success
:
function
(
result
){
console
.
log
(
result
);
console
.
log
(
result
);
},
},
...
...
Api-e004/WebContent/vista/js/buscarPuntosCercanos.js
View file @
fbec7745
...
@@ -5,6 +5,9 @@ jQuery(function($){
...
@@ -5,6 +5,9 @@ jQuery(function($){
$
.
ajax
({
$
.
ajax
({
url
:
'http://localhost:8080/Api-e004/buscar_puntos'
,
url
:
'http://localhost:8080/Api-e004/buscar_puntos'
,
type
:
'GET'
,
type
:
'GET'
,
headers
:{
apiKey
:
"pqntslc"
},
data
:{
data
:{
"lat"
:
$
(
"#latitudConsulta"
).
val
(),
"lat"
:
$
(
"#latitudConsulta"
).
val
(),
"lon"
:
$
(
'#longitudConsulta'
).
val
()
"lon"
:
$
(
'#longitudConsulta'
).
val
()
...
...
Api-e004/WebContent/vista/js/guardarPunto.js
View file @
fbec7745
...
@@ -8,6 +8,9 @@ jQuery(function($){
...
@@ -8,6 +8,9 @@ jQuery(function($){
url
:
'http://localhost:8080/Api-e004/guardar'
,
url
:
'http://localhost:8080/Api-e004/guardar'
,
type
:
"POST"
,
type
:
"POST"
,
//dataType:"json",
//dataType:"json",
headers
:{
apiKey
:
"pqntslc"
},
data
:{
data
:{
"lat"
:
$
(
"#latitudAlta"
).
val
(),
//-25.2820464,
"lat"
:
$
(
"#latitudAlta"
).
val
(),
//-25.2820464,
"lon"
:
$
(
"#longitudAlta"
).
val
(),
//-57.6129376,
"lon"
:
$
(
"#longitudAlta"
).
val
(),
//-57.6129376,
...
...
Api-e004/build/classes/controlador/GeoConexion.class
View file @
fbec7745
No preview for this file type
Api-e004/build/classes/controlador/Prueba.class
deleted
100644 → 0
View file @
ba4ae0de
File deleted
Api-e004/src/api/GeoApi.java
View file @
fbec7745
...
@@ -23,12 +23,15 @@ import modelo.PuntoGeografico;
...
@@ -23,12 +23,15 @@ import modelo.PuntoGeografico;
@WebServlet
({
"/GeoApi"
,
"/punto/*"
,
"/guardar"
,
"/buscar_puntos"
})
@WebServlet
({
"/GeoApi"
,
"/punto/*"
,
"/guardar"
,
"/buscar_puntos"
})
public
class
GeoApi
extends
HttpServlet
{
public
class
GeoApi
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
private
static
final
long
serialVersionUID
=
1L
;
//El valor del api key
private
String
apiKey
=
"pqntslc"
;
/**
/**
* @see HttpServlet#HttpServlet()
* @see HttpServlet#HttpServlet()
*/
*/
public
GeoApi
()
{
public
GeoApi
()
{
super
();
super
();
// TODO Auto-generated constructor stub
// TODO Auto-generated constructor stub
}
}
...
@@ -36,6 +39,11 @@ public class GeoApi extends HttpServlet {
...
@@ -36,6 +39,11 @@ public class GeoApi extends HttpServlet {
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
*/
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
//Para la validacion del api key
if
(!
request
.
getHeader
(
"apiKey"
).
equals
(
this
.
apiKey
))
response
.
sendError
(
401
,
"El api key es incorrecto"
);
String
url
=
request
.
getRequestURI
();
String
url
=
request
.
getRequestURI
();
String
[]
partes
=
url
.
split
(
"/"
);
String
[]
partes
=
url
.
split
(
"/"
);
...
@@ -135,6 +143,10 @@ public class GeoApi extends HttpServlet {
...
@@ -135,6 +143,10 @@ public class GeoApi extends HttpServlet {
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
*/
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
//Para la validacion del api key
if
(!
request
.
getHeader
(
"apiKey"
).
equals
(
this
.
apiKey
))
response
.
sendError
(
401
,
"El api key es incorrecto"
);
// TODO Auto-generated method stub
// TODO Auto-generated method stub
response
.
setContentType
(
"application/json"
);
response
.
setContentType
(
"application/json"
);
...
@@ -170,6 +182,10 @@ public class GeoApi extends HttpServlet {
...
@@ -170,6 +182,10 @@ public class GeoApi extends HttpServlet {
* @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse)
* @see HttpServlet#doDelete(HttpServletRequest, HttpServletResponse)
*/
*/
protected
void
doDelete
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doDelete
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
//Para la validacion del api key
if
(!
request
.
getHeader
(
"apiKey"
).
equals
(
this
.
apiKey
))
response
.
sendError
(
401
,
"El api key es incorrecto"
);
System
.
out
.
println
(
"Ejecutando el delete"
);
System
.
out
.
println
(
"Ejecutando el delete"
);
//Extrae los parámetros del URL. ya que el url que llama a este servlet es
//Extrae los parámetros del URL. ya que el url que llama a este servlet es
...
...
Api-e004/src/controlador/GeoConexion.java
View file @
fbec7745
...
@@ -4,21 +4,17 @@ package controlador;
...
@@ -4,21 +4,17 @@ package controlador;
* @author pedro rolón
* @author pedro rolón
*/
*/
import
java.util.ArrayList
;
import
java.sql.Connection
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.PreparedStatement
;
import
java.sql.PreparedStatement
;
import
java.sql.ResultSet
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
javax.naming.Context
;
import
javax.naming.Context
;
import
javax.naming.InitialContext
;
import
javax.naming.InitialContext
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
javax.sql.DataSource
;
import
javax.sql.DataSource
;
import
modelo.PuntoGeografico
;
import
modelo.PuntoGeografico
;
...
...
Api-e004/src/controlador/Prueba.java
deleted
100644 → 0
View file @
ba4ae0de
package
controlador
;
import
java.io.IOException
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
import
modelo.PuntoGeografico
;
import
controlador.GeoConexion
;
/**
* Servlet implementation class Prueba
*/
@WebServlet
({
"/Prueba"
,
"/prueba"
,
"/prueba/*"
})
public
class
Prueba
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
/**
* @see HttpServlet#HttpServlet()
*/
public
Prueba
()
{
super
();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
// TODO Auto-generated method stub
response
.
getWriter
().
append
(
"Served at: "
).
append
(
request
.
getContextPath
());
GeoConexion
con
=
new
GeoConexion
();
float
latitud
=-
25.2820216f
;
float
longitud
=-
57.6130814f
;
String
nombre
=
"Cancha de tenis Herminio Gimenez"
;
String
url
=
request
.
getRequestURL
().
toString
();
String
method
=
request
.
getMethod
();
//System.out.println(request.getPathInfo().toString());
System
.
out
.
println
(
method
);
System
.
out
.
println
(
url
);
//hola
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
// TODO Auto-generated method stub
doGet
(
request
,
response
);
}
}
README.md
View file @
fbec7745
# Consideraciones
# Consideraciones
*
El API es un servlet llamado GeoApi, que utiliza la clase GeoConexion para interactuar con la base de datos.
*
El API es un servlet llamado GeoApi, que utiliza la clase GeoConexion para interactuar con la base de datos.
*
El proyecto posee interfaz gráfica, pero para ver lo que retorna es necesario abrir la consola del navegador por el momento.
*
El proyecto posee interfaz gráfica, pero para ver lo que retorna es necesario abrir la consola del navegador por el momento.
\ No newline at end of file
*
El api key es "pqntslc".
\ No newline at end of file
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