magoffin.matt.ma2.biz.impl
Class IOBizImpl

java.lang.Object
  extended by magoffin.matt.ma2.biz.impl.IOBizImpl
All Implemented Interfaces:
IOBiz

public class IOBizImpl
extends java.lang.Object
implements IOBiz

Implementation of IOBiz.

Version:
$Revision: 109 $ $Date: 2008-02-15 20:42:33 +1300 (Fri, 15 Feb 2008) $
Author:
matt.magoffin

Nested Class Summary
 
Nested classes/interfaces inherited from interface magoffin.matt.ma2.biz.IOBiz
IOBiz.TwoPhaseExportRequest
 
Field Summary
static java.lang.String DEFAULT_ZIP_MIME_TYPE
          The default property for the getZipMimeType() property.
 
Fields inherited from interface magoffin.matt.ma2.biz.IOBiz
IMPORT_MEDIA_XML_METADATA_NAME
 
Constructor Summary
IOBizImpl()
           
 
Method Summary
 int clearCacheFiles(User user, java.util.Set<MediaSize> ofSize)
          Clear all cache files for a particular user, optionally of a particular size only.
 int deleteMedia(java.util.List<MediaItem> itemsToDelete)
          Delete media item files.
 WorkBiz.WorkInfo exportItems(ExportItemsCommand command, MediaRequest request, MediaResponse response, BizContext context)
          Export a set of media items as a Zip archive.
 WorkBiz.WorkInfo exportMedia(MediaRequest request, MediaResponse response, BizContext context)
          Export media from the application.
 void finish()
          Call to clean up resources as necessary.
 AlbumDao getAlbumDao()
           
 CollectionDao getCollectionDao()
           
 DomainObjectFactory getDomainObjectFactory()
           
 javax.activation.FileTypeMap getFileTypeMap()
           
 MediaBiz getMediaBiz()
           
 MediaItemDao getMediaItemDao()
           
 org.springframework.context.MessageSource getMessages()
           
 org.springframework.core.io.Resource getMetadataSchemaResource()
           
 SystemBiz getSystemBiz()
           
 WorkBiz getWorkBiz()
           
 magoffin.matt.util.ThreadSafeDateFormat getXmlDateFormat()
           
 magoffin.matt.util.ThreadSafeDateFormat getXmlDateTimeFormat()
           
 XmlHelper getXmlHelper()
           
 java.util.Set<java.lang.String> getZipContentTypes()
           
 java.util.List<java.lang.String> getZipIgnorePatterns()
           
 java.lang.String getZipMimeType()
           
 WorkBiz.WorkInfo importMedia(AddMediaCommand command, BizContext context)
          Import media into the application.
 void init()
          Call to initialize after peroprties have been set.
 int moveMedia(java.util.List<MediaItem> itemsToMove, Collection toCollection)
          Move media item files to a new directory.
 void setAlbumDao(AlbumDao albumDao)
           
 void setCollectionDao(CollectionDao collectionDao)
           
 void setDomainObjectFactory(DomainObjectFactory domainObjectFactory)
           
 void setFileTypeMap(javax.activation.FileTypeMap fileTypeMap)
           
 void setMediaBiz(MediaBiz mediaBiz)
           
 void setMediaItemDao(MediaItemDao mediaItemDao)
           
 void setMessages(org.springframework.context.MessageSource messages)
           
 void setMetadataSchemaResource(org.springframework.core.io.Resource metadataSchemaResource)
           
 void setSystemBiz(SystemBiz systemBiz)
           
 void setWorkBiz(WorkBiz workBiz)
           
 void setXmlDateFormat(magoffin.matt.util.ThreadSafeDateFormat xmlDateFormat)
           
 void setXmlDateTimeFormat(magoffin.matt.util.ThreadSafeDateFormat xmlDateTimeFormat)
           
 void setXmlHelper(XmlHelper xmlHelper)
           
 void setZipContentTypes(java.util.Set<java.lang.String> zipContentTypes)
           
 void setZipIgnorePatterns(java.util.List<java.lang.String> zipIgnorePatterns)
           
 void setZipMimeType(java.lang.String zipMimeType)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ZIP_MIME_TYPE

