SMILA 1.0 API documentation

org.eclipse.smila.importing.crawler.file.internal
Class FileCrawlerServiceImpl

java.lang.Object
  extended by org.eclipse.smila.importing.crawler.file.internal.FileCrawlerServiceImpl
All Implemented Interfaces:
ContentFetcher, FileCrawlerService

public class FileCrawlerServiceImpl
extends java.lang.Object
implements FileCrawlerService

Default implementation of a FileCrawlerService.

Author:
stuc07

Field Summary
 
Fields inherited from interface org.eclipse.smila.importing.crawler.file.FileCrawlerService
ATTACHMENT_FILE_CONTENT, PROPERTY_FILE_EXTENSION, PROPERTY_FILE_FOLDER, PROPERTY_FILE_LAST_MODIFIED, PROPERTY_FILE_NAME, PROPERTY_FILE_PATH, PROPERTY_FILE_SIZE
 
Constructor Summary
FileCrawlerServiceImpl()
           
 
Method Summary
 void addAttachment(Record record, java.lang.String pathAttribute, java.lang.String attachmentName)
          Add the content attachment to the given record.
 Record dirToRecord(java.io.File directory, java.lang.String dataSource)
          Create a Record for the given directory and dataSource and fill it with ImportingConstants.ROOT_FOLDER_ATTRIBUTE.
 Record fileToRecord(java.io.File file, java.lang.String dataSource, boolean withContent)
          Create a Record for the given file and dataSource and fill it with all file properties.
 java.io.InputStream getContent(Record record, TaskContext taskContext)
          get a stream on a content object.
 java.util.Set<java.lang.String> getFilePropertyNames()
          Returns a Set containing all file property and attachment names.
 java.util.Collection<java.io.File> list(java.io.File directory)
          List all directories and files of a given directory.
 java.util.Collection<java.io.File> listDirectories(java.io.File directory)
          List all directories of a given directory.
 java.util.Collection<java.io.File> listFiles(java.io.File directory)
          List all files of a given directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileCrawlerServiceImpl

public FileCrawlerServiceImpl()
Method Detail

listFiles

public java.util.Collection<java.io.File> listFiles(java.io.File directory)
Description copied from interface: FileCrawlerService
List all files of a given directory.

Specified by:
listFiles in interface FileCrawlerService
Returns:
a Collection of files

listDirectories

public java.util.Collection<java.io.File> listDirectories(java.io.File directory)
Description copied from interface: FileCrawlerService
List all directories of a given directory.

Specified by:
listDirectories in interface FileCrawlerService
Returns:
a Collection of directories

list

public java.util.Collection<java.io.File> list(java.io.File directory)
Description copied from interface: FileCrawlerService
List all directories and files of a given directory.

Specified by:
list in interface FileCrawlerService
Returns:
a Collection of directories and files

fileToRecord

public Record fileToRecord(java.io.File file,
                           java.lang.String dataSource,
                           boolean withContent)
                    throws java.io.IOException
Description copied from interface: FileCrawlerService
Create a Record for the given file and dataSource and fill it with all file properties. Optionally also fill with content attachment.

Specified by:
fileToRecord in interface FileCrawlerService
withContent - if true fill also content attachment, otherwise not
Returns:
a Record
Throws:
java.io.IOException

addAttachment

public void addAttachment(Record record,
                          java.lang.String pathAttribute,
                          java.lang.String attachmentName)
                   throws java.io.IOException
Description copied from interface: FileCrawlerService
Add the content attachment to the given record.

Specified by:
addAttachment in interface FileCrawlerService
pathAttribute - name of the attribute containing the path to the file
attachmentName - name with which the attachment is stored in the recor
Throws:
java.io.IOException

dirToRecord

public Record dirToRecord(java.io.File directory,
                          java.lang.String dataSource)
Description copied from interface: FileCrawlerService
Create a Record for the given directory and dataSource and fill it with ImportingConstants.ROOT_FOLDER_ATTRIBUTE.

Specified by:
dirToRecord in interface FileCrawlerService
Returns:
a record

getContent

public java.io.InputStream getContent(Record record,
                                      TaskContext taskContext)
                               throws ImportingException
Description copied from interface: ContentFetcher
get a stream on a content object. Make sure to close the stream after usage.

Specified by:
getContent in interface ContentFetcher
Parameters:
record - a crawled record describing the content object.
taskContext - the TaskContexrt containing job parameters and more
Returns:
content stream
Throws:
ImportingException - error accessing the content object.

getFilePropertyNames

public java.util.Set<java.lang.String> getFilePropertyNames()
Description copied from interface: FileCrawlerService
Returns a Set containing all file property and attachment names.

Specified by:
getFilePropertyNames in interface FileCrawlerService
Returns:
a Set of String

SMILA 1.0 API documentation