001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: */
017: package org.apache.cocoon.components.repository;
018:
019: import java.io.InputStream;
020:
021: import org.apache.cocoon.ProcessingException;
022: import org.apache.cocoon.components.repository.helpers.CredentialsToken;
023: import org.apache.cocoon.components.repository.helpers.RepositoryTransactionHelper;
024: import org.apache.cocoon.components.repository.helpers.RepositoryPropertyHelper;
025: import org.apache.cocoon.components.repository.helpers.RepositoryVersioningHelper;
026: import org.apache.excalibur.source.Source;
027: import org.w3c.dom.Document;
028: import org.w3c.dom.Node;
029:
030: /**
031: * A repository interface intended to be used by flowscripts or corresponding wrapper components.
032: */
033: public interface Repository {
034:
035: /**
036: * get content as String
037: *
038: * @param uri the uri of the resource.
039: * @return the content as a String.
040: * @throws ProcessingException
041: */
042: String getContentString(String uri) throws ProcessingException;
043:
044: /**
045: * get content as Stream
046: *
047: * @param uri the uri of the resource.
048: * @return the content as a InputStream.
049: * @throws ProcessingException
050: */
051: InputStream getContentStream(String uri) throws ProcessingException;
052:
053: /**
054: * get content as DOM
055: *
056: * @param uri the uri of the resource.
057: * @return the content as a W3C Document object.
058: * @throws ProcessingException
059: */
060: Document getContentDOM(String uri) throws ProcessingException;
061:
062: /**
063: * save content
064: *
065: * @param uri the uri of the resource.
066: * @param content the to be saved content given as a String.
067: * @return a boolean indicating success.
068: * @throws ProcessingException
069: */
070: boolean saveContent(String uri, String content)
071: throws ProcessingException;
072:
073: /**
074: * save content
075: *
076: * @param uri the uri of the resource.
077: * @param node the to be saved content given as a W3C Node object.
078: * @return a boolean indicating success.
079: * @throws ProcessingException
080: */
081: boolean saveContent(String uri, Node node)
082: throws ProcessingException;
083:
084: /**
085: * save content
086: *
087: * @param uri the uri of the resource.
088: * @param source the to be saved content given as a Excalibur Source object.
089: * @return a boolean indicating success.
090: * @throws ProcessingException
091: */
092: boolean saveContent(String uri, Source source)
093: throws ProcessingException;
094:
095: /**
096: * create a new resource
097: *
098: * @param uri the uri of the resource.
099: * @param content the content to initialize the resource with.
100: * @return a boolean indicating success.
101: * @throws ProcessingException
102: */
103: boolean createResource(String uri, String content)
104: throws ProcessingException;
105:
106: /**
107: * copy a resource
108: *
109: * @param uri the uri of the resource.
110: * @param dest the destination of the copy.
111: * @param recurse if true recursively creates parent collections if not existant
112: * @param overwrite whether to overwrite the destination if it exists.
113: * @return a boolean indicating success.
114: * @throws ProcessingException
115: */
116: boolean copy(String uri, String dest, boolean recurse,
117: boolean overwrite) throws ProcessingException;
118:
119: /**
120: * move a resource
121: *
122: * @param uri the uri of the resource.
123: * @param dest the destination of the move.
124: * @param recurse if true recursively creates parent collections if not existant
125: * @param overwrite whether to overwrite the destination if it exists.
126: * @return a boolean indicating success.
127: * @throws ProcessingException
128: */
129: boolean move(String uri, String dest, boolean recurse,
130: boolean overwrite) throws ProcessingException;
131:
132: /**
133: * remove resource
134: *
135: * @param uri the uri of the resource.
136: * @return a boolean indicating success.
137: * @throws ProcessingException
138: */
139: boolean remove(String uri) throws ProcessingException;
140:
141: /**
142: * checks wether resource exists
143: *
144: * @param uri the uri of the document.
145: * @return a boolean indicating existance of the resource.
146: * @throws ProcessingException
147: */
148: public boolean exists(String uri) throws ProcessingException;
149:
150: /**
151: * make collection
152: *
153: * @param uri the uri of the collection.
154: * @param recursive a boolean indicating wether
155: * the operation should fail if the parent
156: * collection does not exist or wether the
157: * complete path should be created.
158: * @return a boolean indicating success.
159: * @throws ProcessingException
160: */
161: boolean makeCollection(String uri, boolean recursive)
162: throws ProcessingException;
163:
164: /**
165: * get a property helper
166: *
167: * @return the property helper.
168: * Returns null if the Repository does not support properties.
169: */
170: RepositoryPropertyHelper getPropertyHelper();
171:
172: /**
173: * get a transaction helper
174: *
175: * @return a transaction helper.
176: * Returns null if the Repository does neither support transactions nor locks.
177: */
178: RepositoryTransactionHelper getTransactionHelper();
179:
180: /**
181: * get a versioning helper
182: *
183: * @return a versioning helper.
184: * Returns null if the Repository does not support versioning.
185: */
186: RepositoryVersioningHelper getVersioningHelper();
187:
188: /**
189: * get the credentials used against the repository
190: *
191: * @return the credentials in use.
192: */
193: CredentialsToken getCredentials();
194:
195: /**
196: * set the credentials to be used against the repository
197: *
198: * @param credentials the credentials to use.
199: */
200: void setCredentials(CredentialsToken credentials);
201:
202: }
|