org.semanticdesktop.aperture.subcrawler.mime
Class MimeSubCrawler

java.lang.Object
  extended by org.semanticdesktop.aperture.subcrawler.base.AbstractSubCrawler
      extended by org.semanticdesktop.aperture.subcrawler.mime.MimeSubCrawler
All Implemented Interfaces:
DataObjectFactory.PartStreamFactory, SubCrawler

public class MimeSubCrawler
extends AbstractSubCrawler
implements DataObjectFactory.PartStreamFactory

A SubCrawer implementation for message/rfc822-style messages.

It is basically a thin wrapper around the DataObjectFactory.


Constructor Summary
MimeSubCrawler()
           
 
Method Summary
 MessageDataObject createDataObject(URI dataObjectId, DataSource dataSource, RDFContainer metadata, javax.mail.internet.MimeMessage msg)
          Creates a message data object for the given parameters
 DataObject getDataObject(URI parentUri, String path, InputStream stream, DataSource dataSource, Charset charset, String mimeType, RDFContainerFactory factory)
          Get a DataObject from the specified stream with the given path.
 javax.mail.internet.MimeMessage getLastMimeMessage()
          Returns the last MimeMessage that was created internally by the subCrawl method.
 InputStream getPartStream(javax.mail.Part part)
          Returns an input stream with the part content.
 String getUriPrefix()
          Returns the prefix used when generating uris.
 void stopSubCrawler()
          Stops a running crawl as fast as possible.
 void subCrawl(URI id, InputStream stream, SubCrawlerHandler handler, DataSource dataSource, AccessData accessData, Charset charset, String mimeType, RDFContainer parentMetadata)
          Starts crawling the given stream and to report the encountered DataObjects to the given SubCrawlerHandler.
 
Methods inherited from class org.semanticdesktop.aperture.subcrawler.base.AbstractSubCrawler
createChildUri
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MimeSubCrawler

public MimeSubCrawler()
Method Detail

subCrawl

public void subCrawl(URI id,
                     InputStream stream,
                     SubCrawlerHandler handler,
                     DataSource dataSource,
                     AccessData accessData,
                     Charset charset,
                     String mimeType,
                     RDFContainer parentMetadata)
              throws SubCrawlerException
Description copied from interface: SubCrawler
Starts crawling the given stream and to report the encountered DataObjects to the given SubCrawlerHandler. If an AccessData instance is passed, it is used to check if the data objects are to be reported as new, modified, or unmodified. Note that the SubCrawler will not report deleted objects.

Specified by:
subCrawl in interface SubCrawler
Parameters:
id - the URI identifying the object (e.g. a file or web page) from which the stream was obtained. This URI is treated as the URI of the parent object, all objects encountered in the stream are considered to be contained within the parent object. (optional, the implementation may use this uri or the one returned from the RDFContainer.getDescribedUri() method of the parentMetadata)
stream - the stream to be crawled. (obligatory)
handler - The crawler handler that is to receive the notifications from the SubCrawler (obligatory)
dataSource - the data source that will be returned by the DataObject.getDataSource() method of the returned data objects. Some implementations may require that this reference is not null and that it contains some particular information
accessData - the AccessData used to determine if the encountered objects are to be returned as new, modified, unmodified or deleted. Information about new or modified objects is stored within for use in future crawls. This parameter may be null if this functionality is not desired, in which case all DataObjects will be reported as new. (optional)
charset - the charset in which the input stream is encoded (optional).
mimeType - the MIME type of the passed stream (optional).
parentMetadata - The 'parent' RDFContainer, that will contain the metadata about the top-level entity in the stream. A SubCrawler may (in some cases) limit itself to augmenting the metadata in this RDFContainer without delivering any additional DataObjects. (obligatory)
Throws:
SubCrawlerException - if any of the obligatory parameters is null or if any error during the crawling process occured

stopSubCrawler

public void stopSubCrawler()
Description copied from interface: SubCrawler
Stops a running crawl as fast as possible. This method may return before the crawling has actually stopped.

Specified by:
stopSubCrawler in interface SubCrawler

getLastMimeMessage

public javax.mail.internet.MimeMessage getLastMimeMessage()
Returns the last MimeMessage that was created internally by the subCrawl method.


getDataObject

public DataObject getDataObject(URI parentUri,
                                String path,
                                InputStream stream,
                                DataSource dataSource,
                                Charset charset,
                                String mimeType,
                                RDFContainerFactory factory)
                         throws SubCrawlerException,
                                PathNotFoundException
Description copied from interface: SubCrawler
Get a DataObject from the specified stream with the given path.

Specified by:
getDataObject in interface SubCrawler
Overrides:
getDataObject in class AbstractSubCrawler
Parameters:
parentUri - the URI of the parent object where the path will be looked for
path - the path of the requested resource
stream - the stream that contains the resource
dataSource - data source that will be returned by the DataObject.getDataSource() method of the returned data object. Some implementations may require that this reference is not null and that it contains some particular information
charset - the charset in which the input stream is encoded (optional).
mimeType - the MIME type of the passed stream (optional).
factory - An RDFContainerFactory that delivers the RDFContainer to which the metadata of the DataObject should be added. The provided RDFContainer can later be retrieved as the DataObject's metadata container.
Returns:
The DataObject extracted from the given stream with the given path
Throws:
SubCrawlerException - if any I/O error occurs
PathNotFoundException - if the requested path is not found

getUriPrefix

public String getUriPrefix()
Description copied from class: AbstractSubCrawler
Returns the prefix used when generating uris. See the documentation for SubCrawler class for more details.

Specified by:
getUriPrefix in class AbstractSubCrawler
Returns:
the prefix used when generating uris.

getPartStream

public InputStream getPartStream(javax.mail.Part part)
                          throws javax.mail.MessagingException,
                                 IOException
Description copied from interface: DataObjectFactory.PartStreamFactory
Returns an input stream with the part content. It's conceptually a wrapper around the Part.getInputStream() method, designed to allow for customization of the returned input stream.

Specified by:
getPartStream in interface DataObjectFactory.PartStreamFactory
Returns:
an InputStream with the content of the part
Throws:
javax.mail.MessagingException
IOException

createDataObject

public MessageDataObject createDataObject(URI dataObjectId,
                                          DataSource dataSource,
                                          RDFContainer metadata,
                                          javax.mail.internet.MimeMessage msg)
                                   throws javax.mail.MessagingException
Description copied from interface: DataObjectFactory.PartStreamFactory
Creates a message data object for the given parameters

Specified by:
createDataObject in interface DataObjectFactory.PartStreamFactory
Returns:
a message data object for the given parameters
Throws:
javax.mail.MessagingException


Copyright © 2010 Aperture Development Team. All Rights Reserved.