KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > components > repository > Repository


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation.
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.apache.cocoon.components.repository;
17
18 import java.io.InputStream JavaDoc;
19
20 import org.apache.cocoon.ProcessingException;
21 import org.apache.cocoon.components.repository.helpers.CredentialsToken;
22 import org.apache.cocoon.components.repository.helpers.RepositoryTransactionHelper;
23 import org.apache.cocoon.components.repository.helpers.RepositoryPropertyHelper;
24 import org.apache.cocoon.components.repository.helpers.RepositoryVersioningHelper;
25 import org.apache.excalibur.source.Source;
26 import org.w3c.dom.Document JavaDoc;
27 import org.w3c.dom.Node JavaDoc;
28
29
30 /**
31  * A repository interface intended to be used by flowscripts or corresponding wrapper components.
32  */

33 public interface Repository {
34     
35     /**
36      * get content as String
37      *
38      * @param uri the uri of the resource.
39      * @return the content as a String.
40      * @throws ProcessingException
41      */

42     String JavaDoc getContentString(String JavaDoc uri) throws ProcessingException;
43
44     /**
45      * get content as Stream
46      *
47      * @param uri the uri of the resource.
48      * @return the content as a InputStream.
49      * @throws ProcessingException
50      */

51    InputStream JavaDoc getContentStream(String JavaDoc uri) throws ProcessingException;
52
53     /**
54      * get content as DOM
55      *
56      * @param uri the uri of the resource.
57      * @return the content as a W3C Document object.
58      * @throws ProcessingException
59      */

60     Document JavaDoc getContentDOM(String JavaDoc uri) throws ProcessingException;
61
62     /**
63      * save content
64      *
65      * @param uri the uri of the resource.
66      * @param content the to be saved content given as a String.
67      * @return a boolean indicating success.
68      * @throws ProcessingException
69      */

70     boolean saveContent(String JavaDoc uri, String JavaDoc content) throws ProcessingException;
71
72     /**
73      * save content
74      *
75      * @param uri the uri of the resource.
76      * @param node the to be saved content given as a W3C Node object.
77      * @return a boolean indicating success.
78      * @throws ProcessingException
79      */

80     boolean saveContent(String JavaDoc uri, Node JavaDoc node) throws ProcessingException;
81
82     /**
83      * save content
84      *
85      * @param uri the uri of the resource.
86      * @param source the to be saved content given as a Excalibur Source object.
87      * @return a boolean indicating success.
88      * @throws ProcessingException
89      */

90     boolean saveContent(String JavaDoc uri, Source source) throws ProcessingException;
91
92     /**
93      * create a new resource
94      *
95      * @param uri the uri of the resource.
96      * @param content the content to initialize the resource with.
97      * @return a boolean indicating success.
98      * @throws ProcessingException
99      */

100     boolean createResource(String JavaDoc uri, String JavaDoc content) throws ProcessingException;
101
102     /**
103      * copy a resource
104      *
105      * @param uri the uri of the resource.
106      * @param dest the destination of the copy.
107      * @param recurse if true recursively creates parent collections if not existant
108      * @param overwrite whether to overwrite the destination if it exists.
109      * @return a boolean indicating success.
110      * @throws ProcessingException
111      */

112     boolean copy(String JavaDoc uri, String JavaDoc dest, boolean recurse, boolean overwrite) throws ProcessingException;
113
114     /**
115      * move a resource
116      *
117      * @param uri the uri of the resource.
118      * @param dest the destination of the move.
119      * @param recurse if true recursively creates parent collections if not existant
120      * @param overwrite whether to overwrite the destination if it exists.
121      * @return a boolean indicating success.
122      * @throws ProcessingException
123      */

124     boolean move(String JavaDoc uri, String JavaDoc dest, boolean recurse, boolean overwrite) throws ProcessingException;
125
126     /**
127      * remove resource
128      *
129      * @param uri the uri of the resource.
130      * @return a boolean indicating success.
131      * @throws ProcessingException
132      */

133     boolean remove(String JavaDoc uri) throws ProcessingException;
134
135     /**
136      * checks wether resource exists
137      *
138      * @param uri the uri of the document.
139      * @return a boolean indicating existance of the resource.
140      * @throws ProcessingException
141      */

142     public boolean exists(String JavaDoc uri) throws ProcessingException;
143
144     /**
145      * make collection
146      *
147      * @param uri the uri of the collection.
148      * @param recursive a boolean indicating wether
149      * the operation should fail if the parent
150      * collection does not exist or wether the
151      * complete path should be created.
152      * @return a boolean indicating success.
153      * @throws ProcessingException
154      */

155     boolean makeCollection(String JavaDoc uri, boolean recursive) throws ProcessingException;
156
157     /**
158      * get a property helper
159      *
160      * @return the property helper.
161      * Returns null if the Repository does not support properties.
162      */

163     RepositoryPropertyHelper getPropertyHelper();
164
165     /**
166      * get a transaction helper
167      *
168      * @return a transaction helper.
169      * Returns null if the Repository does neither support transactions nor locks.
170      */

171     RepositoryTransactionHelper getTransactionHelper();
172
173     /**
174      * get a versioning helper
175      *
176      * @return a versioning helper.
177      * Returns null if the Repository does not support versioning.
178      */

179     RepositoryVersioningHelper getVersioningHelper();
180
181     /**
182      * get the credentials used against the repository
183      *
184      * @return the credentials in use.
185      */

186     CredentialsToken getCredentials();
187
188     /**
189      * set the credentials to be used against the repository
190      *
191      * @param credentials the credentials to use.
192      */

193     void setCredentials(CredentialsToken credentials);
194
195 }
Popular Tags