001 /**
002 * Copyright 2005-2013 The Kuali Foundation
003 *
004 * Licensed under the Educational Community License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 * http://www.opensource.org/licenses/ecl2.php
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016 package org.kuali.rice.krad.service;
017
018 import org.kuali.rice.krad.bo.Attachment;
019 import org.kuali.rice.krad.bo.Note;
020 import org.kuali.rice.krad.bo.PersistableBusinessObject;
021
022 import java.io.IOException;
023 import java.io.InputStream;
024
025 /**
026 * Defines the methods common to all AttachmentService implementations
027 *
028 *
029 */
030 public interface AttachmentService {
031 /**
032 * Stores the given fileContents and returns referring Attachment object whieh acts as a momento to the archived object.
033 *
034 * @param document TODO
035 * @param foo
036 *
037 * @return Attachment
038 * @throws IOException
039 */
040 public Attachment createAttachment(PersistableBusinessObject parent, String uploadedFileName, String mimeType, int fileSize, InputStream fileContents, String attachmentType) throws IOException;
041
042 /**
043 * Retrieves a given Attachments contents from the corresponding Attachment object
044 *
045 * @param documentAttachment
046 *
047 * @return OutputStream
048 * @throws IOException
049 */
050 public InputStream retrieveAttachmentContents(Attachment attachment) throws IOException;
051
052 /**
053 * Deletes a given DocumentAttachment contents from the corresponding Attachment object
054 *
055 * @param documentAttachment
056 */
057 public void deleteAttachmentContents(Attachment attachment);
058
059 /**
060 *
061 * Moves attachments on notes from the pending directory to the real one
062 * @param note the Note from which to move attachments. If this Note does not
063 * have an attachment then this method does nothing.
064 *
065 * @throws IllegalArgumentException if the given Note is null
066 * @throws IllegalArgumentException if the Note does not have a valid object id
067 */
068 public void moveAttachmentWherePending(Note note);
069
070 /**
071 * Deletes pending attachments that were last modified before the given time. Java does not have easy access to a file's creation
072 * time, so we use modification time instead.
073 *
074 * @param 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
075 * methods return time in this format. If a pending attachment was modified before this time, then it will be deleted (unless an error occurs)
076 */
077 public void deletePendingAttachmentsModifiedBefore(long modificationTime);
078
079 public Attachment getAttachmentByNoteId(Long noteId);
080 }