source: other-projects/gs3-webservices-java-client/trunk/src/GS3DemoClient/org/greenstone/gs3client/dlservices/GS3ServicesAPIA.java@ 26174

Last change on this file since 26174 was 22298, checked in by ak19, 14 years ago

Changes to get Fedora to work with Greenstone3: to let the Greenstone3 Reader Interface work with a Fedora Repository behind the scenes.

File size: 27.3 KB
Line 
1/**
2 *#########################################################################
3 * GS3ServicesAPIA.java - part of the demo-client for Greenstone 3, of the
4 * Greenstone digital library suite from the New Zealand Digital Library
5 * Project at the * University of Waikato, New Zealand.
6 * <BR><BR>
7 * Copyright (C) 2008 New Zealand Digital Library Project
8 * <BR><BR>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 * <BR><BR>
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *########################################################################
19 */
20
21package org.greenstone.gs3client.dlservices;
22
23import javax.swing.JOptionPane;
24
25import java.util.HashMap;
26import java.util.Map;
27
28import java.io.IOException;
29import java.net.MalformedURLException;
30import javax.xml.parsers.ParserConfigurationException;
31import javax.xml.rpc.ServiceException;
32import org.xml.sax.SAXException;
33
34import org.greenstone.gs3client.data.DocumentNodeData;
35
36import org.apache.log4j.Logger; //Import log4j classes
37import java.util.Properties;
38
39/**
40 * GS3ServicesAPIA does two things:
41 * - it implements DigitalLibraryServicesAPIA for enabling the Java-client
42 * to access Greenstone's repository of collections and documents. It
43 * makes this possible through use of Greenstone 3's web services.
44 * - it inherits from GS3WebServicesQBRAPI, which means it inherits all the
45 * methods that deal with invoking the Greenstone 3 web services
46 * functionality (through use of Apache Axis' Service and Call objects).
47 * It therefore provides an equivalent method to each Greenstone 3 web
48 * service operation, even if some of these web service operations are
49 * never called by the Java-client and therefore not prescribed by the
50 * DigitalLibraryServicesAPIA interface.
51 * @author ak19
52*/
53public class GS3ServicesAPIA extends GS3WebServicesQBRAPI
54 implements DigitalLibraryServicesAPIA
55{
56 /** The Logger for this class */
57 static Logger LOG = Logger.getLogger(GS3ServicesAPIA.class);
58
59 /** Storing language settings for requests and responses*/
60 protected String language;
61
62 /** Displays a dialog to get user input for the location of the Greenstone 3
63 * web services' WSDL file */
64 public GS3ServicesAPIA()
65 throws ServiceException, MalformedURLException,
66 ParserConfigurationException, IOException, Exception
67 {
68 this(showWsdlInputDialog());
69 }
70
71 /** GS3ServicesAPIA constructor, which, given the url to the wsdl file,
72 * finds either service and port or the service's endpoint of the GS3 Web
73 * Services and instantiates the associated Service and Call objects.
74 * @param wsdlURLName - location of the WSDL for Greenstone 3's
75 * web services */
76 public GS3ServicesAPIA(String wsdlURLName)
77 throws ServiceException, MalformedURLException,
78 ParserConfigurationException, IOException, SAXException
79 {
80 super(wsdlURLName);
81 // Very important to initialise member language to some value, in
82 // this case, it is set to "" (which Greenstone takes as English).
83 this.language = "";
84 }
85
86 /** Static method that displays a dialog requesting the user to
87 * input the location of Greenstone 3 web services' WSDL file.
88 * @return a String representing the URL location of Greenstone 3 web
89 * services' WSDL file */
90 public static String showWsdlInputDialog()
91 throws Exception
92 {
93 String wsdlURL = "";
94 Properties properties = new Properties();
95
96 // set default values from any properties file
97 try {
98 if(DigitalLibraryServicesAPIA.propertiesFile.exists()) {
99 properties.load(new java.io.FileInputStream(
100 DigitalLibraryServicesAPIA.propertiesFile));
101 }
102 } catch(Exception e) {
103 LOG.warn("Exception loading properties from file "
104 + DigitalLibraryServicesAPIA.propertiesFile
105 + ": " + e);
106 }
107
108 // Show the dialog and get input for the wsdlURL property
109 // It will display GS3WebServicesQBRAPI.defaultWsdlURL in the input
110 // field if it can not find a wsdlURL property in the propertiesFile
111 wsdlURL = JOptionPane.showInputDialog(
112 "Enter the URL of the wsdl file of GS3's QBRSOAPServer web services",
113 properties.getProperty("wsdlURL", GS3WebServicesQBRAPI.defaultWsdlURL)
114 );
115 if(wsdlURL == null) { // cancel pressed
116 throw new CancelException(
117 "User cancelled out of connecting to GS3 Web Services");
118 } else { // if ok clicked, update properties with the input value
119 properties.setProperty("wsdlURL", wsdlURL);
120 }
121
122 // Store the user-entered URL for future use, so it is loaded next time
123 try {
124 java.io.FileOutputStream out = new java.io.FileOutputStream(
125 DigitalLibraryServicesAPIA.propertiesFile);
126 properties.store(out, "GS3ServicesAPIA");
127 out.close();
128 } catch(Exception e) {
129 LOG.warn("Exception writing properties to file "
130 + DigitalLibraryServicesAPIA.propertiesFile
131 + ": " + e);
132 }
133 return wsdlURL;
134 }
135
136 //************DigitalLibraryServicesAPIA METHOD IMPLEMENTATIONS************//
137 /** @return the name of this digital library for displaying in the client */
138 public String getDisplayName() {
139 return "Greenstone3";
140 }
141
142 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
143 * contract.
144 * Sets the preferred language (code) for metadata and other content to be
145 * returned on request messages. If the preferred language is not available,
146 * the implementation may choose to send English back instead, or failing
147 * that, send the data in any other available language.
148 * @param language has to be a language code as recognised by Greenstone3
149 * (the language codes used by W3C probably). E.g. "en" for English. */
150 public void setLanguage(String language) { this.language = language; }
151
152 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
153 * contract.
154 * Gets the language that's set as the preferred language.
155 * @return the language code as recognised by Greenstone3 (which are the
156 * language codes used by W3C probably). E.g. "en" for English. */
157 public String getLanguage() { return language; }
158
159 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
160 * contract.
161 * @return the overall directory path for associated files (not including
162 * the document's nodeID/pid). This can be used to *formulate* the base url
163 * of JEditorPane's HTML documents. If the documents from any digital library
164 * do not contain relative paths, or otherwise deal with the resolution of
165 * relative urls themselves, then return "" from here. */
166 public String getAssocFileBaseURL() { return ""; }
167
168 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
169 * contract.
170 * @return the directory path to the associated files of the given document
171 * node. For instance, the base url of a JEditorPane's HTML documents can be
172 * set to this. */
173 public String getAssocFileBaseURL(DocumentNodeData docNode) {
174 return "_httpdocimg_/"; // for now.
175 // TODO:
176 /*DocumentNodeData root = docNode.getRoot();
177 if(root != null)
178 return root.getAssocFilePath();
179 else return "";*/
180 }
181
182 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
183 * contract
184 * @return Greenstone3 XML describe response message originating from
185 * the Message Router, describing the Collections, ServiceRacks
186 * and Services supported by the Message Router for all collections. */
187 public String describe() {
188 return this.describe(language, "");
189 }
190
191 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
192 * contract.
193 * @param collection is the name of the collection to be described.
194 * @return Greenstone3 XML describe response message originating from a
195 * collection, describing the collection (display items) as well as
196 * listing any services supported specifically by the collection.
197 */
198 public String describeCollection(String collection) {
199 return this.describeCollection(collection, language, "");
200 }
201
202 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
203 * contract.
204 * @param collection is the name of the collection to be described.
205 * @param service is the name of the collection's service to be described.
206 * @return Greenstone3 XML describe response message originating from a
207 * collection's service, describing the service (display items).
208 */
209 public String describeCollectionService(String collection, String service) {
210 return this.describeCollectionService(collection, service, language, "");
211 }
212
213 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
214 * contract.
215 * @param service is the name of the collection's service to be described.
216 * @return Greenstone3 XML describe response message originating from a
217 * general (non-collection specific) service, describing the requested
218 * service (for example with GS3 display items).
219 */
220 public String describeService(String service) {
221 return this.describeService(service, language, "");
222 }
223
224 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
225 * contract.
226 * @param collection is the name of the collection.
227 * @param docIDs is an array of document identifiers of documents whose (text)
228 * contents are requested.
229 * @return a String representing Greenstone3 DocumentContentRetrieve XML
230 * containing the document contents of the documents indicated by docIDs
231 */
232 public String retrieveDocumentContent(String collection, String[] docIDs) {
233 return this.retrieveDocumentContent(collection, language, docIDs);
234 }
235
236 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
237 * contract.
238 * @param collection is the name of the collection.
239 * @param docID is the document identifier of the document whose (text)
240 * content is requested.
241 * @return a String representing Greenstone3 DocumentContentRetrieve XML
242 * containing the document contents of the document indicated by docID
243 */
244 public String retrieveDocumentContent(String collection, String docID) {
245 return this.retrieveDocumentContent(collection, language,
246 new String[]{ docID });
247 }
248
249 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
250 * contract.
251 * @param collection is the name of the collection.
252 * @param docIDs is an array of document identifiers of documents whose
253 * metadata is requested.
254 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
255 * containing all the metadata of all the documents indicated by docIDs
256 * @param metadata is the list of metadata elements to be retrieved for each doc.
257 */
258 public String retrieveDocumentMetadata(String collection, String[] docIDs, String[] metafields) {
259 return this.retrieveDocumentMetadata(collection, language, docIDs, metafields);
260 }
261
262 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
263 * contract.
264 * @param collection is the name of the collection.
265 * @param docID is the document identifier of the document whose metadata is
266 * requested.
267 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
268 * containing all the metadata of the document denoted by docID
269 * @param metadata is the list of metadata elements to be retrieved for each doc.
270 */
271 public String retrieveDocumentMetadata(String collection, String docID, String[] metafields) {
272 return this.retrieveDocumentMetadata(collection, language,
273 new String[] { docID }, metafields);
274 }
275
276 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
277 * contract.
278 * @param collection is the name of the collection.
279 * @param docIDs is an array of document identifiers of documents whose titles
280 * are requested
281 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
282 * containing only the title metadata of the documents denoted by docIDs
283 */
284 public String retrieveTitleMetadata(String collection, String[] docIDs) {
285 final String[] titleMetaName = {"Title"};
286 return this.retrieveDocumentMetadata(collection, language, docIDs,
287 titleMetaName);
288 }
289
290 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
291 * contract.
292 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
293 * containing only the title metadata of the document denoted by docID
294 * @param collection is the name of the collection
295 * @param docID is the document identifier of the document whose titles is
296 * requested */
297 public String retrieveTitleMetadata(String collection, String docID) {
298 final String[] titleMetaName = {"Title"};
299 return this.retrieveDocumentMetadata(collection, language,
300 new String[] { docID }, titleMetaName);
301 }
302
303 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
304 * containing the requested portion of the document structure of the documents
305 * indicated by docIDs:
306 * @param collection is the name of the collection.
307 * @param docIDs is an array of document identifiers of documents whose
308 * hierarchical structures are requested.
309 * @param structure - strings specifying the required structure of each document.
310 * It can be a combination of: ancestors, parent, siblings, children, descendants, entire.
311 * @param info - strings specifying the required structural info of each document.
312 * It can be any combination of: siblingPosition, numSiblings, numChildren.
313 */
314 public String retrieveDocumentStructure(String collection, String[] docIDs, String[] structure, String[] info) {
315 return retrieveDocumentStructure(collection, language, docIDs, structure, info);
316 }
317
318
319 /** @return a String representing Greenstone3 DocumentMetadataRetrieve XML
320 * containing the requested portion of the document structure of the documents
321 * indicated by docIDs:
322 * @param collection is the name of the collection.
323 * @param docID is the document identifier of the document whose hierarchical
324 * structure is requested.
325 * @param structure - strings specifying the required structure of the document.
326 * It can be a combination of: ancestors, parent, siblings, children, descendants, entire.
327 * @param info - strings specifying the required structural info of the document.
328 * It can be any combination of: siblingPosition, numSiblings, numChildren.
329 */
330 public String retrieveDocumentStructure(String collection, String docID, String[] structure, String[] info) {
331 return retrieveDocumentStructure(collection, language,
332 new String[] {docID}, structure, info);
333 }
334
335 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
336 * contract.
337 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
338 * containing the document structure of the documents indicated by docIDs:
339 * this means all their descendants
340 * @param collection is the name of the collection
341 * @param docIDs is an array of document identifiers of documents whose
342 * hierarchical structures are requested */
343 public String retrieveDocumentStructure(String collection, String[] docIDs) {
344 return this.retrieveEntireDocumentStructure(collection, language, docIDs);
345 }
346
347 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
348 * contract.
349 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
350 * containing the document structure of the document indicated by docID:
351 * this means all its descendants
352 * @param collection is the name of the collection
353 * @param docID is the document identifier of the document whose hierarchical
354 * structure is requested*/
355 public String retrieveDocumentStructure(String collection, String docID) {
356 return this.retrieveEntireDocumentStructure(collection, language,
357 new String[] { docID });
358 }
359
360
361 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
362 * contract.
363 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
364 * containing a view of the document structure of the documents denoted by
365 * docs where only the requested documents and their direct children are
366 * returned.
367 * @param collection is the name of the collection
368 * @param docIDs is an array of document identifiers of documents whose
369 * hierarchical structures are requested */
370 public String retrieveDocumentChildren(String collection, String[] docIDs) {
371 return this.retrieveDocumentStructure(collection, collection, docIDs,
372 new String[] { "children" }, null);
373 }
374
375 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
376 * contract.
377 * @return a String representing Greenstone3 DocumentMetadataRetrieve XML
378 * containing a view of the document structure of the document denoted by
379 * docID where only the document and its direct children are returned.
380 * @param collection is the name of the collection
381 * @param docID is the document identifier of the document whose hierarchical
382 * structure is requested */
383 public String retrieveDocumentChildren(String collection, String docID) {
384 return this.retrieveDocumentStructure(collection, collection,
385 new String[] { docID }, new String[] { "children" }, null);
386 }
387
388 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
389 * contract.
390 * @return a String representing Greenstone3 ClassifierBrowse XML
391 * giving the entire *structure* of the classification denoted by
392 * classifierID (including the structures of document descendants of
393 * the classifier).
394 * @param classifierIDs - each ID is of the form CL# where the number (#)
395 * marks out structured sections like CL1.1.3 or CL2
396 * @param collection is the name of the collection
397 * @param service is the name of the browse service (=ClassifierBrowse usually)
398 * @param structure - the requested browse substructure. Can be any combination
399 * of ancestors, parent, siblings, children, descendants.
400 * @param info - the requested structural info. Can be numSiblings, siblingPosition,
401 * numChildren
402 */
403 public String retrieveBrowseStructure(String collection, String service,
404 String[] classifierIDs, String[] structure, String[] info)
405 {
406 return this.browse(collection, service, language, classifierIDs, structure, info);
407 }
408
409 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
410 * contract.
411 * @return a String representing Greenstone3
412 * ClassifierBrowseMetadataRetrieve XML giving all the metadata for
413 * all the subclassifiers denoted by nodeIDs.
414 * @param nodeIDs is of the form CL#.# where the number (#) marks
415 * out structured sections like CL2.1.3. NodeIDs are generally subsections
416 * of top-level classifierNodes (CL#, e.g. CL3).
417 * @param metafields are the classifier metadata fields that are to be returned.
418 * @param collection is the name of the collection
419 * @param service is the name of the Browse's MetadataRetrieve service
420 * (usually the browse service is ClassifierBrowse, in which case it always
421 * has a retrieve service called ClassifierBrowseMetadataRetrieve) */
422 public String retrieveBrowseMetadata(String collection, String service,
423 String[] nodeIDs, String[] metafields)
424 {
425 return this.retrieveBrowseMetadata(collection, service, language, nodeIDs, metafields);
426 }
427
428 /** Part of the GS3 Java-Client's DigitalLibraryServicesAPIA interface
429 * contract.
430 * @return a String representing Greenstone3 XML for a query process
431 * response returning the results for the query denoted by parameter
432 * nameValParamsMap.
433 * @param nameValParamsMap is a Map of name and value pairs for all the
434 * query field data values. The names match the field names that
435 * describeCollectionService() would have returned for the query service.
436 * @param collection is the name of the collection
437 * @param service is the name of the query service
438 */
439 public String query(String collection, String service, Map nameValParamsMap)
440 {
441 return this.query(collection, service, language, nameValParamsMap);
442 }
443
444 /*public static void main(String args[]) {
445 try{
446 GS3ServicesAPIA ws = new GS3ServicesAPIA();
447
448 // (1) trying 4 describe methods
449 System.out.println(ws.describe("", ""));
450 System.out.println(ws.describeCollectionOrServiceRack("gs2mgppdemo", "", ""));
451 System.out.println(ws.describeCollectionService("gs2mgppdemo", "AdvancedFieldQuery", "", ""));
452 System.out.println(ws.describeService("AddItem", "", ""));
453
454
455 // (2) try 3 query methods (simplerFieldQuery twice) + getFieldNameMappings()
456 Map map = new HashMap();
457 map.put("maxDocs", "100");
458 map.put("level", "Sec");
459 map.put("accent", "1");
460 map.put("matchMode", "some");
461 map.put("fqf", "ZZ,ZZ,ZZ,ZZ");
462 map.put("case", "1");
463 map.put("sortBy", "1");
464 map.put("fqv", "snail,water,,");
465
466 String response = ws.query("gs2mgppdemo", "FieldQuery", "", map);
467 System.out.println("Regular query: " + response);
468
469 System.out.println("Field mappings: " + ws.getFieldNameMappings());
470 response = ws.simplerFieldNameQuery(
471 "gs2mgppdemo", "FieldQuery", "", map);
472 System.out.println("response:\n" + response);
473
474 // trying the same with special field names
475 map.clear();
476
477 map.put("maxDocs", "100");
478 map.put("level", "Sec");
479 map.put("accent", "on");
480 map.put("matchMode", "some");
481 map.put("fields", "all fields,all fields,all fields,all fields");
482 map.put("case", "on");
483 map.put("sortBy", "on");
484 map.put("values", "snail,water,,");
485
486 response = ws.simplerFieldNameQuery(
487 "gs2mgppdemo", "FieldQuery", "", map);
488 System.out.println("response:\n" + response);
489
490 // trying query - array version
491 String[] names = {"maxDocs", "level", "accent", "matchMode", "fqf",
492 "case", "sortBy", "fqv"};
493 String[] values = {"100", "Sec", "1", "some", "ZZ,ZZ,ZZ,ZZ",
494 "1", "1", "snail,water,,"};
495 System.out.println(ws.query("gs2mgppdemo", "FieldQuery", "", names, values));
496
497
498 // (3) try 2 browse
499 System.out.println("describe browse:\n"
500 + ws.describeCollectionService("gs2mgppdemo", "ClassifierBrowse", "", ""));
501
502 System.out.println("browse children of CL1-CL4:\n" +
503 ws.browse("gs2mgppdemo", "ClassifierBrowse", "",
504 new String[]{"CL1", "CL2", "CL3", "CL4"}, new String[]{"children"}));
505
506 System.out.println("browse descendants of CL2.3:\n" +
507 ws.browseDescendants("gs2mgppdemo", "ClassifierBrowse", "",
508 new String[]{"CL2.3"}));
509
510
511 // (4) try 2 DocStructure
512 System.out.println("retrieve ancestors and children structure of HASH016193b2847874f3c956d22e.4:\n" +
513 ws.retrieveDocumentStructure("gs2mgppdemo", "",
514 new String[]{"HASH016193b2847874f3c956d22e.4"},
515 new String[]{"ancestors", "children"}, new String[]{"numSiblings"}));
516
517
518 System.out.println("retrieve entire structure of HASH016193b2847874f3c956d22e.4.1:\n" +
519 ws.retrieveEntireDocumentStructure(
520 "gs2mgppdemo", "", new String[]{"HASH016193b2847874f3c956d22e.4.1"}));
521
522
523 // (5) try the 1 DocumentContent retrieve
524 System.out.println("retrieve content of HASH016193b2847874f3c956d22e.4:\n" +
525 ws.retrieveDocumentContent("gs2mgppdemo", "",
526 new String[]{"HASH016193b2847874f3c956d22e.4", "HASH016193b2847874f3c956d22e.4.1",
527 "HASH016193b2847874f3c956d22e.4.2"}));
528
529
530 // (6) try 2 DocumentMeta
531 System.out.println("retrieve title meta of HASH016193b2847874f3c956d22e.4 children:\n" +
532 ws.retrieveDocumentMetadata("gs2mgppdemo", "",
533 new String[]{"HASH016193b2847874f3c956d22e.4.1", "HASH016193b2847874f3c956d22e.4.2",
534 "HASH016193b2847874f3c956d22e.4.3"}, new String[]{"Title"}));
535
536 System.out.println("retrieve all meta of HASH016193b2847874f3c956d22e.4 children:\n" +
537 ws.retrieveAllDocumentMetadata("gs2mgppdemo", "",
538 new String[]{"HASH016193b2847874f3c956d22e.4",
539 "HASH016193b2847874f3c956d22e.4.1", "HASH016193b2847874f3c956d22e.4.2",
540 "HASH016193b2847874f3c956d22e.4.3"}));
541
542 // (7) try 2 BrowseMeta
543 System.out.println("retrieve all browse meta of CL1, CL2, CL2.1, CL3:\n" +
544 ws.retrieveAllBrowseMetadata("gs2mgppdemo", "", "",
545 new String[]{"CL1", "CL2",
546 "CL2.1", "CL3"}));
547
548 System.out.println("retrieve Title, hastxt browse meta of CL1, CL2, CL2.1, CL3:\n" +
549 ws.retrieveBrowseMetadata("gs2mgppdemo", "", "",
550 new String[]{"CL1", "CL2","CL2.1", "CL3"}, new String[]{"Title", "hastxt"}));
551
552 // (8) try process:
553 String requestXMLMessage = "<message>"
554 + "<request lang='' to='gs2mgppdemo/ClassifierBrowseMetadataRetrieve' type='process' uid=''>"
555 + "<paramList>" + "<param name='metadata' value='Title' />"
556 + "<param name='metadata' value='hastxt' /></paramList>"
557 + "<classifierNodeList><classifierNode nodeID='CL1' /><classifierNode nodeID='CL2' />"
558 + "<classifierNode nodeID='CL2.1' /><classifierNode nodeID='CL3' /></classifierNodeList>"
559 + "</request></message>";
560 System.out.println(ws.process(requestXMLMessage));
561
562
563 // (9) activate, deactivate and the 2 reconfigures
564 System.out.println("activate:\n" + ws.activate("collection", "gs2mgppdemo"));
565 System.out.println("deactivate:\n" + ws.deactivate("site", "site1"));
566 System.out.println("configure MR:\n" + ws.reconfigure());
567 System.out.println("configure:\n" + ws.reconfigure("collectionList"));
568
569 // (10) 1 format
570 System.out.println("format:\n" + ws.format("gs2mgppdemo", "FieldQuery", ""));
571
572 // (11) 2 processType: build/NewCollection, build/ImportCollection
573 System.out.println("describe build/NewCollection:\n"
574 + ws.describeService("build/NewCollection", "", ""));
575
576 Map params = new HashMap(10);
577 params.put("creator", "me@home");
578 params.put("collName", "the demo collection");
579 params.put("collShortName", "demo");
580
581 System.out.println("processType build/NewCollection:\n"
582 + ws.processTypeService("build/NewCollection", "", params));
583
584 params.clear();
585 params.put("collection", "demo");
586 System.out.println("processType build/ImportCollection:\n"
587 + ws.processTypeService("build/ImportCollection", "", params));
588
589 // (12) Test status(), if possible
590 System.out.println("status:\n" + ws.status("build/NewCollection", "", "1"));
591
592
593 // (13) One applet-type service:
594 //Map params = new HashMap(10);
595 params.clear();
596 params.put("pc", "1");
597 params.put("pptext", "health");
598 params.put("pfe", "0");
599 params.put("ple", "10");
600 params.put("pfd", "0");
601 params.put("pld", "10");
602 params.put("pfl", "0");
603 params.put("pll", "10");
604 System.out.println("appletTypeService:\n"
605 + ws.appletTypeService("gs2mgppdemo", "PhindApplet", "query", params));
606 // no PhindApplet service deployed in gs2mgppdemo anymore, so maybe that's
607 // why it doesn't work. The request matches what's in the manual (p.50) though.
608
609
610 // (14) One enrich service:
611 params.clear();
612 params.put("annotationType", "Date,Location");
613 String[] nodeIDs = {"HASHac0a04dd14571c60d7fbfd"};
614 String[] nodeContents = { "FOOD AND AGRICULTURE ORGANIZATION OF THE UNITED NATIONS\n"
615 + "Rome 1986\nP-69\nISBN 92-5-102397-2\nFAO 1986"};
616 System.out.println("enrich:\n"
617 + ws.enrich("GatePOSTag", "en", params, nodeIDs, nodeContents));
618 // no GatePOSTag service deployed in gs2mgppdemo anymore, so maybe that's
619 // why it doesn't work. The request matches what's in the manual (p.50) though.
620
621 // (16) try help
622 System.out.println(ws.help());
623 System.out.println(ws.help("describe"));
624
625 }catch(Exception e) {
626 System.out.println("Problem accessing service\n" + e.getMessage());
627 e.printStackTrace();
628 }
629 }*/
630}
Note: See TracBrowser for help on using the repository browser.