Commit d4c589418b6c55baf902ff0f64b6b53e2ba41271
1 parent
ea8b9ed0
Exists in
master
Adição da linha "System.setProperty("jsse.enableSNIExtension",
"false");" para verificar a conexão.
Showing
1 changed file
with
129 additions
and
209 deletions
Show diff stats
src/main/java/br/com/checker/emag/core/ContentEvaluation.java
@@ -103,85 +103,73 @@ public class ContentEvaluation extends Evaluation { | @@ -103,85 +103,73 @@ public class ContentEvaluation extends Evaluation { | ||
103 | 103 | ||
104 | } | 104 | } |
105 | 105 | ||
106 | - protected static class EvaluationRecommendation17 extends | ||
107 | - ContentRecommendation { | 106 | + protected static class EvaluationRecommendation17 extends ContentRecommendation { |
108 | protected List<Occurrence> check() { | 107 | protected List<Occurrence> check() { |
109 | return getEvaluation().checkRecommendation17(); | 108 | return getEvaluation().checkRecommendation17(); |
110 | } | 109 | } |
111 | } | 110 | } |
112 | 111 | ||
113 | - protected static class EvaluationRecommendation18 extends | ||
114 | - ContentRecommendation { | 112 | + protected static class EvaluationRecommendation18 extends ContentRecommendation { |
115 | protected List<Occurrence> check() { | 113 | protected List<Occurrence> check() { |
116 | return getEvaluation().checkRecommendation18(); | 114 | return getEvaluation().checkRecommendation18(); |
117 | } | 115 | } |
118 | } | 116 | } |
119 | 117 | ||
120 | - protected static class EvaluationRecommendation19 extends | ||
121 | - ContentRecommendation { | 118 | + protected static class EvaluationRecommendation19 extends ContentRecommendation { |
122 | protected List<Occurrence> check() { | 119 | protected List<Occurrence> check() { |
123 | return getEvaluation().checkRecommendation19(); | 120 | return getEvaluation().checkRecommendation19(); |
124 | } | 121 | } |
125 | } | 122 | } |
126 | 123 | ||
127 | - protected static class EvaluationRecommendation20 extends | ||
128 | - ContentRecommendation { | 124 | + protected static class EvaluationRecommendation20 extends ContentRecommendation { |
129 | protected List<Occurrence> check() { | 125 | protected List<Occurrence> check() { |
130 | return getEvaluation().checkRecommendation20(); | 126 | return getEvaluation().checkRecommendation20(); |
131 | } | 127 | } |
132 | } | 128 | } |
133 | 129 | ||
134 | - protected static class EvaluationRecommendation21 extends | ||
135 | - ContentRecommendation { | 130 | + protected static class EvaluationRecommendation21 extends ContentRecommendation { |
136 | protected List<Occurrence> check() { | 131 | protected List<Occurrence> check() { |
137 | return getEvaluation().checkRecommendation21(); | 132 | return getEvaluation().checkRecommendation21(); |
138 | } | 133 | } |
139 | } | 134 | } |
140 | 135 | ||
141 | - protected static class EvaluationRecommendation22 extends | ||
142 | - ContentRecommendation { | 136 | + protected static class EvaluationRecommendation22 extends ContentRecommendation { |
143 | protected List<Occurrence> check() { | 137 | protected List<Occurrence> check() { |
144 | return getEvaluation().checkRecommendation22(); | 138 | return getEvaluation().checkRecommendation22(); |
145 | } | 139 | } |
146 | } | 140 | } |
147 | 141 | ||
148 | - protected static class EvaluationRecommendation23 extends | ||
149 | - ContentRecommendation { | 142 | + protected static class EvaluationRecommendation23 extends ContentRecommendation { |
150 | protected List<Occurrence> check() { | 143 | protected List<Occurrence> check() { |
151 | return getEvaluation().checkRecommendation23(); | 144 | return getEvaluation().checkRecommendation23(); |
152 | } | 145 | } |
153 | } | 146 | } |
154 | 147 | ||
155 | - protected static class EvaluationRecommendation24 extends | ||
156 | - ContentRecommendation { | 148 | + protected static class EvaluationRecommendation24 extends ContentRecommendation { |
157 | protected List<Occurrence> check() { | 149 | protected List<Occurrence> check() { |
158 | return getEvaluation().checkRecommendation24(); | 150 | return getEvaluation().checkRecommendation24(); |
159 | } | 151 | } |
160 | } | 152 | } |
161 | 153 | ||
162 | - protected static class EvaluationRecommendation25 extends | ||
163 | - ContentRecommendation { | 154 | + protected static class EvaluationRecommendation25 extends ContentRecommendation { |
164 | protected List<Occurrence> check() { | 155 | protected List<Occurrence> check() { |
165 | return getEvaluation().checkRecommendation25(); | 156 | return getEvaluation().checkRecommendation25(); |
166 | } | 157 | } |
167 | } | 158 | } |
168 | 159 | ||
169 | - protected static class EvaluationRecommendation26 extends | ||
170 | - ContentRecommendation { | 160 | + protected static class EvaluationRecommendation26 extends ContentRecommendation { |
171 | protected List<Occurrence> check() { | 161 | protected List<Occurrence> check() { |
172 | return getEvaluation().checkRecommendation26(); | 162 | return getEvaluation().checkRecommendation26(); |
173 | } | 163 | } |
174 | } | 164 | } |
175 | 165 | ||
176 | - protected static class EvaluationRecommendation27 extends | ||
177 | - ContentRecommendation { | 166 | + protected static class EvaluationRecommendation27 extends ContentRecommendation { |
178 | protected List<Occurrence> check() { | 167 | protected List<Occurrence> check() { |
179 | return getEvaluation().checkRecommendation27(); | 168 | return getEvaluation().checkRecommendation27(); |
180 | } | 169 | } |
181 | } | 170 | } |
182 | 171 | ||
183 | - protected static class EvaluationRecommendation28 extends | ||
184 | - ContentRecommendation { | 172 | + protected static class EvaluationRecommendation28 extends ContentRecommendation { |
185 | protected List<Occurrence> check() { | 173 | protected List<Occurrence> check() { |
186 | return getEvaluation().checkRecommendation28(); | 174 | return getEvaluation().checkRecommendation28(); |
187 | } | 175 | } |
@@ -217,36 +205,30 @@ public class ContentEvaluation extends Evaluation { | @@ -217,36 +205,30 @@ public class ContentEvaluation extends Evaluation { | ||
217 | Attribute xmlns = html.getAttributes().get("xmlns"); | 205 | Attribute xmlns = html.getAttributes().get("xmlns"); |
218 | 206 | ||
219 | String tagHtml = getDocument().getFirstStartTag("html").toString(); | 207 | String tagHtml = getDocument().getFirstStartTag("html").toString(); |
220 | - String doctype = getDocument().getFirstStartTag().toString() | ||
221 | - .replace(" ", ""); | 208 | + String doctype = getDocument().getFirstStartTag().toString().replace(" ", ""); |
222 | 209 | ||
223 | /* | 210 | /* |
224 | - * if ( lang == null && xmlLang == null){ | ||
225 | - * occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); | ||
226 | - * } | 211 | + * if ( lang == null && xmlLang == null){ occurrences.add(this.buildOccurrence("3.1", true, |
212 | + * tagHtml, html, "1")); } | ||
227 | * | 213 | * |
228 | * if(xmlLang != null && !(lang == null || xmlLang == null)){ | 214 | * if(xmlLang != null && !(lang == null || xmlLang == null)){ |
229 | - * occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); | ||
230 | - * }else if (lang != null && lang.getValue().isEmpty()) { | ||
231 | - * occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, | ||
232 | - * "2")); } else if (xmlLang != null && xmlLang.getValue().isEmpty()) { | ||
233 | - * occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, | ||
234 | - * "2")); }else if (xmlns != null && xmlns.getValue().isEmpty()) { | ||
235 | - * occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, | ||
236 | - * "2")); } | 215 | + * occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); }else if (lang != |
216 | + * null && lang.getValue().isEmpty()) { occurrences.add(this.buildOccurrence("3.1", false, | ||
217 | + * tagHtml, html, "2")); } else if (xmlLang != null && xmlLang.getValue().isEmpty()) { | ||
218 | + * occurrences.add(this.buildOccurrence("3.1", false, tagHtml, html, "2")); }else if (xmlns != | ||
219 | + * null && xmlns.getValue().isEmpty()) { occurrences.add(this.buildOccurrence("3.1", false, | ||
220 | + * tagHtml, html, "2")); } | ||
237 | */ | 221 | */ |
238 | 222 | ||
239 | // Caso seja diferente de html5 | 223 | // Caso seja diferente de html5 |
240 | if (!doctype.equalsIgnoreCase("<!DOCTYPEhtml>")) { | 224 | if (!doctype.equalsIgnoreCase("<!DOCTYPEhtml>")) { |
241 | 225 | ||
242 | if (xmlLang == null || lang == null) { | 226 | if (xmlLang == null || lang == null) { |
243 | - occurrences | ||
244 | - .add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); | 227 | + occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); |
245 | } | 228 | } |
246 | } else { | 229 | } else { |
247 | if (lang == null) { | 230 | if (lang == null) { |
248 | - occurrences | ||
249 | - .add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); | 231 | + occurrences.add(this.buildOccurrence("3.1", true, tagHtml, html, "1")); |
250 | } | 232 | } |
251 | } | 233 | } |
252 | 234 | ||
@@ -261,13 +243,11 @@ public class ContentEvaluation extends Evaluation { | @@ -261,13 +243,11 @@ public class ContentEvaluation extends Evaluation { | ||
261 | } | 243 | } |
262 | 244 | ||
263 | /* | 245 | /* |
264 | - * if (lang == null && xmlns != null) { | ||
265 | - * occurrences.add(this.buildOccurrence("3.1", false, html.toString(), | ||
266 | - * html, "2")); } else if (xmlns != null && xmlLang.getValue().isEmpty()) | ||
267 | - * { occurrences.add(this.buildOccurrence("3.1", false, html.toString(), | ||
268 | - * html, "2")); } else if (xmlns != null && xmlns.getValue().isEmpty()) { | ||
269 | - * occurrences.add(this.buildOccurrence("3.1", false, html.toString(), | ||
270 | - * html, "2")); } | 246 | + * if (lang == null && xmlns != null) { occurrences.add(this.buildOccurrence("3.1", false, |
247 | + * html.toString(), html, "2")); } else if (xmlns != null && xmlLang.getValue().isEmpty()) { | ||
248 | + * occurrences.add(this.buildOccurrence("3.1", false, html.toString(), html, "2")); } else if | ||
249 | + * (xmlns != null && xmlns.getValue().isEmpty()) { occurrences.add(this.buildOccurrence("3.1", | ||
250 | + * false, html.toString(), html, "2")); } | ||
271 | */ | 251 | */ |
272 | } | 252 | } |
273 | 253 | ||
@@ -280,15 +260,12 @@ public class ContentEvaluation extends Evaluation { | @@ -280,15 +260,12 @@ public class ContentEvaluation extends Evaluation { | ||
280 | for (Element element : getDocument().getAllElements()) { | 260 | for (Element element : getDocument().getAllElements()) { |
281 | if (!element.getName().equals("html")) { | 261 | if (!element.getName().equals("html")) { |
282 | 262 | ||
283 | - if (element.getName().equals("a") | ||
284 | - && element.getAttributeValue("href") != null) { | 263 | + if (element.getName().equals("a") && element.getAttributeValue("href") != null) { |
285 | if (element.getAttributeValue("href").contains("/?lang=")) { | 264 | if (element.getAttributeValue("href").contains("/?lang=")) { |
286 | - occurrences.add(this.buildOccurrence("3.2", false, | ||
287 | - element.toString(), element, "1")); | 265 | + occurrences.add(this.buildOccurrence("3.2", false, element.toString(), element, "1")); |
288 | } | 266 | } |
289 | } else if (element.getAttributeValue("lang") != null) | 267 | } else if (element.getAttributeValue("lang") != null) |
290 | - occurrences.add(this.buildOccurrence("3.2", false, | ||
291 | - element.toString(), element, "1")); | 268 | + occurrences.add(this.buildOccurrence("3.2", false, element.toString(), element, "1")); |
292 | } | 269 | } |
293 | } | 270 | } |
294 | 271 | ||
@@ -331,8 +308,7 @@ public class ContentEvaluation extends Evaluation { | @@ -331,8 +308,7 @@ public class ContentEvaluation extends Evaluation { | ||
331 | // occurrences.add(new Occurrence("3.3", true, | 308 | // occurrences.add(new Occurrence("3.3", true, |
332 | // "Sem fonte (n�o existe t�tulo na p�gina)",OccurrenceClassification.CONTENT_INFORMATION,"1")); | 309 | // "Sem fonte (n�o existe t�tulo na p�gina)",OccurrenceClassification.CONTENT_INFORMATION,"1")); |
333 | } else if (title.isEmpty()) { | 310 | } else if (title.isEmpty()) { |
334 | - occurrences | ||
335 | - .add(buildOccurrence("3.3", true, title.toString(), title, "1")); | 311 | + occurrences.add(buildOccurrence("3.3", true, title.toString(), title, "1")); |
336 | } | 312 | } |
337 | // } | 313 | // } |
338 | 314 | ||
@@ -341,8 +317,7 @@ public class ContentEvaluation extends Evaluation { | @@ -341,8 +317,7 @@ public class ContentEvaluation extends Evaluation { | ||
341 | 317 | ||
342 | private List<Occurrence> checkRecommendation20() { | 318 | private List<Occurrence> checkRecommendation20() { |
343 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); | 319 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
344 | - occurrences.add(new Occurrence("3.4", false, getDocument() | ||
345 | - .getFirstElement().toString(), | 320 | + occurrences.add(new Occurrence("3.4", false, getDocument().getFirstElement().toString(), |
346 | OccurrenceClassification.CONTENT_INFORMATION)); | 321 | OccurrenceClassification.CONTENT_INFORMATION)); |
347 | return occurrences; | 322 | return occurrences; |
348 | } | 323 | } |
@@ -351,8 +326,7 @@ public class ContentEvaluation extends Evaluation { | @@ -351,8 +326,7 @@ public class ContentEvaluation extends Evaluation { | ||
351 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); | 326 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
352 | UrlSemArquiNoFinal objetoUrlSemArquiNoFinal = new UrlSemArquiNoFinal(); | 327 | UrlSemArquiNoFinal objetoUrlSemArquiNoFinal = new UrlSemArquiNoFinal(); |
353 | 328 | ||
354 | - String urlSemArquiNoFinal = objetoUrlSemArquiNoFinal | ||
355 | - .urlSemArquivoNoFinal(getUrl()); | 329 | + String urlSemArquiNoFinal = objetoUrlSemArquiNoFinal.urlSemArquivoNoFinal(getUrl()); |
356 | 330 | ||
357 | Element LinkComImg; | 331 | Element LinkComImg; |
358 | 332 | ||
@@ -362,75 +336,60 @@ public class ContentEvaluation extends Evaluation { | @@ -362,75 +336,60 @@ public class ContentEvaluation extends Evaluation { | ||
362 | String content = link.getContent().toString(); | 336 | String content = link.getContent().toString(); |
363 | 337 | ||
364 | if (hasEqualsContentHref(link) && isRegistroBr(content)) | 338 | if (hasEqualsContentHref(link) && isRegistroBr(content)) |
365 | - occurrences.add(this.buildOccurrence("3.5", false, link.toString(), | ||
366 | - link, "1")); | 339 | + occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "1")); |
367 | 340 | ||
368 | LinkComImg = link.getFirstElement("img"); | 341 | LinkComImg = link.getFirstElement("img"); |
369 | 342 | ||
370 | if (LinkComImg == null) { | 343 | if (LinkComImg == null) { |
371 | if (!hasContent(link)) { | 344 | if (!hasContent(link)) { |
372 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
373 | - link, "3"));// "2")); | 345 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "3"));// "2")); |
374 | } | 346 | } |
375 | } else { | 347 | } else { |
376 | if (hasLinkComImgWithoutAlt(link)) { | 348 | if (hasLinkComImgWithoutAlt(link)) { |
377 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
378 | - link, "3"));// "2")); | 349 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "3"));// "2")); |
379 | } | 350 | } |
380 | } | 351 | } |
381 | 352 | ||
382 | if (LinkComImg == null) { | 353 | if (LinkComImg == null) { |
383 | // if(hasTitle(link) && isNotAlt(link)) | 354 | // if(hasTitle(link) && isNotAlt(link)) |
384 | if (hasTitle(link) && !hasContent(link)) | 355 | if (hasTitle(link) && !hasContent(link)) |
385 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
386 | - link, "4"));// "3")); | 356 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "4"));// "3")); |
387 | } else { | 357 | } else { |
388 | // if(hasTitle(link) && isNotAlt(link)) | 358 | // if(hasTitle(link) && isNotAlt(link)) |
389 | - if (hasTitle(link) && !hasContent(link) | ||
390 | - && hasLinkComImgWithoutAlt(link)) | ||
391 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
392 | - link, "4"));// "3")); | 359 | + if (hasTitle(link) && !hasContent(link) && hasLinkComImgWithoutAlt(link)) |
360 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "4"));// "3")); | ||
393 | } | 361 | } |
394 | 362 | ||
395 | /* | 363 | /* |
396 | * if(!hasTitle(link) && !hasContent(link) && hasImgWithoutAlt(link)) | 364 | * if(!hasTitle(link) && !hasContent(link) && hasImgWithoutAlt(link)) |
397 | - * occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
398 | - * link,"4")); | 365 | + * occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link,"4")); |
399 | */ | 366 | */ |
400 | 367 | ||
401 | if (hasImgWithoutAlt(link)) | 368 | if (hasImgWithoutAlt(link)) |
402 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
403 | - link, "5"));// "4")); | 369 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "5"));// "4")); |
404 | 370 | ||
405 | if (hasLeiaMaisDescription(link)) | 371 | if (hasLeiaMaisDescription(link)) |
406 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
407 | - link, "6"));// "5")); | 372 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "6"));// "5")); |
408 | 373 | ||
409 | if (hasDiferenteContentSameLink(link)) | 374 | if (hasDiferenteContentSameLink(link)) |
410 | - occurrences.add(this.buildOccurrence("3.5", false, link.toString(), | ||
411 | - link, "10"));// "6")); | 375 | + occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "10"));// "6")); |
412 | 376 | ||
413 | if (isTitleEqualsContent(link)) | 377 | if (isTitleEqualsContent(link)) |
414 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
415 | - link, "12"));// "8")); | 378 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "12"));// "8")); |
416 | 379 | ||
417 | if (hasSameContentDiferentLink(link)) | 380 | if (hasSameContentDiferentLink(link)) |
418 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
419 | - link, "11"));// "7")); | 381 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "11"));// "7")); |
420 | 382 | ||
421 | if (link != null && hasLongContent(link)) | 383 | if (link != null && hasLongContent(link)) |
422 | - occurrences.add(this.buildOccurrence("3.5", false, link.toString(), | ||
423 | - link, "13"));// "9")); | 384 | + occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "13"));// "9")); |
424 | 385 | ||
425 | String retorno = ""; | 386 | String retorno = ""; |
426 | if (link != null) | 387 | if (link != null) |
427 | retorno = isLinkUnavailable(link, urlSemArquiNoFinal); | 388 | retorno = isLinkUnavailable(link, urlSemArquiNoFinal); |
428 | if (retorno.equalsIgnoreCase("erro")) { | 389 | if (retorno.equalsIgnoreCase("erro")) { |
429 | - occurrences.add(this.buildOccurrence("3.5", true, link.toString(), | ||
430 | - link, "14"));// "10")); | 390 | + occurrences.add(this.buildOccurrence("3.5", true, link.toString(), link, "14"));// "10")); |
431 | } else if (retorno.equalsIgnoreCase("aviso")) { | 391 | } else if (retorno.equalsIgnoreCase("aviso")) { |
432 | - occurrences.add(this.buildOccurrence("3.5", false, link.toString(), | ||
433 | - link, "15"));// "10")); | 392 | + occurrences.add(this.buildOccurrence("3.5", false, link.toString(), link, "15"));// "10")); |
434 | } | 393 | } |
435 | 394 | ||
436 | } | 395 | } |
@@ -451,21 +410,19 @@ public class ContentEvaluation extends Evaluation { | @@ -451,21 +410,19 @@ public class ContentEvaluation extends Evaluation { | ||
451 | } | 410 | } |
452 | 411 | ||
453 | if (link.getAttributeValue("href") != null | 412 | if (link.getAttributeValue("href") != null |
454 | - && !link.getAttributeValue("href").toString().trim() | ||
455 | - .equalsIgnoreCase("") | 413 | + && !link.getAttributeValue("href").toString().trim().equalsIgnoreCase("") |
456 | && !link.getAttributeValue("href").substring(0, 1).equals("#") | 414 | && !link.getAttributeValue("href").substring(0, 1).equals("#") |
457 | && !link.getAttributeValue("href").substring(0, 1).equals("/") | 415 | && !link.getAttributeValue("href").substring(0, 1).equals("/") |
458 | && !link.getAttributeValue("href").contains("javascript") | 416 | && !link.getAttributeValue("href").contains("javascript") |
459 | && !link.getAttributeValue("href").contains("@")) { | 417 | && !link.getAttributeValue("href").contains("@")) { |
460 | 418 | ||
461 | /* | 419 | /* |
462 | - * int[] codErro = { 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, | ||
463 | - * 410, 411, 412, 414, 415, 416, 417, 418, 422, 423, 424, 425, 426, 450, | ||
464 | - * 499, 500, 501, 502, 503, 504, 505 }; | 420 | + * int[] codErro = { 400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 414, |
421 | + * 415, 416, 417, 418, 422, 423, 424, 425, 426, 450, 499, 500, 501, 502, 503, 504, 505 }; | ||
465 | */ | 422 | */ |
466 | int codResponse = 0; | 423 | int codResponse = 0; |
467 | 424 | ||
468 | - int[] codErro = { 404 }; | 425 | + int[] codErro = {404}; |
469 | 426 | ||
470 | String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]+$"; | 427 | String regex = "^(https?|ftp|file)://[-a-zA-Z0-9+&@#/%?=~_|!:,.;]*[-a-zA-Z0-9+&@#/%=~_|]+$"; |
471 | 428 | ||
@@ -484,21 +441,19 @@ public class ContentEvaluation extends Evaluation { | @@ -484,21 +441,19 @@ public class ContentEvaluation extends Evaluation { | ||
484 | * clienteHTTPJakartaCommons = new HttpClient(); clienteHTTPJakartaCommons | 441 | * clienteHTTPJakartaCommons = new HttpClient(); clienteHTTPJakartaCommons |
485 | * .getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new | 442 | * .getParams().setParameter(HttpMethodParams.RETRY_HANDLER, new |
486 | * DefaultHttpMethodRetryHandler(3,false)); clienteHTTPJakartaCommons | 443 | * DefaultHttpMethodRetryHandler(3,false)); clienteHTTPJakartaCommons |
487 | - * .getParams().setParameter("http.protocol.allow-circular-redirects" , | ||
488 | - * true); clienteHTTPJakartaCommons.getParams().setParameter( | 444 | + * .getParams().setParameter("http.protocol.allow-circular-redirects" , true); |
445 | + * clienteHTTPJakartaCommons.getParams().setParameter( | ||
489 | * HttpConnectionParams.CONNECTION_TIMEOUT, new Integer(2000)); | 446 | * HttpConnectionParams.CONNECTION_TIMEOUT, new Integer(2000)); |
490 | * | 447 | * |
491 | * metodoRequisicaoGET = new GetMethod(UrlConvertida.toExternalForm() | 448 | * metodoRequisicaoGET = new GetMethod(UrlConvertida.toExternalForm() |
492 | * );//URLEncoder.encode(UrlConvertida.toExternalForm(), "UTF-8")); | 449 | * );//URLEncoder.encode(UrlConvertida.toExternalForm(), "UTF-8")); |
493 | * | 450 | * |
494 | * metodoRequisicaoGET.setRequestHeader("user-agent", "NewUseAgent/1.0"); | 451 | * metodoRequisicaoGET.setRequestHeader("user-agent", "NewUseAgent/1.0"); |
495 | - * metodoRequisicaoGET.setRequestHeader("http.agent", | ||
496 | - * "Jakarta Commons-HttpClient/3.1"); | 452 | + * metodoRequisicaoGET.setRequestHeader("http.agent", "Jakarta Commons-HttpClient/3.1"); |
497 | * metodoRequisicaoGET.setFollowRedirects(true); | 453 | * metodoRequisicaoGET.setFollowRedirects(true); |
498 | */ | 454 | */ |
499 | 455 | ||
500 | - codResponse = verificarConexao(href, "http.agent", | ||
501 | - "Jakarta Commons-HttpClient/3.1"); | 456 | + codResponse = verificarConexao(href, "http.agent", "Jakarta Commons-HttpClient/3.1"); |
502 | if (codResponse != 200) { | 457 | if (codResponse != 200) { |
503 | codResponse = verificarConexao(href, "user-agent", "NewUseAgent/1.0"); | 458 | codResponse = verificarConexao(href, "user-agent", "NewUseAgent/1.0"); |
504 | if (codResponse == -1) { | 459 | if (codResponse == -1) { |
@@ -507,25 +462,21 @@ public class ContentEvaluation extends Evaluation { | @@ -507,25 +462,21 @@ public class ContentEvaluation extends Evaluation { | ||
507 | } | 462 | } |
508 | 463 | ||
509 | /* | 464 | /* |
510 | - * } catch (MalformedURLException e) { e.printStackTrace(); return | ||
511 | - * "aviso"; | 465 | + * } catch (MalformedURLException e) { e.printStackTrace(); return "aviso"; |
512 | * | 466 | * |
513 | * } catch (IOException e) { e.printStackTrace(); return "aviso"; | 467 | * } catch (IOException e) { e.printStackTrace(); return "aviso"; |
514 | * | 468 | * |
515 | - * } catch (IllegalArgumentException e) { e.printStackTrace(); return | ||
516 | - * "aviso"; | 469 | + * } catch (IllegalArgumentException e) { e.printStackTrace(); return "aviso"; |
517 | * | 470 | * |
518 | * } finally { | 471 | * } finally { |
519 | * | 472 | * |
520 | - * if (metodoRequisicaoGET != null){ | ||
521 | - * metodoRequisicaoGET.releaseConnection(); } | 473 | + * if (metodoRequisicaoGET != null){ metodoRequisicaoGET.releaseConnection(); } |
522 | * | 474 | * |
523 | * } | 475 | * } |
524 | */ | 476 | */ |
525 | 477 | ||
526 | /* | 478 | /* |
527 | - * if(huc.getResponseCode() != HttpURLConnection.HTTP_OK) | ||
528 | - * System.out.println(link.toString()); | 479 | + * if(huc.getResponseCode() != HttpURLConnection.HTTP_OK) System.out.println(link.toString()); |
529 | */ | 480 | */ |
530 | for (int cod : codErro) { | 481 | for (int cod : codErro) { |
531 | if (codResponse == cod) { | 482 | if (codResponse == cod) { |
@@ -541,6 +492,7 @@ public class ContentEvaluation extends Evaluation { | @@ -541,6 +492,7 @@ public class ContentEvaluation extends Evaluation { | ||
541 | 492 | ||
542 | private Integer verificarConexao(String href, String usuario, String agente) { | 493 | private Integer verificarConexao(String href, String usuario, String agente) { |
543 | 494 | ||
495 | + System.setProperty("jsse.enableSNIExtension", "false"); | ||
544 | HttpMethod metodoRequisicaoGET = null; | 496 | HttpMethod metodoRequisicaoGET = null; |
545 | HttpClient clienteHTTPJakartaCommons; | 497 | HttpClient clienteHTTPJakartaCommons; |
546 | URL UrlConvertida; | 498 | URL UrlConvertida; |
@@ -561,13 +513,12 @@ public class ContentEvaluation extends Evaluation { | @@ -561,13 +513,12 @@ public class ContentEvaluation extends Evaluation { | ||
561 | // aos links da página por meio do cliente da API Jakarta Commons | 513 | // aos links da página por meio do cliente da API Jakarta Commons |
562 | // VErsão 3.1 | 514 | // VErsão 3.1 |
563 | clienteHTTPJakartaCommons = new HttpClient(); | 515 | clienteHTTPJakartaCommons = new HttpClient(); |
564 | - clienteHTTPJakartaCommons.getParams().setParameter( | ||
565 | - HttpMethodParams.RETRY_HANDLER, | 516 | + clienteHTTPJakartaCommons.getParams().setParameter(HttpMethodParams.RETRY_HANDLER, |
566 | new DefaultHttpMethodRetryHandler(3, false)); | 517 | new DefaultHttpMethodRetryHandler(3, false)); |
567 | - clienteHTTPJakartaCommons.getParams().setParameter( | ||
568 | - "http.protocol.allow-circular-redirects", true); | ||
569 | - clienteHTTPJakartaCommons.getParams().setParameter( | ||
570 | - HttpConnectionParams.CONNECTION_TIMEOUT, new Integer(2000)); | 518 | + clienteHTTPJakartaCommons.getParams().setParameter("http.protocol.allow-circular-redirects", |
519 | + true); | ||
520 | + clienteHTTPJakartaCommons.getParams().setParameter(HttpConnectionParams.CONNECTION_TIMEOUT, | ||
521 | + new Integer(2000)); | ||
571 | 522 | ||
572 | metodoRequisicaoGET = new GetMethod(UrlConvertida.toExternalForm());// URLEncoder.encode(UrlConvertida.toExternalForm(), | 523 | metodoRequisicaoGET = new GetMethod(UrlConvertida.toExternalForm());// URLEncoder.encode(UrlConvertida.toExternalForm(), |
573 | // "UTF-8")); | 524 | // "UTF-8")); |
@@ -575,8 +526,7 @@ public class ContentEvaluation extends Evaluation { | @@ -575,8 +526,7 @@ public class ContentEvaluation extends Evaluation { | ||
575 | metodoRequisicaoGET.setRequestHeader(usuario, agente); | 526 | metodoRequisicaoGET.setRequestHeader(usuario, agente); |
576 | // metodoRequisicaoGET.setFollowRedirects(true); | 527 | // metodoRequisicaoGET.setFollowRedirects(true); |
577 | 528 | ||
578 | - codResponse = clienteHTTPJakartaCommons | ||
579 | - .executeMethod(metodoRequisicaoGET); | 529 | + codResponse = clienteHTTPJakartaCommons.executeMethod(metodoRequisicaoGET); |
580 | 530 | ||
581 | } catch (MalformedURLException e) { | 531 | } catch (MalformedURLException e) { |
582 | e.printStackTrace(); | 532 | e.printStackTrace(); |
@@ -617,21 +567,18 @@ public class ContentEvaluation extends Evaluation { | @@ -617,21 +567,18 @@ public class ContentEvaluation extends Evaluation { | ||
617 | } | 567 | } |
618 | 568 | ||
619 | private boolean hasLongContent(Element link) { | 569 | private boolean hasLongContent(Element link) { |
620 | - return link.getContent().getTextExtractor().toString().length() > 500 ? true | ||
621 | - : false; | 570 | + return link.getContent().getTextExtractor().toString().length() > 500 ? true : false; |
622 | } | 571 | } |
623 | 572 | ||
624 | private boolean hasContent(Element link) { | 573 | private boolean hasContent(Element link) { |
625 | 574 | ||
626 | boolean temConteudo; | 575 | boolean temConteudo; |
627 | 576 | ||
628 | - temConteudo = StringUtils.isNotBlank(link.getContent().getTextExtractor() | ||
629 | - .toString()); | 577 | + temConteudo = StringUtils.isNotBlank(link.getContent().getTextExtractor().toString()); |
630 | 578 | ||
631 | if (!temConteudo) { | 579 | if (!temConteudo) { |
632 | for (Element elemento : link.getAllElements()) { | 580 | for (Element elemento : link.getAllElements()) { |
633 | - temConteudo = StringUtils.isNotBlank(elemento.getContent() | ||
634 | - .getTextExtractor().toString()); | 581 | + temConteudo = StringUtils.isNotBlank(elemento.getContent().getTextExtractor().toString()); |
635 | 582 | ||
636 | if (temConteudo) { | 583 | if (temConteudo) { |
637 | break; | 584 | break; |
@@ -641,13 +588,12 @@ public class ContentEvaluation extends Evaluation { | @@ -641,13 +588,12 @@ public class ContentEvaluation extends Evaluation { | ||
641 | return temConteudo; | 588 | return temConteudo; |
642 | 589 | ||
643 | /* | 590 | /* |
644 | - * quantidadeElementosDentroLink = link.getAllElements().size(); //Verifica | ||
645 | - * se h� elementos como img, span e outros dentro do link. o valor 1 j� est� | ||
646 | - * atribu�do a tag <a> (link avaliado) if(quantidadeElementosDentroLink > 1) | ||
647 | - * { temConteudo = true; } //avalia apenas o texto dentro do link ex: | ||
648 | - * <a>texto entre o link</a> else { temConteudo = | ||
649 | - * StringUtils.isNotBlank(link.getContent().getTextExtractor ().toString()); | ||
650 | - * } return temConteudo; | 591 | + * quantidadeElementosDentroLink = link.getAllElements().size(); //Verifica se h� elementos como |
592 | + * img, span e outros dentro do link. o valor 1 j� est� atribu�do a tag <a> (link avaliado) | ||
593 | + * if(quantidadeElementosDentroLink > 1) { temConteudo = true; } //avalia apenas o texto dentro | ||
594 | + * do link ex: <a>texto entre o link</a> else { temConteudo = | ||
595 | + * StringUtils.isNotBlank(link.getContent().getTextExtractor ().toString()); } return | ||
596 | + * temConteudo; | ||
651 | */ | 597 | */ |
652 | } | 598 | } |
653 | 599 | ||
@@ -685,8 +631,9 @@ public class ContentEvaluation extends Evaluation { | @@ -685,8 +631,9 @@ public class ContentEvaluation extends Evaluation { | ||
685 | private boolean hasLeiaMaisDescription(Element link) { | 631 | private boolean hasLeiaMaisDescription(Element link) { |
686 | String title = link.getAttributeValue("title"); | 632 | String title = link.getAttributeValue("title"); |
687 | String content = link.getContent().getTextExtractor().toString(); | 633 | String content = link.getContent().getTextExtractor().toString(); |
688 | - String altImg = link.getFirstElement("img") != null ? link.getFirstElement( | ||
689 | - "img").getAttributeValue("alt") : ""; | 634 | + String altImg = |
635 | + link.getFirstElement("img") != null ? link.getFirstElement("img").getAttributeValue("alt") | ||
636 | + : ""; | ||
690 | 637 | ||
691 | for (String leiaMais : this.leiaMais) { | 638 | for (String leiaMais : this.leiaMais) { |
692 | 639 | ||
@@ -708,11 +655,9 @@ public class ContentEvaluation extends Evaluation { | @@ -708,11 +655,9 @@ public class ContentEvaluation extends Evaluation { | ||
708 | * Pattern.compile("("+leiaMais+")"); if(title!=null) | 655 | * Pattern.compile("("+leiaMais+")"); if(title!=null) |
709 | * if(pattern.matcher(title.toLowerCase()).find()) return true; | 656 | * if(pattern.matcher(title.toLowerCase()).find()) return true; |
710 | * | 657 | * |
711 | - * if(content!=null) if(pattern.matcher(content.toLowerCase()).find()) | ||
712 | - * return true; | 658 | + * if(content!=null) if(pattern.matcher(content.toLowerCase()).find()) return true; |
713 | * | 659 | * |
714 | - * if(altImg!=null) if(pattern.matcher(altImg.toLowerCase()).find()) return | ||
715 | - * true; } | 660 | + * if(altImg!=null) if(pattern.matcher(altImg.toLowerCase()).find()) return true; } |
716 | */ | 661 | */ |
717 | 662 | ||
718 | return false; | 663 | return false; |
@@ -754,8 +699,7 @@ public class ContentEvaluation extends Evaluation { | @@ -754,8 +699,7 @@ public class ContentEvaluation extends Evaluation { | ||
754 | otherHref = otherLink.getAttributeValue("href"); | 699 | otherHref = otherLink.getAttributeValue("href"); |
755 | if (StringUtils.isBlank(otherHref)) | 700 | if (StringUtils.isBlank(otherHref)) |
756 | continue; | 701 | continue; |
757 | - if (!content.toLowerCase().equals(otherContent.toLowerCase()) | ||
758 | - && href.equals(otherHref)) | 702 | + if (!content.toLowerCase().equals(otherContent.toLowerCase()) && href.equals(otherHref)) |
759 | return true; | 703 | return true; |
760 | } | 704 | } |
761 | return false; | 705 | return false; |
@@ -789,8 +733,7 @@ public class ContentEvaluation extends Evaluation { | @@ -789,8 +733,7 @@ public class ContentEvaluation extends Evaluation { | ||
789 | // otherLink.getContent().getTextExtractor().toString(); | 733 | // otherLink.getContent().getTextExtractor().toString(); |
790 | 734 | ||
791 | if (otherContent != null) | 735 | if (otherContent != null) |
792 | - otherContent = otherContent.replace("http://", "").replaceFirst("(/$)", | ||
793 | - ""); | 736 | + otherContent = otherContent.replace("http://", "").replaceFirst("(/$)", ""); |
794 | 737 | ||
795 | otherHref = otherLink.getAttributeValue("href"); | 738 | otherHref = otherLink.getAttributeValue("href"); |
796 | 739 | ||
@@ -800,8 +743,7 @@ public class ContentEvaluation extends Evaluation { | @@ -800,8 +743,7 @@ public class ContentEvaluation extends Evaluation { | ||
800 | if (StringUtils.isBlank(otherHref)) | 743 | if (StringUtils.isBlank(otherHref)) |
801 | continue; | 744 | continue; |
802 | if (!linksVerificados.contains(content)) { | 745 | if (!linksVerificados.contains(content)) { |
803 | - if (content.toLowerCase().equals(otherContent.toLowerCase()) | ||
804 | - && !href.equals(otherHref)) { | 746 | + if (content.toLowerCase().equals(otherContent.toLowerCase()) && !href.equals(otherHref)) { |
805 | linksVerificados.add(content); | 747 | linksVerificados.add(content); |
806 | return true; | 748 | return true; |
807 | } | 749 | } |
@@ -826,7 +768,7 @@ public class ContentEvaluation extends Evaluation { | @@ -826,7 +768,7 @@ public class ContentEvaluation extends Evaluation { | ||
826 | 768 | ||
827 | String[] parts = null; | 769 | String[] parts = null; |
828 | 770 | ||
829 | - String[] descricoes = { "figura", "imagem", "alt", "descrição", "foto" }; | 771 | + String[] descricoes = {"figura", "imagem", "alt", "descrição", "foto"}; |
830 | 772 | ||
831 | for (Element img : getDocument().getAllElements("img")) { | 773 | for (Element img : getDocument().getAllElements("img")) { |
832 | Attribute alt = img.getAttributes().get("alt"); | 774 | Attribute alt = img.getAttributes().get("alt"); |
@@ -846,14 +788,12 @@ public class ContentEvaluation extends Evaluation { | @@ -846,14 +788,12 @@ public class ContentEvaluation extends Evaluation { | ||
846 | 788 | ||
847 | if (parts.length > 0) | 789 | if (parts.length > 0) |
848 | if (parts[parts.length - 1].toString().equals(contAlt)) | 790 | if (parts[parts.length - 1].toString().equals(contAlt)) |
849 | - occurrences.add(buildOccurrence("3.6", true, img.toString(), img, | ||
850 | - "3")); | 791 | + occurrences.add(buildOccurrence("3.6", true, img.toString(), img, "3")); |
851 | } | 792 | } |
852 | 793 | ||
853 | for (String descricao : descricoes) { | 794 | for (String descricao : descricoes) { |
854 | if (descricao.equalsIgnoreCase(contAlt)) | 795 | if (descricao.equalsIgnoreCase(contAlt)) |
855 | - occurrences | ||
856 | - .add(buildOccurrence("3.6", true, img.toString(), img, "4")); | 796 | + occurrences.add(buildOccurrence("3.6", true, img.toString(), img, "4")); |
857 | 797 | ||
858 | } | 798 | } |
859 | 799 | ||
@@ -887,8 +827,7 @@ public class ContentEvaluation extends Evaluation { | @@ -887,8 +827,7 @@ public class ContentEvaluation extends Evaluation { | ||
887 | if (alt.getValue().equals(altAtt.getValue())) { | 827 | if (alt.getValue().equals(altAtt.getValue())) { |
888 | if (srcAtt != null) { | 828 | if (srcAtt != null) { |
889 | if (!src.getValue().equals(srcAtt.getValue())) { | 829 | if (!src.getValue().equals(srcAtt.getValue())) { |
890 | - occurrences.add(buildOccurrence("3.6", false, | ||
891 | - imgA.toString(), imgA, "7"));// "5")); | 830 | + occurrences.add(buildOccurrence("3.6", false, imgA.toString(), imgA, "7"));// "5")); |
892 | aMap.put(srcAtt.getValue(), img); | 831 | aMap.put(srcAtt.getValue(), img); |
893 | isVerificado = true; | 832 | isVerificado = true; |
894 | } | 833 | } |
@@ -903,8 +842,7 @@ public class ContentEvaluation extends Evaluation { | @@ -903,8 +842,7 @@ public class ContentEvaluation extends Evaluation { | ||
903 | aMap.put(src.getValue(), img); | 842 | aMap.put(src.getValue(), img); |
904 | 843 | ||
905 | if (isVerificado) | 844 | if (isVerificado) |
906 | - occurrences.add(buildOccurrence("3.6", false, img.toString(), img, | ||
907 | - "7"));// "5")); | 845 | + occurrences.add(buildOccurrence("3.6", false, img.toString(), img, "7"));// "5")); |
908 | } | 846 | } |
909 | } | 847 | } |
910 | 848 | ||
@@ -914,13 +852,12 @@ public class ContentEvaluation extends Evaluation { | @@ -914,13 +852,12 @@ public class ContentEvaluation extends Evaluation { | ||
914 | * for (Element img : getDocument().getAllElements("img")) { | 852 | * for (Element img : getDocument().getAllElements("img")) { |
915 | * | 853 | * |
916 | * Attribute src = img.getAttributes().get("src"); Attribute altAtt = | 854 | * Attribute src = img.getAttributes().get("src"); Attribute altAtt = |
917 | - * img.getAttributes().get("alt"); if (altAtt != null && | ||
918 | - * !altAtt.getValue().isEmpty()) { if(aMap.containsKey(altAtt.getValue())){ | ||
919 | - * Attribute srcAtt = img.getAttributes().get("src"); if(srcAtt != null){ | ||
920 | - * if(!aMap.get(altAtt | 855 | + * img.getAttributes().get("alt"); if (altAtt != null && !altAtt.getValue().isEmpty()) { |
856 | + * if(aMap.containsKey(altAtt.getValue())){ Attribute srcAtt = img.getAttributes().get("src"); | ||
857 | + * if(srcAtt != null){ if(!aMap.get(altAtt | ||
921 | * .getValue()).contains("src=\""+srcAtt.getValue()+"\"")) | 858 | * .getValue()).contains("src=\""+srcAtt.getValue()+"\"")) |
922 | - * occurrences.add(buildOccurrence("3.6", false, img.toString(), img, "5")); | ||
923 | - * } }else{ aMap.put(altAtt.getValue(), img.toString()); } } } | 859 | + * occurrences.add(buildOccurrence("3.6", false, img.toString(), img, "5")); } }else{ |
860 | + * aMap.put(altAtt.getValue(), img.toString()); } } } | ||
924 | */ | 861 | */ |
925 | 862 | ||
926 | for (Element img : getDocument().getAllElements("img")) { | 863 | for (Element img : getDocument().getAllElements("img")) { |
@@ -928,8 +865,7 @@ public class ContentEvaluation extends Evaluation { | @@ -928,8 +865,7 @@ public class ContentEvaluation extends Evaluation { | ||
928 | Attribute title = img.getAttributes().get("title"); | 865 | Attribute title = img.getAttributes().get("title"); |
929 | if (alt != null && title != null) { | 866 | if (alt != null && title != null) { |
930 | if (title.getValue().equals(alt.getValue())) | 867 | if (title.getValue().equals(alt.getValue())) |
931 | - occurrences | ||
932 | - .add(buildOccurrence("3.6", true, img.toString(), img, "8"));// "6")); | 868 | + occurrences.add(buildOccurrence("3.6", true, img.toString(), img, "8"));// "6")); |
933 | } | 869 | } |
934 | } | 870 | } |
935 | 871 | ||
@@ -949,8 +885,7 @@ public class ContentEvaluation extends Evaluation { | @@ -949,8 +885,7 @@ public class ContentEvaluation extends Evaluation { | ||
949 | Attribute alt = table.getAttributes().get("alt"); | 885 | Attribute alt = table.getAttributes().get("alt"); |
950 | 886 | ||
951 | if (usemap != null && (alt == null || alt.getValue().isEmpty())) { | 887 | if (usemap != null && (alt == null || alt.getValue().isEmpty())) { |
952 | - occurrences.add(this.buildOccurrence("3.7", true, table.toString(), | ||
953 | - table, "1")); | 888 | + occurrences.add(this.buildOccurrence("3.7", true, table.toString(), table, "1")); |
954 | isMap = true; | 889 | isMap = true; |
955 | } | 890 | } |
956 | 891 | ||
@@ -961,8 +896,7 @@ public class ContentEvaluation extends Evaluation { | @@ -961,8 +896,7 @@ public class ContentEvaluation extends Evaluation { | ||
961 | for (Element area : map.getAllElements("area")) { | 896 | for (Element area : map.getAllElements("area")) { |
962 | Attribute alt = area.getAttributes().get("alt"); | 897 | Attribute alt = area.getAttributes().get("alt"); |
963 | if (alt == null || alt.getValue().isEmpty()) | 898 | if (alt == null || alt.getValue().isEmpty()) |
964 | - occurrences.add(this.buildOccurrence("3.7", true, map.toString(), | ||
965 | - map, "1")); | 899 | + occurrences.add(this.buildOccurrence("3.7", true, map.toString(), map, "1")); |
966 | } | 900 | } |
967 | } | 901 | } |
968 | 902 | ||
@@ -971,8 +905,7 @@ public class ContentEvaluation extends Evaluation { | @@ -971,8 +905,7 @@ public class ContentEvaluation extends Evaluation { | ||
971 | 905 | ||
972 | private List<Occurrence> checkRecommendation24() { | 906 | private List<Occurrence> checkRecommendation24() { |
973 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); | 907 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
974 | - occurrences.add(new Occurrence("3.8", false, getDocument() | ||
975 | - .getFirstElement().toString(), | 908 | + occurrences.add(new Occurrence("3.8", false, getDocument().getFirstElement().toString(), |
976 | OccurrenceClassification.CONTENT_INFORMATION)); | 909 | OccurrenceClassification.CONTENT_INFORMATION)); |
977 | return occurrences; | 910 | return occurrences; |
978 | } | 911 | } |
@@ -980,22 +913,19 @@ public class ContentEvaluation extends Evaluation { | @@ -980,22 +913,19 @@ public class ContentEvaluation extends Evaluation { | ||
980 | private List<Occurrence> checkRecommendation25() { | 913 | private List<Occurrence> checkRecommendation25() { |
981 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); | 914 | List<Occurrence> occurrences = new ArrayList<Occurrence>(); |
982 | 915 | ||
983 | - String doctype = getDocument().getFirstStartTag().toString() | ||
984 | - .replace(" ", ""); | 916 | + String doctype = getDocument().getFirstStartTag().toString().replace(" ", ""); |
985 | 917 | ||
986 | for (Element table : getDocument().getAllElements("table")) { | 918 | for (Element table : getDocument().getAllElements("table")) { |
987 | Attribute summary = table.getAttributes().get("summary"); | 919 | Attribute summary = table.getAttributes().get("summary"); |
988 | 920 | ||
989 | if (!doctype.equalsIgnoreCase("<!DOCTYPEhtml>")) { | 921 | if (!doctype.equalsIgnoreCase("<!DOCTYPEhtml>")) { |
990 | if (summary == null || summary.getValue().equals("")) | 922 | if (summary == null || summary.getValue().equals("")) |
991 | - occurrences.add(buildOccurrence("3.9", false, table.getStartTag() | ||
992 | - .toString(), table, "1")); | 923 | + occurrences |
924 | + .add(buildOccurrence("3.9", false, table.getStartTag().toString(), table, "1")); | ||
993 | } | 925 | } |
994 | 926 | ||
995 | - if (table.getAllElements("caption").isEmpty() | ||
996 | - || table.getAllElements("caption") == null) | ||
997 | - occurrences.add(buildOccurrence("3.9", false, table.getStartTag() | ||
998 | - .toString(), table, "1")); | 927 | + if (table.getAllElements("caption").isEmpty() || table.getAllElements("caption") == null) |
928 | + occurrences.add(buildOccurrence("3.9", false, table.getStartTag().toString(), table, "1")); | ||
999 | } | 929 | } |
1000 | 930 | ||
1001 | return occurrences; | 931 | return occurrences; |
@@ -1010,8 +940,7 @@ public class ContentEvaluation extends Evaluation { | @@ -1010,8 +940,7 @@ public class ContentEvaluation extends Evaluation { | ||
1010 | 940 | ||
1011 | temAssociacao = false; | 941 | temAssociacao = false; |
1012 | 942 | ||
1013 | - if (table.getAllElements("thead").size() > 0 | ||
1014 | - && table.getAllElements("tbody").size() > 0) { | 943 | + if (table.getAllElements("thead").size() > 0 && table.getAllElements("tbody").size() > 0) { |
1015 | temAssociacao = true; | 944 | temAssociacao = true; |
1016 | } else { | 945 | } else { |
1017 | for (Element coluna : table.getAllElements("td")) { | 946 | for (Element coluna : table.getAllElements("td")) { |
@@ -1037,8 +966,8 @@ public class ContentEvaluation extends Evaluation { | @@ -1037,8 +966,8 @@ public class ContentEvaluation extends Evaluation { | ||
1037 | } | 966 | } |
1038 | 967 | ||
1039 | if (!temAssociacao) { | 968 | if (!temAssociacao) { |
1040 | - occurrences.add(this.buildOccurrence("3.10", true, table.getStartTag() | ||
1041 | - .toString(), table, "1")); | 969 | + occurrences.add(this.buildOccurrence("3.10", true, table.getStartTag().toString(), table, |
970 | + "1")); | ||
1042 | } | 971 | } |
1043 | 972 | ||
1044 | } | 973 | } |
@@ -1067,34 +996,29 @@ public class ContentEvaluation extends Evaluation { | @@ -1067,34 +996,29 @@ public class ContentEvaluation extends Evaluation { | ||
1067 | * | 996 | * |
1068 | * while(m.find()){ String conteudoParagrafo = m.group(1); | 997 | * while(m.find()){ String conteudoParagrafo = m.group(1); |
1069 | * | 998 | * |
1070 | - * if(conteudoParagrafo.length() > 1000) | ||
1071 | - * occurrences.add(this.buildOccurrence("3.11", false, | 999 | + * if(conteudoParagrafo.length() > 1000) occurrences.add(this.buildOccurrence("3.11", false, |
1072 | * paragrafo.toString(), paragrafo, "1")); } | 1000 | * paragrafo.toString(), paragrafo, "1")); } |
1073 | */ | 1001 | */ |
1074 | 1002 | ||
1075 | /* | 1003 | /* |
1076 | - * if (paragrafo.getContent().length() > 1000) | ||
1077 | - * occurrences.add(this.buildOccurrence("3.11", false, | ||
1078 | - * paragrafo.toString(), paragrafo, "1")); | 1004 | + * if (paragrafo.getContent().length() > 1000) occurrences.add(this.buildOccurrence("3.11", |
1005 | + * false, paragrafo.toString(), paragrafo, "1")); | ||
1079 | */// comentado por Gibran | 1006 | */// comentado por Gibran |
1080 | 1007 | ||
1081 | String align = paragrafo.getAttributeValue("align"); | 1008 | String align = paragrafo.getAttributeValue("align"); |
1082 | if ("justify".equals(align)) | 1009 | if ("justify".equals(align)) |
1083 | - occurrences.add(this.buildOccurrence("3.11", true, | ||
1084 | - paragrafo.toString(), paragrafo, "2")); | 1010 | + occurrences.add(this.buildOccurrence("3.11", true, paragrafo.toString(), paragrafo, "2")); |
1085 | 1011 | ||
1086 | String style = paragrafo.getAttributeValue("style"); | 1012 | String style = paragrafo.getAttributeValue("style"); |
1087 | if (style != null && style.contains("text-align:justify")) | 1013 | if (style != null && style.contains("text-align:justify")) |
1088 | - occurrences.add(this.buildOccurrence("3.11", true, | ||
1089 | - paragrafo.toString(), paragrafo, "2")); | 1014 | + occurrences.add(this.buildOccurrence("3.11", true, paragrafo.toString(), paragrafo, "2")); |
1090 | } | 1015 | } |
1091 | 1016 | ||
1092 | for (Element tags : getDocument().getAllElements()) { | 1017 | for (Element tags : getDocument().getAllElements()) { |
1093 | if (!tags.getName().equals("p")) { | 1018 | if (!tags.getName().equals("p")) { |
1094 | String style = tags.getAttributeValue("style"); | 1019 | String style = tags.getAttributeValue("style"); |
1095 | if (style != null && style.contains("text-align:justify")) | 1020 | if (style != null && style.contains("text-align:justify")) |
1096 | - occurrences.add(this.buildOccurrence("3.11", true, tags.toString(), | ||
1097 | - tags, "3")); | 1021 | + occurrences.add(this.buildOccurrence("3.11", true, tags.toString(), tags, "3")); |
1098 | } | 1022 | } |
1099 | 1023 | ||
1100 | } | 1024 | } |
@@ -1107,19 +1031,17 @@ public class ContentEvaluation extends Evaluation { | @@ -1107,19 +1031,17 @@ public class ContentEvaluation extends Evaluation { | ||
1107 | for (Element abbr : getDocument().getAllElements("abbr")) { | 1031 | for (Element abbr : getDocument().getAllElements("abbr")) { |
1108 | Attribute title = abbr.getAttributes().get("title"); | 1032 | Attribute title = abbr.getAttributes().get("title"); |
1109 | if (title == null || title.getValue().equals("")) | 1033 | if (title == null || title.getValue().equals("")) |
1110 | - occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, | ||
1111 | - "1")); | 1034 | + occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, "1")); |
1112 | 1035 | ||
1113 | if (abbr.getContent() == null) | 1036 | if (abbr.getContent() == null) |
1114 | - occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, | ||
1115 | - "1")); | 1037 | + occurrences.add(buildOccurrence("3.12", true, abbr.toString(), abbr, "1")); |
1116 | } | 1038 | } |
1117 | 1039 | ||
1118 | return occurrences; | 1040 | return occurrences; |
1119 | } | 1041 | } |
1120 | 1042 | ||
1121 | - private Occurrence buildOccurrence(String code, boolean error, String tag, | ||
1122 | - Element element, String criterio) { | 1043 | + private Occurrence buildOccurrence(String code, boolean error, String tag, Element element, |
1044 | + String criterio) { | ||
1123 | return super.buildOccurrence(code, error, tag, element, | 1045 | return super.buildOccurrence(code, error, tag, element, |
1124 | OccurrenceClassification.CONTENT_INFORMATION, criterio); | 1046 | OccurrenceClassification.CONTENT_INFORMATION, criterio); |
1125 | } | 1047 | } |
@@ -1128,20 +1050,18 @@ public class ContentEvaluation extends Evaluation { | @@ -1128,20 +1050,18 @@ public class ContentEvaluation extends Evaluation { | ||
1128 | return OccurrenceClassification.CONTENT_INFORMATION; | 1050 | return OccurrenceClassification.CONTENT_INFORMATION; |
1129 | } | 1051 | } |
1130 | 1052 | ||
1131 | - private String[] hrefRegistroBr = { "COM", "COM.BR", "ECO.BR", "EMP.BR", | ||
1132 | - "NET.BR", "EDU.BR", "ADM.BR", "ADV.BR", "ARQ.BR", "ATO.BR", "BIO.BR", | ||
1133 | - "BMD.BR", "CIM.BR", "CNG.BR", "CNT.BR", "ECN.BR", "ENG.BR", "ETI.B", | ||
1134 | - "FND.BR", "FOT.BR", "FST.BR", "GGF.BR", "JOR.BR", "LEL.BR", "MAT.BR", | ||
1135 | - "MED.BR", "MUS.BR", "NOT.BR", "NTR.BR", "ODO.BR", "PPG.BR", "PRO.BR", | ||
1136 | - "PSC.BR", "QSL.BR", "SLG.BR", "TAXI.BR", "TEO.BR", "TRD.BR", "VET.BR", | ||
1137 | - "ZLG.BR", "BLOG.BR", "FLOG.BR", "NOM.BR", "VLOG.BR", "WIKI.BR", "AGR.BR", | ||
1138 | - "ART.BR", "ESP.BR", "ETC.BR", "FAR.BR", "IMB.BR", "IND.BR", "INF.BR", | ||
1139 | - "RADIO.BR", "REC.BR", "SRV.BR", "TMP.BR", "TUR.BR", "TV.BR", "AM.BR", | ||
1140 | - "COOP.BR", "FM.BR", "G12.BR", "GOV.BR", "MIL.BR", "ORG.BR", "PSI.BR", | ||
1141 | - "B.BR", "JUS.BR", "LEG.BR", "MP.BR" }; | ||
1142 | - | ||
1143 | - private String[] leiaMais = { "clique aqui", "leia mais", "saiba mais", | ||
1144 | - "veja mais", "acesse a lista", "mais" }; | 1053 | + private String[] hrefRegistroBr = {"COM", "COM.BR", "ECO.BR", "EMP.BR", "NET.BR", "EDU.BR", |
1054 | + "ADM.BR", "ADV.BR", "ARQ.BR", "ATO.BR", "BIO.BR", "BMD.BR", "CIM.BR", "CNG.BR", "CNT.BR", | ||
1055 | + "ECN.BR", "ENG.BR", "ETI.B", "FND.BR", "FOT.BR", "FST.BR", "GGF.BR", "JOR.BR", "LEL.BR", | ||
1056 | + "MAT.BR", "MED.BR", "MUS.BR", "NOT.BR", "NTR.BR", "ODO.BR", "PPG.BR", "PRO.BR", "PSC.BR", | ||
1057 | + "QSL.BR", "SLG.BR", "TAXI.BR", "TEO.BR", "TRD.BR", "VET.BR", "ZLG.BR", "BLOG.BR", "FLOG.BR", | ||
1058 | + "NOM.BR", "VLOG.BR", "WIKI.BR", "AGR.BR", "ART.BR", "ESP.BR", "ETC.BR", "FAR.BR", "IMB.BR", | ||
1059 | + "IND.BR", "INF.BR", "RADIO.BR", "REC.BR", "SRV.BR", "TMP.BR", "TUR.BR", "TV.BR", "AM.BR", | ||
1060 | + "COOP.BR", "FM.BR", "G12.BR", "GOV.BR", "MIL.BR", "ORG.BR", "PSI.BR", "B.BR", "JUS.BR", | ||
1061 | + "LEG.BR", "MP.BR"}; | ||
1062 | + | ||
1063 | + private String[] leiaMais = {"clique aqui", "leia mais", "saiba mais", "veja mais", | ||
1064 | + "acesse a lista", "mais"}; | ||
1145 | 1065 | ||
1146 | private List<Occurrence> oder(List<Occurrence> occurrences) { | 1066 | private List<Occurrence> oder(List<Occurrence> occurrences) { |
1147 | // Sorting | 1067 | // Sorting |