source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/GS2Construct.java@ 24855

Last change on this file since 24855 was 24855, checked in by sjm84, 12 years ago

Reformatting this file ahead of some changes

  • Property svn:keywords set to Author Date Id Revision
File size: 22.0 KB
Line 
1/*
2 * GS2Construct.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 */
19package org.greenstone.gsdl3.service;
20
21import org.greenstone.gsdl3.util.*;
22import org.greenstone.gsdl3.build.*;
23
24import org.w3c.dom.Document;
25import org.w3c.dom.Node;
26import org.w3c.dom.Text;
27import org.w3c.dom.Element;
28import org.w3c.dom.NodeList;
29
30import java.util.Collections;
31import java.util.HashMap;
32import java.util.Map;
33import java.util.List;
34import java.util.ArrayList;
35import java.io.File;
36import java.util.Locale;
37
38import org.apache.log4j.*;
39
40/**
41 * A Services class for building collections provides a wrapper around the old
42 * perl scripts
43 *
44 * @author <a href="mailto:[email protected]">Katherine Don</a>
45 * @version $Revision: 24855 $
46 */
47public class GS2Construct extends ServiceRack
48{
49
50 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.GS2Construct.class.getName());
51
52 // services offered
53 private static final String NEW_SERVICE = "NewCollection";
54 private static final String ADD_DOC_SERVICE = "AddDocument";
55 private static final String IMPORT_SERVICE = "ImportCollection";
56 private static final String BUILD_SERVICE = "BuildCollection";
57 private static final String ACTIVATE_SERVICE = "ActivateCollection";
58 private static final String DELETE_SERVICE = "DeleteCollection";
59 private static final String RELOAD_SERVICE = "ReloadCollection";
60
61 // params used
62 private static final String COL_PARAM = "collection";
63 private static final String NEW_COL_TITLE_PARAM = "collTitle";
64 private static final String NEW_COL_ABOUT_PARAM = "collAbout";
65 private static final String CREATOR_PARAM = "creator";
66 private static final String NEW_FILE_PARAM = "newfile";
67 private static final String PROCESS_ID_PARAM = GSParams.PROCESS_ID;
68 private static final String BUILDTYPE_PARAM = "buildType";
69 private static final String BUILDTYPE_MG = "mg";
70 private static final String BUILDTYPE_MGPP = "mgpp";
71
72 // the list of the collections - store between some method calls
73 private String[] collection_list = null;
74
75 // set of listeners for any construction commands
76 protected Map listeners = null;
77
78 public GS2Construct()
79 {
80 this.listeners = Collections.synchronizedMap(new HashMap());
81
82 }
83
84 /** returns a specific service description */
85 protected Element getServiceDescription(String service, String lang, String subset)
86 {
87
88 Element description = this.doc.createElement(GSXML.SERVICE_ELEM);
89 description.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
90 description.setAttribute(GSXML.NAME_ATT, service);
91 if (subset == null || subset.equals(GSXML.DISPLAY_TEXT_ELEM + GSXML.LIST_MODIFIER))
92 {
93 description.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_NAME, getTextString(service + ".name", lang)));
94 description.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_DESCRIPTION, getTextString(service + ".description", lang)));
95 description.appendChild(GSXML.createDisplayTextElement(this.doc, GSXML.DISPLAY_TEXT_SUBMIT, getTextString(service + ".submit", lang)));
96 }
97 if (subset == null || subset.equals(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER))
98 {
99 Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
100 description.appendChild(param_list);
101
102 if (service.equals(NEW_SERVICE))
103 {
104
105 Element param = GSXML.createParameterDescription(this.doc, NEW_COL_TITLE_PARAM, getTextString("param." + NEW_COL_TITLE_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null);
106 param_list.appendChild(param);
107 param = GSXML.createParameterDescription(this.doc, CREATOR_PARAM, getTextString("param." + CREATOR_PARAM, lang), GSXML.PARAM_TYPE_STRING, null, null, null);
108 param_list.appendChild(param);
109 param = GSXML.createParameterDescription(this.doc, NEW_COL_ABOUT_PARAM, getTextString("param." + NEW_COL_ABOUT_PARAM, lang), GSXML.PARAM_TYPE_TEXT, null, null, null);
110 param_list.appendChild(param);
111 String[] types = { BUILDTYPE_MGPP, BUILDTYPE_MG };
112 String[] type_texts = { getTextString("param." + BUILDTYPE_PARAM + "." + BUILDTYPE_MGPP, lang), getTextString("param." + BUILDTYPE_PARAM + "." + BUILDTYPE_MG, lang) };
113
114 param = GSXML.createParameterDescription(this.doc, BUILDTYPE_PARAM, getTextString("param." + BUILDTYPE_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, BUILDTYPE_MGPP, types, type_texts);
115 param_list.appendChild(param);
116 }
117 else if (service.equals(ACTIVATE_SERVICE) || service.equals(IMPORT_SERVICE) || service.equals(BUILD_SERVICE) || service.equals(RELOAD_SERVICE) || service.equals(DELETE_SERVICE))
118 {
119
120 this.collection_list = getCollectionList();
121 Element param = GSXML.createParameterDescription(this.doc, COL_PARAM, getTextString("param." + COL_PARAM, lang), GSXML.PARAM_TYPE_ENUM_SINGLE, null, this.collection_list, this.collection_list);
122 param_list.appendChild(param);
123 }
124 else
125 {
126 // invalid service name
127 return null;
128 }
129 }
130 return description;
131 }
132
133 // each service must have a method "process<New service name>"
134
135 protected Element processNewCollection(Element request)
136 {
137 return runCommand(request, GS2PerlConstructor.NEW);
138 }
139
140 /** TODO:implement this */
141 protected Element processAddDocument(Element request)
142 {
143 // decode the file name, add it to the import directory
144 String name = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
145 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
146 response.setAttribute(GSXML.FROM_ATT, name);
147 Element status = this.doc.createElement(GSXML.STATUS_ELEM);
148 response.appendChild(status);
149 //String lang = request.getAttribute(GSXML.LANG_ATT);
150 //String request_type = request.getAttribute(GSXML.TYPE_ATT);
151 Text t = this.doc.createTextNode("AddDocument: not implemented yet");
152 status.appendChild(t);
153 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
154 return response;
155 }
156
157 protected Element processImportCollection(Element request)
158 {
159 return runCommand(request, GS2PerlConstructor.IMPORT);
160 }
161
162 protected Element processBuildCollection(Element request)
163 {
164 return runCommand(request, GS2PerlConstructor.BUILD);
165 }
166
167 protected Element processActivateCollection(Element request)
168 {
169 Element response = runCommand(request, GS2PerlConstructor.ACTIVATE);
170 // this activates the collection on disk. but now we need to tell
171 // the MR about it. but we have to wait until the process is finished.
172 Element status = (Element) GSXML.getChildByTagName(response, GSXML.STATUS_ELEM);
173 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
174 HashMap params = GSXML.extractParams(param_list, false);
175 String coll_name = (String) params.get(COL_PARAM);
176 String lang = request.getAttribute(GSXML.LANG_ATT);
177 // check for finished
178 int status_code = Integer.parseInt(status.getAttribute(GSXML.STATUS_ERROR_CODE_ATT));
179 if (GSStatus.isCompleted(status_code) && GSStatus.isError(status_code))
180 {
181 // we shouldn't carry out the next bit, just return the response
182 return response;
183 }
184 String id = status.getAttribute(GSXML.STATUS_PROCESS_ID_ATT);
185 GS2PerlListener listener = (GS2PerlListener) this.listeners.get(id);
186 if (listener == null)
187 {
188 logger.error("somethings gone wrong, couldn't find the listener");
189 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
190 return response;
191 }
192 while (!GSStatus.isCompleted(status_code))
193 {
194 // wait for the process, and keep checking the status code
195 // there is probably a better way to do this.
196 try
197 {
198 Thread.currentThread().sleep(100);
199 }
200 catch (Exception e)
201 { // ignore
202 }
203 status_code = listener.getStatus();
204 }
205
206 // add the rest of the messages to the status node
207 Text t = this.doc.createTextNode("\n" + listener.getUpdate());
208 status.appendChild(t);
209 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(listener.getStatus()));
210 if (GSStatus.isError(status_code))
211 {
212 return response; // without doing the next bit
213 }
214
215 t = this.doc.createTextNode("\n");
216 status.appendChild(t);
217 // once have got here, we assume
218 // the first bit proceeded successfully, now reload the collection
219 systemRequest("reload", coll_name, status, lang); // this will append more messages to the status, and overwrite the error code att
220 return response;
221
222 }
223
224 protected Element processDeleteCollection(Element request)
225 {
226
227 // the response to send back
228 String name = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
229 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
230 response.setAttribute(GSXML.FROM_ATT, name);
231 Element status = this.doc.createElement(GSXML.STATUS_ELEM);
232 response.appendChild(status);
233 Text t = null; // the text node for the error/success message
234 String lang = request.getAttribute(GSXML.LANG_ATT);
235 String request_type = request.getAttribute(GSXML.TYPE_ATT);
236
237 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
238 HashMap params = GSXML.extractParams(param_list, false);
239
240 boolean get_status_only = false;
241 if (request_type.equals(GSXML.REQUEST_TYPE_STATUS))
242 {
243 get_status_only = true;
244 }
245 if (get_status_only)
246 {
247 // at the moment, delete is synchronous. but it may take ages so should do the command in another thread maybe? in which case we will want to ask for status
248 logger.error("had a status request for delete - this shouldn't happen!!");
249 //t = this.doc.createTextNode("");
250 //status.appendChild(t);
251 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
252 return response;
253 }
254 String coll_name = (String) params.get(COL_PARAM);
255 String[] args = { coll_name };
256 File coll_dir = new File(GSFile.collectionBaseDir(this.site_home, coll_name));
257 // check that the coll is there in the first place
258 if (!coll_dir.exists())
259 {
260 t = this.doc.createTextNode(getTextString("delete.exists_error", lang, args));
261 status.appendChild(t);
262 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
263 return response;
264 }
265
266 // try to delete the directory
267 if (!GSFile.deleteFile(coll_dir))
268 {
269 t = this.doc.createTextNode(getTextString("delete.delete_error", lang, args));
270 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
271 status.appendChild(t);
272 return response;
273 }
274 systemRequest("delete", coll_name, status, lang);
275 return response;
276 }
277
278 protected Element processReloadCollection(Element request)
279 {
280
281 // the response to send back
282 String name = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
283 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
284 response.setAttribute(GSXML.FROM_ATT, name);
285 Element status = this.doc.createElement(GSXML.STATUS_ELEM);
286 response.appendChild(status);
287 Text t = null; // the text node for the error/success message
288
289 String lang = request.getAttribute(GSXML.LANG_ATT);
290 String request_type = request.getAttribute(GSXML.TYPE_ATT);
291
292 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
293 HashMap params = GSXML.extractParams(param_list, false);
294
295 boolean get_status_only = false;
296 if (request_type.equals(GSXML.REQUEST_TYPE_STATUS))
297 {
298 get_status_only = true;
299 }
300 if (get_status_only)
301 {
302 // reload is synchronous - this makes no sense
303 logger.error("had a status request for reload - this shouldn't happen!!");
304 //t = this.doc.createTextNode("");
305 //status.appendChild(t);
306 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
307 return response;
308 }
309
310 String coll_name = (String) params.get(COL_PARAM);
311 systemRequest("reload", coll_name, status, lang);
312 return response;
313
314 }
315
316 /**
317 * send a configure request to the message router action name should be
318 * "delete" or "reload" response will be put into the status element
319 */
320 protected void systemRequest(String action_name, String coll_name, Element status, String lang)
321 {
322
323 // send the request to the MR
324 Element message = this.doc.createElement(GSXML.MESSAGE_ELEM);
325 Element request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_SYSTEM, "", lang, "");
326 message.appendChild(request);
327 Element command = this.doc.createElement(GSXML.SYSTEM_ELEM);
328 request.appendChild(command);
329 command.setAttribute(GSXML.SYSTEM_MODULE_TYPE_ATT, GSXML.COLLECTION_ELEM);
330 command.setAttribute(GSXML.SYSTEM_MODULE_NAME_ATT, coll_name);
331
332 if (action_name.equals("delete"))
333 {
334 command.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_DEACTIVATE);
335 }
336 else if (action_name.equals("reload"))
337 {
338 command.setAttribute(GSXML.TYPE_ATT, GSXML.SYSTEM_TYPE_ACTIVATE);
339 }
340 else
341 {
342 logger.error("invalid action name passed to systemRequest:" + action_name);
343 return;
344 }
345 request.appendChild(command);
346 Node response = this.router.process(message); // at the moment, get no info in response so ignore it
347 Text t;
348 String[] args = { coll_name };
349
350 if (response == null)
351 {
352 t = this.doc.createTextNode(getTextString(action_name + ".configure_error", lang, args));
353 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
354 status.appendChild(t);
355 return;
356 }
357
358 // if we got here, we have succeeded!
359 t = this.doc.createTextNode(getTextString(action_name + ".success", lang, args));
360 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.SUCCESS));
361 status.appendChild(t);
362 }
363
364 /**
365 * configure the service module for now, all services have type=build - need
366 * to think about this
367 */
368 public boolean configure(Element info, Element extra_info)
369 {
370 if (!super.configure(info, extra_info))
371 {
372 return false;
373 }
374
375 logger.info("configuring GS2Construct");
376
377 Element e = null;
378 // hard code in the services for now
379
380 // set up short_service_info_ - for now just has name and type
381
382 e = this.doc.createElement(GSXML.SERVICE_ELEM);
383 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
384 e.setAttribute(GSXML.NAME_ATT, NEW_SERVICE);
385 this.short_service_info.appendChild(e);
386
387 e = this.doc.createElement(GSXML.SERVICE_ELEM);
388 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
389 e.setAttribute(GSXML.NAME_ATT, IMPORT_SERVICE);
390 this.short_service_info.appendChild(e);
391
392 e = this.doc.createElement(GSXML.SERVICE_ELEM);
393 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
394 e.setAttribute(GSXML.NAME_ATT, BUILD_SERVICE);
395 this.short_service_info.appendChild(e);
396
397 e = this.doc.createElement(GSXML.SERVICE_ELEM);
398 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
399 e.setAttribute(GSXML.NAME_ATT, ACTIVATE_SERVICE);
400 this.short_service_info.appendChild(e);
401
402 e = this.doc.createElement(GSXML.SERVICE_ELEM);
403 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
404 e.setAttribute(GSXML.NAME_ATT, DELETE_SERVICE);
405 this.short_service_info.appendChild(e);
406
407 e = this.doc.createElement(GSXML.SERVICE_ELEM);
408 e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
409 e.setAttribute(GSXML.NAME_ATT, RELOAD_SERVICE);
410 this.short_service_info.appendChild(e);
411
412 //e = this.doc.createElement(GSXML.SERVICE_ELEM);
413 //e.setAttribute(GSXML.TYPE_ATT, GSXML.SERVICE_TYPE_PROCESS);
414 //e.setAttribute(GSXML.NAME_ATT, ADD_DOC_SERVICE);
415 //this.short_service_info.appendChild(e);
416
417 return true;
418 }
419
420 /** returns a response element */
421 protected Element runCommand(Element request, int type)
422 {
423
424 // the response to send back
425 String name = GSPath.getFirstLink(request.getAttribute(GSXML.TO_ATT));
426 Element response = this.doc.createElement(GSXML.RESPONSE_ELEM);
427 response.setAttribute(GSXML.FROM_ATT, name);
428 Element status = this.doc.createElement(GSXML.STATUS_ELEM);
429 response.appendChild(status);
430
431 String lang = request.getAttribute(GSXML.LANG_ATT);
432 String request_type = request.getAttribute(GSXML.TYPE_ATT);
433
434 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
435 HashMap params = GSXML.extractParams(param_list, false);
436
437 boolean get_status_only = false;
438 if (request_type.equals(GSXML.REQUEST_TYPE_STATUS))
439 {
440 get_status_only = true;
441 }
442
443 // just check for status messages if that's all that's required
444 if (get_status_only)
445 {
446 String id = (String) params.get(PROCESS_ID_PARAM);
447 status.setAttribute(GSXML.STATUS_PROCESS_ID_ATT, id);
448 GS2PerlListener listener = (GS2PerlListener) this.listeners.get(id);
449 if (listener == null)
450 {
451 Text t = this.doc.createTextNode(getTextString("general.process_id_error", lang));
452 status.appendChild(t);
453 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
454 }
455 else
456 {
457 Text t = this.doc.createTextNode(listener.getUpdate());
458 status.appendChild(t);
459 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(listener.getStatus()));
460 // check that we actually should be removing the listener here
461 if (listener.isFinished())
462 { // remove this listener - its job is done
463 this.listeners.remove(id); // not working
464 }
465 }
466 return response;
467
468 }
469
470 // do teh actual command
471 String coll_name = null;
472 if (type == GS2PerlConstructor.NEW)
473 {
474 String coll_title = (String) params.get(NEW_COL_TITLE_PARAM);
475 coll_name = createNewCollName(coll_title);
476 }
477 else
478 {
479 coll_name = (String) params.get(COL_PARAM);
480 }
481 logger.error("Coll name = " + coll_name);
482 // makes a paramList of the relevant params
483 Element other_params = extractOtherParams(params, type);
484
485 //create the constructor to do the work
486
487 GS2PerlConstructor constructor = new GS2PerlConstructor("perl_build");
488 if (!constructor.configure())
489 {
490 Text t = this.doc.createTextNode(getTextString("general.configure_constructor_error", lang));
491 status.appendChild(t);
492 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ERROR));
493 return response;
494 }
495
496 constructor.setSiteHome(this.site_home);
497 constructor.setCollectionName(coll_name);
498 constructor.setActionType(type);
499 constructor.setProcessParams(other_params);
500 // the listener
501 GS2PerlListener listener = new GS2PerlListener();
502 constructor.addListener(listener);
503 constructor.start();
504
505 String id = newID();
506 this.listeners.put(id, listener);
507
508 status.setAttribute(GSXML.STATUS_PROCESS_ID_ATT, id);
509 status.setAttribute(GSXML.STATUS_ERROR_CODE_ATT, Integer.toString(GSStatus.ACCEPTED));
510 Text t = this.doc.createTextNode(getTextString("general.process_start", lang));
511 status.appendChild(t);
512 return response;
513
514 }
515
516 //************************
517 // some helper functions
518 //************************
519
520 /** parse the collect directory and return a list of collection names */
521 protected String[] getCollectionList()
522 {
523
524 File collectDir = new File(GSFile.collectDir(this.site_home));
525 if (!collectDir.exists())
526 {
527 logger.error("couldn't find collect dir: " + collectDir.toString());
528 return null;
529 }
530 logger.info("GS2Construct: reading thru directory " + collectDir.getPath() + " to find collections.");
531 File[] contents = collectDir.listFiles();
532 int num_colls = 0;
533 for (int i = 0; i < contents.length; i++)
534 {
535 if (contents[i].isDirectory() && !contents[i].getName().startsWith("CVS"))
536 {
537 num_colls++;
538 }
539 }
540
541 String[] names = new String[num_colls];
542
543 for (int i = 0, j = 0; i < contents.length; i++)
544 {
545 if (contents[i].isDirectory())
546 {
547 String colName = contents[i].getName();
548 if (!colName.startsWith("CVS"))
549 {
550 names[j] = colName;
551 j++;
552 }
553
554 }
555 }
556
557 return names;
558
559 }
560
561 /** ids used for process id */
562 private int current_id = 0;
563
564 private String newID()
565 {
566 current_id++;
567 return Integer.toString(current_id);
568 }
569
570 /** creates a new short name from the collection title */
571 protected String createNewCollName(String coll_title)
572 {
573
574 String base_name = null;
575 // take the first 6 letters
576 if (coll_title.length() < 6)
577 {
578 base_name = coll_title;
579 }
580 else
581 {
582 base_name = coll_title.substring(0, 6);
583 }
584 File coll_dir = new File(GSFile.collectionBaseDir(this.site_home, base_name));
585 if (!coll_dir.exists())
586 { // this name is ok - not used yet
587 return base_name;
588 }
589
590 // now we have to make a new name until we get a good one
591 // try name1, name2 name3 etc
592 int i = 0;
593 while (coll_dir.exists())
594 {
595 i++;
596 coll_dir = new File(GSFile.collectionBaseDir(this.site_home, base_name + Integer.toString(i)));
597 }
598 return base_name + Integer.toString(i);
599
600 }
601
602 /**
603 * takes the params from the request (in the HashMap) and extracts any that
604 * need to be passed to the constructor and puts them into a paramList
605 * element
606 */
607 protected Element extractOtherParams(HashMap params, int type)
608 {
609
610 Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
611 if (type == GS2PerlConstructor.NEW)
612 {
613 Element param = this.doc.createElement(GSXML.PARAM_ELEM);
614 param.setAttribute(GSXML.NAME_ATT, "creator");
615 param.setAttribute(GSXML.VALUE_ATT, (String) params.get(CREATOR_PARAM));
616
617 param_list.appendChild(param);
618 param = this.doc.createElement(GSXML.PARAM_ELEM);
619 param.setAttribute(GSXML.NAME_ATT, "about");
620 param.setAttribute(GSXML.VALUE_ATT, (String) params.get(NEW_COL_ABOUT_PARAM));
621 param_list.appendChild(param);
622 param = this.doc.createElement(GSXML.PARAM_ELEM);
623 param.setAttribute(GSXML.NAME_ATT, "title");
624 param.setAttribute(GSXML.VALUE_ATT, (String) params.get(NEW_COL_TITLE_PARAM));
625 param_list.appendChild(param);
626 param = this.doc.createElement(GSXML.PARAM_ELEM);
627 param.setAttribute(GSXML.NAME_ATT, "buildtype");
628 param.setAttribute(GSXML.VALUE_ATT, (String) params.get(BUILDTYPE_PARAM));
629 param_list.appendChild(param);
630 return param_list;
631 }
632
633 // other ones dont have params yet
634 return null;
635 }
636
637}
Note: See TracBrowser for help on using the repository browser.