public static final java.lang.String DEFAULT_ZIP_MIME_TYPE
The default property for the getZipMimeType() property.

See Also:
Constant Field Values
Constructor Detail

IOBizImpl

public IOBizImpl()
Method Detail

init

public void init()
Call to initialize after peroprties have been set.


finish

public void finish()
Call to clean up resources as necessary.


importMedia

public WorkBiz.WorkInfo importMedia(AddMediaCommand command,
                                    BizContext context)
Description copied from interface: IOBiz
Import media into the application.

This method is designed to allow for imports that take some time to run, and thus should happen asynchronously. Thus a WorkInfo object is returned, which will give details of the status of the import job. The WorkBiz.getInfo(long) method can be used to query the status of the job at a later point, using the ticket returned by WorkBiz.WorkInfo.getTicket().

Specified by:
importMedia in interface IOBiz
Parameters:
command - the media to import
context - the biz context
Returns:
a WorkInfo with status of the import job

deleteMedia

public int deleteMedia(java.util.List<MediaItem> itemsToDelete)
Description copied from interface: IOBiz
Delete media item files.

This method deletes the files associated with the MediaItem instances, but does not delete the MediaItem instances from the backend database. It should also clean up any cache files for the associated items.

Specified by:
deleteMedia in interface IOBiz
Parameters:
itemsToDelete - the items to delete
Returns:
number of items successfully deleted

moveMedia

public int moveMedia(java.util.List<MediaItem> itemsToMove,
                     Collection toCollection)
Description copied from interface: IOBiz
Move media item files to a new directory.

Specified by:
moveMedia in interface IOBiz
Parameters:
itemsToMove - the items to move
toCollection - the Collection to move them to
Returns:
the number of files moved

exportMedia

public WorkBiz.WorkInfo exportMedia(MediaRequest request,
                                    MediaResponse response,
                                    BizContext context)
Description copied from interface: IOBiz
Export media from the application.

Specified by:
exportMedia in interface IOBiz
Parameters:
request - the request
response - the response
context - the biz context
Returns:
a WorkInfo with status of the export job

exportItems

public WorkBiz.WorkInfo exportItems(ExportItemsCommand command,
                                    MediaRequest request,
                                    MediaResponse response,
                                    BizContext context)
Description copied from interface: IOBiz
Export a set of media items as a Zip archive.

If ExportItemsCommand.getAlbumId() or ExportItemsCommand.getAlbumKey() is non-null, then this will export all the items of that album into a zip archive. Otherwise it will export all the items specified by ExportItemsCommand.getItemIds(). The quality and size parameters are not used, it will instead rely on the setting in the MediaRequest.

This method should support two-phase procesing if the MediaResponse is null. The method should return a WorkInfo as normal but the WorkRequest returned by WorkBiz.WorkInfo.getWorkRequest() must implement IOBiz.TwoPhaseExportRequest. The work to export the items should not begin until a later time when IOBiz.TwoPhaseExportRequest.setMediaResponse(MediaResponse) is called. The implementation must wait only for a finite amount of time for setMediaResponse to be called, after which time the job can be discarded.

This is to allow for flexibility with the calling applicaiton GUI where the work ticket is needed before the actual OutputStream is ready for the exported items.

Specified by:
exportItems in interface IOBiz
Parameters:
command - the export command
request - the request (for all media in the album)
response - the response
context - the context
Returns:
a WorkInfo with status of the export job

clearCacheFiles

public int clearCacheFiles(User user,
                           java.util.Set<MediaSize> ofSize)
Description copied from interface: IOBiz
Clear all cache files for a particular user, optionally of a particular size only.

Specified by:
clearCacheFiles in interface IOBiz
Parameters:
user - the user to clear cache files for
ofSize - if specified, a set of sizes to clear
Returns:
the number of files deleted

getZipIgnorePatterns

public java.util.List<java.lang.String> getZipIgnorePatterns()
Returns:
the zipIgnorePatterns

setZipIgnorePatterns

public void setZipIgnorePatterns(java.util.List<java.lang.String> zipIgnorePatterns)
Parameters:
zipIgnorePatterns - the zipIgnorePatterns to set

