KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > pentaho > core > repository > IContentItem


1 /*
2  * Copyright 2006 Pentaho Corporation. All rights reserved.
3  * This software was developed by Pentaho Corporation and is provided under the terms
4  * of the Mozilla Public License, Version 1.1, or any later version. You may not use
5  * this file except in compliance with the license. If you need a copy of the license,
6  * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
7  * BI Platform. The Initial Developer is Pentaho Corporation.
8  *
9  * Software distributed under the Mozilla Public License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
11  * the license for the specific language governing your rights and limitations.
12  *
13  * @created Jul 1, 2005
14  * @author Marc Batchelor
15  *
16  */

17
18 package org.pentaho.core.repository;
19
20 import java.io.IOException JavaDoc;
21 import java.io.InputStream JavaDoc;
22 import java.io.OutputStream JavaDoc;
23 import java.io.Reader JavaDoc;
24 import java.util.Date JavaDoc;
25 import java.util.List JavaDoc;
26
27 import javax.activation.FileDataSource JavaDoc;
28
29 import org.pentaho.core.repository.content.ContentException;
30
31 /**
32  *
33  * Construction of a new ContentItem is managed by
34  * ContentLocation.newContentItem. This is because there is a parent-child
35  * relationship between ContentLocations and content items. To avoid having a
36  * content item reach back into it's parent to add itself to the children list,
37  * you instead call the content location to construct a content item. A content
38  * item cannot exist without a content location.
39  *
40  * @see ContentLocation
41  * @author mbatchel
42  *
43  */

44 public interface IContentItem {
45
46     /**
47      * Keep multiple versions when request for an output stream is received
48      */

49     public static final int WRITEMODE_KEEPVERSIONS = 0;
50
51     /**
52      * Overwrite each time a request for a new output stream is received.
53      */

54     public static final int WRITEMODE_OVERWRITE = 1;
55
56     /**
57      * Append to existing file when request for a new output stream is received.
58      */

59     public static final int WRITEMODE_APPEND = 2;
60     // Probably not necessary or ever used. Wanted to consider it though.
61

62     /**
63      * @return The ContentItem Id
64      */

65     public String JavaDoc getId();
66
67     /**
68      * @return The ContentItem path
69      */

70     public String JavaDoc getPath();
71
72     /**
73      * @return The name of the content item
74      */

75     public String JavaDoc getName();
76
77     /**
78      * @return The title of the content item
79      */

80     public String JavaDoc getTitle();
81
82     /**
83      * @return The MimeType of the content item.
84      */

85     public String JavaDoc getMimeType();
86
87     /**
88      * @return The URL (optional) of the content item
89      */

90     public String JavaDoc getUrl();
91
92     /**
93      * @return If this is a multiple-versioned style of content item, return the
94      * whole list for admin purposes
95      */

96     public List JavaDoc getFileVersions();
97
98     /**
99      * Removes all the version from Hibernate
100      *
101      */

102     public void removeAllVersions();
103
104     /**
105      * Removes the file with the id specified
106      */

107     public void removeVersion(String JavaDoc fileId);
108
109     /**
110      * Gets an input stream from the Content item. If the content item doesn't
111      * exist on disk, throws an exception
112      *
113      * @return An input stream from the file system that is represented by this
114      * content item
115      * @throws ContentException
116      */

117     public InputStream JavaDoc getInputStream() throws ContentException;
118
119     /**
120      * Returns a reader from the content item. If the content item doesn't exist
121      * an exception is thrown.
122      *
123      * @return A Reader from the file system that is pointed to by this content
124      * item.
125      * @throws ContentException
126      */

127     public FileDataSource JavaDoc getDataSource();
128
129     public Reader JavaDoc getReader() throws ContentException;
130
131     /**
132      * The behavior of this method depends upon it's write mode (defined only at
133      * construction).
134      *
135      * If the write mode is WRITEMODE_KEEPVERSIONS, this method will create a
136      * new file on the disk, and add it to it's internal list of files, and
137      * return an output stream.
138      *
139      * If the write mode is WRITEMODE_OVERWRITE, this method will create an
140      * output stream and overwrite the existing file on the disk if it's found,
141      * or will create the file if it doesn't exist.
142      *
143      * If the write mode is WRITEMODE_APPEND, this method will append to the
144      * existing file on disk (if it exists), or create it if it doesn't exist.
145      *
146      * @param actionName
147      * The name of the action that is obtaining the output stream.
148      * @throws IOException
149      * @return the OutputStream to write to
150      */

151     public OutputStream JavaDoc getOutputStream(String JavaDoc actionName) throws IOException JavaDoc;
152
153     /**
154      * @return The name of the action from the latest ContentItemFile class that
155      * the ContentItem contains.
156      */

157     public String JavaDoc getActionName();
158
159     /**
160      * @return This returns the Id of the ContentItemFile class that the
161      * ContentItem contains.
162      */

163     public String JavaDoc getFileId();
164
165     /**
166      * @return The file size from the latest ContentItemFile class that the
167      * ContentItem contains.
168      */

169     public long getFileSize();
170
171     /**
172      * @return The file date/time from the latest ContentItemFile class that the
173      * ContentItem contains.
174      */

175     public Date JavaDoc getFileDateTime();
176
177     /**
178      * Sets the mime type
179      *
180      * @param mimeType
181      * The mime type to set.
182      */

183     public void setMimeType(String JavaDoc mimeType);
184
185     /**
186      * Removes all versions of this item from
187      * the repository and removes this item
188      * from underlying persistence layer.
189      *
190      */

191     public void makeTransient();
192     
193 }
194
Popular Tags