Dekoh platform API

dekoh.portal.fwk.importer
Class AbstractImportProcessor

java.lang.Object
  extended by dekoh.portal.fwk.importer.AbstractImportProcessor
All Implemented Interfaces:
ImportProcessor

public abstract class AbstractImportProcessor
extends Object
implements ImportProcessor

Content application that intend to manage digital assets that are represented as files (like JPG, mp3, mov) can extend this class to import the metadata into Dekoh Database.

Since:
Apr 30, 2007

Field Summary
protected  String applicationAutoImportProperty
           
protected  String applicationContextPath
           
protected  DIOEntityManager em
           
protected  LocalUser owner
           
 
Constructor Summary
protected AbstractImportProcessor(DIOEntityManagerFactory dioemf, String contextpath, String autoImportLocationProperty)
           
protected AbstractImportProcessor(LocalRequestContext localRequestContext, String contextpath, String autoImportLocationProperty)
           
 
Method Summary
protected  void addToMyCollection(DioCollection rootCollection)
           
 void beginImport()
          Marks the begin for batched commit of files to Dekoh.
 void close()
          Close Resources (if any) used by processor.
 void commitChanges()
          Commit all the changes that have been batched since last ImportProcessor.beginImport() callback.
protected  DioCollection createAndPersistNewCollection(File collectionDir, String collectionName, LocalUser owner)
           
protected  DioCollection createAndPersistNewCollection(RootFolder root, File collectionDir, String collectionName)
           
protected  void createPath(File dir, DioCollection collection, RootFolder rootFolder)
           
protected abstract  List findAllByFileAndSourceDir(File file, Directory sourceDir)
           
protected  DioCollection findAlreadyPersistedCollection(String autoImportLocation, RootFolder rootFolder)
           
protected abstract  DigitalObject findByFileAndSourceDir(File file, Directory sourceDir)
           
static DioCollection findCollectionAutoImportProperty(DIOEntityManager em, String applicationAutoImportProperty, String autoImportLocation)
           
static DioCollection findCollectionAutoImportProperty(DIOEntityManager em, String applicationAutoImportProperty, String autoImportLocation, LocalUser owner)
           
 List findFilesThatAreRemovedFromFileSystem(File dir)
          Arranges the newly Imported Collection and clears the local cache
protected  String getAutoImportPath(File dir)
           
protected  DioCollection getOrCreateCollection(RootFolder root, File dir, String collectionName)
           
protected abstract  File getSourceFile(DigitalObject digitalObject)
          Used to find the files on disk that are removed, for which Digital objects still exist.
 ImportStatusInfo importDigitalObject(ImportRequest importRequest)
           
protected  ImportStatusInfo importDirectory(RootFolder root, File dir, String collectionName)
           
 boolean isNewDirectory(File directory, RootFolder rootFolder)
          ImportService will use this method to check if Dekoh Database has DigitialObject representations of Files that are removed from filesystem.
protected  boolean isParentDirImportedInThisImportContext(File parentDir)
           
protected  Directory lookupDirectoryEntity(File parentDir)
          Opmization to exploit depth first search the ImportService is most likely to employ when emitting events.
 ImportStatusInfo removeFileFromDB(File removedFile)
          Remove the digitalObject for this file from Dekoh.
 void rollback()
          Rollback if there is an active transaction started by ImportProcessor.beginImport()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface dekoh.portal.fwk.importer.ImportProcessor
importDigitalObject, importDigitalObject
 

Field Detail

em

protected DIOEntityManager em

applicationContextPath

protected String applicationContextPath

applicationAutoImportProperty

protected final String applicationAutoImportProperty

owner

protected LocalUser owner
Constructor Detail

AbstractImportProcessor

protected AbstractImportProcessor(LocalRequestContext localRequestContext,
                                  String contextpath,
                                  String autoImportLocationProperty)

AbstractImportProcessor

protected AbstractImportProcessor(DIOEntityManagerFactory dioemf,
                                  String contextpath,
                                  String autoImportLocationProperty)
Method Detail

importDigitalObject

public ImportStatusInfo importDigitalObject(ImportRequest importRequest)
Specified by:
importDigitalObject in interface ImportProcessor

isNewDirectory

public boolean isNewDirectory(File directory,
                              RootFolder rootFolder)
Description copied from interface: ImportProcessor
ImportService will use this method to check if Dekoh Database has DigitialObject representations of Files that are removed from filesystem.

This method is generally used when ImportedDirectories.getDirectoryStatus(java.io.File,RootFolder)} cannot determine the state of a directory.

