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-11 15:24:46 -0700 (Mon, 11 Aug 2003) $'
8
 * '$Revision: 1784 $'
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

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

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

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

    
74
    /**
75
     * Insert an XML document into the repository.
76
     *
77
     * @param docid the docid to insert the document
78
     * @param xmlDocument a Reader for accessing the XML document to be inserted
79
     * @param schema a Reader for accessing the DTD or XML Schema for 
80
     *               the document
81
     * @throws InsufficientKarmaException when the user has insufficent rights 
82
     *                                    for the operation
83
     */
84
    public void insert(String docid, Reader xmlDocument, Reader schema)
85
        throws InsufficientKarmaException;
86

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

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

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