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: tao $'
7
 *     '$Date: 2003-08-11 18:29:03 -0700 (Mon, 11 Aug 2003) $'
8
 * '$Revision: 1785 $'
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
     * @throws InsufficientKarmaException when the user has insufficent rights 
84
     *                                    for the operation
85
     */
86
    public void insert(String docid, Reader xmlDocument, Reader schema)
87
        throws InsufficientKarmaException;
88

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

    
102
    /**
103
     * Delete an XML document in the repository.
104
     *
105
     * @param docid the docid to delete
106
     * @throws InsufficientKarmaException when the user has insufficent rights 
107
     *                                    for the operation
108
     */
109
    public void delete(String docid)
110
        throws InsufficientKarmaException;
111

    
112
    /**
113
     * When the MetacatFactory creates an instance it needs to set the
114
     * MetacatUrl to which connections should be made.
115
     *
116
     * @param metacatUrl the URL for the metacat server
117
     */
118
    public void setMetacatUrl(String metacatUrl);
119
}
(2-2/7)