1 | <!doctype html public "-//w3c//dtd html 4.0 transitional//en">
|
---|
2 | <html>
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
|
---|
5 | <meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.2.16-22 i686) [Netscape]">
|
---|
6 | <title>: Package org.nzdl.gsdl.service</title>
|
---|
7 | <!--NewPage-->
|
---|
8 | <!-- Generated by javadoc on Thu Mar 08 23:01:13 GMT+13:00 2001 -->
|
---|
9 | </head>
|
---|
10 | <body bgcolor="#FFFFFF">
|
---|
11 | Provides services for java client-side communication
|
---|
12 | to a Greenstone Digital Library via CORBA.
|
---|
13 | <p><b>See:</b>
|
---|
14 | <br> <b><a href="#package_description">Description</a></b>
|
---|
15 | <table BORDER CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
|
---|
16 | <tr BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
---|
17 | <td COLSPAN="2"><b><font size=+2>Interface Summary</font></b></td>
|
---|
18 | </tr>
|
---|
19 |
|
---|
20 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
21 | <td WIDTH="15%"><b><i><a href="NzdlService.html">NzdlService</a></i></b></td>
|
---|
22 |
|
---|
23 | <td>An object that services CORBA client requests to a Greenstone Digital
|
---|
24 | Library.</td>
|
---|
25 | </tr>
|
---|
26 | </table>
|
---|
27 |
|
---|
28 | <table BORDER CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
|
---|
29 | <tr BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
|
---|
30 | <td COLSPAN="2"><b><font size=+2>Class Summary</font></b></td>
|
---|
31 | </tr>
|
---|
32 |
|
---|
33 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
34 | <td WIDTH="15%"><b><a href="NzdlCollectionInfo.html">NzdlCollectionInfo</a></b></td>
|
---|
35 |
|
---|
36 | <td>An object that stores information on a collection.</td>
|
---|
37 | </tr>
|
---|
38 |
|
---|
39 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
40 | <td WIDTH="15%"><b><a href="NzdlQuery.html">NzdlQuery</a></b></td>
|
---|
41 |
|
---|
42 | <td>NzdlQuery is an object that holds the options for a query and is easily
|
---|
43 | configured by the user.</td>
|
---|
44 | </tr>
|
---|
45 |
|
---|
46 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
47 | <td WIDTH="15%"><b><a href="NzdlQueryHit.html">NzdlQueryHit</a></b></td>
|
---|
48 |
|
---|
49 | <td>Holds a single result from a query.</td>
|
---|
50 | </tr>
|
---|
51 |
|
---|
52 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
53 | <td WIDTH="15%"><b><a href="NzdlRequest.html">NzdlRequest</a></b></td>
|
---|
54 |
|
---|
55 | <td>An object that holds CORBA request data ready for by servicing by <tt><a href="NzdlService.html">NzdlService</a></tt>.</td>
|
---|
56 | </tr>
|
---|
57 |
|
---|
58 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
59 | <td WIDTH="15%"><b><a href="NzdlResponse.html">NzdlResponse</a></b></td>
|
---|
60 |
|
---|
61 | <td>An object that holds data from a response after a <tt><a href="NzdlRequest.html">NzdlRequest</a></tt>
|
---|
62 | has been serviced by <tt><a href="NzdlService.html">NzdlService</a></tt>.</td>
|
---|
63 | </tr>
|
---|
64 |
|
---|
65 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
66 | <td WIDTH="15%"><b><a href="NzdlResultSet.html">NzdlResultSet</a></b></td>
|
---|
67 |
|
---|
68 | <td>An object that holds results extracted from a response by <tt><a href="NzdlResponse.html#getResultSet()">NzdlResponse.getResultSet()</a></tt>.</td>
|
---|
69 | </tr>
|
---|
70 |
|
---|
71 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
72 | <td WIDTH="15%"><b><a href="NzdlServiceClient.html">NzdlServiceClient</a></b></td>
|
---|
73 |
|
---|
74 | <td>Used to implement the <tt><a href="NzdlService.html">NzdlService</a></tt>
|
---|
75 | object.</td>
|
---|
76 | </tr>
|
---|
77 |
|
---|
78 | <tr BGCOLOR="#FFFFFF" CLASS="TableRowColor">
|
---|
79 | <td WIDTH="15%"><b><a href="NzdlServiceServer.html">NzdlServiceServer</a></b></td>
|
---|
80 |
|
---|
81 | <td>SimpleServer Based on algorithms in ...</td>
|
---|
82 | </tr>
|
---|
83 | </table>
|
---|
84 |
|
---|
85 | <p><a NAME="package_description"></a><!-- -->
|
---|
86 | <h2>
|
---|
87 | Package org.nzdl.gsdl.service Description</h2>
|
---|
88 | Provides services for java client-side communication to a Greenstone Digital
|
---|
89 | Library via CORBA.
|
---|
90 | <br>
|
---|
91 | <h2>
|
---|
92 | Further Requirements</h2>
|
---|
93 |
|
---|
94 | <ul>
|
---|
95 | <li>
|
---|
96 | Sun Java 2 version 1.3 (or later)</li>
|
---|
97 |
|
---|
98 | <li>
|
---|
99 | Corbaserver, a server-side application for communicating to a Greenstone
|
---|
100 | Digital Library.</li>
|
---|
101 | </ul>
|
---|
102 |
|
---|
103 | <h2>
|
---|
104 | Java Interface Data Flows</h2>
|
---|
105 |
|
---|
106 | <center><img SRC="nzdl-service-package.png" ALT="NZDL Data Flow Diagram" height=280 width=637></center>
|
---|
107 |
|
---|
108 | <p><br>
|
---|
109 | <h2>
|
---|
110 | A Typical Query</h2>
|
---|
111 | From a users perspective, a typical query may work as follows:
|
---|
112 | <ul>
|
---|
113 | <li>
|
---|
114 | Create instances of the necessary NZDL Java-Client objects:</li>
|
---|
115 |
|
---|
116 | <ul>
|
---|
117 | <li>
|
---|
118 | a <b>NzdlQuery</b> object</li>
|
---|
119 |
|
---|
120 | <li>
|
---|
121 | a <b>NzdlRequest </b>object using your <b>NzdlQuery</b> object</li>
|
---|
122 |
|
---|
123 | <li>
|
---|
124 | a <b>NzdlResponse</b> object that will eventually hold response
|
---|
125 | data</li>
|
---|
126 |
|
---|
127 | <li>
|
---|
128 | a <b>NzdlService</b> object to service CORBA interface requests
|
---|
129 | to a Greenstone collection</li>
|
---|
130 | </ul>
|
---|
131 |
|
---|
132 | <li>
|
---|
133 | Use the <b>NzdlService</b> object (with collection name and <b>NzdlRequest
|
---|
134 | </b>object)
|
---|
135 | to query the CORBA interface and place the reply into the <b>NzdlResponse</b>
|
---|
136 | object.</li>
|
---|
137 |
|
---|
138 | <li>
|
---|
139 | Create an instance of the <b>NzdlResultSet</b> object. Use <b>NzdlResponse.getResultSet()
|
---|
140 | </b>to
|
---|
141 | extract response data into the <b>NzdlResultSet</b> object.</li>
|
---|
142 |
|
---|
143 | <li>
|
---|
144 | Use the <b>NzdlResultSet</b> methods to view data such as document IDs</li>
|
---|
145 |
|
---|
146 | <br>Get documents using <b>NzdlService.getDocument()</b></ul>
|
---|
147 | <b></b>
|
---|
148 | <h1>
|
---|
149 | Sample Code</h1>
|
---|
150 | <tt>/**</tt>
|
---|
151 | <br><tt>* TrivialDemo.java.</tt>
|
---|
152 | <br><tt>* A very simple application that:</tt>
|
---|
153 | <br><tt>* - reads an Interoperable Object Reference (IOR) from a file;</tt>
|
---|
154 | <br><tt>* - lists all available collections;</tt>
|
---|
155 | <br><tt>* - searches "demo" collection for "snail farming";</tt>
|
---|
156 | <br><tt>* - prints the number of hits;</tt>
|
---|
157 | <br><tt>* - lists first 10 titles found;</tt>
|
---|
158 | <br><tt>* - displays the unformatted text of first document found.</tt>
|
---|
159 | <br><tt>*/</tt>
|
---|
160 | <br><tt>import java.io.*;</tt>
|
---|
161 | <br><tt>import java.util.*;</tt>
|
---|
162 | <br><tt>import java.lang.*;</tt>
|
---|
163 | <br><tt>import org.nzdl.gsdl.service.*; //the java-client stuff</tt>
|
---|
164 | <p><tt>public class TrivialDemo {</tt>
|
---|
165 | <br><tt> public static void main( String [] args )</tt>
|
---|
166 | <br><tt> {</tt>
|
---|
167 | <br><tt> String myIorFile = "/tmp/localcorba.objid";</tt>
|
---|
168 | <br><tt> String myQueryString = "snail farming";</tt>
|
---|
169 | <br><tt> String myCollection = "demo";</tt>
|
---|
170 | <p><tt> // Use NzdlService to create corba connection</tt>
|
---|
171 | <br><tt> NzdlService myService = new NzdlServiceClient</tt>
|
---|
172 | <br><tt>
|
---|
173 | ( null, null, getIor(myIorFile) );</tt>
|
---|
174 | <p><tt> // Use getCollectionSet to obtain List of Collections</tt>
|
---|
175 | <br><tt> Set myCollections = myService.getCollectionSet();</tt>
|
---|
176 | <p><tt> //Display List of Collections</tt>
|
---|
177 | <br><tt> System.out.println("\nThe available collections:");</tt>
|
---|
178 | <p><tt> for (Iterator i = myCollections.iterator(); i.hasNext();
|
---|
179 | )</tt>
|
---|
180 | <br><tt> {</tt>
|
---|
181 | <br><tt> String collName = (String)
|
---|
182 | i.next();</tt>
|
---|
183 | <br><tt> System.out.println("
|
---|
184 | "+ collName);</tt>
|
---|
185 | <br><tt> }</tt>
|
---|
186 | <p><tt> // Find The Number of documents in my collection</tt>
|
---|
187 | <br><tt> NzdlCollectionInfo myInfo = myService.getCollectionInfo(myCollection);</tt>
|
---|
188 | <br><tt> System.out.println("\nNum Of Collection docs
|
---|
189 | = "+myInfo.getNumOfDocs());</tt>
|
---|
190 | <br><tt> </tt>
|
---|
191 | <br><tt> // Create query object</tt>
|
---|
192 | <br><tt> NzdlQuery query = new NzdlQuery( myQueryString
|
---|
193 | );</tt><tt></tt>
|
---|
194 | <p><tt> // Create request object</tt>
|
---|
195 | <br><tt> NzdlRequest request = new NzdlRequest( query
|
---|
196 | );</tt><tt></tt>
|
---|
197 | <p><tt> // create response object</tt>
|
---|
198 | <br><tt> NzdlResponse response = new NzdlResponse( );</tt>
|
---|
199 | <br>
|
---|
200 | <br><tt> // use service to get response from request
|
---|
201 | to myCollection</tt>
|
---|
202 | <br><tt> myService.service( myCollection, request, response
|
---|
203 | );</tt>
|
---|
204 | <p><tt> // use getResultSet to get results from response</tt>
|
---|
205 | <br><tt> NzdlResultSet results = response.getResultSet();</tt><tt></tt>
|
---|
206 | <p><tt> // getNumOfDocs</tt>
|
---|
207 | <br><tt> System.out.println("\nNumber of hits = "+results.getNumOfDocs());</tt><tt></tt>
|
---|
208 | <p><tt> // Use getDocumentIDs to build list of titles
|
---|
209 | (defaults: 1 - 10)</tt>
|
---|
210 | <br><tt> List docIDs = results.getDocumentIDs();</tt>
|
---|
211 | <br><tt> System.out.println("\nThe titles:");</tt>
|
---|
212 | <br><tt> for (ListIterator i = docIDs.listIterator();
|
---|
213 | i.hasNext(); )</tt>
|
---|
214 | <br><tt> {</tt>
|
---|
215 | <br><tt> Set metaData</tt>
|
---|
216 | <br><tt> = myService.getMetaData(
|
---|
217 | myCollection,(String)i.next(),"Title");</tt>
|
---|
218 | <br><tt> Iterator j = metaData.iterator();</tt>
|
---|
219 | <br><tt> System.out.println(j.next());
|
---|
220 | //print title metadata</tt>
|
---|
221 | <br><tt> }</tt>
|
---|
222 | <br><tt> System.out.println("\nThe first document returned
|
---|
223 | was:");</tt>
|
---|
224 | <p><tt> // Print first document returned</tt>
|
---|
225 | <br><tt> String myDoc</tt>
|
---|
226 | <br><tt> = myService.getDocument(myCollection,(String)docIDs.get(0));</tt>
|
---|
227 | <br><tt> System.out.println(myDoc);</tt>
|
---|
228 | <p><tt> } // end of main</tt>
|
---|
229 | <br>
|
---|
230 | <p><tt> // Read the IOR from a file</tt>
|
---|
231 | <br><tt> static private String getIor(String sourceOfID)
|
---|
232 | {</tt>
|
---|
233 | <br><tt> String ior = null;</tt>
|
---|
234 | <br><tt> try</tt>
|
---|
235 | <br><tt> {</tt>
|
---|
236 | <br><tt> BufferedReader input</tt>
|
---|
237 | <br><tt>
|
---|
238 | = new BufferedReader(new FileReader(sourceOfID));</tt>
|
---|
239 | <br><tt> ior = input.readLine();</tt>
|
---|
240 | <br><tt> }</tt>
|
---|
241 | <br><tt> catch (java.io.IOException e)</tt>
|
---|
242 | <br><tt> {</tt>
|
---|
243 | <br><tt> System.err.println("Error
|
---|
244 | reading IOR key:\n" + e);</tt>
|
---|
245 | <br><tt> System.exit(1);</tt>
|
---|
246 | <br><tt> }</tt>
|
---|
247 | <br><tt> return ior;</tt>
|
---|
248 | <br><tt> } //end of getIors</tt><tt></tt>
|
---|
249 | <p><tt>} // end of demo class</tt>
|
---|
250 | <br>
|
---|
251 | </body>
|
---|
252 | </html>
|
---|