[3649] | 1 | /*
|
---|
| 2 | * GS2MGRetrieve.java
|
---|
| 3 | * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org
|
---|
| 4 | *
|
---|
| 5 | * This program is free software; you can redistribute it and/or modify
|
---|
| 6 | * it under the terms of the GNU General Public License as published by
|
---|
| 7 | * the Free Software Foundation; either version 2 of the License, or
|
---|
| 8 | * (at your option) any later version.
|
---|
| 9 | *
|
---|
| 10 | * This program is distributed in the hope that it will be useful,
|
---|
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 13 | * GNU General Public License for more details.
|
---|
| 14 | *
|
---|
| 15 | * You should have received a copy of the GNU General Public License
|
---|
| 16 | * along with this program; if not, write to the Free Software
|
---|
| 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
---|
| 18 | */
|
---|
| 19 | package org.greenstone.gsdl3.service;
|
---|
| 20 |
|
---|
| 21 | import org.greenstone.gsdl3.util.*;
|
---|
| 22 |
|
---|
| 23 | import org.w3c.dom.Document;
|
---|
| 24 | import org.w3c.dom.Node;
|
---|
| 25 | import org.w3c.dom.Text;
|
---|
| 26 | import org.w3c.dom.Element;
|
---|
| 27 | import org.w3c.dom.NodeList;
|
---|
| 28 | /**
|
---|
| 29 | *
|
---|
| 30 | * @author <a href="mailto:[email protected]">Katherine Don</a>
|
---|
| 31 | * @version $Revision: 3649 $
|
---|
| 32 | */
|
---|
| 33 |
|
---|
| 34 | public class GS2MGRetrieve
|
---|
| 35 | extends ServiceRack {
|
---|
| 36 |
|
---|
| 37 | // the services on offer
|
---|
| 38 | private static final String DOCUMENT_RETRIEVE_SERVICE = "DocumentRetrieve";
|
---|
| 39 | private static final String METADATA_RETRIEVE_SERVICE = "MetadataRetrieve";
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | /** creates a display element containing all the text strings needed to display the service page, in the language specified */
|
---|
| 43 | protected Element createServiceDisplay(String service, String lang) {
|
---|
| 44 | Element display = doc_.createElement(GSXML.DISPLAY_ELEM);
|
---|
| 45 | display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, getTextString(service+".name", lang)));
|
---|
| 46 | display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang)));
|
---|
| 47 |
|
---|
| 48 | Element param;
|
---|
| 49 |
|
---|
| 50 | return display;
|
---|
| 51 |
|
---|
| 52 | }
|
---|
| 53 |
|
---|
| 54 |
|
---|
| 55 | /** configure this service */
|
---|
| 56 | public boolean configure(Element info) {
|
---|
| 57 |
|
---|
| 58 | System.out.println("configuring GS2MGRetrieve");
|
---|
| 59 |
|
---|
| 60 | Element e = null;
|
---|
| 61 | // these entries should reflect the build config file - some services may not be available depending on how the colleciton was built.
|
---|
| 62 | // set up short_service_info_ - for now just has name and type
|
---|
| 63 | e = doc_.createElement(GSXML.SERVICE_ELEM);
|
---|
| 64 | e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
|
---|
| 65 | e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE);
|
---|
| 66 | short_service_info_.appendChild(e);
|
---|
| 67 |
|
---|
| 68 | e = doc_.createElement(GSXML.SERVICE_ELEM);
|
---|
| 69 | e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
|
---|
| 70 | e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE);
|
---|
| 71 | short_service_info_.appendChild(e);
|
---|
| 72 |
|
---|
| 73 |
|
---|
| 74 | // set up service_info_map_ - for now, just has the same elements as above
|
---|
| 75 | // should have full details about each service incl params lists etc.
|
---|
| 76 | e = doc_.createElement(GSXML.SERVICE_ELEM);
|
---|
| 77 | e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
|
---|
| 78 | e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE);
|
---|
| 79 | service_info_map_.put(DOCUMENT_RETRIEVE_SERVICE, e);
|
---|
| 80 |
|
---|
| 81 | e = doc_.createElement(GSXML.SERVICE_ELEM);
|
---|
| 82 | e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY);
|
---|
| 83 | e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE);
|
---|
| 84 | service_info_map_.put(METADATA_RETRIEVE_SERVICE, e);
|
---|
| 85 |
|
---|
| 86 | return true;
|
---|
| 87 | }
|
---|
| 88 | /** retrieve a document */
|
---|
| 89 | protected Element processDocumentRetrieve(Element request) {
|
---|
| 90 | Element result = doc_.createElement(GSXML.RESPONSE_ELEM);
|
---|
| 91 | result.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE);
|
---|
| 92 |
|
---|
| 93 | // dummy result
|
---|
| 94 | Text t = null;
|
---|
| 95 | t = doc_.createTextNode(DOCUMENT_RETRIEVE_SERVICE+" result... ");
|
---|
| 96 | result.appendChild(t);
|
---|
| 97 | return result;
|
---|
| 98 | }
|
---|
| 99 |
|
---|
| 100 | /** retrieve metadata */
|
---|
| 101 | protected Element processMetadataRetrieve(Element request) {
|
---|
| 102 | Element result = doc_.createElement(GSXML.RESPONSE_ELEM);
|
---|
| 103 | result.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE);
|
---|
| 104 |
|
---|
| 105 | // dummy result
|
---|
| 106 | Text t = null;
|
---|
| 107 | t = doc_.createTextNode(METADATA_RETRIEVE_SERVICE+" result... ");
|
---|
| 108 | result.appendChild(t);
|
---|
| 109 | return result;
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | }
|
---|