001: /*
002: * Copyright 2006 Pentaho Corporation. All rights reserved.
003: * This software was developed by Pentaho Corporation and is provided under the terms
004: * of the Mozilla Public License, Version 1.1, or any later version. You may not use
005: * this file except in compliance with the license. If you need a copy of the license,
006: * please go to http://www.mozilla.org/MPL/MPL-1.1.txt. The Original Code is the Pentaho
007: * BI Platform. The Initial Developer is Pentaho Corporation.
008: *
009: * Software distributed under the Mozilla Public License is distributed on an "AS IS"
010: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. Please refer to
011: * the license for the specific language governing your rights and limitations.
012: *
013: * @created Jul 1, 2005
014: * @author Marc Batchelor
015: *
016: */
017:
018: package org.pentaho.core.repository;
019:
020: import java.io.IOException;
021: import java.io.InputStream;
022: import java.io.OutputStream;
023: import java.io.Reader;
024: import java.util.Date;
025: import java.util.List;
026:
027: import javax.activation.FileDataSource;
028:
029: import org.pentaho.core.repository.content.ContentException;
030: import org.pentaho.core.solution.MimeTypeListener;
031:
032: /**
033: *
034: * Construction of a new ContentItem is managed by
035: * ContentLocation.newContentItem. This is because there is a parent-child
036: * relationship between ContentLocations and content items. To avoid having a
037: * content item reach back into it's parent to add itself to the children list,
038: * you instead call the content location to construct a content item. A content
039: * item cannot exist without a content location.
040: *
041: * @see ContentLocation
042: * @author mbatchel
043: *
044: */
045: public interface IContentItem extends MimeTypeListener {
046:
047: /**
048: * Keep multiple versions when request for an output stream is received
049: */
050: public static final int WRITEMODE_KEEPVERSIONS = 0;
051:
052: /**
053: * Overwrite each time a request for a new output stream is received.
054: */
055: public static final int WRITEMODE_OVERWRITE = 1;
056:
057: /**
058: * Append to existing file when request for a new output stream is received.
059: */
060: public static final int WRITEMODE_APPEND = 2;
061:
062: // Probably not necessary or ever used. Wanted to consider it though.
063:
064: /**
065: * @return The ContentItem Id
066: */
067: public String getId();
068:
069: /**
070: * @return The ContentItem path
071: */
072: public String getPath();
073:
074: /**
075: * @return The name of the content item
076: */
077: public String getName();
078:
079: /**
080: * @return The title of the content item
081: */
082: public String getTitle();
083:
084: /**
085: * @return The MimeType of the content item.
086: */
087: public String getMimeType();
088:
089: /**
090: * @return The URL (optional) of the content item
091: */
092: public String getUrl();
093:
094: /**
095: * @return If this is a multiple-versioned style of content item, return the
096: * whole list for admin purposes
097: */
098: public List getFileVersions();
099:
100: /**
101: * Removes all the version from Hibernate
102: *
103: */
104: public void removeAllVersions();
105:
106: /**
107: * Removes the file with the id specified
108: */
109: public void removeVersion(String fileId);
110:
111: /**
112: * Gets an input stream from the Content item. If the content item doesn't
113: * exist on disk, throws an exception
114: *
115: * @return An input stream from the file system that is represented by this
116: * content item
117: * @throws ContentException
118: */
119: public InputStream getInputStream() throws ContentException;
120:
121: /**
122: * Returns a reader from the content item. If the content item doesn't exist
123: * an exception is thrown.
124: *
125: * @return A Reader from the file system that is pointed to by this content
126: * item.
127: * @throws ContentException
128: */
129: public FileDataSource getDataSource();
130:
131: public Reader getReader() throws ContentException;
132:
133: /**
134: * The behavior of this method depends upon it's write mode (defined only at
135: * construction).
136: *
137: * If the write mode is WRITEMODE_KEEPVERSIONS, this method will create a
138: * new file on the disk, and add it to it's internal list of files, and
139: * return an output stream.
140: *
141: * If the write mode is WRITEMODE_OVERWRITE, this method will create an
142: * output stream and overwrite the existing file on the disk if it's found,
143: * or will create the file if it doesn't exist.
144: *
145: * If the write mode is WRITEMODE_APPEND, this method will append to the
146: * existing file on disk (if it exists), or create it if it doesn't exist.
147: *
148: * @param actionName
149: * The name of the action that is obtaining the output stream.
150: * @throws IOException
151: * @return the OutputStream to write to
152: */
153: public OutputStream getOutputStream(String actionName)
154: throws IOException;
155:
156: public void closeOutputStream();
157:
158: /**
159: * @return The name of the action from the latest ContentItemFile class that
160: * the ContentItem contains.
161: */
162: public String getActionName();
163:
164: /**
165: * @return This returns the Id of the ContentItemFile class that the
166: * ContentItem contains.
167: */
168: public String getFileId();
169:
170: /**
171: * @return The file size from the latest ContentItemFile class that the
172: * ContentItem contains.
173: */
174: public long getFileSize();
175:
176: /**
177: * @return The file date/time from the latest ContentItemFile class that the
178: * ContentItem contains.
179: */
180: public Date getFileDateTime();
181:
182: /**
183: * Sets the mime type
184: *
185: * @param mimeType
186: * The mime type to set.
187: */
188: public void setMimeType(String mimeType);
189:
190: /**
191: * Removes all versions of this item from
192: * the repository and removes this item
193: * from underlying persistence layer.
194: *
195: */
196: public void makeTransient();
197:
198: }
|