KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > snipsnap > snip > attachment > storage > AttachmentStorage


1 /*
2  * This file is part of "SnipSnap Wiki/Weblog".
3  *
4  * Copyright (c) 2002 Stephan J. Schmidt, Matthias L. Jugel
5  * All Rights Reserved.
6  *
7  * Please visit http://snipsnap.org/ for updates and contact.
8  *
9  * --LICENSE NOTICE--
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23  * --LICENSE NOTICE--
24  */

25
26 package org.snipsnap.snip.attachment.storage;
27
28 import org.snipsnap.snip.attachment.Attachment;
29
30 import java.io.InputStream JavaDoc;
31 import java.io.OutputStream JavaDoc;
32 import java.io.IOException JavaDoc;
33
34 /**
35  * Interface that describes backends for attachment storage
36  *
37  * @author Stephan J. Schmidt
38  * @version $Id: AttachmentStorage.java 1693 2004-06-27 10:59:44Z leo $
39  */

40
41 public interface AttachmentStorage {
42   /**
43    * Check if the attachment actually exists.
44    * @param attachment the attachment to check
45    * @return true for existing data or false if missing
46    */

47   public boolean exists(Attachment attachment);
48   /**
49    * Get the output stream for this attachment to store its data in.
50    * @param attachment the attachment meta data
51    * @return an output stream where the data can be written to
52    * @throws IOException if the attachment cannot be stored
53    */

54   public OutputStream JavaDoc getOutputStream(Attachment attachment) throws IOException JavaDoc;
55   /**
56    * Get an input stream to read the attachment data.
57    * @param attachment the attachment meta data
58    * @return the input stream to read from
59    * @throws IOException if the attachment cannot be read
60    */

61   public InputStream JavaDoc getInputStream(Attachment attachment) throws IOException JavaDoc;
62   /**
63    * Delete the attachment
64    * @param attachment the attachment meta data
65    * @throws IOException if the data cannot be deleted
66    */

67   public void delete(Attachment attachment) throws IOException JavaDoc;
68   /**
69    * Verify the meta data of the attachment. An implementation should check
70    * all available information about the attachment, like size, modification
71    * time and if possible the file type. If there are differences the metda data
72    * will be modified and the method returns false.
73    *
74    * @param attachment the attachment meta data
75    * @return true if the meta data is correct, false if the attachment meta data was modified
76    * @throws IOException if the attachment is missing or not verifyable
77    *
78    */

79   public boolean verify(Attachment attachment) throws IOException JavaDoc;
80 }
81
Popular Tags