getCollectionDao

public CollectionDao getCollectionDao()
Returns:
Returns the collectionDao.

setCollectionDao

public void setCollectionDao(CollectionDao collectionDao)
Parameters:
collectionDao - The collectionDao to set.

getMediaBiz

public MediaBiz getMediaBiz()
Returns:
Returns the mediaBiz.

setMediaBiz

public void setMediaBiz(MediaBiz mediaBiz)
Parameters:
mediaBiz - The mediaBiz to set.

getMediaItemDao

public MediaItemDao getMediaItemDao()
Returns:
Returns the mediaItemDao.

setMediaItemDao

public void setMediaItemDao(MediaItemDao mediaItemDao)
Parameters:
mediaItemDao - The mediaItemDao to set.

getMessages

public org.springframework.context.MessageSource getMessages()
Returns:
Returns the messages.

setMessages

public void setMessages(org.springframework.context.MessageSource messages)
Parameters:
messages - The messages to set.

getWorkBiz

public WorkBiz getWorkBiz()
Returns:
Returns the workBiz.

setWorkBiz

public void setWorkBiz(WorkBiz workBiz)
Parameters:
workBiz - The workBiz to set.

getZipContentTypes

public java.util.Set<java.lang.String> getZipContentTypes()
Returns:
Returns the zipContentTypes.

setZipContentTypes

public void setZipContentTypes(java.util.Set<java.lang.String> zipContentTypes)
Parameters:
zipContentTypes - The zipContentTypes to set.

getSystemBiz

public SystemBiz getSystemBiz()
Returns:
Returns the systemBiz.

setSystemBiz

public void setSystemBiz(SystemBiz systemBiz)
Parameters:
systemBiz - The systemBiz to set.

getFileTypeMap

public javax.activation.FileTypeMap getFileTypeMap()
Returns:
the fileTypeMap

setFileTypeMap

public void setFileTypeMap(javax.activation.FileTypeMap fileTypeMap)
Parameters:
fileTypeMap - the fileTypeMap to set

getAlbumDao

public AlbumDao getAlbumDao()
Returns:
the albumDao

setAlbumDao

public void setAlbumDao(AlbumDao albumDao)
Parameters:
albumDao - the albumDao to set

getDomainObjectFactory

public DomainObjectFactory getDomainObjectFactory()
Returns:
the domainObjectFactory

setDomainObjectFactory

public void setDomainObjectFactory(DomainObjectFactory domainObjectFactory)
Parameters:
domainObjectFactory - the domainObjectFactory to set

getXmlHelper

public XmlHelper getXmlHelper()
Returns:
the xmlHelper

setXmlHelper

public void setXmlHelper(XmlHelper xmlHelper)
Parameters:
xmlHelper - the xmlHelper to set

getMetadataSchemaResource

public org.springframework.core.io.Resource getMetadataSchemaResource()
Returns:
the metadataSchemaResource

setMetadataSchemaResource

public void setMetadataSchemaResource(org.springframework.core.io.Resource metadataSchemaResource)
Parameters:
metadataSchemaResource - the metadataSchemaResource to set

getXmlDateFormat

public magoffin.matt.util.ThreadSafeDateFormat getXmlDateFormat()
Returns:
the xmlDateFormat

setXmlDateFormat

public void setXmlDateFormat(magoffin.matt.util.ThreadSafeDateFormat xmlDateFormat)
Parameters:
xmlDateFormat - the xmlDateFormat to set

getXmlDateTimeFormat

public magoffin.matt.util.ThreadSafeDateFormat getXmlDateTimeFormat()
Returns:
the xmlDateTimeFormat

setXmlDateTimeFormat

public void setXmlDateTimeFormat(magoffin.matt.util.ThreadSafeDateFormat xmlDateTimeFormat)
Parameters:
xmlDateTimeFormat - the xmlDateTimeFormat to set

getZipMimeType

public java.lang.String getZipMimeType()
Returns:
the zipMimeType

setZipMimeType

public void setZipMimeType(java.lang.String zipMimeType)
Parameters:
zipMimeType - the zipMimeType to set