When metadata extraction fails, perform the same check that content transformation now does, and give a more helpful error message if the mime type is wrong on the content

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@22878 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2010-10-05 11:04:55 +00:00
parent f62629d5d4
commit e08fd4e940
3 changed files with 18 additions and 58 deletions

View File

@@ -660,12 +660,24 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
}
catch (Throwable e)
{
// Ask Tika to detect the document, and report back on if
// the current mime type is plausible
String typeErrorMessage = null;
String differentType = mimetypeService.getMimetypeIfNotMatches(reader.getReader());
if(differentType != null)
{
typeErrorMessage = "\n" +
" claimed mime type: " + reader.getMimetype() + "\n" +
" detected mime type: " + differentType;
}
if (logger.isDebugEnabled())
{
logger.debug(
"Metadata extraction failed: \n" +
" Extracter: " + this + "\n" +
" Content: " + reader,
" Content: " + reader +
typeErrorMessage,
e);
}
else
@@ -674,7 +686,8 @@ abstract public class AbstractMappingMetadataExtracter implements MetadataExtrac
"Metadata extraction failed (turn on DEBUG for full error): \n" +
" Extracter: " + this + "\n" +
" Content: " + reader + "\n" +
" Failure: " + e.getMessage());
" Failure: " + e.getMessage() +
typeErrorMessage);
}
}
finally