Project

General

Profile

1
/**
2
 *  '$RCSfile$'
3
 *  Copyright: 2000 Regents of the University of California and the
4
 *              National Center for Ecological Analysis and Synthesis
5
 *
6
 *   '$Author: jones $'
7
 *     '$Date: 2003-08-12 00:24:36 -0700 (Tue, 12 Aug 2003) $'
8
 * '$Revision: 1789 $'
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
import java.io.IOException;
29

    
30
/**
31
 *  This interface provides methods for initializing and logging in to a 
32
 *  Metacat server, and then querying, reading, transforming, inserting, 
33
 *  updating and deleting documents from that server.
34
 */
35
public interface Metacat
36
{
37
    /**
38
     *  Method used to log in to a metacat server. Implementations will need
39
     *  to cache a cookie value to make the session persistent.  Each time a
40
     *  call is made to one of the other methods (e.g., read), the cookie will
41
     *  need to be passed back to the metacat server along with the request.
42
     *
43
     *  @param username   the username of the user, like an LDAP DN
44
     *  @param password   the password for that user for authentication
45
     *  @throws MetacatAuthException when the username/password could
46
     *                    not be authenticated
47
     */
48
    public void login(String username, String password) 
49
           throws MetacatAuthException, MetacatInaccessibleException;
50

    
51
    /**
52
     * Read an XML document from the metacat server session, accessed by docid,
53
     * and returned as a Reader.
54
     *
55
     * @param docid the identifier of the document to be read
56
     * @return a Reader for accessing the document
57
     * @throws InsufficientKarmaException when the user has insufficent rights 
58
     *                                    for the operation
59
     * @throws MetacatInaccessibleException when the metacat server can not be
60
     *                                    reached or does not respond
61
     * @throws MetacatException when the metacat server generates another error
62
     */
63
    public Reader read(String docid) throws InsufficientKarmaException,
64
        MetacatInaccessibleException, MetacatException;
65

    
66
    /**
67
     * Query the metacat document store with the given metacat-compatible 
68
     * query document, and return the result set as a Reader.
69
     *
70
     * @param xmlQuery a Reader for accessing the XML version of the query
71
     * @return a Reader for accessing the result set
72
     */
73
    public Reader query(Reader xmlQuery) throws MetacatInaccessibleException,
74
                                                IOException;
75

    
76
    /**
77
     * Insert an XML document into the repository.
78
     *
79
     * @param docid the docid to insert the document
80
     * @param xmlDocument a Reader for accessing the XML document to be inserted
81
     * @param schema a Reader for accessing the DTD or XML Schema for 
82
     *               the document
83
     * @return the metacat response message
84
     * @throws InsufficientKarmaException when the user has insufficent rights 
85
     *                                    for the operation
86
     * @throws MetacatInaccessibleException when the metacat server can not be
87
     *                                    reached or does not respond
88
     * @throws MetacatException when the metacat server generates another error
89
     * @throws IOException when there is an error reading the xml document
90
     */
91
    public String insert(String docid, Reader xmlDocument, Reader schema)
92
        throws InsufficientKarmaException, MetacatException, IOException,
93
        MetacatInaccessibleException;
94

    
95
    /**
96
     * Update an XML document in the repository.
97
     *
98
     * @param docid the docid to update
99
     * @param xmlDocument a Reader for accessing the XML text to be updated
100
     * @param schema a Reader for accessing the DTD or XML Schema for 
101
     *               the document
102
     * @throws InsufficientKarmaException when the user has insufficent rights 
103
     *                                    for the operation
104
     */
105
    public void update(String docid, Reader xmlDocument, Reader schema)
106
        throws InsufficientKarmaException;
107

    
108
    /**
109
     * Delete an XML document in the repository.
110
     *
111
     * @param docid the docid to delete
112
     * @throws InsufficientKarmaException when the user has insufficent rights 
113
     *                                    for the operation
114
     */
115
    public void delete(String docid)
116
        throws InsufficientKarmaException;
117

    
118
    /**
119
     * When the MetacatFactory creates an instance it needs to set the
120
     * MetacatUrl to which connections should be made.
121
     *
122
     * @param metacatUrl the URL for the metacat server
123
     */
124
    public void setMetacatUrl(String metacatUrl);
125
}
(2-2/7)