KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > outerj > daisy > books > store > BookInstance


1 /*
2  * Copyright 2004 Outerthought bvba and Schaubroeck nv
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.outerj.daisy.books.store;
17
18 import org.outerx.daisy.x10Bookstoremeta.ResourcePropertiesDocument;
19
20 import java.io.InputStream JavaDoc;
21 import java.io.OutputStream JavaDoc;
22 import java.io.IOException JavaDoc;
23 import java.net.URI JavaDoc;
24
25 public interface BookInstance {
26     String JavaDoc getName();
27
28     /**
29      * Returns a stream for the given resource. The stream will already be buffered if needed.
30      *
31      * <p>Throws a {@link BookResourceNotFoundException} if the path does not exist.
32      *
33      * <p><b style="color: red">It is the callers' responsibility to close this stream!</b>
34      */

35     InputStream JavaDoc getResource(String JavaDoc path);
36
37     /**
38      * Returns null if not available.
39      */

40     ResourcePropertiesDocument getResourceProperties(String JavaDoc path);
41
42     /**
43      * Stores a resource under the given path.
44      *
45      * <p>The implementation of this method is required to close the input stream, even
46      * if an exception occurs.
47      */

48     void storeResource(String JavaDoc path, InputStream JavaDoc is);
49
50     void storeResourceProperties(String JavaDoc path, ResourcePropertiesDocument resourcePropertiesDocument);
51
52     /**
53      * Get an output stream to store a resource in the book instance.
54      *
55      * <p> This will return a buffered stream if necessary, no need to wrap it into a BufferedOutputStream
56      * yourself.
57      *
58      * <p><b style="color: red">It is the callers' responsibility to close this stream!</b>
59      */

60     OutputStream JavaDoc getResourceOutputStream(String JavaDoc path) throws IOException JavaDoc;
61
62     boolean rename(String JavaDoc path, String JavaDoc newName);
63
64     boolean exists(String JavaDoc path);
65
66     long getLastModified(String JavaDoc path);
67
68     long getContentLength(String JavaDoc path);
69
70     void lock();
71
72     void unlock();
73
74     BookAcl getAcl();
75
76     void setAcl(BookAcl bookAcl);
77
78     /**
79      * Returns true if the user can perform management operations on this book instance.
80      */

81     boolean canManage();
82
83     PublicationsInfo getPublicationsInfo();
84
85     void addPublication(PublicationInfo publicationInfo);
86
87     void setPublications(PublicationsInfo publicationsInfo);
88
89     /**
90      * Returns a Java URI that can be used to retrieve the resource. Bypasses the BookInstance abstraction.
91      */

92     URI JavaDoc getResourceURI(String JavaDoc path);
93
94     /**
95      * Note: while this returns a mutable object, it is a clone of the original
96      * and any changed performed on it will not have effect.
97      */

98     BookInstanceMetaData getMetaData();
99
100     void setMetaData(BookInstanceMetaData metaData);
101
102     String JavaDoc[] getDescendantPaths(String JavaDoc path);
103 }
104
Popular Tags