You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by ni...@apache.org on 2010/02/19 18:55:32 UTC
svn commit: r911878 - in /poi/trunk/src: documentation/content/xdocs/
java/org/apache/poi/poifs/filesystem/
scratchpad/src/org/apache/poi/hsmf/datatypes/
scratchpad/testcases/org/apache/poi/hsmf/parsers/
testcases/org/apache/poi/poifs/filesystem/
Author: nick
Date: Fri Feb 19 17:55:32 2010
New Revision: 911878
URL: http://svn.apache.org/viewvc?rev=911878&view=rev
Log:
Fix an issue with the HSMF tests working on some machines but not others - Make poifs.filesystem.DirectoryNode preserve the original ordering of its files, which HSMF needs to be able
to correctly match up chunks
Modified:
poi/trunk/src/documentation/content/xdocs/status.xml
poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
Modified: poi/trunk/src/documentation/content/xdocs/status.xml
URL: http://svn.apache.org/viewvc/poi/trunk/src/documentation/content/xdocs/status.xml?rev=911878&r1=911877&r2=911878&view=diff
==============================================================================
--- poi/trunk/src/documentation/content/xdocs/status.xml (original)
+++ poi/trunk/src/documentation/content/xdocs/status.xml Fri Feb 19 17:55:32 2010
@@ -34,6 +34,7 @@
<changes>
<release version="3.7-SNAPSHOT" date="2010-??-??">
+ <action dev="POI-DEVELOPERS" type="fix">Make poifs.filesystem.DirectoryNode preserve the original ordering of its files, which HSMF needs to be able to correctly match up chunks</action>
<action dev="POI-DEVELOPERS" type="add">Support evaluation of indirect defined names in INDIRECT</action>
<action dev="POI-DEVELOPERS" type="fix">43670 - Improve HDGF ChunkV11 separator detection, and short string detection, to solve the "Negative length of ChunkHeader" problem</action>
<action dev="POI-DEVELOPERS" type="add">48617 - Optionally allow the overriding of the Locale used by DataFormatter to control how the default number and date formats should look</action>
Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java?rev=911878&r1=911877&r2=911878&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/DirectoryNode.java Fri Feb 19 17:55:32 2010
@@ -41,7 +41,9 @@
{
// Map of Entry instances, keyed by their names
- private Map<String,Entry> _entries;
+ private Map<String,Entry> _byname;
+ // Our list of entries, kept sorted to preserve order
+ private ArrayList<Entry> _entries;
// the POIFSFileSystem we belong to
private POIFSFileSystem _filesystem;
@@ -75,7 +77,8 @@
});
}
_filesystem = filesystem;
- _entries = new HashMap<String, Entry>();
+ _byname = new HashMap<String, Entry>();
+ _entries = new ArrayList<Entry>();
Iterator<Property> iter = property.getChildren();
while (iter.hasNext())
@@ -93,7 +96,8 @@
childNode = new DocumentNode(( DocumentProperty ) child,
this);
}
- _entries.put(childNode.getName(), childNode);
+ _entries.add(childNode);
+ _byname.put(childNode.getName(), childNode);
}
}
@@ -149,7 +153,8 @@
(( DirectoryProperty ) getProperty()).addChild(property);
_filesystem.addDocument(document);
- _entries.put(property.getName(), rval);
+ _entries.add(rval);
+ _byname.put(property.getName(), rval);
return rval;
}
@@ -165,7 +170,7 @@
boolean changeName(final String oldName, final String newName)
{
boolean rval = false;
- EntryNode child = ( EntryNode ) _entries.get(oldName);
+ EntryNode child = ( EntryNode ) _byname.get(oldName);
if (child != null)
{
@@ -173,8 +178,8 @@
.changeName(child.getProperty(), newName);
if (rval)
{
- _entries.remove(oldName);
- _entries.put(child.getProperty().getName(), child);
+ _byname.remove(oldName);
+ _byname.put(child.getProperty().getName(), child);
}
}
return rval;
@@ -196,7 +201,8 @@
if (rval)
{
- _entries.remove(entry.getName());
+ _entries.remove(entry);
+ _byname.remove(entry.getName());
_filesystem.remove(entry);
}
return rval;
@@ -217,7 +223,7 @@
public Iterator<Entry> getEntries()
{
- return _entries.values().iterator();
+ return _entries.iterator();
}
/**
@@ -263,7 +269,7 @@
if (name != null)
{
- rval = _entries.get(name);
+ rval = _byname.get(name);
}
if (rval == null)
{
@@ -332,7 +338,8 @@
(( DirectoryProperty ) getProperty()).addChild(property);
_filesystem.addDirectory(property);
- _entries.put(name, rval);
+ _entries.add(rval);
+ _byname.put(name, rval);
return rval;
}
@@ -416,10 +423,7 @@
List components = new ArrayList();
components.add(getProperty());
- SortedMap<String,Entry> sortedEntries =
- new TreeMap<String,Entry>(_entries);
- Iterator<Entry> iter = sortedEntries.values().iterator();
-
+ Iterator<Entry> iter = _entries.iterator();
while (iter.hasNext())
{
components.add(iter.next());
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java?rev=911878&r1=911877&r2=911878&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/AttachmentChunks.java Fri Feb 19 17:55:32 2010
@@ -105,7 +105,6 @@
* Orders by the attachment number.
*/
public static class AttachmentChunksSorter implements Comparator<AttachmentChunks> {
- @Override
public int compare(AttachmentChunks a, AttachmentChunks b) {
return a.poifsName.compareTo(b.poifsName);
}
Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java?rev=911878&r1=911877&r2=911878&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hsmf/datatypes/RecipientChunks.java Fri Feb 19 17:55:32 2010
@@ -197,7 +197,6 @@
* Orders by the recipient number.
*/
public static class RecipientChunksSorter implements Comparator<RecipientChunks> {
- @Override
public int compare(RecipientChunks a, RecipientChunks b) {
if(a.recipientNumber < b.recipientNumber)
return -1;
Modified: poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java?rev=911878&r1=911877&r2=911878&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java (original)
+++ poi/trunk/src/scratchpad/testcases/org/apache/poi/hsmf/parsers/TestPOIFSChunkParser.java Fri Feb 19 17:55:32 2010
@@ -151,10 +151,10 @@
assertEquals(9, groups.length);
assertTrue(groups[0] instanceof Chunks);
assertTrue(groups[1] instanceof RecipientChunks);
- assertTrue(groups[2] instanceof AttachmentChunks);
+ assertTrue(groups[2] instanceof RecipientChunks);
assertTrue(groups[3] instanceof RecipientChunks);
assertTrue(groups[4] instanceof RecipientChunks);
- assertTrue(groups[5] instanceof RecipientChunks);
+ assertTrue(groups[5] instanceof AttachmentChunks);
assertTrue(groups[6] instanceof RecipientChunks);
assertTrue(groups[7] instanceof RecipientChunks);
assertTrue(groups[8] instanceof NameIdChunks);
@@ -162,33 +162,33 @@
// In FS order initially
RecipientChunks[] chunks = new RecipientChunks[] {
(RecipientChunks)groups[1],
+ (RecipientChunks)groups[2],
(RecipientChunks)groups[3],
(RecipientChunks)groups[4],
- (RecipientChunks)groups[5],
(RecipientChunks)groups[6],
(RecipientChunks)groups[7],
};
assertEquals(6, chunks.length);
assertEquals(0, chunks[0].recipientNumber);
- assertEquals(4, chunks[1].recipientNumber);
- assertEquals(3, chunks[2].recipientNumber);
- assertEquals(2, chunks[3].recipientNumber);
- assertEquals(1, chunks[4].recipientNumber);
- assertEquals(5, chunks[5].recipientNumber);
+ assertEquals(2, chunks[1].recipientNumber);
+ assertEquals(4, chunks[2].recipientNumber);
+ assertEquals(5, chunks[3].recipientNumber);
+ assertEquals(3, chunks[4].recipientNumber);
+ assertEquals(1, chunks[5].recipientNumber);
// Check
assertEquals("'Ashutosh Dandavate'", chunks[0].getRecipientName());
assertEquals("ashutosh.dandavate@alfresco.com", chunks[0].getRecipientEmailAddress());
- assertEquals("nick.burch@alfresco.com", chunks[1].getRecipientName());
- assertEquals("nick.burch@alfresco.com", chunks[1].getRecipientEmailAddress());
- assertEquals("nickb@alfresco.com", chunks[2].getRecipientName());
- assertEquals("nickb@alfresco.com", chunks[2].getRecipientEmailAddress());
- assertEquals("'Mike Farman'", chunks[3].getRecipientName());
- assertEquals("mikef@alfresco.com", chunks[3].getRecipientEmailAddress());
- assertEquals("'Paul Holmes-Higgin'", chunks[4].getRecipientName());
- assertEquals("paul.hh@alfresco.com", chunks[4].getRecipientEmailAddress());
- assertEquals("'Roy Wetherall'", chunks[5].getRecipientName());
- assertEquals("roy.wetherall@alfresco.com", chunks[5].getRecipientEmailAddress());
+ assertEquals("'Mike Farman'", chunks[1].getRecipientName());
+ assertEquals("mikef@alfresco.com", chunks[1].getRecipientEmailAddress());
+ assertEquals("nick.burch@alfresco.com", chunks[2].getRecipientName());
+ assertEquals("nick.burch@alfresco.com", chunks[2].getRecipientEmailAddress());
+ assertEquals("'Roy Wetherall'", chunks[3].getRecipientName());
+ assertEquals("roy.wetherall@alfresco.com", chunks[3].getRecipientEmailAddress());
+ assertEquals("nickb@alfresco.com", chunks[4].getRecipientName());
+ assertEquals("nickb@alfresco.com", chunks[4].getRecipientEmailAddress());
+ assertEquals("'Paul Holmes-Higgin'", chunks[5].getRecipientName());
+ assertEquals("paul.hh@alfresco.com", chunks[5].getRecipientEmailAddress());
// Now sort, and re-check
Arrays.sort(chunks, new RecipientChunksSorter());
Modified: poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java?rev=911878&r1=911877&r2=911878&view=diff
==============================================================================
--- poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java (original)
+++ poi/trunk/src/testcases/org/apache/poi/poifs/filesystem/TestDirectoryNode.java Fri Feb 19 17:55:32 2010
@@ -158,26 +158,36 @@
DirectoryEntry root = fs.getRoot();
// verify cannot delete the root directory
- assertTrue(!root.delete());
+ assertFalse(root.delete());
+ assertTrue(root.isEmpty());
+
DirectoryEntry dir = fs.createDirectory("myDir");
- assertTrue(!root.isEmpty());
+ assertFalse(root.isEmpty());
+ assertTrue(dir.isEmpty());
// verify can delete empty directory
+ assertFalse(root.delete());
assertTrue(dir.delete());
+
+ // Now look at a non-empty one
dir = fs.createDirectory("NextDir");
DocumentEntry doc =
dir.createDocument("foo",
new ByteArrayInputStream(new byte[ 1 ]));
- assertTrue(!dir.isEmpty());
+ assertFalse(root.isEmpty());
+ assertFalse(dir.isEmpty());
- // verify cannot delete empty directory
- assertTrue(!dir.delete());
+ // verify cannot delete non-empty directory
+ assertFalse(dir.delete());
+
+ // but we can delete it if we remove the document
assertTrue(doc.delete());
-
- // verify now we can delete it
+ assertTrue(dir.isEmpty());
assertTrue(dir.delete());
+
+ // It's really gone!
assertTrue(root.isEmpty());
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org