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 |
1780
|
jones
|
|
32 |
|
|
/**
|
33 |
2240
|
sgarg
|
* This interface provides methods for initializing and logging in to a
|
34 |
|
|
* Metacat server, and then querying, reading, transforming, inserting,
|
35 |
1780
|
jones
|
* updating and deleting documents from that server.
|
36 |
|
|
*/
|
37 |
|
|
public interface Metacat
|
38 |
|
|
{
|
39 |
|
|
/**
|
40 |
|
|
* Method used to log in to a metacat server. Implementations will need
|
41 |
|
|
* to cache a cookie value to make the session persistent. Each time a
|
42 |
|
|
* call is made to one of the other methods (e.g., read), the cookie will
|
43 |
|
|
* need to be passed back to the metacat server along with the request.
|
44 |
|
|
*
|
45 |
|
|
* @param username the username of the user, like an LDAP DN
|
46 |
|
|
* @param password the password for that user for authentication
|
47 |
1822
|
jones
|
* @return the response string from metacat in XML format
|
48 |
1780
|
jones
|
* @throws MetacatAuthException when the username/password could
|
49 |
|
|
* not be authenticated
|
50 |
|
|
*/
|
51 |
2240
|
sgarg
|
public String login(String username, String password)
|
52 |
1780
|
jones
|
throws MetacatAuthException, MetacatInaccessibleException;
|
53 |
2240
|
sgarg
|
|
54 |
1797
|
tao
|
/**
|
55 |
1822
|
jones
|
* Method used to log out a metacat server. The Metacat server will end
|
56 |
|
|
* the session when this call is invoked.
|
57 |
1797
|
tao
|
*
|
58 |
1822
|
jones
|
* @return the response string from metacat in XML format
|
59 |
1797
|
tao
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
60 |
|
|
* reached or does not respond
|
61 |
|
|
*/
|
62 |
2240
|
sgarg
|
public String logout() throws MetacatInaccessibleException,
|
63 |
1822
|
jones
|
MetacatException;
|
64 |
1780
|
jones
|
|
65 |
|
|
/**
|
66 |
|
|
* Read an XML document from the metacat server session, accessed by docid,
|
67 |
|
|
* and returned as a Reader.
|
68 |
|
|
*
|
69 |
|
|
* @param docid the identifier of the document to be read
|
70 |
|
|
* @return a Reader for accessing the document
|
71 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
72 |
1780
|
jones
|
* for the operation
|
73 |
1784
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
74 |
|
|
* reached or does not respond
|
75 |
|
|
* @throws MetacatException when the metacat server generates another error
|
76 |
1780
|
jones
|
*/
|
77 |
1784
|
jones
|
public Reader read(String docid) throws InsufficientKarmaException,
|
78 |
|
|
MetacatInaccessibleException, MetacatException;
|
79 |
1780
|
jones
|
|
80 |
|
|
/**
|
81 |
2261
|
sgarg
|
* Read inline data from the metacat server session, accessed by
|
82 |
|
|
* inlinedataid, and returned as a Reader.
|
83 |
|
|
*
|
84 |
|
|
* @param inlinedataid the identifier of the document to be read
|
85 |
|
|
* @return a Reader for accessing the document
|
86 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
87 |
|
|
* for the operation
|
88 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
89 |
|
|
* reached or does not respond
|
90 |
|
|
* @throws MetacatException when the metacat server generates another error
|
91 |
|
|
*/
|
92 |
|
|
public Reader readInlineData(String inlinedataid)
|
93 |
|
|
throws InsufficientKarmaException,
|
94 |
|
|
MetacatInaccessibleException, MetacatException;
|
95 |
|
|
|
96 |
|
|
/**
|
97 |
2240
|
sgarg
|
* Query the metacat document store with the given metacat-compatible
|
98 |
1780
|
jones
|
* query document, and return the result set as a Reader.
|
99 |
|
|
*
|
100 |
|
|
* @param xmlQuery a Reader for accessing the XML version of the query
|
101 |
|
|
* @return a Reader for accessing the result set
|
102 |
|
|
*/
|
103 |
1785
|
tao
|
public Reader query(Reader xmlQuery) throws MetacatInaccessibleException,
|
104 |
|
|
IOException;
|
105 |
1780
|
jones
|
|
106 |
|
|
/**
|
107 |
|
|
* Insert an XML document into the repository.
|
108 |
|
|
*
|
109 |
|
|
* @param docid the docid to insert the document
|
110 |
|
|
* @param xmlDocument a Reader for accessing the XML document to be inserted
|
111 |
2240
|
sgarg
|
* @param schema a Reader for accessing the DTD or XML Schema for
|
112 |
1780
|
jones
|
* the document
|
113 |
1789
|
jones
|
* @return the metacat response message
|
114 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
115 |
1780
|
jones
|
* for the operation
|
116 |
1789
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
117 |
|
|
* reached or does not respond
|
118 |
|
|
* @throws MetacatException when the metacat server generates another error
|
119 |
|
|
* @throws IOException when there is an error reading the xml document
|
120 |
1780
|
jones
|
*/
|
121 |
1789
|
jones
|
public String insert(String docid, Reader xmlDocument, Reader schema)
|
122 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
123 |
|
|
MetacatInaccessibleException;
|
124 |
1780
|
jones
|
|
125 |
|
|
/**
|
126 |
|
|
* Update an XML document in the repository.
|
127 |
|
|
*
|
128 |
|
|
* @param docid the docid to update
|
129 |
|
|
* @param xmlDocument a Reader for accessing the XML text to be updated
|
130 |
2240
|
sgarg
|
* @param schema a Reader for accessing the DTD or XML Schema for
|
131 |
1780
|
jones
|
* the document
|
132 |
1795
|
jones
|
* @return the metacat response message
|
133 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
134 |
1780
|
jones
|
* for the operation
|
135 |
1795
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
136 |
|
|
* reached or does not respond
|
137 |
|
|
* @throws MetacatException when the metacat server generates another error
|
138 |
|
|
* @throws IOException when there is an error reading the xml document
|
139 |
1780
|
jones
|
*/
|
140 |
1795
|
jones
|
public String update(String docid, Reader xmlDocument, Reader schema)
|
141 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
142 |
|
|
MetacatInaccessibleException;
|
143 |
1780
|
jones
|
|
144 |
|
|
/**
|
145 |
2240
|
sgarg
|
* Upload an XML document into the repository.
|
146 |
|
|
*
|
147 |
|
|
* @param docid the docid to insert the document
|
148 |
|
|
* @param xmlDocument a Reader for accessing the document to be inserted
|
149 |
|
|
* @return the metacat response message
|
150 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
151 |
|
|
* for the operation
|
152 |
|
|
* @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 |
|
|
*/
|
157 |
|
|
public String upload(String docid, File file)
|
158 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
159 |
|
|
MetacatInaccessibleException;
|
160 |
|
|
|
161 |
|
|
/**
|
162 |
2264
|
sgarg
|
* Upload an XML document into the repository.
|
163 |
|
|
*
|
164 |
|
|
* @param docid the docid to insert the document
|
165 |
|
|
* @param fileName the name of the document
|
166 |
|
|
* @param fileData InputStream of the document that has to be inserted
|
167 |
|
|
* @param size size of the data being sent. If more data is
|
168 |
|
|
* found in the InputStream, an error would be reported.
|
169 |
|
|
* @return the metacat response message
|
170 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
171 |
|
|
* for the operation
|
172 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
173 |
|
|
* reached or does not respond
|
174 |
|
|
* @throws MetacatException when the metacat server generates another error
|
175 |
|
|
* @throws IOException when there is an error reading the xml document
|
176 |
|
|
*/
|
177 |
|
|
public String upload(String docid, String fileName,
|
178 |
|
|
InputStream fileData, int size)
|
179 |
|
|
throws InsufficientKarmaException, MetacatException, IOException,
|
180 |
|
|
MetacatInaccessibleException;
|
181 |
|
|
|
182 |
|
|
/**
|
183 |
1780
|
jones
|
* Delete an XML document in the repository.
|
184 |
|
|
*
|
185 |
|
|
* @param docid the docid to delete
|
186 |
1795
|
jones
|
* @return the metacat response message
|
187 |
2240
|
sgarg
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
188 |
1780
|
jones
|
* for the operation
|
189 |
1795
|
jones
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
190 |
|
|
* reached or does not respond
|
191 |
|
|
* @throws MetacatException when the metacat server generates another error
|
192 |
1780
|
jones
|
*/
|
193 |
1795
|
jones
|
public String delete(String docid)
|
194 |
|
|
throws InsufficientKarmaException, MetacatException,
|
195 |
|
|
MetacatInaccessibleException;
|
196 |
1780
|
jones
|
|
197 |
|
|
/**
|
198 |
2326
|
harris
|
* set the access on an XML document in the repository.
|
199 |
|
|
*
|
200 |
2327
|
harris
|
* @param _docid the docid of the document for which the access should be applied.
|
201 |
2326
|
harris
|
*
|
202 |
|
|
* @param _principal the document's principal
|
203 |
|
|
*
|
204 |
|
|
* @param _permission the access permission to be applied to the docid
|
205 |
|
|
* {e.g. read,write,all}
|
206 |
|
|
*
|
207 |
|
|
* @param _permType the permission type to be applied to the document
|
208 |
|
|
* {e.g. allow or deny}
|
209 |
|
|
*
|
210 |
|
|
* @param _permOrder the order that the document's permissions should be
|
211 |
|
|
* processed {e.g. denyFirst or allowFirst}
|
212 |
|
|
*
|
213 |
|
|
*
|
214 |
|
|
* @return the metacat response message
|
215 |
|
|
*
|
216 |
|
|
* @throws InsufficientKarmaException when the user has insufficent rights
|
217 |
|
|
* for the operation
|
218 |
|
|
* @throws MetacatInaccessibleException when the metacat server can not be
|
219 |
|
|
* reached or does not respond
|
220 |
|
|
* @throws MetacatException when the metacat server generates another error
|
221 |
|
|
*/
|
222 |
|
|
public String setAccess(String _docid, String _principal, String
|
223 |
|
|
_permission, String _permType, String _permOrder )
|
224 |
|
|
throws InsufficientKarmaException, MetacatException,
|
225 |
|
|
MetacatInaccessibleException;
|
226 |
|
|
|
227 |
|
|
/**
|
228 |
1780
|
jones
|
* When the MetacatFactory creates an instance it needs to set the
|
229 |
|
|
* MetacatUrl to which connections should be made.
|
230 |
|
|
*
|
231 |
|
|
* @param metacatUrl the URL for the metacat server
|
232 |
|
|
*/
|
233 |
|
|
public void setMetacatUrl(String metacatUrl);
|
234 |
1822
|
jones
|
|
235 |
|
|
/**
|
236 |
|
|
* Get the session identifier for this session.
|
237 |
|
|
*
|
238 |
|
|
* @returns the sessionId as a String, or null if the session is invalid
|
239 |
|
|
*/
|
240 |
|
|
public String getSessionId();
|
241 |
1826
|
jones
|
|
242 |
|
|
/**
|
243 |
2240
|
sgarg
|
* Set the session identifier for this session. This identifier was
|
244 |
|
|
* previously established with a call to login. To continue to use the
|
245 |
1826
|
jones
|
* same session, set the session id before making a call to one of the
|
246 |
|
|
* metacat access methods (e.g., read, query, insert, etc.).
|
247 |
|
|
*
|
248 |
|
|
* @param String the sessionId from a previously established session
|
249 |
|
|
*/
|
250 |
|
|
public void setSessionId(String sessionId);
|
251 |
2336
|
tao
|
|
252 |
|
|
/**
|
253 |
|
|
* The method will return the lasted revision in metacat server
|
254 |
|
|
* for a given document id. If some error happent, this method will throw
|
255 |
|
|
* a exception.
|
256 |
|
|
* @param docId String the given docid you want to use. the docid it self
|
257 |
|
|
* can have or haven't revision number
|
258 |
|
|
* @throws MetacatException
|
259 |
|
|
*/
|
260 |
|
|
public int getNewestDocRevision(String docId) throws MetacatException;
|
261 |
1780
|
jones
|
}
|