1 package com.atlassian.bonnie.search.extractor;
2
3 import com.atlassian.bonnie.search.SearchableAttachment;
4 import org.apache.poi.poifs.eventfilesystem.POIFSReader;
5 import org.slf4j.Logger;
6 import org.slf4j.LoggerFactory;
7
8 import java.io.IOException;
9 import java.io.InputStream;
10
11 @Deprecated
12 public class MsPowerpointContentExtractor extends BaseAttachmentContentExtractor
13 {
14 private static final Logger log = LoggerFactory.getLogger(MsPowerpointContentExtractor.class);
15
16 private static final String[] CONTENT_TYPES =
17 {
18 "application/powerpoint",
19 "application/mspowerpoint",
20 "application/x-mspowerpoint",
21 "application/vnd.ms-powerpoint"
22 };
23
24 private static final String[] EXTENSIONS = {"ppt"};
25
26 protected String[] getMatchingContentTypes()
27 {
28 return CONTENT_TYPES;
29 }
30
31 protected String[] getMatchingFileExtensions()
32 {
33 return EXTENSIONS;
34 }
35
36 protected String extractText(InputStream is, SearchableAttachment attachment) throws ExtractorException
37 {
38 StringBuffer content = new StringBuffer();
39
40 POIFSReader r = new POIFSReader();
41 r.registerListener(new PowerPointListener(content));
42
43 try
44 {
45 r.read(is);
46 }
47 catch (IOException e)
48 {
49 throw new ExtractorException("Error reading content of Powerpoint document: " + e.getMessage(), e);
50
51 }
52
53 return content.toString();
54 }
55 }