O portal Liferay realiza busca dentro de arquivos, como por exemplo, arquivos pdf, word, etc…
Por algum motivo, essa busca pode começar a dar problemas e um deles é a inserção de caracteres inválidos dentro do xml que o portlet de Busca utiliza para fazer a leitura.
Para identificar esse problema observe que o log começará a avisar sobre um erro na leitura do xml no momento em que o portal tenta fazer a busca nos arquivos.
A maneira como corrigimos esse problema foi identificar o local onde ele faz essa leitura e utilizar um método em java que retira os caracteres inválidos do xml, como é narrado abaixo:
O método que criamos é o seguinte:
String stripNonValidXMLCharacters(String in) {
StringBuffer out = new StringBuffer(); // Used to hold the output.
char current; // Used to reference the current character.
if (in == null || ("".equals(in))) return ""; // vacancy test.
for (int i = 0; i < in.length(); i++) { current = in.charAt(i); // NOTE: No IndexOutOfBoundsException caught here; it should not happen. if ((current == 0x9) || (current == 0xA) || (current == 0xD) || ((current >= 0x20) && (current <= 0xD7FF)) || ((current >= 0xE000) && (current <= 0xFFFD)) || ((current >= 0x10000) && (current <= 0x10FFFF)))
out.append(current);
}
return out.toString();
}
E inserimos esse método no arquivo liferay-portal-5.2.3\tomcat-6.0.18\webapps\ROOT\html\portlet\search\search.jsp
No momento em que ele faz a leitura do xml, na linha # 169 inserimos o seguinte código:
xml = stripNonValidXMLCharacters(xml);
e-commerce & e-learning