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 | */
|
---|
19 | package org.greenstone.gsdl3.service;
|
---|
20 |
|
---|
21 | import org.greenstone.gsdl3.util.*;
|
---|
22 |
|
---|
23 | import org.greenstone.mgpp.*;
|
---|
24 | import org.w3c.dom.Document;
|
---|
25 | import org.w3c.dom.Node;
|
---|
26 | import org.w3c.dom.Element;
|
---|
27 | import org.w3c.dom.Text;
|
---|
28 |
|
---|
29 | import java.util.Vector;
|
---|
30 | import java.util.HashMap;
|
---|
31 | import java.io.File;
|
---|
32 | import java.io.Serializable;
|
---|
33 |
|
---|
34 | import org.apache.log4j.*;
|
---|
35 |
|
---|
36 | /**
|
---|
37 | * GsdlCollageServices - the gsdl collage browsing service
|
---|
38 | *
|
---|
39 | */
|
---|
40 | public 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 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
|
---|
92 | app_info +="<param name='library' value='library'/>"; // TODO
|
---|
93 | app_info +="<param name='collection' value='";
|
---|
94 | app_info += this.cluster_name + "'/>";
|
---|
95 | //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
|
---|
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='localsite' />\n";
|
---|
99 | //app_info += "<param name='documentroot' value='library/collection/" + this.cluster_name + "/'/>";
|
---|
100 | app_info += "<param name='documentroot' value='greenstone3'/>\n";
|
---|
101 | app_info += "<param name='verbosity' value='3' />\n";
|
---|
102 | app_info += "<param name='imageType' value='.jpg%%.png' />\n";
|
---|
103 | //app_info += "<param name='hrefMustHave' value='smallbea' />\n";
|
---|
104 | //app_info += "<param name='imageMustNotHave' value='hl=%x=%gt=%gc=%.pr' />\n";
|
---|
105 | app_info += "<param name='imageMustNotHave' value='interfaces/' />\n";
|
---|
106 | app_info += "<param name='gwcgi' value='http://localhost:8383/greenstone3/library/collection/smallbea/' /><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
|
---|
107 |
|
---|
108 | Document dom = this.converter.getDOM(app_info);
|
---|
109 | if (dom==null) {
|
---|
110 | logger.error("Couldn't parse applet info");
|
---|
111 | return false;
|
---|
112 | }
|
---|
113 | Element app_elem = dom.getDocumentElement();
|
---|
114 | applet_description.appendChild(this.desc_doc.importNode(app_elem, true));
|
---|
115 |
|
---|
116 | return true;
|
---|
117 | }
|
---|
118 |
|
---|
119 | protected Element getServiceDescription(Document doc, String service, String lang, String subset) {
|
---|
120 | if (!service.equals(GSDL_COLLAGE_SERVICE)) {
|
---|
121 | return null;
|
---|
122 | }
|
---|
123 | Element describe = (Element)doc.importNode(applet_description,true);
|
---|
124 |
|
---|
125 | Element el1 = GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_NAME, getTextString(GSDL_COLLAGE_SERVICE+".name", lang));
|
---|
126 | describe.appendChild(el1);
|
---|
127 |
|
---|
128 | Element el2 = GSXML.createDisplayTextElement(doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(GSDL_COLLAGE_SERVICE+".description", lang));
|
---|
129 | describe.appendChild(el2);
|
---|
130 |
|
---|
131 | return describe;
|
---|
132 | }
|
---|
133 |
|
---|
134 | protected Element processGsdlCollageApplet(Element request) {
|
---|
135 | Document result_doc = XMLConverter.newDOM();
|
---|
136 |
|
---|
137 | // the result element
|
---|
138 | Element result = result_doc.createElement(GSXML.RESPONSE_ELEM);
|
---|
139 | result.setAttribute(GSXML.FROM_ATT, GSDL_COLLAGE_SERVICE);
|
---|
140 | result.setAttribute(GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
|
---|
141 |
|
---|
142 | // applet result info must be in appletInfo element
|
---|
143 | Element applet_data = result_doc.createElement(GSXML.APPLET_DATA_ELEM);
|
---|
144 | result.appendChild(applet_data);
|
---|
145 | Element gsdlCollage_data = result_doc.createElement("gsdlCollageData");
|
---|
146 | applet_data.appendChild(gsdlCollage_data);
|
---|
147 |
|
---|
148 | gsdlCollage_data.appendChild(result_doc.createTextNode("TODO: GsdlCollage applet doesn't actually do any processing"));
|
---|
149 |
|
---|
150 | return result;
|
---|
151 |
|
---|
152 |
|
---|
153 | }// processGsdlCollageApplet
|
---|
154 |
|
---|
155 | protected Element gsdlCollageError(Document collage_doc, String message) {
|
---|
156 | Element e = collage_doc.createElement("gsdlCollageError");
|
---|
157 | Text t = collage_doc.createTextNode(message);
|
---|
158 | e.appendChild(t);
|
---|
159 | return e;
|
---|
160 | }
|
---|
161 |
|
---|
162 | }
|
---|
163 |
|
---|