Proper fix for unreported issue with OOo-based extraction of Office 07 metadata.

Added a new metadata extractor based on POI for docx, xlsx and pptx mime types.
Changed OpenOfficeMetadataExtracter so that it no longer supports these mime types.
Added the new test code to ContentMinimalContextTestSuite

Some tidying up of code in AbstractMetadataExtracterTest and OpenOfficeMetadataExtracter to reflect the fact that this extractor does not handle these mime types any more.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@19792 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Neil McErlean
2010-04-09 12:10:06 +00:00
parent fa927055d9
commit de612572d9
8 changed files with 269 additions and 24 deletions

View File

@@ -104,13 +104,8 @@ public abstract class AbstractMetadataExtracterTest extends TestCase
Map<QName, Serializable> properties = extractFromMimetype(mimetype);
// check we got something
// Properties come back null-valued back for author, title, description for xlsx & pptx
if (mimetype.equals(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET) == false &&
mimetype.equals(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION) == false)
{
assertFalse("extractFromMimetype should return at least some properties, none found for " + mimetype,
properties.isEmpty());
}
assertFalse("extractFromMimetype should return at least some properties, none found for " + mimetype,
properties.isEmpty());
// check common metadata
testCommonMetadata(mimetype, properties);
@@ -174,24 +169,22 @@ public abstract class AbstractMetadataExtracterTest extends TestCase
}
// Title and description
if (mimetype.equals(MimetypeMap.MIMETYPE_OPENXML_SPREADSHEET) ||
mimetype.equals(MimetypeMap.MIMETYPE_OPENXML_PRESENTATION)) {
return;
}
assertEquals(
"Property " + ContentModel.PROP_TITLE + " not found for mimetype " + mimetype,
QUICK_TITLE,
DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_TITLE)));
assertEquals(
"Property " + ContentModel.PROP_DESCRIPTION + " not found for mimetype " + mimetype,
QUICK_DESCRIPTION,
DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_DESCRIPTION)));
if (!skipDescriptionCheck(mimetype)) {
assertEquals(
"Property " + ContentModel.PROP_DESCRIPTION + " not found for mimetype " + mimetype,
QUICK_DESCRIPTION,
DefaultTypeConverter.INSTANCE.convert(String.class, properties.get(ContentModel.PROP_DESCRIPTION)));
}
}
protected abstract void testFileSpecificMetadata(String mimetype, Map<QName, Serializable> properties);
/**
* This method can be overridden to cause the author/creator property check to be skipped.
* The default behaviour is for the check to be skipped for all MIME types.
* The default behaviour is for the check not to be skipped for all MIME types.
*
* @param mimetype
* @return <code>true</code> to skip the checks, else <code>false</code>
@@ -201,6 +194,18 @@ public abstract class AbstractMetadataExtracterTest extends TestCase
return false;
}
/**
* This method can be overridden to cause the description property check to be skipped.
* The default behaviour is for the check not to be skipped for all MIME types.
*
* @param mimetype
* @return <code>true</code> to skip the checks, else <code>false</code>
*/
protected boolean skipDescriptionCheck(String mimetype)
{
return false;
}
public void testZeroLengthFile() throws Exception
{