org.opencms.mail
Class CmsVfsDataSource

java.lang.Object
  extended by org.opencms.mail.CmsVfsDataSource
All Implemented Interfaces:
javax.activation.DataSource

public class CmsVfsDataSource
extends java.lang.Object
implements javax.activation.DataSource

DataSource wrapper for VFS resources, allows easy sending of VFS resources as email attachments.

Since:
6.2.0
Version:
$Revision: 1.8 $
Author:
Alexander Kandzior, Jan Baudisch

Constructor Summary
CmsVfsDataSource(CmsObject cms, CmsResource resource)
          Creates a new data source for the given VFS resource.
 
Method Summary
 java.lang.String getContentType()
           
 java.io.InputStream getInputStream()
          Returns an input stream baded on the file contents.
 java.lang.String getName()
          Returns the root path of the given resource.
 java.io.OutputStream getOutputStream()
          Don't use this method, VFS resources can't be written using this datasource class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CmsVfsDataSource

public CmsVfsDataSource(CmsObject cms,
                        CmsResource resource)
                 throws CmsException
Creates a new data source for the given VFS resource.

Parameters:
cms - the current users OpenCms context
resource - the resource to use
Throws:
CmsException - in case of errors accessing the resource in the VFS
Method Detail

getContentType

public java.lang.String getContentType()
Specified by:
getContentType in interface javax.activation.DataSource
See Also:
DataSource.getContentType()

getInputStream

public java.io.InputStream getInputStream()
Returns an input stream baded on the file contents.

Specified by:
getInputStream in interface javax.activation.DataSource
See Also:
DataSource.getInputStream()

getName

public java.lang.String getName()
Returns the root path of the given resource.

Specified by:
getName in interface javax.activation.DataSource
See Also:
DataSource.getName()

getOutputStream

public java.io.OutputStream getOutputStream()
Don't use this method, VFS resources can't be written using this datasource class.

This method will just return a new ByteArrayOutputStream.

Specified by:
getOutputStream in interface javax.activation.DataSource
See Also:
DataSource.getOutputStream()