Fixed closing of input stream

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@2428 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Derek Hulley
2006-02-17 12:24:09 +00:00
parent 2d1258dd7c
commit c7afc8286e

View File

@@ -17,6 +17,7 @@
package org.alfresco.repo.content.metadata; package org.alfresco.repo.content.metadata;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.io.Serializable; import java.io.Serializable;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
@@ -27,8 +28,6 @@ import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.service.cmr.repository.ContentIOException; import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader; import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.namespace.QName; import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.poi.hpsf.DocumentSummaryInformation; import org.apache.poi.hpsf.DocumentSummaryInformation;
import org.apache.poi.hpsf.PropertySet; import org.apache.poi.hpsf.PropertySet;
import org.apache.poi.hpsf.PropertySetFactory; import org.apache.poi.hpsf.PropertySetFactory;
@@ -43,8 +42,6 @@ import org.apache.poi.poifs.eventfilesystem.POIFSReaderListener;
*/ */
public class OfficeMetadataExtracter extends AbstractMetadataExtracter public class OfficeMetadataExtracter extends AbstractMetadataExtracter
{ {
private static final Log logger = LogFactory.getLog(OfficeMetadataExtracter.class);
private static String[] mimeTypes = new String[] { MimetypeMap.MIMETYPE_WORD, MimetypeMap.MIMETYPE_EXCEL, private static String[] mimeTypes = new String[] { MimetypeMap.MIMETYPE_WORD, MimetypeMap.MIMETYPE_EXCEL,
MimetypeMap.MIMETYPE_PPT }; MimetypeMap.MIMETYPE_PPT };
@@ -76,7 +73,7 @@ public class OfficeMetadataExtracter extends AbstractMetadataExtracter
} }
else if (ps instanceof DocumentSummaryInformation) else if (ps instanceof DocumentSummaryInformation)
{ {
DocumentSummaryInformation dsi = (DocumentSummaryInformation) ps; // DocumentSummaryInformation dsi = (DocumentSummaryInformation) ps;
// These are not really interesting to any aspect: // These are not really interesting to any aspect:
// trimPut(ContentModel.PROP_xxx, dsi.getCompany(), // trimPut(ContentModel.PROP_xxx, dsi.getCompany(),
@@ -91,11 +88,13 @@ public class OfficeMetadataExtracter extends AbstractMetadataExtracter
} }
} }
}; };
InputStream is = null;
try try
{ {
POIFSReader r = new POIFSReader(); is = reader.getContentInputStream();
r.registerListener(readerListener, SummaryInformation.DEFAULT_STREAM_NAME); POIFSReader poiFSReader = new POIFSReader();
r.read(reader.getContentInputStream()); poiFSReader.registerListener(readerListener, SummaryInformation.DEFAULT_STREAM_NAME);
poiFSReader.read(is);
} }
catch (IOException e) catch (IOException e)
{ {
@@ -103,5 +102,12 @@ public class OfficeMetadataExtracter extends AbstractMetadataExtracter
+ " reader: " + reader, + " reader: " + reader,
e); e);
} }
finally
{
if (is != null)
{
try { is.close(); } catch (IOException e) {}
}
}
} }
} }