Adding Indexers to codeBeamer
codeBeamer indexes for search Excel, MS-Word, Power-Point, RTF, PDF, Html, xml, Wiki and Plain text documents and attachments.
Following steps must be executed to add additional Indexers:
A java class must implement the interface com.intland.codebeamer.search.handler.DocumentHandler and the Indexer must be added to /install_dir/tomcat/webapps/cb/WEB-INF/classes/general.xml to get it known for codeBeamer.
The example below shows the plain-text Indexer assigned to the mime-type text/plain:
public class PlainTextHandler implements DocumentHandler {
private String encoding = null;
public Document getDocument(InputStream is) throws DocumentHandlerException {
try {
String body = Common.readFileToString(is, getEncoding());
if (body != null && body.length() != 0) {
Document doc = new Document();
doc.add(new Field(Fields.BODY, body, Field.Store.NO, Field.Index.TOKENIZED));
return doc;
}
return null;
} catch (IOException e) {
throw new DocumentHandlerException(e);
}
}
public String getEncoding() {
return encoding;
}
public void setEncoding(String enc) {
encoding = StringUtils.trimToNull(enc);
}
}
The appropriate entry in general.xml:
<mime-mapping>
<class>com.intland.codebeamer.search.handler.types.text.PlainTextHandler</class>
<mime-type>text/plain</mime-type>
</mime-mapping>
The indexer class must be in CLASSPATH of codeBeamer (for example under /install_dir/tomcat/webapps/cb/WEB-INF/classes) and after modifying general.xml Codebeamer must be re-started.