source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GsdlCollageBrowse.java@ 38921

Last change on this file since 38921 was 38921, checked in by anupama, 2 months ago

Minor correction to GS3 service and bringing unused (still not working) part of classifier.xsl up to speed.

File size: 7.0 KB
Line 
1/*
2 * GsdlCollage Services java file
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 */
19package org.greenstone.gsdl3.service;
20
21import org.greenstone.gsdl3.util.*;
22
23import org.greenstone.mgpp.*;
24import org.w3c.dom.Document;
25import org.w3c.dom.Node;
26import org.w3c.dom.Element;
27import org.w3c.dom.Text;
28
29import java.util.Vector;
30import java.util.HashMap;
31import java.io.File;
32import java.io.Serializable;
33
34import org.apache.log4j.*;
35
36/**
37 * GsdlCollageServices - the gsdl collage browsing service
38 *
39 */
40public class GsdlCollageBrowse
41 extends ServiceRack {
42
43 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GsdlCollageBrowse.class.getName());
44
45 // the services on offer
46 private static final String GSDL_COLLAGE_SERVICE = "GsdlCollageApplet";
47
48 private String basepath = null;
49
50 private Element applet_description = null;
51
52 public GsdlCollageBrowse() {
53 super();
54 }
55
56 public void cleanUp() {
57 super.cleanUp();
58
59 }
60
61 /** configure the service module
62 *
63 * @param info a DOM Element containing any config info for the service
64 * @return true if configured
65 */
66 public boolean configure(Element info, Element extra_info) {
67
68 if (!super.configure(info, extra_info)){
69 return false;
70 }
71
72 logger.info("configuring GsdlCollageBrowse");
73
74 // set up short_service_info_ - for now just has name and type
75 Element e = this.desc_doc.createElement(GSXML.SERVICE_ELEM);
76 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_APPLET);
77 e.setAttribute(GSXML.NAME_ATT, GSDL_COLLAGE_SERVICE);
78 this.short_service_info.appendChild(e);
79
80 // set up the static applet description
81
82 applet_description = this.desc_doc.createElement(GSXML.SERVICE_ELEM);
83 applet_description.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_APPLET);
84 applet_description.setAttribute(GSXML.NAME_ATT, GSDL_COLLAGE_SERVICE);
85
86 // add in the applet info for the gsdl collage applet
87 // need to make this dynamic - library names etc
88 // change the applet params - have a single param with the library name
89 // this is left blank at this end, and must be filled in by applet action - if the library name is not needed, this param is left out
90
91 String siteName = this.site_home.substring(this.site_home.lastIndexOf("/sites/")+"/sites/".length());
92
93 String app_info = "<"+GSXML.APPLET_ELEM+" CODEBASE='applet' CODE='org.greenstone.applet.GsdlCollageApplet.GsdlCollageApplet.class' ARCHIVE='GsdlCollageApplet.jar' WIDTH='600' HEIGHT='300'>"; // w=645,h=780
94 app_info +="<param name='library' value='" + this.library_name + "'/>";
95 app_info +="<param name='collection' value='" + this.cluster_name + "'/>";
96 app_info += "<param name='gsdlversion' value='3' />";
97 app_info += "<param name='baseurl' value='http://localhost:8383/greenstone3/' />";
98 //app_info += "<param name='sitename' value='"+ this.site_home +"' />\n";
99 //app_info += "<param name='hrefMustHave' value='smallbea' />\n";
100 app_info += "<param name='hrefMustHave' value='" + this.library_name + "/sites/" + siteName + "/collect/" + this.cluster_name + "'/>\n";
101 //app_info += "<param name='gwcgi' value='http://localhost:8383/greenstone3/library' /><param name='classifier' value='CL3.1' /><param name='hrefMustHave' value='CL3' /><param name='imageMustNotHave' value='hl=%x=%gt=%gc=%.pr' /><param name='imageType' value='.jpg%%.png' /><param name='maxDepth' value='500' /><param name='maxDisplay' value='25' /><param name='refreshDelay' value='1500' /><param name='isJava2' value='auto' /><param name='bgcolor' value='#96c29a' />The Collage Applet.</"+GSXML.APPLET_ELEM+">"; // TODO
102
103 //app_info += "<param name='documentroot' value='library/collection/" + this.cluster_name + "/'/>";
104 app_info += "<param name='documentroot' value='greenstone3'/>\n"; // TODO
105 app_info += "<param name='verbosity' value='3' />\n";
106 app_info += "<param name='imageType' value='.jpg%.png' />\n";
107 app_info += "<param name='imageMustNotHave' value='interfaces/' />\n";
108 app_info += "<param name='classifier' value='CL2.3' /><param name='maxDepth' value='500' /><param name='maxDisplay' value='25' /><param name='refreshDelay' value='1500' /><param name='isJava2' value='auto' /><param name='bgcolor' value='#96c29a' />The Collage Applet.</"+GSXML.APPLET_ELEM+">"; // TODO
109
110 Document dom = this.converter.getDOM(app_info);
111 if (dom==null) {
112 logger.error("Couldn't parse applet info");
113 return false;
114 }
115 Element app_elem = dom.getDocumentElement();
116 applet_description.appendChild(this.desc_doc.importNode(app_elem, true));
117
118 return true;
119 }
120
121 protected Element getServiceDescription(Document doc, String service, String lang, String subset) {
122 if (!service.equals(GSDL_COLLAGE_SERVICE)) {
123 return null;
124 }
125 Element describe = (Element)doc.importNode(applet_description,true);
126
127 Element el1 = GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(GSDL_COLLAGE_SERVICE+".name", lang));
128 describe.appendChild(el1);
129
130 Element el2 = GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(GSDL_COLLAGE_SERVICE+".description", lang));
131 describe.appendChild(el2);
132
133 return describe;
134 }
135
136 protected Element processGsdlCollageApplet(Element request) {
137 Document result_doc = XMLConverter.newDOM();
138
139 // the result element
140 Element result = result_doc.createElement(GSXML.RESPONSE_ELEM);
141 result.setAttribute(GSXML.FROM_ATT, GSDL_COLLAGE_SERVICE);
142 result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
143
144 // applet result info must be in appletInfo element
145 Element applet_data = result_doc.createElement(GSXML.APPLET_DATA_ELEM);
146 result.appendChild(applet_data);
147 Element gsdlCollage_data = result_doc.createElement("gsdlCollageData");
148 applet_data.appendChild(gsdlCollage_data);
149
150 gsdlCollage_data.appendChild(result_doc.createTextNode("TODO: GsdlCollage applet doesn't actually do any processing"));
151
152 return result;
153
154
155 }// processGsdlCollageApplet
156
157 protected Element gsdlCollageError(Document collage_doc, String message) {
158 Element e = collage_doc.createElement("gsdlCollageError");
159 Text t = collage_doc.createTextNode(message);
160 e.appendChild(t);
161 return e;
162 }
163
164}
165
Note: See TracBrowser for help on using the repository browser.