Specified by:
isNewDirectory in interface ImportProcessor
Returns:
true if a digitalObject for the directory exists in Dekoh
See Also:
ImportProcessor.findFilesThatAreRemovedFromFileSystem(java.io.File)

findAlreadyPersistedCollection

protected DioCollection findAlreadyPersistedCollection(String autoImportLocation,
                                                       RootFolder rootFolder)
Parameters:
autoImportLocation -
rootFolder -
Returns:
null if not yet persisted

findCollectionAutoImportProperty

public static DioCollection findCollectionAutoImportProperty(DIOEntityManager em,
                                                             String applicationAutoImportProperty,
                                                             String autoImportLocation)

findCollectionAutoImportProperty

public static DioCollection findCollectionAutoImportProperty(DIOEntityManager em,
                                                             String applicationAutoImportProperty,
                                                             String autoImportLocation,
                                                             LocalUser owner)

isParentDirImportedInThisImportContext

protected boolean isParentDirImportedInThisImportContext(File parentDir)

importDirectory

protected ImportStatusInfo importDirectory(RootFolder root,
                                           File dir,
                                           String collectionName)

createPath

protected void createPath(File dir,
                          DioCollection collection,
                          RootFolder rootFolder)

lookupDirectoryEntity

protected Directory lookupDirectoryEntity(File parentDir)
Opmization to exploit depth first search the ImportService is most likely to employ when emitting events.

Parameters:
parentDir - looking for this one..
Returns:
Directory entity corresponding to the given dir. never null

commitChanges

public void commitChanges()
Description copied from interface: ImportProcessor
Commit all the changes that have been batched since last ImportProcessor.beginImport() callback. Batching of commits is required to control heap usage by the created but yet to be persisted DigitalObjects

Specified by:
commitChanges in interface ImportProcessor
See Also:
dekoh.portal.fwk.persistence.DIOEntityManager#commitTx()}

beginImport

public void beginImport()
Description copied from interface: ImportProcessor
Marks the begin for batched commit of files to Dekoh. ImportService will call this method whenever it sees a new Directory or when a pre-set limit is reached while importing files in a directory.

Implementations are expected to start a new Transaction when this method is called.

Specified by:
beginImport in interface ImportProcessor
See Also:
ImportProcessor.commitChanges(), ImportProcessor.isNewDirectory(java.io.File,RootFolder), ImportConfig.getNumberOfFilesInBatch(), dekoh.portal.fwk.persistence.DIOEntityManagerFactory#createDIOEntityManager()}

rollback

public void rollback()
Description copied from interface: ImportProcessor
Rollback if there is an active transaction started by ImportProcessor.beginImport()

Specified by:
rollback in interface ImportProcessor

close

public void close()
Description copied from interface: ImportProcessor
Close Resources (if any) used by processor.

Specified by:
close in interface ImportProcessor

getOrCreateCollection

protected DioCollection getOrCreateCollection(RootFolder root,
                                              File dir,
                                              String collectionName)

getAutoImportPath

protected String getAutoImportPath(File dir)

createAndPersistNewCollection

protected DioCollection createAndPersistNewCollection(File collectionDir,
                                                      String collectionName,
                                                      LocalUser owner)

createAndPersistNewCollection

protected DioCollection createAndPersistNewCollection(RootFolder root,
                                                      File collectionDir,
                                                      String collectionName)

addToMyCollection

protected void addToMyCollection(DioCollection rootCollection)

findFilesThatAreRemovedFromFileSystem

public List findFilesThatAreRemovedFromFileSystem(File dir)
Arranges the newly Imported Collection and clears the local cache

Specified by:
findFilesThatAreRemovedFromFileSystem in interface ImportProcessor
Returns:
list of files to be removed

getSourceFile

protected abstract File getSourceFile(DigitalObject digitalObject)
Used to find the files on disk that are removed, for which Digital objects still exist.

Parameters:
digitalObject - represents a file, because files from User's desktop are being imported.
Returns:
file

removeFileFromDB

public ImportStatusInfo removeFileFromDB(File removedFile)
Description copied from interface: ImportProcessor
Remove the digitalObject for this file from Dekoh. This method usually follows ImportProcessor.findFilesThatAreRemovedFromFileSystem(java.io.File), other cases when this mehtod may be called is when user triggers deletion.

Specified by:
removeFileFromDB in interface ImportProcessor

findByFileAndSourceDir

protected abstract DigitalObject findByFileAndSourceDir(File file,
                                                        Directory sourceDir)

findAllByFileAndSourceDir

protected abstract List findAllByFileAndSourceDir(File file,
                                                  Directory sourceDir)

Dekoh platform API

© 2009 Pramati Technologies - Dekoh - Portal for Developers