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-08 16:16:24 -0700 (Fri, 08 Aug 2003) $'
8
 * '$Revision: 1780 $'
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
     */
59
    public Reader read(String docid) throws InsufficientKarmaException;
60

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

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

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

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

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