mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-24 17:32:48 +00:00
Merged V2.2 to HEAD
7534: Merged V2.1 to HEAD 7398: XPath metadata extractor selector handles malformed and empty XML files 7401: Fix AR-1879: JBPM Timer never fires 7413: Contribution: Integrity checker ignores exceptions that would normally trigger transaction retries. 7416: AR-1884.Unicode wildcard processing. 7417: Added filtering of pseudo files when a partial wildcard search path is used, such as '*.csv'. AR-1889. 7436: AR-1863: major version's can now be created via the web service API; 7451: Fix for handling of UTF-8 application/x-www-form-urlencoded encoded form arguments as raised in support ticket 242 7458: Fix for AR-1900 7520: Fix to Template API where content was not retrievable from custom d:content properties on a node git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8413 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -114,6 +114,19 @@ public class XmlMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
Map<QName, Serializable> destination,
|
||||
Map<String, Set<QName>> mapping)
|
||||
{
|
||||
// Check the content length
|
||||
if (reader.getSize() == 0)
|
||||
{
|
||||
// There is no content. We don't spoof any properties so there can be nothing extracted.
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\n" +
|
||||
"XML document has zero length, so bypassing extraction: \n" +
|
||||
" Document: " + reader);
|
||||
}
|
||||
return destination;
|
||||
}
|
||||
|
||||
MetadataExtracter extracter = null;
|
||||
// Select a worker
|
||||
for (ContentWorkerSelector<MetadataExtracter> selector : selectors)
|
||||
@@ -123,6 +136,10 @@ public class XmlMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
{
|
||||
extracter = selector.getWorker(spawnedReader);
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
// The selector failed, so try another
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (reader.isChannelOpen())
|
||||
@@ -149,8 +166,14 @@ public class XmlMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
// Did we find anything?
|
||||
if (extracter == null)
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("\n" +
|
||||
"No working metadata extractor could be found: \n" +
|
||||
" Document: " + reader);
|
||||
}
|
||||
// There will be no properties extracted
|
||||
modifiedProperties = Collections.emptyMap();
|
||||
modifiedProperties = destination;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -176,7 +199,7 @@ public class XmlMetadataExtracter extends AbstractMappingMetadataExtracter
|
||||
"XML metadata extractor redirected: \n" +
|
||||
" Reader: " + reader + "\n" +
|
||||
" Extracter: " + extracter + "\n" +
|
||||
" Extracted: " + modifiedProperties);
|
||||
" Metadata: " + modifiedProperties);
|
||||
}
|
||||
return modifiedProperties;
|
||||
}
|
||||
|
@@ -67,6 +67,8 @@ public class XmlMetadataExtracterTest extends TestCase
|
||||
{
|
||||
private static final String FILE_ALFRESCO_MODEL = "xml-metadata/alfresco-model-sample.xml";
|
||||
private static final String FILE_ECLIPSE_PROJECT = "xml-metadata/eclipse-project-sample.xml";
|
||||
private static final String FILE_EMPTY = "xml-metadata/empty-sample.xml";
|
||||
private static final String FILE_MALFORMED = "xml-metadata/malformed-sample.xml";
|
||||
|
||||
private static final String CTX_LOCATION = "classpath:xml-metadata/xml-metadata-test-context.xml";
|
||||
private static final ApplicationContext ctx = new ClassPathXmlApplicationContext(CTX_LOCATION);
|
||||
@@ -157,6 +159,38 @@ public class XmlMetadataExtracterTest extends TestCase
|
||||
assertEquals("JavaCC Nature", checkProperties.get(ContentModel.PROP_DESCRIPTION));
|
||||
}
|
||||
|
||||
public void testEmptyFile() throws Exception
|
||||
{
|
||||
// Get an empty file
|
||||
ContentReader reader = getReader(FILE_EMPTY);
|
||||
assertTrue(reader.exists());
|
||||
|
||||
// Pass it to the extracter
|
||||
PropertyMap checkProperties = new PropertyMap();
|
||||
checkProperties.put(ContentModel.PROP_TITLE, getName());
|
||||
xmlMetadataExtracter.extract(reader, checkProperties);
|
||||
|
||||
// The map should be unaffected
|
||||
assertNotNull("Properties changed by empty file extraction", checkProperties.get(ContentModel.PROP_TITLE));
|
||||
assertEquals("Properties changed by empty file extraction", getName(), checkProperties.get(ContentModel.PROP_TITLE));
|
||||
}
|
||||
|
||||
public void testMalformedFile() throws Exception
|
||||
{
|
||||
// Get an empty file
|
||||
ContentReader reader = getReader(FILE_MALFORMED);
|
||||
assertTrue(reader.exists());
|
||||
|
||||
// Pass it to the extracter
|
||||
PropertyMap checkProperties = new PropertyMap();
|
||||
checkProperties.put(ContentModel.PROP_TITLE, getName());
|
||||
xmlMetadataExtracter.extract(reader, checkProperties);
|
||||
|
||||
// The map should be unaffected
|
||||
assertNotNull("Properties changed by malformed file extraction", checkProperties.get(ContentModel.PROP_TITLE));
|
||||
assertEquals("Properties changed by malformed file extraction", getName(), checkProperties.get(ContentModel.PROP_TITLE));
|
||||
}
|
||||
|
||||
public void testRootElementNameSelector() throws Exception
|
||||
{
|
||||
// Load the example files
|
||||
|
Reference in New Issue
Block a user