source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/service/DocumentBasket.java@ 25635

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

Fixing Greenstone 3's use (or lack thereof) of generics, this was done automatically so we may want to change it over time. This change will also auto-format any files that have not already been formatted.

  • Property svn:executable set to *
File size: 21.5 KB
Line 
1/*
2 * DocumentBasket.java
3 * Copyright (C) 2006 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
20package org.greenstone.gsdl3.service;
21
22import java.sql.Statement;
23import java.util.Hashtable;
24import java.util.HashMap;
25import java.util.ArrayList;
26import java.util.HashSet;
27import java.util.Iterator;
28
29import org.w3c.dom.Element;
30import org.w3c.dom.NodeList;
31
32import org.greenstone.util.GlobalProperties;
33import org.greenstone.gsdl3.util.GSParams;
34import org.greenstone.gsdl3.util.GSXML;
35import org.greenstone.gsdl3.util.GSPath;
36import org.greenstone.gsdl3.util.UserContext;
37
38import java.net.InetAddress;
39import java.util.Properties;
40import java.util.Date;
41
42import javax.mail.*;
43import javax.mail.internet.*;
44
45import java.awt.event.ActionEvent;
46import java.awt.event.ActionListener;
47import javax.swing.Timer;
48
49import java.io.*;
50
51import org.apache.log4j.*;
52
53public class DocumentBasket extends ServiceRack
54{
55
56 static Logger logger = Logger.getLogger(org.greenstone.gsdl3.service.DocumentBasket.class.getName());
57
58 // the services on offer
59 // these strings must match what is found in the properties file
60 protected static final String ADD_ITEM_SERVICE = "AddDocument";
61 protected static final String DISPLAY_ITEMS_SERVICE = "DisplayDocumentList";
62 protected static final String ITEM_NUM_SERVICE = "GetDocuments";
63 protected static final String DELETE_ITEMS_SERVICE = "DeleteDocuments";
64 protected static final String DELETE_ITEM_SERVICE = "DeleteDocument";
65 protected static final String CLEAR_ITEMS_SERVICE = "ClearDocuments";
66 //added
67 protected static final String MERGE_ITEM_SERVICE = "MergeDocument";
68 protected static final String ITEM_PARAM = "item";
69 protected static final String delimiter = "|";
70 protected static final int delay = 1800000;
71
72 protected static final String BASKET_BOOK = "documentBasketBook";
73
74 protected Hashtable<String, Hashtable<String, Hashtable<String, Item>>> userMap = null;
75 protected Hashtable<String, UserTimer> timerMap = null;
76 protected String username = "";
77 protected String password = "";
78
79 /** constructor */
80 public DocumentBasket()
81 {
82 userMap = new Hashtable<String, Hashtable<String, Hashtable<String, Item>>>();
83 timerMap = new Hashtable<String, UserTimer>();
84 }
85
86 private Hashtable<String, Hashtable<String, Item>> updateDocMap(Element request)
87 {
88 String id = request.getAttribute("uid");
89
90 if (userMap.containsKey(id))
91 {
92 if (timerMap.containsKey(id))
93 {
94 UserTimer timer = timerMap.get(id);
95 timer.restart();
96 }
97 return userMap.get(id);
98 }
99 else
100 {
101 UserTimer timer = new UserTimer(delay, id);
102 timerMap.put(id, timer);
103 timer.start();
104 Hashtable<String, Hashtable<String, Item>> newDocs = new Hashtable<String, Hashtable<String, Item>>();
105 userMap.put(id, newDocs);
106 return newDocs;
107 }
108 }
109
110 /** configure this service */
111 public boolean configure(Element info, Element extra_info)
112 {
113 logger.info("Configuring DocumentBasket...");
114 this.config_info = info;
115
116 // set up short_service_info_ - for now just has name and type
117 Element add_service = this.doc.createElement(GSXML.SERVICE_ELEM);
118 add_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
119 add_service.setAttribute(GSXML.NAME_ATT, ADD_ITEM_SERVICE);
120 this.short_service_info.appendChild(add_service);
121
122 // set up short_service_info_ - for now just has name and type
123 Element disp_service = this.doc.createElement(GSXML.SERVICE_ELEM);
124 disp_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
125 disp_service.setAttribute(GSXML.NAME_ATT, DISPLAY_ITEMS_SERVICE);
126 this.short_service_info.appendChild(disp_service);
127
128 // set up short_service_info_ - for now just has name and type
129 Element num_service = this.doc.createElement(GSXML.SERVICE_ELEM);
130 num_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
131 num_service.setAttribute(GSXML.NAME_ATT, ITEM_NUM_SERVICE);
132 this.short_service_info.appendChild(num_service);
133
134 // set up short_service_info_ - for now just has name and type
135 Element delete_service = this.doc.createElement(GSXML.SERVICE_ELEM);
136 delete_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
137 delete_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEMS_SERVICE);
138 this.short_service_info.appendChild(delete_service);
139
140 // set up short_service_info_ - for now just has name and type
141 Element deleteone_service = this.doc.createElement(GSXML.SERVICE_ELEM);
142 deleteone_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
143 deleteone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE);
144 this.short_service_info.appendChild(deleteone_service);
145
146 // set up short_service_info_ - for now just has name and type
147 Element deleteall_service = this.doc.createElement(GSXML.SERVICE_ELEM);
148 deleteall_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
149 deleteall_service.setAttribute(GSXML.NAME_ATT, CLEAR_ITEMS_SERVICE);
150 this.short_service_info.appendChild(deleteall_service);
151
152 // set up short_service_info_ - for now just has name and type
153 Element merge_service = this.doc.createElement(GSXML.SERVICE_ELEM);
154 merge_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
155 merge_service.setAttribute(GSXML.NAME_ATT, MERGE_ITEM_SERVICE);
156 this.short_service_info.appendChild(merge_service);
157
158 return true;
159 }
160
161 /** returns a specific service description */
162 protected Element getServiceDescription(String service_id, String lang, String subset)
163 {
164 if (service_id.equals(ADD_ITEM_SERVICE))
165 {
166 Element add_service = this.doc.createElement(GSXML.SERVICE_ELEM);
167 add_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
168 add_service.setAttribute(GSXML.NAME_ATT, ADD_ITEM_SERVICE);
169 return add_service;
170 }
171 if (service_id.equals(DISPLAY_ITEMS_SERVICE))
172 {
173
174 Element disp_service = this.doc.createElement(GSXML.SERVICE_ELEM);
175 disp_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
176 disp_service.setAttribute(GSXML.NAME_ATT, DISPLAY_ITEMS_SERVICE);
177 return disp_service;
178 }
179
180 if (service_id.equals(ITEM_NUM_SERVICE))
181 {
182
183 Element num_service = this.doc.createElement(GSXML.SERVICE_ELEM);
184 num_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
185 num_service.setAttribute(GSXML.NAME_ATT, ITEM_NUM_SERVICE);
186 return num_service;
187 }
188
189 if (service_id.equals(DELETE_ITEMS_SERVICE))
190 {
191
192 Element del_service = this.doc.createElement(GSXML.SERVICE_ELEM);
193 del_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
194 del_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEMS_SERVICE);
195 return del_service;
196 }
197
198 if (service_id.equals(CLEAR_ITEMS_SERVICE))
199 {
200
201 Element clear_service = this.doc.createElement(GSXML.SERVICE_ELEM);
202 clear_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
203 clear_service.setAttribute(GSXML.NAME_ATT, CLEAR_ITEMS_SERVICE);
204 return clear_service;
205 }
206
207 if (service_id.equals(DELETE_ITEM_SERVICE))
208 {
209
210 Element delone_service = this.doc.createElement(GSXML.SERVICE_ELEM);
211 delone_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
212 delone_service.setAttribute(GSXML.NAME_ATT, DELETE_ITEM_SERVICE);
213 return delone_service;
214 }
215 if (service_id.equals(MERGE_ITEM_SERVICE))
216 {
217 Element merge_service = this.doc.createElement(GSXML.SERVICE_ELEM);
218 merge_service.setAttribute(GSXML.TYPE_ATT, "gather"); // what??
219 merge_service.setAttribute(GSXML.NAME_ATT, MERGE_ITEM_SERVICE);
220 return merge_service;
221 }
222 return null;
223 }
224
225 protected Element processAddDocument(Element request)
226 {
227 //System.err.println("REQUEST = " + GSXML.xmlNodeToString(request));
228 Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
229 //System.err.println("DOCSMAP = " + docsMap);
230 // Create a new (empty) result message
231 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
232
233 // Get the parameters of the request
234 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
235 if (param_list == null)
236 {
237 logger.error("DocumentBasket Error: AddDocument request had no paramList.");
238 return result; // Return the empty result
239 }
240
241 HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
242 //System.err.println("PARAMS = " + params);
243 String item = (String) params.get("item");
244
245 int startIndex = item.startsWith(BASKET_BOOK) ? BASKET_BOOK.length() : 0;
246
247 String collection = "";
248 int pos = item.indexOf(":");
249 if (pos != -1)
250 {
251 collection = item.substring(startIndex, pos);
252 item = item.substring(pos + 1);
253 }
254
255 //logger.error("COLLECTION = " + collection + " *** ITEM = " + item);
256 if (docsMap.containsKey(collection))
257 {
258 Hashtable<String, Item> items = docsMap.get(collection);
259 if (!items.containsKey(item))
260 {
261 Item newItem = generateItem(collection, item);
262 items.put(item, newItem);
263 result.appendChild(newItem.wrapIntoElement());
264 }
265 }
266 else
267 {
268 Hashtable<String, Item> items = new Hashtable<String, Item>();
269 Item newItem = generateItem(collection, item);
270 items.put(item, newItem);
271 docsMap.put(collection, items);
272 result.appendChild(newItem.wrapIntoElement());
273 }
274
275 return result;
276 }
277
278 protected Element processMergeDocument(Element request)
279 {
280 // Get the parameters of the request
281 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
282 if (param_list == null)
283 {
284 logger.error("DocumentBasket Error: MergeDocument request had no paramList.");
285 return null; // Return the empty result
286 }
287
288 HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
289
290 String docString = (String) params.get("docs");
291 String[] docs = docString.split("-");
292
293 for (String d : docs)
294 {
295 logger.error("DOC = " + d);
296 }
297
298 /*
299 * try{ System.out.println("Concatenate Two PDF"); PdfReader reader1 =
300 * new PdfReader("3A01-01_Part_1-001.pdf"); PdfReader reader2 = new
301 * PdfReader("3A01-01_Part_1-017.pdf"); PdfCopyFields copy = new
302 * PdfCopyFields(new FileOutputStream("concatenatedPDF.pdf"));
303 * copy.addDocument(reader1); copy.addDocument(reader2); copy.close(); }
304 * catch(Exception ex) { ex.printStackTrace(); }
305 */
306 // added -->
307
308 try
309 {
310 {
311 PrintWriter pw = new PrintWriter(new FileOutputStream("G:/output1.xml"));
312 File file = new File("G:/greenstone3-svn/web/sites/localsite/collect/peij21/archives/HASH0189.dir/");
313 File[] files = file.listFiles();
314
315 for (int i = 0; i < files.length; i++)
316 {
317
318 //System.out.println(files[i].getName());
319 String fileName = files[i].getName();
320
321 if (fileName.equals("doc.xml"))
322 {
323
324 System.out.println("Processing " + files[i].getPath() + "... ");
325 BufferedReader br = new BufferedReader(new FileReader(files[i].getPath()));
326 String line = br.readLine();
327 while (line != null)
328 {
329 pw.println(line);
330 line = br.readLine();
331 }
332 br.close();
333
334 }
335
336 }
337
338 File file1 = new File("G:/greenstone3-svn/web/sites/localsite/collect/peij21/archives/HASHfdc0.dir/");
339 File[] files1 = file1.listFiles();
340
341 for (int i = 0; i < files1.length; i++)
342 {
343
344 //System.out.println(files[i].getName());
345 String fileName = files1[i].getName();
346
347 if (fileName.equals("doc.xml"))
348 {
349
350 System.out.println("Processing " + files1[i].getPath() + "... ");
351 BufferedReader br = new BufferedReader(new FileReader(files1[i].getPath()));
352 String line = br.readLine();
353 while (line != null)
354 {
355 pw.println(line);
356 line = br.readLine();
357 }
358 br.close();
359
360 }
361
362 }
363
364 pw.close();
365
366 System.out.println("All doc.xml files have been concatenated into output1.xml");
367 }
368 }
369 catch (Exception ex)
370 {
371 ex.printStackTrace();
372 }
373 return null;
374 }
375
376 //end
377 private Item generateItem(String collection, String id)
378 {
379 Item item = new Item(collection, id);
380 String to = GSPath.appendLink(collection, "DocumentMetadataRetrieve");
381 ArrayList<String> tmp = new ArrayList<String>();
382 tmp.add(id);
383
384 UserContext userContext = new UserContext();
385 userContext.setLanguage("en");
386 userContext.setUserID("dumy");
387
388 Element response = getDocumentMetadata(to, userContext, tmp.iterator());
389 Element doc_node = (Element) response.getElementsByTagName(GSXML.DOC_NODE_ELEM).item(0);
390
391 String node_id = doc_node.getAttribute(GSXML.NODE_ID_ATT);
392 Element metadata_list = (Element) doc_node.getElementsByTagName(GSXML.METADATA_ELEM + GSXML.LIST_MODIFIER).item(0);
393
394 //assign title metadata if any
395 Element metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "Title");
396 if (metadata != null)
397 {
398 item.title = GSXML.getNodeText(metadata).trim();
399 }
400 //assign date metadata if any
401 metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "Date");
402 if (metadata != null)
403 {
404 item.date = GSXML.getNodeText(metadata).trim();
405 }
406
407 //assign root title metadata if any
408 metadata = GSXML.getNamedElement(metadata_list, "metadata", "name", "root_Title");
409 if (metadata != null)
410 {
411 String rootTitle = GSXML.getNodeText(metadata).trim();
412 if (!rootTitle.equals(item.title))
413 {
414 item.rootTitle = rootTitle;
415 }
416
417 }
418
419 return item;
420 }
421
422 protected Element processClearDocuments(Element request)
423 {
424 Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
425
426 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
427
428 // Get the parameters of the request
429 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
430
431 if (param_list == null)
432 {
433 logger.error("DocumentBasket Error: DeleteDocument request had no paramList.");
434 return result; // Return the empty result
435 }
436
437 HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
438 String collection = (String) params.get(GSParams.COLLECTION);
439
440 if (collection == null)
441 return result;
442
443 docsMap.put(collection, new Hashtable<String, Item>());
444
445 return result;
446 }
447
448 protected Element processDeleteDocuments(Element request)
449 {
450 Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
451
452 // Create a new (empty) result message
453 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
454
455 // Get the parameters of the request
456 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
457
458 //GSXML.printXMLNode(param_list);
459
460 if (param_list == null)
461 {
462 logger.error("DocumentBasket Error: DeleteDocument request had no paramList.");
463 return result; // Return the empty result
464 }
465
466 HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
467
468 String param = (String) params.get("items");
469
470 if (param == null)
471 return result;
472
473 String[] items = param.split("\\|");
474
475 for (int i = 0; i < items.length; i++)
476 {
477 String item = items[i];
478 if (item.trim().length() == 0)
479 continue;
480
481 String collection = "";
482 int pos = item.indexOf(":");
483 if (pos != -1)
484 {
485 collection = item.substring(0, pos);
486 item = item.substring(pos + 1);
487 }
488
489 if (docsMap.containsKey(collection))
490 {
491 Hashtable itemMap = docsMap.get(collection);
492 if (itemMap.containsKey(item))
493 {
494 itemMap.remove(item);
495 }
496 if (itemMap.size() == 0)
497 {
498 docsMap.remove(collection);
499 }
500 }
501 }
502
503 return result;
504 }
505
506 protected Element processDeleteDocument(Element request)
507 {
508 Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
509
510 // Create a new (empty) result message
511 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
512
513 // Get the parameters of the request
514 Element param_list = (Element) GSXML.getChildByTagName(request, GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
515
516 //GSXML.printXMLNode(param_list);
517
518 if (param_list == null)
519 {
520 logger.error("DocumentBasket Error: DeleteDocument request had no paramList.");
521 return result; // Return the empty result
522 }
523
524 HashMap<String, Serializable> params = GSXML.extractParams(param_list, false);
525
526 String item = (String) params.get("item");
527
528 if (item == null)
529 return result;
530
531 String collection = "";
532 int pos = item.indexOf(":");
533
534 if (pos != -1)
535 {
536 collection = item.substring(0, pos);
537 item = item.substring(pos + 1);
538 }
539
540 if (docsMap.containsKey(collection))
541 {
542 Hashtable itemMap = docsMap.get(collection);
543 if (itemMap.containsKey(item))
544 {
545 itemMap.remove(item);
546 }
547 if (itemMap.size() == 0)
548 {
549 docsMap.remove(collection);
550 }
551 }
552
553 return result;
554 }
555
556 protected Element processGetDocuments(Element request)
557 {
558 // GSXML.printXMLNode(request);
559 Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
560
561 // Create a new (empty) result message
562 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
563
564 int size = 0;
565 String ids = "";
566 Iterator<String> keys = docsMap.keySet().iterator();
567
568 while (keys.hasNext())
569 {
570 Hashtable items = docsMap.get(keys.next());
571 size += items.size();
572 Iterator values = items.values().iterator();
573 while (values.hasNext())
574 {
575 Item item = (Item) values.next();
576 result.appendChild(item.wrapIntoElement());
577 }
578 }
579
580 Element selement = this.doc.createElement("size");
581 selement.setAttribute("value", size + "");
582 result.appendChild(selement);
583
584 return result;
585 }
586
587 private Element getDocumentMetadata(String to, UserContext userContext, Iterator<String> ids)
588 {
589
590 // Build a request to obtain some document metadata
591 Element dm_message = this.doc.createElement(GSXML.MESSAGE_ELEM);
592 Element dm_request = GSXML.createBasicRequest(this.doc, GSXML.REQUEST_TYPE_PROCESS, to, userContext);
593 dm_message.appendChild(dm_request);
594
595 // Create a parameter list to specify the required metadata information
596 HashSet<String> meta_names = new HashSet<String>();
597 meta_names.add("Title"); // the default
598 meta_names.add("root_Title");
599 meta_names.add("Date");
600
601 Element param_list = this.doc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
602
603 Element param = null;
604 Iterator<String> i = meta_names.iterator();
605 while (i.hasNext())
606 {
607 String name = i.next();
608 param = this.doc.createElement(GSXML.PARAM_ELEM);
609 param_list.appendChild(param);
610 param.setAttribute(GSXML.NAME_ATT, "metadata");
611 param.setAttribute(GSXML.VALUE_ATT, name);
612 }
613
614 dm_request.appendChild(param_list);
615
616 // create the doc node list for the metadata request
617 Element dm_doc_list = this.doc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
618 dm_request.appendChild(dm_doc_list);
619
620 while (ids.hasNext())
621 {
622 // Add the documentNode to the list
623 Element dm_doc_node = this.doc.createElement(GSXML.DOC_NODE_ELEM);
624 dm_doc_list.appendChild(dm_doc_node);
625 dm_doc_node.setAttribute(GSXML.NODE_ID_ATT, ids.next());
626 }
627
628 return (Element) this.router.process(dm_message);
629 }
630
631 protected Element processDisplayDocumentList(Element request)
632 {
633 Hashtable<String, Hashtable<String, Item>> docsMap = updateDocMap(request);
634
635 // Create a new (empty) result message
636 Element result = this.doc.createElement(GSXML.RESPONSE_ELEM);
637
638 Iterator<String> keys = docsMap.keySet().iterator();
639
640 while (keys.hasNext())
641 {
642 String collection = keys.next();
643 Hashtable items = docsMap.get(collection);
644 Iterator itemItr = items.values().iterator();
645
646 Element collectionNode = this.doc.createElement("documentList");
647 collectionNode.setAttribute("name", collection);
648 result.appendChild(collectionNode);
649
650 while (itemItr.hasNext())
651 {
652 Item item = (Item) itemItr.next();
653 Element itemElement = this.doc.createElement("item");
654
655 collectionNode.appendChild(itemElement);
656 itemElement.setAttribute("name", item.docid);
657 itemElement.setAttribute("collection", item.collection);
658 itemElement.setAttribute("title", item.title);
659 itemElement.setAttribute("date", item.date);
660 itemElement.setAttribute("root_title", item.rootTitle);
661 }
662 }
663
664 return result;
665 }
666
667 protected class Item
668 {
669 public String collection;
670 public String docid;
671 public String title = "";
672 public String query = "";
673 public String date = "";
674 public String rootTitle = "";
675
676 public Item(String coll, String id)
677 {
678 this.collection = coll;
679 this.docid = id;
680 }
681
682 public boolean equals(Object o)
683 {
684 if (!(o instanceof Item))
685 {
686 return false;
687 }
688
689 Item item = (Item) o;
690 String id = collection + ":" + docid;
691 String idin = item.collection + ":" + item.docid;
692 return id.equals(idin);
693 }
694
695 public String toString()
696 {
697 return collection + ":" + docid + ":" + "[" + ((!rootTitle.equals("")) ? (rootTitle + ":") : "") + title + "]";
698 }
699
700 public Element wrapIntoElement()
701 {
702 Element itemElement = doc.createElement("item");
703 itemElement.setAttribute("name", docid);
704 itemElement.setAttribute("collection", collection);
705 itemElement.setAttribute("title", title);
706 itemElement.setAttribute("date", date);
707 itemElement.setAttribute("root_title", rootTitle);
708 return itemElement;
709 }
710 }
711
712 private class UserTimer extends Timer implements ActionListener
713 {
714 String id = "";
715
716 public UserTimer(int delay, String id)
717 {
718 super(delay, (ActionListener) null);
719 addActionListener(this);
720 this.id = id;
721 }
722
723 public void actionPerformed(ActionEvent e)
724 {
725 userMap.remove(id);
726 timerMap.remove(id);
727 stop();
728 }
729 }
730}
Note: See TracBrowser for help on using the repository browser.