Constants.JCR_DATA, 0), ItemType.PROPERTY));
// index if have jcr:mimeType sibling for this binary property only
try
{
DocumentReader dreader =
extractor.getDocumentReader(ValueDataUtil.getString(pmime.getValues().get(0)));
data = propData.getValues();
if (data == null)
{
LOG.warn("null value found at property " + prop.getQPath().getAsString());
return;
}
// check the jcr:encoding property
PropertyData encProp = node.getProperty(Constants.JCR_ENCODING.getAsString());
if (encProp == null && !node.containAllProperties())
{
encProp =
(PropertyData)stateProvider.getItemData(node, new QPathEntry(Constants.JCR_ENCODING, 0),
ItemType.PROPERTY);
}
String encoding = null;
if (encProp != null)
{
// encoding parameter used
ValueDataUtil.getString(encProp.getValues().get(0));
}
if (dreader instanceof AdvancedDocumentReader)
{
// its a tika document reader that supports getContentAsReader
for (ValueData pvd : data)
{
// tikaDocumentReader will close inputStream, so no need to close it at finally
// statement
InputStream is = null;
is = pvd.getAsStream();
Reader reader;
if (encoding != null)
{
reader = ((AdvancedDocumentReader)dreader).getContentAsReader(is, encoding);
}
else
{
reader = ((AdvancedDocumentReader)dreader).getContentAsReader(is);
}
doc.add(createFulltextField(reader));
}
}
else
{
// old-style document reader
for (ValueData pvd : data)
{
InputStream is = null;
try
{
is = pvd.getAsStream();
Reader reader;
if (encoding != null)
{
reader = new StringReader(dreader.getContentAsText(is, encoding));
}
else
{
reader = new StringReader(dreader.getContentAsText(is));
}
doc.add(createFulltextField(reader));
}
finally
{