Commit 57b5d9449ed30dba3a8b311482545dc45aa1571a
1 parent
3005fcc0
Exists in
master
Web Service.
Showing
8 changed files
with
330 additions
and
421 deletions
Show diff stats
src/main/java/br/com/ases/business/impl/AvaliacaoBusinessImpl.java
... | ... | @@ -158,10 +158,10 @@ public class AvaliacaoBusinessImpl implements AvaliacaoBusiness { |
158 | 158 | String[] chaveValor; |
159 | 159 | String recomendacaoProperties = ""; |
160 | 160 | String recomendacaoAntiga = ""; // Serve identificar a mudan�a de recomenda��o |
161 | - String recomendacao = ""; | |
161 | + //String recomendacao = ""; | |
162 | 162 | String criterioProperties = ""; |
163 | - String criterio = ""; | |
164 | - String criterioAntido = ""; | |
163 | + //String criterio = ""; | |
164 | + //String criterioAntido = ""; | |
165 | 165 | String recomendacaoCriterio[]; |
166 | 166 | String tipoTeste = ""; |
167 | 167 | String tipoBusca = ""; |
... | ... | @@ -174,7 +174,7 @@ public class AvaliacaoBusinessImpl implements AvaliacaoBusiness { |
174 | 174 | Integer totalErros = 0; |
175 | 175 | Integer totalAvisos = 0; |
176 | 176 | Boolean isErro; |
177 | - Boolean recomendacaoTemCriterio = false; | |
177 | + //Boolean recomendacaoTemCriterio = false; | |
178 | 178 | |
179 | 179 | try { |
180 | 180 | |
... | ... | @@ -398,45 +398,6 @@ public class AvaliacaoBusinessImpl implements AvaliacaoBusiness { |
398 | 398 | int qtdLinhas = 0; |
399 | 399 | |
400 | 400 | |
401 | - | |
402 | - /* | |
403 | - * for(Integer rn : rns){ //Recomenda��o Avaliada // | |
404 | - * postParams.addParam | |
405 | - * ("relatorioAvaliacao.recomendacoes["+countReq+"].idRecomendacao", | |
406 | - * Integer.toString((rn))); | |
407 | - * | |
408 | - * int qtdErros = 0; | |
409 | - * | |
410 | - * | |
411 | - * | |
412 | - * for(SummarizedOccurrence occurence : occurrences){ String[] idRec | |
413 | - * = occurence.getCheckPoint().split("\\."); | |
414 | - * | |
415 | - * | |
416 | - * qtdLinhas = qtdLinhas + occurence.getLines().size(); | |
417 | - * | |
418 | - * //Critérios | |
419 | - * | |
420 | - * | |
421 | - * | |
422 | - * if(rn == Integer.parseInt(idRec[0])){ | |
423 | - * | |
424 | - * qtdErros = qtdErros + Integer.parseInt(occurence.isError()?occurence.getNumberOfOccurrences():"0"); | |
425 | - * postParams.addParam("relatorioAvaliacao.recomendacoes["+countReq+"].criterios["+countCriterio+"].idCriterio",idRec[1]) | |
426 | - * .addParam("relatorioAvaliacao.recomendacoes["+countReq+"].criterios["+countCriterio+"].qtdeErros",occurence.isError()?occurence.getNumberOfOccurrences():"0") | |
427 | - * .addParam("relatorioAvaliacao.recomendacoes["+countReq+"].criterios["+countCriterio+"].qtdeItens",Integer.toString(occurence.getLines().size())); | |
428 | - * | |
429 | - * | |
430 | - * }else countCriterio = 0; | |
431 | - * | |
432 | - * countCriterio++; } | |
433 | - * | |
434 | - * postParams.addParam("relatorioAvaliacao.recomendacoes["+countReq+"].totalErros", Integer.toString(qtdErros)); | |
435 | - * //postParams.addParam("relatorioAvaliacao.qtdeLinhas",Integer.toString(qtdLinhas)); countReq++; | |
436 | - * | |
437 | - * } | |
438 | - */ | |
439 | - | |
440 | 401 | postParams.addParam("relatorioAvaliacao.qtdeLinhas", Integer.toString(qtdLinhas)); |
441 | 402 | |
442 | 403 | Gson g = new GsonBuilder().create(); |
... | ... | @@ -449,36 +410,7 @@ public class AvaliacaoBusinessImpl implements AvaliacaoBusiness { |
449 | 410 | |
450 | 411 | return nota; |
451 | 412 | |
452 | - /* | |
453 | - * Nota nota = null ; //Vers�o desenvolvida por Rodrigo try { | |
454 | - * WebChecker.PostParams postParams = | |
455 | - * WebChecker.from(CALCULAR_NOTA_REST).withPostRequest() | |
456 | - * .addParam("avaliationReport.url", url) | |
457 | - * .addParam("avaliationReport.date", | |
458 | - * "2014-04-24 10:07:02.447 GMT-03:00"); | |
459 | - * | |
460 | - * int index = 0; for(SummarizedOccurrence occurence : occurrences){ | |
461 | - * postParams | |
462 | - * .addParam("avaliationReport.checkPoints["+index+"].identificador", | |
463 | - * occurence.getCheckPoint()) | |
464 | - * .addParam("avaliationReport.checkPoints["+index+"].totalErrors", | |
465 | - * occurence.isError()?occurence.getNumberOfOccurrences():"0") | |
466 | - * .addParam("avaliationReport.checkPoints["+index+"].totalWarnings", | |
467 | - * ((!occurence.isError() && | |
468 | - * !occurence.getNumberOfOccurrences().equals(SummarizedOccurrence | |
469 | - * .EMPTY_LINES) )?occurence.getNumberOfOccurrences():"0")); index++; } | |
470 | - * | |
471 | - * System.out.println(this.eseloProperties.getUrl("url")); | |
472 | - * System.out.println(postParams.execute().getContent()); | |
473 | - * | |
474 | - * Gson g = new GsonBuilder().create(); nota = | |
475 | - * g.fromJson(postParams.execute().getContent(), Nota.class); | |
476 | - * | |
477 | - * }catch(Exception e){ nota = new EseloController(null).new Nota(url, | |
478 | - * "---" , "0.0"); } | |
479 | - * | |
480 | - * return nota; | |
481 | - */ | |
413 | + | |
482 | 414 | } |
483 | 415 | |
484 | 416 | // Passa a recomenda��o do Ases como chave e retorna a recomenda��o do Eselo | ... | ... |
src/main/java/br/com/ases/controller/AvaliacaoController.java
... | ... | @@ -29,6 +29,8 @@ import java.util.regex.Pattern; |
29 | 29 | import javax.servlet.ServletContext; |
30 | 30 | import javax.ws.rs.QueryParam; |
31 | 31 | |
32 | +import org.apache.poi.hssf.record.PageBreakRecord.Break; | |
33 | + | |
32 | 34 | import net.sf.jasperreports.engine.JRException; |
33 | 35 | import br.com.ases.business.AvaliacaoBusiness; |
34 | 36 | import br.com.ases.controller.EseloController.Nota; |
... | ... | @@ -60,6 +62,7 @@ import br.com.caelum.vraptor.Validator; |
60 | 62 | import br.com.caelum.vraptor.interceptor.download.FileDownload; |
61 | 63 | import br.com.caelum.vraptor.interceptor.multipart.UploadedFile; |
62 | 64 | import br.com.caelum.vraptor.ioc.spring.VRaptorRequestHolder; |
65 | +import br.com.caelum.vraptor.validator.Message; | |
63 | 66 | import br.com.caelum.vraptor.view.Results; |
64 | 67 | import br.com.checker.emag.Occurrence; |
65 | 68 | import br.com.checker.emag.OccurrenceClassification; |
... | ... | @@ -95,7 +98,7 @@ public class AvaliacaoController { |
95 | 98 | private ServletContext application; |
96 | 99 | private DetalheAvaliacao detalheAvaliacao; |
97 | 100 | private UtilitiesProperties utilitiesProperties; |
98 | - //private StringBuffer xml; | |
101 | + // private StringBuffer xml; | |
99 | 102 | private CriterioProperties criterioProperties; |
100 | 103 | private String chaveIdentificaAvaliacao; |
101 | 104 | private String novaChave; |
... | ... | @@ -971,7 +974,7 @@ public class AvaliacaoController { |
971 | 974 | AvaliacaoAutomatica avaliacaoAutomatica = new AvaliacaoAutomatica(); |
972 | 975 | ErroWs erroWs = new ErroWs(); |
973 | 976 | this.dataHoraAvaliacao = (String) DateUtil.dataHoraAtual(); |
974 | - | |
977 | + | |
975 | 978 | WebChecker.PostParams postParams = |
976 | 979 | WebChecker.from(this.eseloProperties.getUrl("urlAutenticacaoServico")).withPostRequest(); |
977 | 980 | postParams.addParam("codigoHash", codigoHash); |
... | ... | @@ -979,270 +982,263 @@ public class AvaliacaoController { |
979 | 982 | Gson g = new GsonBuilder().create(); |
980 | 983 | |
981 | 984 | Boolean usuarioAutorizado = g.fromJson(postParams.execute().getContent(), Boolean.class); |
982 | - | |
983 | - // UsuarioServicoWeb usuario = g.fromJson(postParams.execute().getContent(), | |
984 | - // UsuarioServicoWeb.class); | |
985 | - // g.fromJson(content, UsuarioServicoWeb.class); | |
986 | 985 | |
987 | - //xml = new StringBuffer(); | |
988 | 986 | |
989 | - if (usuarioAutorizado) { | |
990 | - // tipoSaida deve ser "json" ou "xml"; | |
991 | - try { | |
987 | + if (url == null || tipoSaida == null || codigoHash == null ||(!tipoSaida.equalsIgnoreCase("xml") | |
988 | + && !tipoSaida.equalsIgnoreCase("json"))) { | |
989 | + | |
990 | + erroWs.setDataHora(this.dataHoraAvaliacao); | |
992 | 991 | |
993 | - Validate validate = new Validate(this.validator); | |
992 | + List<String> mensagensErros = new ArrayList<String>(); | |
994 | 993 | |
995 | - if (validate.url(url)) { | |
994 | + if (url == null) | |
995 | + { | |
996 | + erroWs.setUrl(""); | |
997 | + mensagensErros.add("Favor, verificar o parâmetro 'url'!"); | |
998 | + } | |
999 | + else | |
1000 | + { | |
1001 | + erroWs.setUrl(url); | |
1002 | + } | |
1003 | + if (tipoSaida == null||(!tipoSaida.equalsIgnoreCase("xml") | |
1004 | + && !tipoSaida.equalsIgnoreCase("json"))) | |
1005 | + { | |
1006 | + mensagensErros.add("Favor, verificar o parâmetro 'tipoSaida'!"); | |
1007 | + } | |
1008 | + if (codigoHash == null) | |
1009 | + { | |
1010 | + mensagensErros.add("Há necessidade de autorização de serviço por meio código hash!"); | |
1011 | + } | |
1012 | + | |
1013 | + erroWs.setMensagem(mensagensErros); | |
996 | 1014 | |
997 | - if (url.startsWith("www")) { | |
998 | - url = "http://" + url; | |
999 | - } | |
1015 | + if(tipoSaida == null || (!tipoSaida.equalsIgnoreCase("xml") | |
1016 | + && !tipoSaida.equalsIgnoreCase("json"))) | |
1017 | + { | |
1018 | + result.use(Results.xml()).from(erroWs).recursive().serialize(); | |
1019 | + }else if (tipoSaida.equalsIgnoreCase("json")) { | |
1020 | + result.use(Results.json()).withoutRoot().from(erroWs).recursive().serialize(); | |
1021 | + } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1022 | + result.use(Results.xml()).from(erroWs).recursive().serialize(); | |
1023 | + } | |
1024 | + } else { | |
1025 | + if (usuarioAutorizado) { | |
1026 | + // tipoSaida deve ser "json" ou "xml"; | |
1027 | + try { | |
1000 | 1028 | |
1001 | - WebChecker pagina = WebChecker.from(url).withGetRequest().execute(); | |
1029 | + Validate validate = new Validate(this.validator); | |
1002 | 1030 | |
1003 | - int[] errorsWarningsCss = avaliacaoBusiness.getErrorCount(true, url); | |
1004 | - int[] errorsWarningsHtml = avaliacaoBusiness.getErrorCount(false, url); | |
1031 | + if (validate.url(url)) { | |
1005 | 1032 | |
1006 | - Checker checker = from(pagina.getContent(), url); | |
1033 | + if (url.startsWith("www")) { | |
1034 | + url = "http://" + url; | |
1035 | + } | |
1007 | 1036 | |
1008 | - checker.with(marking()); | |
1009 | - checker.with(content()); | |
1010 | - checker.with(presentation()); | |
1011 | - checker.with(multimedia()); | |
1012 | - checker.with(form()); | |
1013 | - checker.with(behavior()); | |
1014 | 1037 | |
1015 | - Pattern pp = Pattern.compile("(http://www.)?([a-z]*)(.)?"); | |
1016 | - Matcher mm = pp.matcher(url.toLowerCase().replace("https", "http")); | |
1017 | 1038 | |
1018 | - if (mm.find()) { | |
1019 | - this.tituloSite = ""; | |
1020 | - } | |
1039 | + WebChecker pagina = WebChecker.from(url).withGetRequest().execute(); | |
1021 | 1040 | |
1022 | - ContentEvaluation conteudo = new ContentEvaluation(checker.getDocument()); | |
1041 | + int[] errorsWarningsCss = avaliacaoBusiness.getErrorCount(true, url); | |
1042 | + int[] errorsWarningsHtml = avaliacaoBusiness.getErrorCount(false, url); | |
1023 | 1043 | |
1024 | - this.tituloSite = conteudo.retornarTituloSiteAvaliado(); | |
1044 | + Checker checker = from(pagina.getContent(), url); | |
1025 | 1045 | |
1026 | - Nota nota = null; | |
1046 | + checker.with(marking()); | |
1047 | + checker.with(content()); | |
1048 | + checker.with(presentation()); | |
1049 | + checker.with(multimedia()); | |
1050 | + checker.with(form()); | |
1051 | + checker.with(behavior()); | |
1027 | 1052 | |
1028 | - List<Entry<OccurrenceKey, List<Occurrence>>> mapaListaOcorrencias = | |
1029 | - avaliacaoBusiness.retornarCriteriosTeste(checker.check()); | |
1053 | + Pattern pp = Pattern.compile("(http://www.)?([a-z]*)(.)?"); | |
1054 | + Matcher mm = pp.matcher(url.toLowerCase().replace("https", "http")); | |
1030 | 1055 | |
1031 | - nota = avaliacaoBusiness.obterNotaEselo(checker.getDocument(), url, mapaListaOcorrencias); | |
1032 | - | |
1033 | - this.sumarizarResultasNoResponse(checker.checkSumarized(), result); | |
1034 | - | |
1035 | - this.detalheAvaliacao.inicializar(avaliacaoBusiness.retornarCriterios(checker.check()), | |
1036 | - errorsWarningsCss, errorsWarningsHtml); | |
1037 | - | |
1038 | - | |
1039 | - | |
1040 | - List<SummarizedOccurrence> checkSumarized = checker.checkSumarized(); | |
1041 | - | |
1042 | - avisosFerramentasHtmlCssW3c = new ArrayList<String>(); | |
1043 | - List<ResumoAvaliacao> resumoErrosAvisos = obterResumoAvaliacao(); | |
1044 | - | |
1045 | - // pegar os dados e montar o xml | |
1046 | - // List<Occurrence> listOcorrencias; | |
1047 | - // Occurrence detalhe; | |
1048 | - OccurrenceKey rn = null; | |
1049 | - boolean type = false; | |
1050 | - // boolean criterioAdicionar = false; | |
1051 | - // String criterioAdicionado = ""; | |
1052 | - // String idCriterio = null; | |
1053 | - int totalErros = 0; | |
1054 | - int totalAvisos = 0; | |
1055 | - | |
1056 | - /*xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | |
1057 | - xml.append("<avaliacao-automatica>\n"); | |
1058 | - xml.append("<pagina-avaliada>\n"); | |
1059 | - xml.append("<titulo>" + this.tituloSite + "</titulo>\n"); | |
1060 | - xml.append("<tamanho>" + pagina.getContentLength() + "</tamanho>\n"); | |
1061 | - xml.append("<data-hora>" + this.dataHoraAvaliacao + "</data-hora>\n"); | |
1062 | - xml.append("</pagina-avaliada>\n"); | |
1063 | - xml.append("<resumo-avaliacao>\n"); | |
1064 | - xml.append("<nota-avaliacao>" + nota.getValor() + "</nota-avaliacao>\n");*/ | |
1065 | - | |
1066 | - | |
1067 | - | |
1068 | - | |
1069 | - | |
1070 | - PaginaAvaliada paginaAvaliada = new PaginaAvaliada(); | |
1071 | - | |
1072 | - paginaAvaliada.setPagina(url); | |
1073 | - paginaAvaliada.setTitulo(this.tituloSite); | |
1074 | - paginaAvaliada.setTamanho(pagina.getContentLength()); | |
1075 | - paginaAvaliada.setDataHora(this.dataHoraAvaliacao); | |
1076 | - | |
1077 | - avaliacaoAutomatica.setPaginaAvaliada(paginaAvaliada); | |
1078 | - | |
1079 | - ResumoAvaliacaoWs resumoAvaliacaoWs = new ResumoAvaliacaoWs(); | |
1080 | - | |
1081 | - resumoAvaliacaoWs.setNotaAvaliacao(nota.getValor()); | |
1082 | - | |
1083 | - | |
1084 | - List<Secao> lsSecao = new ArrayList<Secao>(); | |
1085 | - Secao secao; | |
1086 | - | |
1087 | - for (ResumoAvaliacao resumoAvaliacao : resumoErrosAvisos) { | |
1088 | - | |
1089 | - secao = new Secao(); | |
1090 | - | |
1091 | - secao.setNome(resumoAvaliacao.getTipo().getDescription()); | |
1092 | - secao.setQuantidadeErro(resumoAvaliacao.getQuantidadeErros()); | |
1093 | - secao.setQuantidadeAviso(resumoAvaliacao.getQuantidadeAvisos()); | |
1094 | - lsSecao.add(secao); | |
1095 | - | |
1096 | - /* xml.append("<secao>"); | |
1097 | - xml.append("<nome>" + resumoAvaliacao.getTipo().getDescription() + "</nome>\n"); | |
1098 | - xml.append("<quantidade-erro>" + resumoAvaliacao.getQuantidadeErros() | |
1099 | - + "</quantidade-erro>\n"); | |
1100 | - xml.append("<quantidade-aviso>" + resumoAvaliacao.getQuantidadeAvisos() | |
1101 | - + "</quantidade-aviso>\n"); | |
1102 | - xml.append("</secao>\n");*/ | |
1103 | - | |
1104 | - totalErros += resumoAvaliacao.getQuantidadeErros(); | |
1105 | - totalAvisos += resumoAvaliacao.getQuantidadeAvisos(); | |
1106 | - } | |
1107 | - | |
1108 | - resumoAvaliacaoWs.setSecao(lsSecao); | |
1109 | - resumoAvaliacaoWs.setTotalErros(totalErros); | |
1110 | - resumoAvaliacaoWs.setTotalAvisos(totalAvisos); | |
1111 | - | |
1112 | - avaliacaoAutomatica.setResumoAvaliacao(resumoAvaliacaoWs); | |
1113 | - | |
1114 | - | |
1115 | - /*xml.append("<total-erros>" + totalErros + "</total-erros>\n"); | |
1116 | - xml.append("<total-avisos>" + totalAvisos + "</total-avisos>\n"); | |
1117 | - xml.append("</resumo-avaliacao>\n");*/ | |
1118 | - | |
1119 | - String recomendacaoCompara = ""; | |
1120 | - | |
1121 | - List<RecomendacaoAvaliacao> lsRecomendacaoAvaliacao = new ArrayList<RecomendacaoAvaliacao>(); | |
1122 | - | |
1123 | - RecomendacaoAvaliacao recomendacaoAvaliacao = new RecomendacaoAvaliacao(); | |
1124 | - | |
1125 | - for (SummarizedOccurrence avaliacao : checkSumarized) { | |
1126 | - rn = OccurrenceKey.valueOf(avaliacao.getCheckPoint()); | |
1127 | - type = avaliacao.isError(); | |
1128 | - | |
1129 | - // if(!recomendacaoCompara.equalsIgnoreCase(avaliacao.getCheckPoint().toString())) | |
1130 | - // { | |
1131 | - if (!recomendacaoCompara.equalsIgnoreCase("")) { | |
1132 | - lsRecomendacaoAvaliacao.add(recomendacaoAvaliacao); | |
1133 | - recomendacaoAvaliacao = new RecomendacaoAvaliacao(); | |
1134 | - //xml.append("</recomendacao-avaliacao>\n"); | |
1056 | + if (mm.find()) { | |
1057 | + this.tituloSite = ""; | |
1135 | 1058 | } |
1136 | - | |
1137 | - | |
1138 | - recomendacaoAvaliacao.setNumeroRecomendacao(avaliacao.getCheckPoint()); | |
1139 | - recomendacaoAvaliacao.setErroRecomendacao(type); | |
1140 | - recomendacaoAvaliacao.setDescricaoRecomendacao(avaliacao.getDescription()); | |
1141 | - recomendacaoAvaliacao.setNumeroRecomendacao(avaliacao.getCheckPoint()); | |
1142 | - recomendacaoAvaliacao.setLinhasCodigoFonteRecomendacao(avaliacao.getStringLines()); | |
1143 | - recomendacaoAvaliacao.setQuantidadeRecomendacao(avaliacao.getNumberOfOccurrences()); | |
1144 | - /* xml.append("<recomendacao-avaliacao>\n"); | |
1145 | - xml.append("<numero-recomendacao>" + avaliacao.getCheckPoint() | |
1146 | - + "</numero-recomendacao>\n"); | |
1147 | - xml.append("<erro-recomendacao>" + type + "</erro-recomendacao>\n"); | |
1148 | - xml.append("<descricao-recomendacao>" + avaliacao.getDescription() | |
1149 | - + "</descricao-recomendacao>\n"); | |
1150 | - xml.append("<quantidade-recomendacao>" + avaliacao.getNumberOfOccurrences() | |
1151 | - + "</quantidade-recomendacao>\n"); | |
1152 | - xml.append("<linhas-codigo-fonte-recomendacao>" + avaliacao.getStringLines() | |
1153 | - + "</linhas-codigo-fonte-recomendacao>\n");*/ | |
1154 | - // } | |
1155 | - | |
1156 | - | |
1157 | - List<CriterioWs> lsCriterioWs = new ArrayList<CriterioWs>(); | |
1158 | - | |
1159 | - // Critérios iniciam aqui | |
1160 | - | |
1161 | - lsCriterioWs = criarRelatorioCriterios(rn, type); | |
1162 | - | |
1163 | - recomendacaoAvaliacao.setLsCriterio(lsCriterioWs); | |
1164 | - | |
1165 | - | |
1166 | - // Critérios terminam aqui | |
1167 | - | |
1168 | - | |
1169 | - recomendacaoCompara = avaliacao.getCheckPoint().toString(); | |
1170 | - } | |
1171 | - lsRecomendacaoAvaliacao.add(recomendacaoAvaliacao); | |
1172 | - avaliacaoAutomatica.setLsRecomendacaoAvaliacao(lsRecomendacaoAvaliacao); | |
1173 | - | |
1174 | - //xml.append("</recomendacao-avaliacao>\n"); | |
1175 | - | |
1176 | - // xml.append("</avaliacao-automatica>\n"); | |
1177 | - if (tipoSaida.equalsIgnoreCase("json")) { | |
1178 | - result.use(Results.json()).withoutRoot().from(avaliacaoAutomatica).recursive().serialize(); | |
1179 | - } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1180 | - result.use(Results.xml()).from(avaliacaoAutomatica).recursive().serialize(); | |
1059 | + | |
1060 | + ContentEvaluation conteudo = new ContentEvaluation(checker.getDocument()); | |
1061 | + | |
1062 | + this.tituloSite = conteudo.retornarTituloSiteAvaliado(); | |
1063 | + | |
1064 | + Nota nota = null; | |
1065 | + | |
1066 | + List<Entry<OccurrenceKey, List<Occurrence>>> mapaListaOcorrencias = | |
1067 | + avaliacaoBusiness.retornarCriteriosTeste(checker.check()); | |
1068 | + | |
1069 | + nota = | |
1070 | + avaliacaoBusiness.obterNotaEselo(checker.getDocument(), url, mapaListaOcorrencias); | |
1071 | + | |
1072 | + this.sumarizarResultasNoResponse(checker.checkSumarized(), result); | |
1073 | + | |
1074 | + this.detalheAvaliacao.inicializar(avaliacaoBusiness.retornarCriterios(checker.check()), | |
1075 | + errorsWarningsCss, errorsWarningsHtml); | |
1076 | + | |
1077 | + | |
1078 | + | |
1079 | + List<SummarizedOccurrence> checkSumarized = checker.checkSumarized(); | |
1080 | + | |
1081 | + avisosFerramentasHtmlCssW3c = new ArrayList<String>(); | |
1082 | + List<ResumoAvaliacao> resumoErrosAvisos = obterResumoAvaliacao(); | |
1083 | + | |
1084 | + // pegar os dados e montar o xml | |
1085 | + | |
1086 | + OccurrenceKey rn = null; | |
1087 | + boolean type = false; | |
1088 | + | |
1089 | + int totalErros = 0; | |
1090 | + int totalAvisos = 0; | |
1091 | + | |
1092 | + | |
1093 | + PaginaAvaliada paginaAvaliada = new PaginaAvaliada(); | |
1094 | + | |
1095 | + paginaAvaliada.setPagina(url); | |
1096 | + paginaAvaliada.setTitulo(this.tituloSite); | |
1097 | + paginaAvaliada.setTamanho(pagina.getContentLength()); | |
1098 | + paginaAvaliada.setDataHora(this.dataHoraAvaliacao); | |
1099 | + | |
1100 | + avaliacaoAutomatica.setPaginaAvaliada(paginaAvaliada); | |
1101 | + | |
1102 | + ResumoAvaliacaoWs resumoAvaliacaoWs = new ResumoAvaliacaoWs(); | |
1103 | + | |
1104 | + resumoAvaliacaoWs.setNotaAvaliacao(nota.getValor()); | |
1105 | + | |
1106 | + | |
1107 | + List<Secao> lsSecao = new ArrayList<Secao>(); | |
1108 | + Secao secao; | |
1109 | + | |
1110 | + for (ResumoAvaliacao resumoAvaliacao : resumoErrosAvisos) { | |
1111 | + | |
1112 | + secao = new Secao(); | |
1113 | + | |
1114 | + secao.setNome(resumoAvaliacao.getTipo().getDescription()); | |
1115 | + secao.setQuantidadeErro(resumoAvaliacao.getQuantidadeErros()); | |
1116 | + secao.setQuantidadeAviso(resumoAvaliacao.getQuantidadeAvisos()); | |
1117 | + lsSecao.add(secao); | |
1118 | + | |
1119 | + totalErros += resumoAvaliacao.getQuantidadeErros(); | |
1120 | + totalAvisos += resumoAvaliacao.getQuantidadeAvisos(); | |
1121 | + } | |
1122 | + | |
1123 | + resumoAvaliacaoWs.setSecao(lsSecao); | |
1124 | + resumoAvaliacaoWs.setTotalErros(totalErros); | |
1125 | + resumoAvaliacaoWs.setTotalAvisos(totalAvisos); | |
1126 | + | |
1127 | + avaliacaoAutomatica.setResumoAvaliacao(resumoAvaliacaoWs); | |
1128 | + | |
1129 | + | |
1130 | + String recomendacaoCompara = ""; | |
1131 | + | |
1132 | + List<RecomendacaoAvaliacao> lsRecomendacaoAvaliacao = | |
1133 | + new ArrayList<RecomendacaoAvaliacao>(); | |
1134 | + | |
1135 | + RecomendacaoAvaliacao recomendacaoAvaliacao = new RecomendacaoAvaliacao(); | |
1136 | + | |
1137 | + for (SummarizedOccurrence avaliacao : checkSumarized) { | |
1138 | + rn = OccurrenceKey.valueOf(avaliacao.getCheckPoint()); | |
1139 | + type = avaliacao.isError(); | |
1140 | + | |
1141 | + if (!recomendacaoCompara.equalsIgnoreCase("")) { | |
1142 | + lsRecomendacaoAvaliacao.add(recomendacaoAvaliacao); | |
1143 | + recomendacaoAvaliacao = new RecomendacaoAvaliacao(); | |
1144 | + } | |
1145 | + | |
1146 | + | |
1147 | + recomendacaoAvaliacao.setNumeroRecomendacao(avaliacao.getCheckPoint()); | |
1148 | + recomendacaoAvaliacao.setErroRecomendacao(type); | |
1149 | + recomendacaoAvaliacao.setDescricaoRecomendacao(avaliacao.getDescription()); | |
1150 | + recomendacaoAvaliacao.setNumeroRecomendacao(avaliacao.getCheckPoint()); | |
1151 | + recomendacaoAvaliacao.setLinhasCodigoFonteRecomendacao(avaliacao.getStringLines()); | |
1152 | + recomendacaoAvaliacao.setQuantidadeRecomendacao(avaliacao.getNumberOfOccurrences()); | |
1153 | + | |
1154 | + | |
1155 | + List<CriterioWs> lsCriterioWs = new ArrayList<CriterioWs>(); | |
1156 | + | |
1157 | + // Critérios iniciam aqui | |
1158 | + | |
1159 | + lsCriterioWs = criarRelatorioCriterios(rn, type); | |
1160 | + | |
1161 | + recomendacaoAvaliacao.setLsCriterio(lsCriterioWs); | |
1162 | + | |
1163 | + | |
1164 | + // Critérios terminam aqui | |
1165 | + | |
1166 | + | |
1167 | + recomendacaoCompara = avaliacao.getCheckPoint().toString(); | |
1168 | + } | |
1169 | + lsRecomendacaoAvaliacao.add(recomendacaoAvaliacao); | |
1170 | + avaliacaoAutomatica.setLsRecomendacaoAvaliacao(lsRecomendacaoAvaliacao); | |
1171 | + | |
1172 | + if (tipoSaida.equalsIgnoreCase("json")) { | |
1173 | + result.use(Results.json()).withoutRoot().from(avaliacaoAutomatica).recursive() | |
1174 | + .serialize(); | |
1175 | + } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1176 | + result.use(Results.xml()).from(avaliacaoAutomatica).recursive().serialize(); | |
1177 | + } | |
1178 | + | |
1179 | + } else { | |
1180 | + | |
1181 | + this.validator = validate.getMessage(); | |
1182 | + erroWs.setUrl(url); | |
1183 | + erroWs.setDataHora(this.dataHoraAvaliacao); | |
1184 | + | |
1185 | + List<String> mensagensErros = new ArrayList<String>(); | |
1186 | + Integer contador = 0; | |
1187 | + for (Message mensagem : validate.getMessage().getErrors()) { | |
1188 | + mensagensErros.add(validate.getMessage().getErrors().get(contador).getMessage()); | |
1189 | + contador++; | |
1190 | + } | |
1191 | + | |
1192 | + erroWs.setMensagem(mensagensErros); | |
1193 | + | |
1194 | + if (tipoSaida.equalsIgnoreCase("json")) { | |
1195 | + result.use(Results.json()).withoutRoot().from(erroWs).recursive().serialize(); | |
1196 | + } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1197 | + result.use(Results.xml()).from(erroWs).recursive().serialize(); | |
1198 | + } | |
1199 | + | |
1181 | 1200 | } |
1182 | - | |
1183 | - } else { | |
1184 | - /* xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | |
1185 | - xml.append("<avaliacao-automatica>\n"); | |
1186 | - xml.append("<pagina-avaliada>\n"); | |
1187 | - xml.append("<titulo>" + this.tituloSite + "</titulo>\n"); | |
1188 | - xml.append("<data-hora>" + this.dataHoraAvaliacao + "</data-hora>\n"); | |
1189 | - xml.append("</pagina-avaliada>\n"); | |
1190 | - xml.append("<resumo-avaliacao>Não foi possível avaliar essa URI"); | |
1191 | - xml.append("</resumo-avaliacao>\n");*/ | |
1192 | - | |
1193 | - | |
1201 | + | |
1202 | + | |
1203 | + } catch (Exception e) { | |
1204 | + | |
1205 | + e.printStackTrace(); | |
1206 | + | |
1194 | 1207 | erroWs.setUrl(url); |
1195 | 1208 | erroWs.setDataHora(this.dataHoraAvaliacao); |
1196 | - erroWs.setMensagem("Não foi possível avaliar essa url."); | |
1197 | - | |
1198 | - if (tipoSaida.equalsIgnoreCase("json")) { | |
1199 | - result.use(Results.json()).withoutRoot().from(erroWs).serialize(); | |
1200 | - } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1201 | - result.use(Results.xml()).from(erroWs).serialize(); | |
1202 | - } | |
1203 | 1209 | |
1204 | - // System.out.println("Enviar xml de erro"); | |
1210 | + List<String> mensagensErros = new ArrayList<String>(); | |
1211 | + | |
1212 | + mensagensErros.add(e.getMessage()); | |
1213 | + | |
1214 | + erroWs.setMensagem(mensagensErros); | |
1215 | + | |
1216 | + | |
1217 | + if (tipoSaida.equalsIgnoreCase("json")) { | |
1218 | + result.use(Results.json()).withoutRoot().from(erroWs).recursive().serialize(); | |
1219 | + } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1220 | + result.use(Results.xml()).from(erroWs).recursive().serialize(); | |
1221 | + } | |
1205 | 1222 | } |
1206 | - | |
1207 | 1223 | |
1208 | - } catch (Exception e) { | |
1209 | - /* xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"); | |
1210 | - xml.append("<avaliacao-automatica>\n"); | |
1211 | - xml.append("<pagina-avaliada>\n"); | |
1212 | - xml.append("<titulo>" + this.tituloSite + "</titulo>\n"); | |
1213 | - xml.append("<data-hora>" + this.dataHoraAvaliacao + "</data-hora>\n"); | |
1214 | - xml.append("</pagina-avaliada>\n"); | |
1215 | - xml.append("<resumo-avaliacao>Não foi possível avaliar essa URI"); | |
1216 | - xml.append("</resumo-avaliacao>\n");*/ | |
1217 | - | |
1218 | - e.printStackTrace(); | |
1219 | - | |
1224 | + } else { | |
1225 | + | |
1220 | 1226 | erroWs.setUrl(url); |
1221 | 1227 | erroWs.setDataHora(this.dataHoraAvaliacao); |
1222 | - erroWs.setMensagem(e.getMessage()); | |
1223 | - | |
1224 | - if (tipoSaida.equalsIgnoreCase("json")) { | |
1225 | - result.use(Results.json()).withoutRoot().from(erroWs).serialize(); | |
1226 | - } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1227 | - result.use(Results.xml()).from(erroWs).serialize(); | |
1228 | + List<String> mensagensErros = new ArrayList<String>(); | |
1229 | + | |
1230 | + mensagensErros.add("Código hash não confere!"); | |
1231 | + | |
1232 | + erroWs.setMensagem(mensagensErros); | |
1233 | + | |
1234 | + if (tipoSaida.equalsIgnoreCase("json")) { | |
1235 | + result.use(Results.json()).withoutRoot().from(erroWs).recursive().serialize(); | |
1236 | + } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1237 | + result.use(Results.xml()).from(erroWs).recursive().serialize(); | |
1228 | 1238 | } |
1239 | + | |
1229 | 1240 | } |
1230 | - | |
1231 | - } else { | |
1232 | - | |
1233 | - erroWs.setUrl(url); | |
1234 | - erroWs.setDataHora(this.dataHoraAvaliacao); | |
1235 | - erroWs.setMensagem("Código hash não confere!"); | |
1236 | - | |
1237 | - if (tipoSaida.equalsIgnoreCase("json")) { | |
1238 | - result.use(Results.json()).withoutRoot().from(erroWs).serialize(); | |
1239 | - } else if (tipoSaida.equalsIgnoreCase("xml")) { | |
1240 | - result.use(Results.xml()).from(erroWs).serialize(); | |
1241 | - } | |
1242 | - //xml.append("erro"); | |
1243 | - | |
1244 | 1241 | } |
1245 | - | |
1246 | 1242 | } |
1247 | 1243 | |
1248 | 1244 | public List<CriterioWs> criarRelatorioCriterios(OccurrenceKey rn, boolean isError) { |
... | ... | @@ -1251,123 +1247,112 @@ public class AvaliacaoController { |
1251 | 1247 | boolean recomendacao1_1_2Adicionada = false; |
1252 | 1248 | boolean recomendacao1_1_7Adicionada = false; |
1253 | 1249 | boolean recomendacao1_1_8Adicionada = false; |
1250 | + | |
1251 | + // UtilitiesProperties utilitiesProperties = new UtilitiesProperties(application); | |
1252 | + | |
1253 | + String notExibCrit = this.utilitiesProperties.get("notExibCrit"); | |
1254 | + | |
1255 | + String[] listaNotExibCrit = notExibCrit.split(" "); | |
1256 | + | |
1257 | + | |
1254 | 1258 | |
1255 | 1259 | String codigoFonte = ""; |
1260 | + boolean haCodigoFonte; | |
1256 | 1261 | String criterioCompara = ""; |
1257 | 1262 | String numeroCriterio = ""; |
1258 | 1263 | List<CriterioWs> lsCriterioWs = new ArrayList<CriterioWs>(); |
1259 | 1264 | CriterioWs criterioWs; |
1260 | - | |
1265 | + | |
1261 | 1266 | List<CodigoFonteCriterio> lsCodigoFonteCriterio = new ArrayList<CodigoFonteCriterio>(); |
1262 | 1267 | CodigoFonteCriterio codigoFonteCriterio = new CodigoFonteCriterio(); |
1263 | - | |
1268 | + | |
1264 | 1269 | for (Occurrence occurrence : this.detalheAvaliacao.get(rn, isError).getOcorrencias()) { |
1265 | 1270 | criterioWs = new CriterioWs(); |
1271 | + haCodigoFonte = true; | |
1266 | 1272 | |
1267 | 1273 | numeroCriterio = occurrence.getCriterio(); |
1268 | - | |
1269 | - // if (!aReq.contains(rn.getCode() + "." + numeroCriterio)) | |
1270 | - // { | |
1271 | 1274 | |
1272 | - if (!rn.getCode().toString().equalsIgnoreCase("1.1") || !isError) { | |
1273 | - if (rn.getCode().toString().equalsIgnoreCase("1.1") && numeroCriterio.equalsIgnoreCase("7") && !recomendacao1_1_7Adicionada) { | |
1274 | - | |
1275 | - codigoFonte = "Serviço de validação de HTML do W3C"; | |
1275 | + String recomend = rn.getCode().toString() + "." + numeroCriterio; | |
1276 | + | |
1277 | + for (String naotExibCrit : listaNotExibCrit ) { | |
1278 | + if(naotExibCrit.equalsIgnoreCase(recomend)) | |
1279 | + { | |
1280 | + codigoFonte = "Não há código fonte a ser exibido."; | |
1281 | + haCodigoFonte = false; | |
1282 | + break; | |
1283 | + } | |
1284 | + } | |
1285 | + | |
1286 | + if (!rn.getCode().toString().equalsIgnoreCase("1.1") || !isError) { | |
1287 | + | |
1288 | + if (rn.getCode().toString().equalsIgnoreCase("1.1") && numeroCriterio.equalsIgnoreCase("7") | |
1289 | + && !recomendacao1_1_7Adicionada) { | |
1290 | + | |
1291 | + codigoFonte = haCodigoFonte == false ? codigoFonte : "Serviço de validação de HTML do W3C"; | |
1276 | 1292 | recomendacao1_1_7Adicionada = true; |
1277 | 1293 | } else if (rn.getCode().toString().equalsIgnoreCase("1.1") |
1278 | 1294 | && numeroCriterio.equalsIgnoreCase("8") && !recomendacao1_1_8Adicionada) { |
1279 | - codigoFonte = "Serviço de validação de CSS do W3C"; | |
1295 | + codigoFonte = haCodigoFonte == false ? codigoFonte : "Serviço de validação de CSS do W3C"; | |
1280 | 1296 | recomendacao1_1_8Adicionada = true; |
1281 | 1297 | } else { |
1282 | - codigoFonte = | |
1298 | + codigoFonte = haCodigoFonte == false ? codigoFonte : | |
1283 | 1299 | occurrence.getTag().replaceAll("<", "<").replaceAll(">", ">") |
1284 | 1300 | .replaceAll(" ", " "); |
1285 | 1301 | } |
1286 | 1302 | |
1287 | 1303 | if (!criterioCompara.equalsIgnoreCase(occurrence.getCriterio().toString())) { |
1288 | - | |
1304 | + | |
1289 | 1305 | if (!criterioCompara.equalsIgnoreCase("")) { |
1290 | 1306 | criterioWs.setCodigoFonteCriterio(lsCodigoFonteCriterio); |
1291 | 1307 | codigoFonteCriterio = new CodigoFonteCriterio(); |
1292 | - //xml.append("</criterio>\n"); | |
1308 | + // xml.append("</criterio>\n"); | |
1293 | 1309 | } |
1294 | 1310 | |
1295 | 1311 | criterioWs.setNumeroCriterio(numeroCriterio); |
1296 | - criterioWs.setNomeCriterio(criterioProperties.getDescricao(rn.getCode() + "." + numeroCriterio)); | |
1312 | + criterioWs.setNomeCriterio(criterioProperties.getDescricao(rn.getCode() + "." | |
1313 | + + numeroCriterio)); | |
1297 | 1314 | criterioWs.setErroCriterio(occurrence.isError()); |
1298 | 1315 | criterioWs.setQuantidadeCriterio(verificaQuantidadeCriterio(rn, isError, numeroCriterio)); |
1299 | - | |
1300 | - | |
1301 | - codigoFonteCriterio.setNumeroLinha(occurrence.getLine()); | |
1302 | - codigoFonteCriterio.setConteudoLinha("<![CDATA[" + codigoFonte + "]]>"); | |
1316 | + | |
1317 | + | |
1318 | + codigoFonteCriterio.setNumeroLinha(haCodigoFonte == false ? 0 :occurrence.getLine()); | |
1319 | + codigoFonteCriterio.setConteudoLinha(haCodigoFonte == false ? codigoFonte : "<![CDATA[" + codigoFonte + "]]>"); | |
1303 | 1320 | lsCodigoFonteCriterio.add(codigoFonteCriterio); |
1304 | - | |
1305 | - | |
1306 | - /* xml.append("<criterio>\n"); | |
1307 | - xml.append("<numero-criterio>" + numeroCriterio + "</numero-criterio>\n"); | |
1308 | - xml.append("<nome-criterio>" | |
1309 | - + criterioProperties.getDescricao(rn.getCode() + "." + numeroCriterio) | |
1310 | - + "</nome-criterio>\n"); | |
1311 | - xml.append("<erro-criterio>" + occurrence.isError() + "</erro-criterio>\n"); | |
1312 | - xml.append("<quantidade-criterio>" | |
1313 | - + verificaQuantidadeCriterio(rn, isError, numeroCriterio) | |
1314 | - + "</quantidade-criterio>\n"); | |
1315 | - xml.append("<codigo-fonte-criterio>\n"); | |
1316 | - xml.append("<numero-linha>" + occurrence.getLine() + "</numero-linha>\n"); | |
1317 | - xml.append("<conteudo-linha><![CDATA[" + codigoFonte + "]]></conteudo-linha>\n"); | |
1318 | - xml.append("</codigo-fonte-criterio>\n");*/ | |
1319 | 1321 | |
1320 | 1322 | |
1321 | 1323 | criterioCompara = occurrence.getCriterio(); |
1322 | 1324 | } else { |
1323 | - codigoFonteCriterio = new CodigoFonteCriterio(); | |
1324 | - codigoFonteCriterio.setNumeroLinha(occurrence.getLine()); | |
1325 | - codigoFonteCriterio.setConteudoLinha("<![CDATA[" | |
1325 | + codigoFonteCriterio = new CodigoFonteCriterio(); | |
1326 | + codigoFonteCriterio.setNumeroLinha(haCodigoFonte == false ? 0 :occurrence.getLine()); | |
1327 | + codigoFonteCriterio.setConteudoLinha(haCodigoFonte == false ? codigoFonte :"<![CDATA[" | |
1326 | 1328 | + occurrence.getTag().replaceAll("<", "<").replaceAll(">", ">") |
1327 | 1329 | .replaceAll(" ", " ") + "]]>"); |
1328 | 1330 | lsCodigoFonteCriterio.add(codigoFonteCriterio); |
1329 | - | |
1330 | - /*xml.append("<codigo-fonte-criterio>\n"); | |
1331 | - xml.append("<numero-linha>" + occurrence.getLine() + "</numero-linha>\n"); | |
1332 | - xml.append("<conteudo-linha><![CDATA[" | |
1333 | - + occurrence.getTag().replaceAll("<", "<").replaceAll(">", ">") | |
1334 | - .replaceAll(" ", " ") + "]]></conteudo-linha>\n"); | |
1335 | - xml.append("</codigo-fonte-criterio>\n");*/ | |
1336 | - } | |
1331 | + | |
1332 | + } | |
1337 | 1333 | |
1338 | 1334 | } else { |
1339 | 1335 | if (numeroCriterio.equalsIgnoreCase("1") && !recomendacao1_1_1Adicionada) { |
1340 | - | |
1336 | + | |
1341 | 1337 | if (!criterioCompara.equalsIgnoreCase("")) { |
1342 | 1338 | criterioWs.setCodigoFonteCriterio(lsCodigoFonteCriterio); |
1343 | 1339 | codigoFonteCriterio = new CodigoFonteCriterio(); |
1344 | - //xml.append("</criterio>\n"); | |
1340 | + // xml.append("</criterio>\n"); | |
1345 | 1341 | } |
1346 | - | |
1342 | + | |
1347 | 1343 | criterioWs.setNumeroCriterio(numeroCriterio); |
1348 | - criterioWs.setNomeCriterio(criterioProperties.getDescricao(rn.getCode() + "." + numeroCriterio)); | |
1344 | + criterioWs.setNomeCriterio(criterioProperties.getDescricao(rn.getCode() + "." | |
1345 | + + numeroCriterio)); | |
1349 | 1346 | criterioWs.setErroCriterio(occurrence.isError()); |
1350 | 1347 | criterioWs.setQuantidadeCriterio(verificaQuantidadeCriterio(rn, isError, numeroCriterio)); |
1351 | - | |
1352 | - // codigoFonteCriterio = new CodigoFonteCriterio(); | |
1353 | - codigoFonteCriterio.setNumeroLinha(occurrence.getLine()); | |
1348 | + | |
1349 | + | |
1350 | + // Seta-se "0" por não possuir essa informação | |
1351 | + codigoFonteCriterio.setNumeroLinha(0); | |
1354 | 1352 | codigoFonteCriterio.setConteudoLinha("Serviço de validação de HTML do W3C"); |
1355 | 1353 | lsCodigoFonteCriterio.add(codigoFonteCriterio); |
1356 | - | |
1357 | - /*xml.append("<criterio>\n"); | |
1358 | - xml.append("<numero-criterio>" + numeroCriterio + "</numero-criterio>\n"); | |
1359 | - xml.append("<nome-criterio>" | |
1360 | - + criterioProperties.getDescricao(rn.getCode() + "." + numeroCriterio) | |
1361 | - + "</nome-criterio>\n"); | |
1362 | - xml.append("<erro-criterio>" + occurrence.isError() + "</erro-criterio>\n"); | |
1363 | - xml.append("<quantidade-criterio>" | |
1364 | - + verificaQuantidadeCriterio(rn, isError, numeroCriterio) | |
1365 | - + "</quantidade-criterio>\n"); | |
1366 | - xml.append("<codigo-fonte-criterio>\n"); | |
1367 | - xml.append("<numero-linha>" + occurrence.getLine() + "</numero-linha>\n"); | |
1368 | - xml.append("<conteudo-linha>Serviço de validação de HTML do W3C</conteudo-linha>\n"); | |
1369 | - xml.append("</codigo-fonte-criterio>\n");*/ | |
1370 | 1354 | |
1355 | + | |
1371 | 1356 | criterioCompara = occurrence.getCriterio(); |
1372 | 1357 | recomendacao1_1_1Adicionada = true; |
1373 | 1358 | } |
... | ... | @@ -1376,49 +1361,36 @@ public class AvaliacaoController { |
1376 | 1361 | if (!criterioCompara.equalsIgnoreCase("")) { |
1377 | 1362 | criterioWs.setCodigoFonteCriterio(lsCodigoFonteCriterio); |
1378 | 1363 | codigoFonteCriterio = new CodigoFonteCriterio(); |
1379 | - //xml.append("</criterio>\n"); | |
1364 | + // xml.append("</criterio>\n"); | |
1380 | 1365 | } |
1381 | 1366 | |
1382 | 1367 | criterioWs.setNumeroCriterio(numeroCriterio); |
1383 | - criterioWs.setNomeCriterio(criterioProperties.getDescricao(rn.getCode() + "." + numeroCriterio)); | |
1368 | + criterioWs.setNomeCriterio(criterioProperties.getDescricao(rn.getCode() + "." | |
1369 | + + numeroCriterio)); | |
1384 | 1370 | criterioWs.setErroCriterio(occurrence.isError()); |
1385 | 1371 | criterioWs.setQuantidadeCriterio(verificaQuantidadeCriterio(rn, isError, numeroCriterio)); |
1386 | - | |
1387 | - //codigoFonteCriterio = new CodigoFonteCriterio(); | |
1388 | - codigoFonteCriterio.setNumeroLinha(occurrence.getLine()); | |
1372 | + | |
1373 | + | |
1374 | + // Seta-se "0" por não possuir essa informação | |
1375 | + codigoFonteCriterio.setNumeroLinha(0); | |
1389 | 1376 | codigoFonteCriterio.setConteudoLinha("Serviço de validação de CSS do W3C"); |
1390 | 1377 | lsCodigoFonteCriterio.add(codigoFonteCriterio); |
1391 | - | |
1392 | - /* xml.append("<criterio>\n"); | |
1393 | - xml.append("<numero-criterio>" + numeroCriterio + "</numero-criterio>\n"); | |
1394 | - xml.append("<nome-criterio>" | |
1395 | - + criterioProperties.getDescricao(rn.getCode() + "." + numeroCriterio) | |
1396 | - + "</nome-criterio>\n"); | |
1397 | - xml.append("<erro-criterio>" + occurrence.isError() + "</erro-criterio>\n"); | |
1398 | - xml.append("<quantidade-criterio>" | |
1399 | - + verificaQuantidadeCriterio(rn, isError, numeroCriterio) | |
1400 | - + "</quantidade-criterio>\n"); | |
1401 | - xml.append("<codigo-fonte-criterio>\n"); | |
1402 | - xml.append("<numero-linha>" + occurrence.getLine() + "</numero-linha>\n"); | |
1403 | - xml.append("<conteudo-linha>Serviço de validação de CSS do W3C</conteudo-linha>\n"); | |
1404 | - xml.append("</codigo-fonte-criterio>\n");*/ | |
1405 | 1378 | |
1406 | 1379 | criterioCompara = occurrence.getCriterio(); |
1407 | 1380 | recomendacao1_1_2Adicionada = true; |
1408 | 1381 | } |
1409 | 1382 | |
1410 | - } | |
1411 | - if(lsCodigoFonteCriterio.size() > 0) | |
1412 | - { | |
1383 | + } | |
1384 | + if (lsCodigoFonteCriterio.size() > 0) { | |
1413 | 1385 | criterioWs.setCodigoFonteCriterio(lsCodigoFonteCriterio); |
1414 | 1386 | lsCodigoFonteCriterio = new ArrayList<CodigoFonteCriterio>(); |
1415 | 1387 | lsCriterioWs.add(criterioWs); |
1416 | 1388 | } |
1417 | 1389 | // } |
1418 | 1390 | } |
1419 | - //xml.append("</criterio>\n"); | |
1391 | + // xml.append("</criterio>\n"); | |
1420 | 1392 | return lsCriterioWs; |
1421 | - | |
1393 | + | |
1422 | 1394 | |
1423 | 1395 | } |
1424 | 1396 | ... | ... |
src/main/java/br/com/ases/controller/ContatoController.java
... | ... | @@ -58,7 +58,7 @@ public class ContatoController { |
58 | 58 | |
59 | 59 | EnvioEmailSemAutenticacao envioEmailSemAutenticacao = new EnvioEmailSemAutenticacao(email.getHost(), Integer.toString(email.getPort())); |
60 | 60 | |
61 | - respSendEmail = envioEmailSemAutenticacao.sendMail(contato.getEmail(),email.getTo(), "Ases - " + StringHelper.convertFromUTF8(contato.getAssunto()), StringHelper.convertFromUTF8(contato.getMensagem()),email.getAuth(), email.getAuthUser(), email.getAuthPass()); | |
61 | + respSendEmail = envioEmailSemAutenticacao.sendMail(contato.getEmail(),email.getTo(), "Fad - " + StringHelper.convertFromUTF8(contato.getAssunto()), StringHelper.convertFromUTF8(contato.getMensagem()),email.getAuth(), email.getAuthUser(), email.getAuthPass()); | |
62 | 62 | |
63 | 63 | |
64 | 64 | /*String respSendEmail = email.sendEmail("Contato","govbr@planejamento.gov.br", contato.getNome(),contato.getEmail(),StringHelper.convertFromUTF8(contato.getAssunto()), | ... | ... |
src/main/java/br/com/ases/infra/TesteEseloProperties.java
src/main/java/br/com/ases/model/utilities/Validate.java
... | ... | @@ -32,7 +32,7 @@ public class Validate { |
32 | 32 | this.validator.add(new ValidationMessage("Favor preencher o campo NOME!", "error")); |
33 | 33 | isValido = false; |
34 | 34 | } else if (contato.getNome().length() > 200) { |
35 | - this.validator.add(new ValidationMessage("O campo NOME aceita até 200 caracteres.", | |
35 | + this.validator.add(new ValidationMessage("O campo NOME aceita até 200 caracteres.", | |
36 | 36 | "error")); |
37 | 37 | isValido = false; |
38 | 38 | } |
... | ... | @@ -47,14 +47,14 @@ public class Validate { |
47 | 47 | // this.validator.add(new |
48 | 48 | // ValidationMessage("Não foi possível enviar a mensagem! E-MAIL '"+contato.getEmail()+"' considerado inválido!", |
49 | 49 | // "error")); |
50 | - this.validator.add(new ValidationMessage("E-MAIL considerado inválido!", "error")); | |
50 | + this.validator.add(new ValidationMessage("E-MAIL considerado inválido!", "error")); | |
51 | 51 | isValido = false; |
52 | 52 | } |
53 | 53 | } |
54 | 54 | |
55 | 55 | if (contato.getAssunto() == null) { |
56 | 56 | this.validator.add(new ValidationMessage( |
57 | - "Favor escolher uma das opções no campo ASSUNTO!", "error")); | |
57 | + "Favor escolher uma das opções no campo ASSUNTO!", "error")); | |
58 | 58 | isValido = false; |
59 | 59 | } |
60 | 60 | |
... | ... | @@ -80,7 +80,7 @@ public class Validate { |
80 | 80 | if (campo == null || campo.length() <= 10) { |
81 | 81 | this.validator |
82 | 82 | .add(new ValidationMessage( |
83 | - "Não foi possível realizar a avaliação! Favor preencher o campo URL.", | |
83 | + "Não foi possível realizar a avaliação! Favor preencher o campo URL.", | |
84 | 84 | "warning")); |
85 | 85 | isValido = false; |
86 | 86 | } else { |
... | ... | @@ -91,7 +91,7 @@ public class Validate { |
91 | 91 | codResponse = verificarConexao(campo, "http.agent", "Jakarta Commons-HttpClient/3.1"); |
92 | 92 | if (codResponse != 200) { |
93 | 93 | this.validator.add(new ValidationMessage( |
94 | - "Não foi possível realizar a avaliação! URL " + campo | |
94 | + "Não foi possível realizar a avaliação! URL " + campo | |
95 | 95 | + " é considerada inválida.", "warning")); |
96 | 96 | isValido = false; |
97 | 97 | } else { |
... | ... | @@ -154,7 +154,7 @@ public class Validate { |
154 | 154 | if (campo == null || campo.length() <= 10) { |
155 | 155 | this.validator |
156 | 156 | .add(new ValidationMessage( |
157 | - "Não foi possível realizar a avaliação! Favor preencher o campo Código a analisar.", | |
157 | + "Não foi possível realizar a avaliação! Favor preencher o campo Código a analisar.", | |
158 | 158 | "warning")); |
159 | 159 | return false; |
160 | 160 | } |
... | ... | @@ -167,7 +167,7 @@ public class Validate { |
167 | 167 | if (!m.find()) { |
168 | 168 | this.validator |
169 | 169 | .add(new ValidationMessage( |
170 | - "Não foi possível realizar a avaliação! O código fonte não é do tipo HTML ou XHTML.", | |
170 | + "Não foi possível realizar a avaliação! O código fonte não é do tipo HTML ou XHTML.", | |
171 | 171 | "warning")); |
172 | 172 | return false; |
173 | 173 | } |
... | ... | @@ -175,7 +175,7 @@ public class Validate { |
175 | 175 | if (campo.length() > 1048576) { |
176 | 176 | this.validator |
177 | 177 | .add(new ValidationMessage( |
178 | - "Não foi possível realizar a avaliação! Tamanho máximo permitido para código fonte é até 1024KB.", | |
178 | + "Não foi possível realizar a avaliação! Tamanho máximo permitido para código fonte é até 1024KB.", | |
179 | 179 | "warning")); |
180 | 180 | return false; |
181 | 181 | } |
... | ... | @@ -189,7 +189,7 @@ public class Validate { |
189 | 189 | if (file == null) { |
190 | 190 | this.validator |
191 | 191 | .add(new ValidationMessage( |
192 | - "Não foi possível realizar a avaliação! Favor realizar o upload do arquivo.", | |
192 | + "Não foi possível realizar a avaliação! Favor realizar o upload do arquivo.", | |
193 | 193 | "warning")); |
194 | 194 | return false; |
195 | 195 | } |
... | ... | @@ -199,7 +199,7 @@ public class Validate { |
199 | 199 | || fileType.equals("application/xhtml") || fileType.equals("application/xml"))) { |
200 | 200 | this.validator |
201 | 201 | .add(new ValidationMessage( |
202 | - "Não foi possível realizar a avaliação! As extensões permitidas para o arquivo são: .xht, .htm, .html ou .xhtml.", | |
202 | + "Não foi possível realizar a avaliação! As extensções permitidas para o arquivo são: .xht, .htm, .html ou .xhtml.", | |
203 | 203 | "warning")); |
204 | 204 | return false; |
205 | 205 | } |
... | ... | @@ -207,7 +207,7 @@ public class Validate { |
207 | 207 | if (file.getSize() > 1048576) { |
208 | 208 | this.validator |
209 | 209 | .add(new ValidationMessage( |
210 | - "Não foi possével realizar o upload do arquivo! Tamanho máximo permitido é de 1024KB.", | |
210 | + "Não foi possível realizar o upload do arquivo! Tamanho máximo permitido é de 1024KB.", | |
211 | 211 | "warning")); |
212 | 212 | return false; |
213 | 213 | } |
... | ... | @@ -226,7 +226,7 @@ public class Validate { |
226 | 226 | if (!m.find()) { |
227 | 227 | this.validator |
228 | 228 | .add(new ValidationMessage( |
229 | - "Não foi possível realizar a avaliação! O conteédo do arquivo não é do tipo HTML ou XHTML.", | |
229 | + "Não foi possível realizar a avaliação! O conteúdo do arquivo não é do tipo HTML ou XHTML.", | |
230 | 230 | "warning")); |
231 | 231 | return false; |
232 | 232 | } | ... | ... |
src/main/java/br/com/ases/ws/model/CriterioWs.java
... | ... | @@ -39,11 +39,11 @@ public class CriterioWs { |
39 | 39 | public void setErroCriterio(Boolean erroCriterio) { |
40 | 40 | if(erroCriterio) |
41 | 41 | { |
42 | - this.erroCriterio = "true"; | |
42 | + this.erroCriterio = "erro"; | |
43 | 43 | } |
44 | 44 | else |
45 | 45 | { |
46 | - this.erroCriterio = "false"; | |
46 | + this.erroCriterio = "aviso"; | |
47 | 47 | } |
48 | 48 | } |
49 | 49 | public Integer getQuantidadeCriterio() { | ... | ... |
src/main/java/br/com/ases/ws/model/ErroWs.java
1 | 1 | package br.com.ases.ws.model; |
2 | 2 | |
3 | +import java.util.List; | |
4 | + | |
3 | 5 | import com.thoughtworks.xstream.annotations.XStreamAlias; |
4 | 6 | |
7 | +@XStreamAlias("avaliacao-automatica") | |
5 | 8 | public class ErroWs { |
6 | 9 | |
7 | 10 | |
8 | 11 | private String url; |
9 | 12 | @XStreamAlias("data-hora") |
10 | 13 | private String dataHora; |
11 | - private String mensagem; | |
14 | + @XStreamAlias("mensagem-erro") | |
15 | + private List<String> mensagem; | |
12 | 16 | |
13 | 17 | |
14 | 18 | public String getUrl() { |
... | ... | @@ -23,12 +27,13 @@ public class ErroWs { |
23 | 27 | public void setDataHora(String dataHora) { |
24 | 28 | this.dataHora = dataHora; |
25 | 29 | } |
26 | - public String getMensagem() { | |
30 | + public List<String> getMensagem() { | |
27 | 31 | return mensagem; |
28 | 32 | } |
29 | - public void setMensagem(String mensagem) { | |
33 | + public void setMensagem(List<String> mensagem) { | |
30 | 34 | this.mensagem = mensagem; |
31 | 35 | } |
36 | + | |
32 | 37 | |
33 | 38 | |
34 | 39 | } | ... | ... |
src/main/java/br/com/ases/ws/model/RecomendacaoAvaliacao.java
... | ... | @@ -33,11 +33,11 @@ public class RecomendacaoAvaliacao { |
33 | 33 | public void setErroRecomendacao(Boolean erroRecomendacao) { |
34 | 34 | if(erroRecomendacao) |
35 | 35 | { |
36 | - this.erroRecomendacao = "true"; | |
36 | + this.erroRecomendacao = "erro"; | |
37 | 37 | } |
38 | 38 | else |
39 | 39 | { |
40 | - this.erroRecomendacao = "false"; | |
40 | + this.erroRecomendacao = "aviso"; | |
41 | 41 | } |
42 | 42 | } |
43 | 43 | public String getDescricaoRecomendacao() { | ... | ... |