View Javadoc

1   package com.atlassian.plugin;
2   
3   import java.io.*;
4   
5   /**
6    * An XML plugin artifact that is just the atlassian-plugin.xml file
7    *
8    * @since 2.1.0
9    */
10  public class XmlPluginArtifact implements PluginArtifact
11  {
12      private final File xmlFile;
13  
14      public XmlPluginArtifact(File xmlFile)
15      {
16          this.xmlFile = xmlFile;
17      }
18  
19      /**
20       * Always returns null, since it doesn't make sense for an XML artifact
21       */
22      public InputStream getResourceAsStream(String name) throws PluginParseException
23      {
24          return null;
25      }
26  
27      public String getName()
28      {
29          return xmlFile.getName();
30      }
31  
32      /**
33       * @return a buffered file input stream of the file on disk. This input stream
34       * is not resettable.
35       */
36      public InputStream getInputStream()
37      {
38          try
39          {
40              return new BufferedInputStream(new FileInputStream(xmlFile));
41          }
42          catch (FileNotFoundException e)
43          {
44              throw new RuntimeException("Could not find XML file for eading: " + xmlFile, e);
45          }
46      }
47  }