org.kuali.rice.kns.service.impl
Class AttachmentServiceImpl

java.lang.Object
  extended by org.kuali.rice.kns.service.impl.AttachmentServiceImpl
All Implemented Interfaces:
AttachmentService

@Transactional
public class AttachmentServiceImpl
extends Object
implements AttachmentService

Attachment service implementation


Field Summary
private  AttachmentDao attachmentDao
           
private  KualiConfigurationService kualiConfigurationService
           
private static org.apache.log4j.Logger LOG
           
private static int MAX_DIR_LEVELS
           
private  Map<String,String> mimeTypeMapping
           
 
Constructor Summary
AttachmentServiceImpl()
           
 
Method Summary
 String convertMimeTypeToIconPath(String attachmentMimeTypeCode)
           
 Attachment createAttachment(PersistableBusinessObject parent, String uploadedFileName, String mimeType, int fileSize, InputStream fileContents, String attachmentTypeCode)
          Stores the given fileContents and returns referring Attachment object whieh acts as a momento to the archived object.
 void deleteAttachmentContents(Attachment attachment)
          Deletes a given DocumentAttachment contents from the corresponding Attachment object
 void deletePendingAttachmentsModifiedBefore(long modificationTime)
          Deletes pending attachments that were last modified before the given time.
 Attachment getAttachmentByNoteId(Long noteId)
          Retrieves an Attachment by note identifier.
 AttachmentDao getAttachmentDao()
          Retrieves a data access object
private  String getDocumentDirectory(String objectId)
           
private  String getDocumentFileStorageLocation(String objectId)
           
 KualiConfigurationService getKualiConfigurationService()
          Gets the configService attribute.
 Map<String,String> getMimeTypeMapping()
           
private  String getPendingDirectory()
           
private  void moveAttachmentFromPending(Attachment attachment, String objectId)
           
 void moveAttachmentsWherePending(List notes, String objectId)
          Moves attachments on notes from the pending directory to the real one
 InputStream retrieveAttachmentContents(Attachment attachment)
          /* (non-Javadoc)
 void setAttachmentDao(AttachmentDao d)
          Sets the data access object
 void setKualiConfigurationService(KualiConfigurationService configService)
          Sets the configService attribute value.
 void setMimeTypeMapping(Map<String,String> mimeTypeMapping)
           
private  void writeInputStreamToFileStorage(InputStream fileContents, String fullPathUniqueFileName)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAX_DIR_LEVELS

private static final int MAX_DIR_LEVELS
See Also:
Constant Field Values

LOG

private static org.apache.log4j.Logger LOG

kualiConfigurationService

private KualiConfigurationService kualiConfigurationService

attachmentDao

private AttachmentDao attachmentDao

mimeTypeMapping

private Map<String,String> mimeTypeMapping
Constructor Detail

AttachmentServiceImpl

public AttachmentServiceImpl()
Method Detail

getAttachmentByNoteId

public Attachment getAttachmentByNoteId(Long noteId)
Retrieves an Attachment by note identifier.

Specified by:
getAttachmentByNoteId in interface AttachmentService
See Also:
AttachmentService.getAttachmentByNoteId(java.lang.Long)

convertMimeTypeToIconPath

public String convertMimeTypeToIconPath(String attachmentMimeTypeCode)
Specified by:
convertMimeTypeToIconPath in interface AttachmentService

createAttachment

public Attachment createAttachment(PersistableBusinessObject parent,
                                   String uploadedFileName,
                                   String mimeType,
                                   int fileSize,
                                   InputStream fileContents,
                                   String attachmentTypeCode)
                            throws IOException
Description copied from interface: AttachmentService
Stores the given fileContents and returns referring Attachment object whieh acts as a momento to the archived object.

Specified by:
createAttachment in interface AttachmentService
Returns:
Attachment
Throws:
IOException
See Also:
org.kuali.rice.kns.service.DocumentAttachmentService#createAttachment(java.lang.String, java.lang.String, int, java.io.InputStream, Document)

writeInputStreamToFileStorage

private void writeInputStreamToFileStorage(InputStream fileContents,
                                           String fullPathUniqueFileName)
                                    throws IOException
Throws:
IOException

moveAttachmentsWherePending

public void moveAttachmentsWherePending(List notes,
                                        String objectId)
Description copied from interface: AttachmentService
Moves attachments on notes from the pending directory to the real one

Specified by:
moveAttachmentsWherePending in interface AttachmentService

moveAttachmentFromPending

private void moveAttachmentFromPending(Attachment attachment,
                                       String objectId)
                                throws IOException
Throws:
IOException

deleteAttachmentContents

public void deleteAttachmentContents(Attachment attachment)
Description copied from interface: AttachmentService
Deletes a given DocumentAttachment contents from the corresponding Attachment object

Specified by:
deleteAttachmentContents in interface AttachmentService

getPendingDirectory

private String getPendingDirectory()

getDocumentDirectory

private String getDocumentDirectory(String objectId)

retrieveAttachmentContents

public InputStream retrieveAttachmentContents(Attachment attachment)
                                       throws IOException
/* (non-Javadoc)

Specified by:
retrieveAttachmentContents in interface AttachmentService
Returns:
OutputStream
Throws:
IOException
See Also:
org.kuali.rice.kns.service.DocumentAttachmentService#retrieveAttachmentContents(org.kuali.rice.kns.document.DocumentAttachment)

getDocumentFileStorageLocation

private String getDocumentFileStorageLocation(String objectId)

deletePendingAttachmentsModifiedBefore

public void deletePendingAttachmentsModifiedBefore(long modificationTime)
Description copied from interface: AttachmentService
Deletes pending attachments that were last modified before the given time. Java does not have easy access to a file's creation time, so we use modification time instead.

Specified by:
deletePendingAttachmentsModifiedBefore in interface AttachmentService
Parameters:
modificationTime - the number of milliseconds since "the epoch" (i.e.January 1, 1970, 00:00:00 GMT). java.util.Date and java.util.Calendar's methods return time in this format. If a pending attachment was modified before this time, then it will be deleted (unless an error occurs)
See Also:
AttachmentService.deletePendingAttachmentsModifiedBefore(long)

setAttachmentDao

public void setAttachmentDao(AttachmentDao d)
Sets the data access object

Parameters:
d -

getAttachmentDao

public AttachmentDao getAttachmentDao()
Retrieves a data access object


getKualiConfigurationService

public KualiConfigurationService getKualiConfigurationService()
Gets the configService attribute.

Returns:
Returns the configService.

setKualiConfigurationService

public void setKualiConfigurationService(KualiConfigurationService configService)
Sets the configService attribute value.

Parameters:
configService - The configService to set.

getMimeTypeMapping

public Map<String,String> getMimeTypeMapping()

setMimeTypeMapping

public void setMimeTypeMapping(Map<String,String> mimeTypeMapping)


Copyright © 2004-2011 The Kuali Foundation. All Rights Reserved.