1 |
1780
|
jones
|
/**
|
2 |
|
|
* '$RCSfile$'
|
3 |
|
|
* Copyright: 2000 Regents of the University of California and the
|
4 |
|
|
* National Center for Ecological Analysis and Synthesis
|
5 |
|
|
*
|
6 |
|
|
* '$Author$'
|
7 |
|
|
* '$Date$'
|
8 |
|
|
* '$Revision$'
|
9 |
|
|
*
|
10 |
|
|
* This program is free software; you can redistribute it and/or modify
|
11 |
|
|
* it under the terms of the GNU General Public License as published by
|
12 |
|
|
* the Free Software Foundation; either version 2 of the License, or
|
13 |
|
|
* (at your option) any later version.
|
14 |
|
|
*
|
15 |
|
|
* This program is distributed in the hope that it will be useful,
|
16 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
17 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
18 |
|
|
* GNU General Public License for more details.
|
19 |
|
|
*
|
20 |
|
|
* You should have received a copy of the GNU General Public License
|
21 |
|
|
* along with this program; if not, write to the Free Software
|
22 |
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
23 |
|
|
*/
|
24 |
|
|
|
25 |
|
|
package edu.ucsb.nceas.metacat.client;
|
26 |
|
|
|
27 |
|
|
import java.io.Reader;
|
28 |
1785
|
tao
|
import java.io.IOException;
|
29 |
2240
|
sgarg
|
import java.io.File;
|
30 |
2264
|
sgarg
|
import java.io.InputStream;
|
31 |
3141
|
berkley
|
import java.util.Vector;
|
32 |
1780
|
jones
|
|
33 |
|
|
/**
|
34 |
2240
|
sgarg
|
* This interface provides methods for initializing and logging in to a
|
35 |
|
|
* Metacat server, and then querying, reading, transforming, inserting,
|
36 |
1780
|
jones
|
* updating and deleting documents from that server.
|
37 |
|
|
*/
|
38 |
|
|
public interface Metacat
|
39 |
|
|
{
|
40 |
|
|
/**
|
41 |
|
|
* Method used to log in to a metacat server. Implementations will need
|
42 |
|
|
* to cache a cookie value to make the session persistent. Each time a
|
43 |
|
|
* call is made to one of the other methods (e.g., read), the cookie will
|
44 |
|
|
* need to be passed back to the metacat server along with the request.
|
45 |
|
|
*
|
46 |
|
|
* @param username the username of the user, like an LDAP DN
|
47 |
|
|
* @param password the password for that user for authentication
|
48 |
1822
|
jones
|
* @return the response string from metacat in XML format
|
49 |
1780
|
jones
|
* @throws MetacatAuthException when the username/password could
|
50 |
|
|
* not be authenticated
|
51 |
|
|
*/
|
52 |
2240
|
sgarg
|
public String login(String username, String password)
|
53 |
1780
|
jones
|
throws MetacatAuthException, MetacatInaccessibleException;
|
54 |
2240
|
sgarg
|
|
55 |
1797
|
tao
|
/**
|
56 |
1822
|
jones
|
* Method used to log out a metacat server. The Metacat server will end
|
57 |
|
|
* the session when this call is invoked.
|
58 |
1797
|
tao
|
*
|
59 |
1822
|
jones
|
* @return the response string from metacat in XML format
|
60 |
1797
|
tao
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
61 |
|
|
* reached or does not respond
|
62 |
|
|
*/
|
63 |
2240
|
sgarg
|
public String logout() throws MetacatInaccessibleException,
|
64 |
1822
|
jones
|
MetacatException;
|
65 |
1780
|
jones
|
|
66 |
|
|
/**
|
67 |
|
|
* Read an XML document from the metacat server session, accessed by docid,
|
68 |
|
|
* and returned as a Reader.
|
69 |
|
|
*
|
70 |
|
|
* @param docid the identifier of the document to be read
|
71 |
|
|
* @return a Reader for accessing the document
|
72 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
73 |
1780
|
jones
|
* for the operation
|
74 |
1784
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
75 |
|
|
* reached or does not respond
|
76 |
|
|
* @throws MetacatException when the metacat server generates another error
|
77 |
1780
|
jones
|
*/
|
78 |
5066
|
leinfelder
|
public InputStream read(String docid) throws InsufficientKarmaException,
|
79 |
2989
|
berkley
|
MetacatInaccessibleException, DocumentNotFoundException, MetacatException;
|
80 |
1780
|
jones
|
|
81 |
|
|
/**
|
82 |
2261
|
sgarg
|
* Read inline data from the metacat server session, accessed by
|
83 |
|
|
* inlinedataid, and returned as a Reader.
|
84 |
|
|
*
|
85 |
|
|
* @param inlinedataid the identifier of the document to be read
|
86 |
|
|
* @return a Reader for accessing the document
|
87 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
88 |
|
|
* for the operation
|
89 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
90 |
|
|
* reached or does not respond
|
91 |
|
|
* @throws MetacatException when the metacat server generates another error
|
92 |
|
|
*/
|
93 |
5066
|
leinfelder
|
public InputStream readInlineData(String inlinedataid)
|
94 |
2261
|
sgarg
|
throws InsufficientKarmaException,
|
95 |
|
|
MetacatInaccessibleException, MetacatException;
|
96 |
|
|
|
97 |
|
|
/**
|
98 |
2240
|
sgarg
|
* Query the metacat document store with the given metacat-compatible
|
99 |
1780
|
jones
|
* query document, and return the result set as a Reader.
|
100 |
|
|
*
|
101 |
|
|
* @param xmlQuery a Reader for accessing the XML version of the query
|
102 |
|
|
* @return a Reader for accessing the result set
|
103 |
|
|
*/
|
104 |
1785
|
tao
|
public Reader query(Reader xmlQuery) throws MetacatInaccessibleException,
|
105 |
|
|
IOException;
|
106 |
3463
|
tao
|
|
107 |
|
|
|
108 |
|
|
/**
|
109 |
|
|
* Query the metacat document store with the given metacat-compatible
|
110 |
|
|
* query document and qformat, and return the result set as a Reader.
|
111 |
|
|
*
|
112 |
|
|
* @param xmlQuery a Reader for accessing the XML version of the query
|
113 |
|
|
* @param qformat the format of return doc. It can be xml, knb, lter and etal.
|
114 |
|
|
* @return a Reader for accessing the result set
|
115 |
|
|
*/
|
116 |
|
|
public Reader query(Reader xmlQuery, String qformat) throws MetacatInaccessibleException,
|
117 |
|
|
IOException;
|
118 |
1780
|
jones
|
|
119 |
|
|
/**
|
120 |
3721
|
jones
|
* Insert an XML document into the repository, making it available for
|
121 |
|
|
* searching using the query() methods.
|
122 |
1780
|
jones
|
*
|
123 |
|
|
* @param docid the docid to insert the document
|
124 |
|
|
* @param xmlDocument a Reader for accessing the XML document to be inserted
|
125 |
2240
|
sgarg
|
* @param schema a Reader for accessing the DTD or XML Schema for
|
126 |
1780
|
jones
|
* the document
|
127 |
1789
|
jones
|
* @return the metacat response message
|
128 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
129 |
1780
|
jones
|
* for the operation
|
130 |
1789
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
131 |
|
|
* reached or does not respond
|
132 |
|
|
* @throws MetacatException when the metacat server generates another error
|
133 |
|
|
* @throws IOException when there is an error reading the xml document
|
134 |
1780
|
jones
|
*/
|
135 |
1789
|
jones
|
public String insert(String docid, Reader xmlDocument, Reader schema)
|
136 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
137 |
|
|
MetacatInaccessibleException;
|
138 |
1780
|
jones
|
|
139 |
|
|
/**
|
140 |
3721
|
jones
|
* Update an XML document in the repository by providing a new version of
|
141 |
|
|
* the XML document. The new version is placed in the search index,
|
142 |
|
|
* and older versions are archived (accessible by read(), but not in the
|
143 |
|
|
* search index).
|
144 |
1780
|
jones
|
*
|
145 |
|
|
* @param docid the docid to update
|
146 |
|
|
* @param xmlDocument a Reader for accessing the XML text to be updated
|
147 |
2240
|
sgarg
|
* @param schema a Reader for accessing the DTD or XML Schema for
|
148 |
1780
|
jones
|
* the document
|
149 |
1795
|
jones
|
* @return the metacat response message
|
150 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
151 |
1780
|
jones
|
* for the operation
|
152 |
1795
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
153 |
|
|
* reached or does not respond
|
154 |
|
|
* @throws MetacatException when the metacat server generates another error
|
155 |
|
|
* @throws IOException when there is an error reading the xml document
|
156 |
1780
|
jones
|
*/
|
157 |
1795
|
jones
|
public String update(String docid, Reader xmlDocument, Reader schema)
|
158 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
159 |
|
|
MetacatInaccessibleException;
|
160 |
1780
|
jones
|
|
161 |
|
|
/**
|
162 |
3721
|
jones
|
* Upload a data document into the repository. Data files are stored on
|
163 |
|
|
* metacat and may be in any format (binary or text), but they are all
|
164 |
|
|
* treated as if they were binary. Data files are not searched by the
|
165 |
|
|
* query() methods because they are not loaded into the XML store because
|
166 |
|
|
* they are not XML documents. The File parameter is used to determine a
|
167 |
|
|
* name for the uploaded document.
|
168 |
2240
|
sgarg
|
*
|
169 |
3721
|
jones
|
* @param docid the identifier to be used for the document
|
170 |
|
|
* @param file the File to be uploaded
|
171 |
|
|
* @param document a InputStream containing the data to be uploaded
|
172 |
2240
|
sgarg
|
* @return the metacat response message
|
173 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
174 |
|
|
* for the operation
|
175 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
176 |
|
|
* reached or does not respond
|
177 |
|
|
* @throws MetacatException when the metacat server generates another error
|
178 |
|
|
* @throws IOException when there is an error reading the xml document
|
179 |
|
|
*/
|
180 |
|
|
public String upload(String docid, File file)
|
181 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
182 |
|
|
MetacatInaccessibleException;
|
183 |
|
|
|
184 |
|
|
/**
|
185 |
3721
|
jones
|
* Upload a data document into the repository. Data files are stored on
|
186 |
|
|
* metacat and may be in any format (binary or text), but they are all
|
187 |
|
|
* treated as if they were binary. Data files are not searched by the
|
188 |
|
|
* query() methods because they are not loaded into the XML store because
|
189 |
|
|
* they are not XML documents. The name for the document is set explicitly
|
190 |
|
|
* using the filename parameter.
|
191 |
2264
|
sgarg
|
*
|
192 |
3721
|
jones
|
* @param docid the identifier to be used for the document
|
193 |
|
|
* @param filename the name to be used in the MIME description of the uploaded file
|
194 |
|
|
* @param document a InputStream containing the data to be uploaded
|
195 |
2264
|
sgarg
|
* @return the metacat response message
|
196 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
197 |
|
|
* for the operation
|
198 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
199 |
|
|
* reached or does not respond
|
200 |
|
|
* @throws MetacatException when the metacat server generates another error
|
201 |
|
|
* @throws IOException when there is an error reading the xml document
|
202 |
|
|
*/
|
203 |
|
|
public String upload(String docid, String fileName,
|
204 |
|
|
InputStream fileData, int size)
|
205 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
206 |
|
|
MetacatInaccessibleException;
|
207 |
|
|
|
208 |
|
|
/**
|
209 |
1780
|
jones
|
* Delete an XML document in the repository.
|
210 |
|
|
*
|
211 |
|
|
* @param docid the docid to delete
|
212 |
1795
|
jones
|
* @return the metacat response message
|
213 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
214 |
1780
|
jones
|
* for the operation
|
215 |
1795
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
216 |
|
|
* reached or does not respond
|
217 |
|
|
* @throws MetacatException when the metacat server generates another error
|
218 |
1780
|
jones
|
*/
|
219 |
1795
|
jones
|
public String delete(String docid)
|
220 |
|
|
throws InsufficientKarmaException, MetacatException,
|
221 |
|
|
MetacatInaccessibleException;
|
222 |
1780
|
jones
|
|
223 |
5112
|
daigle
|
public String getAccessControl(String docid)
|
224 |
|
|
throws InsufficientKarmaException, MetacatException,MetacatInaccessibleException;
|
225 |
|
|
|
226 |
1780
|
jones
|
/**
|
227 |
2326
|
harris
|
* set the access on an XML document in the repository.
|
228 |
|
|
*
|
229 |
2327
|
harris
|
* @param _docid the docid of the document for which the access should be applied.
|
230 |
2326
|
harris
|
*
|
231 |
|
|
* @param _principal the document's principal
|
232 |
|
|
*
|
233 |
|
|
* @param _permission the access permission to be applied to the docid
|
234 |
|
|
* {e.g. read,write,all}
|
235 |
|
|
*
|
236 |
|
|
* @param _permType the permission type to be applied to the document
|
237 |
|
|
* {e.g. allow or deny}
|
238 |
|
|
*
|
239 |
|
|
* @param _permOrder the order that the document's permissions should be
|
240 |
|
|
* processed {e.g. denyFirst or allowFirst}
|
241 |
|
|
*
|
242 |
|
|
*
|
243 |
|
|
* @return the metacat response message
|
244 |
|
|
*
|
245 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
246 |
|
|
* for the operation
|
247 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
248 |
|
|
* reached or does not respond
|
249 |
|
|
* @throws MetacatException when the metacat server generates another error
|
250 |
|
|
*/
|
251 |
5112
|
daigle
|
public String setAccess(String docid, String principal, String
|
252 |
|
|
permission, String permType, String permOrder )
|
253 |
|
|
throws InsufficientKarmaException, MetacatException, MetacatInaccessibleException;
|
254 |
2326
|
harris
|
|
255 |
5112
|
daigle
|
public String setAccess(String docid, String accessBlock)
|
256 |
|
|
throws InsufficientKarmaException, MetacatException, MetacatInaccessibleException;
|
257 |
|
|
|
258 |
2326
|
harris
|
/**
|
259 |
1780
|
jones
|
* When the MetacatFactory creates an instance it needs to set the
|
260 |
|
|
* MetacatUrl to which connections should be made.
|
261 |
|
|
*
|
262 |
|
|
* @param metacatUrl the URL for the metacat server
|
263 |
|
|
*/
|
264 |
|
|
public void setMetacatUrl(String metacatUrl);
|
265 |
1822
|
jones
|
|
266 |
|
|
/**
|
267 |
|
|
* Get the session identifier for this session.
|
268 |
|
|
*
|
269 |
|
|
* @returns the sessionId as a String, or null if the session is invalid
|
270 |
|
|
*/
|
271 |
|
|
public String getSessionId();
|
272 |
1826
|
jones
|
|
273 |
|
|
/**
|
274 |
2240
|
sgarg
|
* Set the session identifier for this session. This identifier was
|
275 |
|
|
* previously established with a call to login. To continue to use the
|
276 |
1826
|
jones
|
* same session, set the session id before making a call to one of the
|
277 |
|
|
* metacat access methods (e.g., read, query, insert, etc.).
|
278 |
|
|
*
|
279 |
|
|
* @param String the sessionId from a previously established session
|
280 |
|
|
*/
|
281 |
|
|
public void setSessionId(String sessionId);
|
282 |
2683
|
sgarg
|
|
283 |
2336
|
tao
|
/**
|
284 |
2683
|
sgarg
|
* Get the logged in user for this session.
|
285 |
|
|
*
|
286 |
|
|
* @returns the response received from the server for action=getloggeduserinfo
|
287 |
|
|
*/
|
288 |
|
|
public String getloggedinuserinfo() throws MetacatInaccessibleException;
|
289 |
|
|
|
290 |
|
|
/**
|
291 |
2981
|
jones
|
* The method will return the latest revision in metacat server
|
292 |
|
|
* for a given document id. If some error happens, this method will throw
|
293 |
|
|
* an exception.
|
294 |
2336
|
tao
|
* @param docId String the given docid you want to use. the docid it self
|
295 |
|
|
* can have or haven't revision number
|
296 |
|
|
* @throws MetacatException
|
297 |
|
|
*/
|
298 |
|
|
public int getNewestDocRevision(String docId) throws MetacatException;
|
299 |
2981
|
jones
|
|
300 |
|
|
/**
|
301 |
|
|
* Return the highest document id for a given scope. This is used by
|
302 |
|
|
* clients to make it easier to determine the next free identifier in a
|
303 |
|
|
* sequence for a given scope.
|
304 |
|
|
* @param scope String the scope to use for looking up the latest id
|
305 |
|
|
* @throws MetacatException when an error occurs
|
306 |
|
|
*/
|
307 |
|
|
public String getLastDocid(String scope) throws MetacatException;
|
308 |
3141
|
berkley
|
|
309 |
|
|
/**
|
310 |
|
|
* return a list of all docids that match a given scope. if scope is null
|
311 |
|
|
* return all docids registered in the system
|
312 |
|
|
* @param scope String the scope to use to limit the docid query
|
313 |
|
|
* @throws MetacatException when an error occurs
|
314 |
|
|
*/
|
315 |
|
|
public Vector getAllDocids(String scope) throws MetacatException;
|
316 |
3143
|
berkley
|
|
317 |
|
|
/**
|
318 |
|
|
* return true of the given docid is registered, false if not
|
319 |
|
|
* @param scope String the scope to use to limit the docid query
|
320 |
|
|
* @throws MetacatException when an error occurs
|
321 |
|
|
*/
|
322 |
|
|
public boolean isRegistered(String docid) throws MetacatException;
|
323 |
5914
|
leinfelder
|
|
324 |
|
|
/**
|
325 |
|
|
* Returns the character encoding used used when communicating with Metacat.
|
326 |
|
|
* @return character encoding name
|
327 |
|
|
*/
|
328 |
|
|
public String getEncoding();
|
329 |
|
|
|
330 |
|
|
/**
|
331 |
|
|
* Returns the character encoding used used when communicating with Metacat.
|
332 |
|
|
* @param encoding The encoding (i.e. "UTF-8")
|
333 |
|
|
*/
|
334 |
|
|
public void setEncoding(String encoding);
|
335 |
|
|
|
336 |
1780
|
jones
|
}
|