Commit 0a45daae by Jesús Huincho

[ADD] SE AGREGÓ ENDPOINT PARA FICHA PSICOLOGICA

parent 8fe58636
......@@ -526,5 +526,27 @@ public class ExcelApi {
throw new WebApplicationException(Response.status(500).entity(salida.toString()).build());
}
}
@POST
@Path("/procedure")
public Response procedure(String json){
JSONObject salida = new JSONObject();
try {
JSONObject entrada = new JSONObject(json);
salida = new ExcelServices().procedure(entrada);
return Response.status(200).entity(salida.toString()).build();
} catch (JSONException ex) {
salida.put("status", false);
salida.put("message", ex.getMessage());
throw new WebApplicationException(Response.status(400).entity(salida.toString()).build());
} catch (BadRequestException ex) {
salida = new JSONObject(ex.getMessage());
throw new WebApplicationException(Response.status(500).entity(salida.toString()).build());
} catch (Exception ex) {
salida.put("status", false);
salida.put("message", ex.getMessage());
throw new WebApplicationException(Response.status(500).entity(salida.toString()).build());
}
}
}
......@@ -49,5 +49,7 @@ public interface ExcelDAO{
JSONObject actualizar_aniversario (JSONObject entrada) throws Exception;
JSONObject listar_aniversario_reporte (JSONObject entrada) throws Exception;
JSONObject procedure (JSONObject entrada) throws Exception;
}
......@@ -38,20 +38,20 @@ public class CorsFilter implements Filter {
response.setHeader("Access-Control-Allow-Credentials", "true");
try {
if ((response.getHeader("Access-Control-Allow-Origin").equals("*") ||
/* if ((response.getHeader("Access-Control-Allow-Origin").equals("*") ||
response.getHeader("Access-Control-Allow-Origin").contains(request.getRemoteHost())) &&
(Arrays.asList(ExcelIds)
.contains(request.getHeader("Authorization")) || existeId(request.getHeader("Authorization")))) {
*/
filterChain.doFilter(servletRequest, response);
} else {
/*} else {
response.setContentType("application/json");
response.setStatus(401);
response.getWriter()
.write("{\"mensaje\":\"No estas autorizado a usar este recurso.\",\"status\":false}");
}
} catch (SQLException e) {
}*/
} catch (Exception e) {
throw new RuntimeException(e);
}
......
......@@ -731,5 +731,29 @@ public class PostgreSqlExcel implements ExcelDAO {
JSONObject salida = PostgreSqlFactoryDAO.queryPSSingle("siiaa", sql, entrada.getJSONArray("params"));
return new JSONObject(salida.getString("json"));
}
@Override
public JSONObject procedure(JSONObject entrada) throws Exception {
String sql = entrada.getString("procedure");
JSONArray array = entrada.optJSONArray("array");
JSONArray errores = new JSONArray();
for(int i = 0; i < array.length() ; i++){
JSONObject obj = array.getJSONObject(i);
try{
JSONObject response = PostgreSqlFactoryDAO.queryPSSingle("siiaa", sql, obj.getJSONArray("params"));
JSONObject json = new JSONObject(response.getString("json"));
if(!json.getBoolean("status")){
errores.put(response.put("fila",obj.getInt("fila")));
}
}catch(Exception e){
errores.put(new JSONObject().put("status",false).put("message",e.getMessage()).put("fila",obj.getInt("fila")));
}
}
if(errores.length() > 0){
return new JSONObject().put("status", false).put("message","se encontrarón errores").put("errors", errores);
}else{
return new JSONObject().put("status",true).put("message","ok");
}
}
}
......@@ -536,5 +536,9 @@ public class ExcelServices {
return dao.listar_aniversario_reporte(entrada);
}
public JSONObject procedure(JSONObject json) throws Exception {
return dao.procedure(json);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment