/* * GS2MGRetrieve.java * Copyright (C) 2002 New Zealand Digital Library, http://www.nzdl.org * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ package org.greenstone.gsdl3.service; import org.greenstone.gsdl3.util.*; import org.w3c.dom.Document; import org.w3c.dom.Node; import org.w3c.dom.Text; import org.w3c.dom.Element; import org.w3c.dom.NodeList; /** * * @author Katherine Don * @version $Revision: 3649 $ */ public class GS2MGRetrieve extends ServiceRack { // the services on offer private static final String DOCUMENT_RETRIEVE_SERVICE = "DocumentRetrieve"; private static final String METADATA_RETRIEVE_SERVICE = "MetadataRetrieve"; /** creates a display element containing all the text strings needed to display the service page, in the language specified */ protected Element createServiceDisplay(String service, String lang) { Element display = doc_.createElement(GSXML.DISPLAY_ELEM); display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_NAME_ELEM, getTextString(service+".name", lang))); display.appendChild(GSXML.createTextElement(doc_, GSXML.DISPLAY_SUBMIT_ELEM, getTextString(service+".submit", lang))); Element param; return display; } /** configure this service */ public boolean configure(Element info) { System.out.println("configuring GS2MGRetrieve"); Element e = null; // these entries should reflect the build config file - some services may not be available depending on how the colleciton was built. // set up short_service_info_ - for now just has name and type e = doc_.createElement(GSXML.SERVICE_ELEM); e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); short_service_info_.appendChild(e); e = doc_.createElement(GSXML.SERVICE_ELEM); e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); short_service_info_.appendChild(e); // set up service_info_map_ - for now, just has the same elements as above // should have full details about each service incl params lists etc. e = doc_.createElement(GSXML.SERVICE_ELEM); e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); e.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); service_info_map_.put(DOCUMENT_RETRIEVE_SERVICE, e); e = doc_.createElement(GSXML.SERVICE_ELEM); e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_QUERY); e.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); service_info_map_.put(METADATA_RETRIEVE_SERVICE, e); return true; } /** retrieve a document */ protected Element processDocumentRetrieve(Element request) { Element result = doc_.createElement(GSXML.RESPONSE_ELEM); result.setAttribute(GSXML.NAME_ATT, DOCUMENT_RETRIEVE_SERVICE); // dummy result Text t = null; t = doc_.createTextNode(DOCUMENT_RETRIEVE_SERVICE+" result... "); result.appendChild(t); return result; } /** retrieve metadata */ protected Element processMetadataRetrieve(Element request) { Element result = doc_.createElement(GSXML.RESPONSE_ELEM); result.setAttribute(GSXML.NAME_ATT, METADATA_RETRIEVE_SERVICE); // dummy result Text t = null; t = doc_.createTextNode(METADATA_RETRIEVE_SERVICE+" result... "); result.appendChild(t); return result; } }