Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
Asistencia
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Billy Larru
Asistencia
Commits
7c6150a3
Commit
7c6150a3
authored
Aug 14, 2018
by
Billy Larru
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "modificando js para usar jsp dentro de directorios"
This reverts commit
ebb21f89
.
parent
cde77307
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
256 additions
and
153 deletions
+256
-153
RequestFilter.java
src/main/java/asistencia/filters/RequestFilter.java
+233
-0
RequestsFilter.java
src/main/java/asistencia/filters/RequestsFilter.java
+9
-8
GeneralUtils.java
src/main/java/asistencia/utilities/GeneralUtils.java
+1
-0
sidebar.js
src/main/webapp/js/pages/sidebar.js
+13
-20
registrarhorario.jsp
src/main/webapp/registrarhorario.jsp
+0
-25
controlAsistencia.jsp
src/main/webapp/vistas/administrativos/controlAsistencia.jsp
+0
-25
toleranciaMasiva.jsp
src/main/webapp/vistas/administrativos/toleranciaMasiva.jsp
+0
-25
toleranciaParticular.jsp
...in/webapp/vistas/administrativos/toleranciaParticular.jsp
+0
-25
registrarhorario.jsp
src/main/webapp/vistas/registrarhorario.jsp
+0
-25
No files found.
src/main/java/asistencia/filters/RequestFilter.java
0 → 100644
View file @
7c6150a3
///*
// * To change this license header, choose License Headers in Project Properties.
// * To change this template file, choose Tools | Templates
// * and open the template in the editor.
// */
//package asistencia.filters;
//
//import java.io.IOException;
//import java.io.PrintStream;
//import java.io.PrintWriter;
//import java.io.StringWriter;
//import java.util.ArrayList;
//import java.util.List;
//import javax.servlet.Filter;
//import javax.servlet.FilterChain;
//import javax.servlet.FilterConfig;
//import javax.servlet.ServletException;
//import javax.servlet.ServletRequest;
//import javax.servlet.ServletResponse;
//import javax.servlet.annotation.WebFilter;
//import javax.servlet.http.Cookie;
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import javax.ws.rs.WebApplicationException;
//import javax.ws.rs.core.Response;
//import org.json.JSONArray;
//import org.json.JSONObject;
//import asistencia.config.RequestPath;
//import asistencia.utilities.GeneralUtils;
//import asistencia.utilities.HttpRequest;
//
///**
// *
// * @author sistem08user
// */
//@WebFilter(filterName = "RequestFilter", urlPatterns = {"/*"})
//public class RequestFilter implements Filter {
//
// // The filter configuration object we are associated with. If
// // this value is null, this filter instance is not currently
// // configured.
// private FilterConfig filterConfig = null;
//
// public RequestFilter() {
// }
//
// private void doBeforeProcessing(ServletRequest req, ServletResponse resp, FilterChain chain)
// throws IOException, ServletException {
// HttpServletRequest request = (HttpServletRequest) req;
// HttpServletResponse response = (HttpServletResponse) resp;
// String uri = request.getRequestURI();
//
// if (uri.endsWith("Asistencia") || uri.endsWith("Asistencia/")
// || uri.contains("vistas/index.jsp")
// || uri.contains("plantilla/assets") || uri.endsWith(".js") || uri.endsWith(".css")
// || uri.endsWith(".png") || uri.endsWith(".jpg") || uri.endsWith(".gif")
// || uri.contains("/login") || uri.contains("vistas/redireccionarServlet")
// || uri.contains("vistas/interceptar")) {
// chain.doFilter(request, response);
// } else {
// if (request.getSession().getAttribute("codigo") != null) {
// if (uri.endsWith(".jsp")) {
// HttpSession session = request.getSession();
// HttpRequest httpRequest = new HttpRequest();
// JSONObject valid = null;
// String respuesta = "";
// String auth = "";
// try {
// if (session.getAttribute("Authorization") != null) {
// auth = (String) session.getAttribute("Authorization");
// } else {
// setError(response);
// }
// respuesta = httpRequest.getRespuesta(RequestPath.VERIFICAR_LOGIN, HttpRequest.POST, new JSONObject("{}"), auth);
// valid = new JSONObject(respuesta);
// if (valid.getBoolean("status")) {
// JSONObject menu = new JSONObject(valid.getString("menu"));//Obtiene el menu
// List<Object> vistas = new ArrayList<>();
// JSONObject rolvista = valid.getJSONObject("rolvista");
// JSONArray urls = rolvista.getJSONArray("vistas");
// for (int i = 0; i < urls.length(); i++) {
// vistas.add(urls.get(i));
// }
// vistas.add("main.jsp");
// String ruta = request.getRequestURI();
// int indice = GeneralUtils.obtenerIndex(ruta);
// String rutaJsp = ruta.substring(indice, ruta.length());
// boolean acceso = vistas.contains(rutaJsp);
// if (!acceso) {
// request.getSession().setAttribute("error", "no tiene acceso a la vista solicitada");//Esta session se elimina en el jsp (para que no ocupe memoria)
//// request.getRequestDispatcher("/vistas/error.jsp").forward(request, response);
// response.sendRedirect("error/error.jsp");
// return;
// }
// session.setAttribute("menu", menu.toString());
// } else {
// deleteCredenciales(response, request);
// request.getSession().setAttribute("error", "no tiene credenciales validas");
//// request.getRequestDispatcher("/vistas/error.jsp").forward(request, response);
// response.sendRedirect("error/error.jsp");
// return;
//// setError(response);
// }
// } catch (Exception ex) {
// request.getSession().setAttribute("error", ex.getMessage());
//// request.getRequestDispatcher("/vistas/error.jsp").forward(request, response);
// response.sendRedirect("error/error.jsp");
// return;
//// setError(response);
// }
// }
// chain.doFilter(request, response);
// } else {
// deleteCredenciales(response, request);
// response.sendRedirect("index.jsp");
// }
// }
// }
//
// private void deleteCredenciales(HttpServletResponse response, HttpServletRequest request) {
// Cookie cookieAuth = new Cookie("Authorization", "");
// cookieAuth.setMaxAge(0);
// request.getSession().invalidate();
// response.addCookie(cookieAuth);
// }
//
// private void sendError(HttpServletResponse response) throws IOException {
// response.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
// response.sendError(401);
// }
//
// public void setError(HttpServletResponse response) throws IOException {
// Response.ResponseBuilder builder = null;
// sendError(response);
// builder = Response.status(Response.Status.UNAUTHORIZED).entity(response);
// throw new WebApplicationException(builder.build());
// }
//
// private void doAfterProcessing(ServletRequest request, ServletResponse response)
// throws IOException, ServletException {
//
// }
//
// public void doFilter(ServletRequest req, ServletResponse resp,
// FilterChain chain)
// throws IOException, ServletException {
// System.out.println("Entrando al filtro");
// doBeforeProcessing(req, resp, chain);
//
//// chain.doFilter(req, resp);
// doAfterProcessing(req, resp);
//
// }
//
// /**
// * Return the filter configuration object for this filter.
// */
// public FilterConfig getFilterConfig() {
// return (this.filterConfig);
// }
//
// /**
// * Set the filter configuration object for this filter.
// *
// * @param filterConfig The filter configuration object
// */
// public void setFilterConfig(FilterConfig filterConfig) {
// this.filterConfig = filterConfig;
// }
//
// /**
// * Destroy method for this filter
// */
// public void destroy() {
// }
//
// /**
// * Init method for this filter
// */
// public void init(FilterConfig filterConfig) {
//
// }
//
// private void sendProcessingError(Throwable t, ServletResponse response) {
// String stackTrace = getStackTrace(t);
//
// if (stackTrace != null && !stackTrace.equals("")) {
// try {
// response.setContentType("text/html");
// PrintStream ps = new PrintStream(response.getOutputStream());
// PrintWriter pw = new PrintWriter(ps);
// pw.print("<html>\n<head>\n<title>Error</title>\n</head>\n<body>\n"); //NOI18N
//
// // PENDING! Localize this for next official release
// pw.print("<h1>The resource did not process correctly</h1>\n<pre>\n");
// pw.print(stackTrace);
// pw.print("</pre></body>\n</html>"); //NOI18N
// pw.close();
// ps.close();
// response.getOutputStream().close();
// } catch (Exception ex) {
// }
// } else {
// try {
// PrintStream ps = new PrintStream(response.getOutputStream());
// t.printStackTrace(ps);
// ps.close();
// response.getOutputStream().close();
// } catch (Exception ex) {
// }
// }
// }
//
// public static String getStackTrace(Throwable t) {
// String stackTrace = null;
// try {
// StringWriter sw = new StringWriter();
// PrintWriter pw = new PrintWriter(sw);
// t.printStackTrace(pw);
// pw.close();
// sw.close();
// stackTrace = sw.getBuffer().toString();
// } catch (Exception ex) {
// }
// return stackTrace;
// }
//
// public void log(String msg) {
// filterConfig.getServletContext().log(msg);
// }
//
//}
src/main/java/asistencia/filters/RequestsFilter.java
View file @
7c6150a3
...
...
@@ -47,7 +47,7 @@ public class RequestsFilter implements Filter {
String
uri
=
request
.
getRequestURI
();
if
(
uri
.
endsWith
(
"vistas/index.jsp"
))
{
if
(
request
.
getSession
().
getAttribute
(
"codigo"
)
!=
null
)
{
response
.
sendRedirect
(
request
.
getContextPath
()
+
"/vistas/
main.jsp"
);
response
.
sendRedirect
(
"
main.jsp"
);
return
;
}
chain
.
doFilter
(
req
,
resp
);
...
...
@@ -75,30 +75,31 @@ public class RequestsFilter implements Filter {
for
(
int
i
=
0
;
i
<
urls
.
length
();
i
++)
{
vistas
.
add
(
urls
.
get
(
i
));
}
vistas
.
add
(
"main.jsp"
);
String
ruta
=
request
.
getRequestURI
();
// int indice = GeneralUtils.obtenerIndex(ruta);
// String rutaJsp = ruta.substring(indice, ruta.length());
String
rutaJsp
=
GeneralUtils
.
obtenerURIvista
(
ruta
);
System
.
out
.
println
(
"Ruta: "
+
ruta
);
System
.
out
.
println
(
"rutajsp: "
+
rutaJsp
);
System
.
out
.
println
(
"Ruta: "
+
ruta
);
System
.
out
.
println
(
"rutajsp: "
+
rutaJsp
);
System
.
out
.
println
(
vistas
);
boolean
acceso
=
vistas
.
contains
(
rutaJsp
);
System
.
out
.
println
(
acceso
);
if
(!
acceso
)
{
request
.
getSession
().
setAttribute
(
"error"
,
"no tiene acceso a la vista solicitada"
);
//Esta session se elimina en el jsp (para que no ocupe memoria)
request
.
getRequestDispatcher
(
request
.
getContextPath
()
+
"/vistas/error.jsp"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/vistas/error.jsp"
).
forward
(
request
,
response
);
return
;
}
session
.
setAttribute
(
"menu"
,
menu
.
toString
());
}
else
{
deleteCredenciales
(
response
,
request
);
request
.
getSession
().
setAttribute
(
"error"
,
"no tiene credenciales validas"
);
request
.
getRequestDispatcher
(
request
.
getContextPath
()
+
"/vistas/error.jsp"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/vistas/error.jsp"
).
forward
(
request
,
response
);
return
;
}
}
catch
(
Exception
ex
)
{
request
.
getSession
().
setAttribute
(
"error"
,
ex
.
getMessage
());
request
.
getRequestDispatcher
(
request
.
getContextPath
()
+
"/vistas/error.jsp"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/vistas/error.jsp"
).
forward
(
request
,
response
);
return
;
}
}
...
...
@@ -106,7 +107,7 @@ public class RequestsFilter implements Filter {
}
else
{
deleteCredenciales
(
response
,
request
);
request
.
getSession
().
setAttribute
(
"error"
,
"no tiene una sesion activa"
);
request
.
getRequestDispatcher
(
request
.
getContextPath
()
+
"/vistas/error.jsp"
).
forward
(
request
,
response
);
request
.
getRequestDispatcher
(
"/vistas/error.jsp"
).
forward
(
request
,
response
);
}
}
}
...
...
src/main/java/asistencia/utilities/GeneralUtils.java
View file @
7c6150a3
...
...
@@ -37,6 +37,7 @@ public class GeneralUtils {
if
(
matcher
.
find
())
{
rutaVista
=
matcher
.
group
(
1
);
}
System
.
out
.
println
(
rutaVista
);
return
rutaVista
;
}
}
src/main/webapp/js/pages/sidebar.js
View file @
7c6150a3
...
...
@@ -6,9 +6,8 @@ const DOMSideBar = {
},
setMenu
()
{
let
location
=
window
.
location
;
// let position = getUrl(location.pathname, "/");
// let path = location.pathname.substring(position + 1);//obtiene el nombre de la vista jsp para activar la clase .active
let
path
=
getUrl
(
location
.
href
);
let
position
=
getUrl
(
location
.
pathname
,
"/"
);
let
path
=
location
.
pathname
.
substring
(
position
+
1
);
//obtiene el nombre de la vista jsp para activar la clase .active
let
menu
=
document
.
getElementById
(
"MENU"
);
let
c
=
window
.
sidebar
;
//obtiene el menu
console
.
log
(
c
)
...
...
@@ -16,7 +15,6 @@ const DOMSideBar = {
let
html
=
""
;
let
active
=
""
;
/* Recorrer titulos */
debugger
;
for
(
var
i
in
contenido
)
{
let
titulo
=
contenido
[
i
].
titulo
;
html
+=
`<li class="navigation-header"><span><i class="fa
${
titulo
.
ico
}
fa-lg" title="Main pages"></i>
${
titulo
.
nombre
}
</span></li>`
;
...
...
@@ -45,7 +43,7 @@ const DOMSideBar = {
}
else
{
active
=
''
;
}
html
+=
`<li class="
${
active
}
"><a href="
${
contextPath
}
vistas/
${
subcategoria
[
l
].
url
}
"><span>
${
primeraLetraMayuscula
(
subcategoria
[
l
].
nombre
)}
</span></a></li>`
;
html
+=
`<li class="
${
active
}
"><a href="
${
subcategoria
[
l
].
url
}
"><span>
${
primeraLetraMayuscula
(
subcategoria
[
l
].
nombre
)}
</span></a></li>`
;
}
html
+=
`</li></ul>`
;
}
else
{
...
...
@@ -70,21 +68,15 @@ const DOMSideBar = {
logOut
();
}
}
//let getUrl = (pathname, caracter) => {
// let position = 0;
// for (let i = pathname.length - 1; i > 0; i--) {
// if (pathname[i] === caracter) {
// position = i;
// break;
// }
// }
// return position;
//}
let
getUrl
=
path
=>
{
let
pattern
=
"^(?:.*)/vistas/(.*)$"
;
let
match
=
path
.
match
(
pattern
);
return
match
[
1
];
let
getUrl
=
(
pathname
,
caracter
)
=>
{
let
position
=
0
;
for
(
let
i
=
pathname
.
length
-
1
;
i
>
0
;
i
--
)
{
if
(
pathname
[
i
]
===
caracter
)
{
position
=
i
;
break
;
}
}
return
position
;
}
DOMSideBar
.
init
();
\ No newline at end of file
src/main/webapp/registrarhorario.jsp
deleted
100644 → 0
View file @
cde77307
<jsp:include
page=
"/vistas/templates/validar.jsp"
/>
<
%@
page
contentType=
"text/html"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<jsp:include
page=
"/vistas/templates/header.jsp"
/>
<!--template-core-->
<!--css de la pagina-->
<!--css-->
</head>
<body>
<jsp:include
page=
"/vistas/templates/header-body.jsp"
/>
<!-- content -->
<!-- / content -->
<jsp:include
page=
"/vistas/templates/footer-body.jsp"
/>
<!--js de la pagina-->
<!--<script src="${pageContext.request.contextPath}/plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>-->
<!--js-->
</body>
</html>
\ No newline at end of file
src/main/webapp/vistas/administrativos/controlAsistencia.jsp
deleted
100644 → 0
View file @
cde77307
<jsp:include
page=
"/vistas/templates/validar.jsp"
/>
<
%@
page
contentType=
"text/html"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<jsp:include
page=
"/vistas/templates/header.jsp"
/>
<!--template-core-->
<!--css de la pagina-->
<!--css-->
</head>
<body>
<jsp:include
page=
"/vistas/templates/header-body.jsp"
/>
<!-- content -->
<!-- / content -->
<jsp:include
page=
"/vistas/templates/footer-body.jsp"
/>
<!--js de la pagina-->
<!--<script src="${pageContext.request.contextPath}/plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>-->
<!--js-->
</body>
</html>
\ No newline at end of file
src/main/webapp/vistas/administrativos/toleranciaMasiva.jsp
deleted
100644 → 0
View file @
cde77307
<jsp:include
page=
"/vistas/templates/validar.jsp"
/>
<
%@
page
contentType=
"text/html"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<jsp:include
page=
"/vistas/templates/header.jsp"
/>
<!--template-core-->
<!--css de la pagina-->
<!--css-->
</head>
<body>
<jsp:include
page=
"/vistas/templates/header-body.jsp"
/>
<!-- content -->
<!-- / content -->
<jsp:include
page=
"/vistas/templates/footer-body.jsp"
/>
<!--js de la pagina-->
<!--<script src="${pageContext.request.contextPath}/plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>-->
<!--js-->
</body>
</html>
\ No newline at end of file
src/main/webapp/vistas/administrativos/toleranciaParticular.jsp
deleted
100644 → 0
View file @
cde77307
<jsp:include
page=
"/vistas/templates/validar.jsp"
/>
<
%@
page
contentType=
"text/html"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<jsp:include
page=
"/vistas/templates/header.jsp"
/>
<!--template-core-->
<!--css de la pagina-->
<!--css-->
</head>
<body>
<jsp:include
page=
"/vistas/templates/header-body.jsp"
/>
<!-- content -->
<!-- / content -->
<jsp:include
page=
"/vistas/templates/footer-body.jsp"
/>
<!--js de la pagina-->
<!--<script src="${pageContext.request.contextPath}/plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>-->
<!--js-->
</body>
</html>
\ No newline at end of file
src/main/webapp/vistas/registrarhorario.jsp
deleted
100644 → 0
View file @
cde77307
<jsp:include
page=
"/vistas/templates/validar.jsp"
/>
<
%@
page
contentType=
"text/html"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<jsp:include
page=
"/vistas/templates/header.jsp"
/>
<!--template-core-->
<!--css de la pagina-->
<!--css-->
</head>
<body>
<jsp:include
page=
"/vistas/templates/header-body.jsp"
/>
<!-- content -->
<!-- / content -->
<jsp:include
page=
"/vistas/templates/footer-body.jsp"
/>
<!--js de la pagina-->
<!--<script src="${pageContext.request.contextPath}/plantilla/assets/js/plugins/tables/datatables/datatables.min.js" type="text/javascript"></script>-->
<!--js-->
</body>
</html>
\ 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