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

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