source: main/trunk/greenstone3/src/java/org/greenstone/gsdl3/core/URLFilter.java@ 33387

Last change on this file since 33387 was 33387, checked in by kjdon, 5 years ago

removed all my debug statements

  • Property svn:executable set to *
File size: 23.5 KB
Line 
1package org.greenstone.gsdl3.core;
2
3import java.io.File;
4import java.io.IOException;
5import java.util.ArrayList;
6import java.util.Arrays;
7import java.util.HashMap;
8import java.util.Hashtable;
9import java.util.Map;
10
11import javax.servlet.Filter;
12import javax.servlet.FilterChain;
13import javax.servlet.FilterConfig;
14import javax.servlet.ServletContext;
15import javax.servlet.ServletException;
16import javax.servlet.ServletOutputStream;
17import javax.servlet.ServletRequest;
18import javax.servlet.ServletResponse;
19import javax.servlet.http.HttpSession;
20import javax.servlet.http.HttpServletRequest;
21import javax.servlet.http.HttpServletRequestWrapper;
22import javax.servlet.http.HttpServletResponse;
23
24import java.awt.event.ActionEvent;
25import java.awt.event.ActionListener;
26import javax.swing.Timer;
27
28import org.apache.commons.io.FileUtils;
29import org.apache.commons.lang3.StringUtils;
30
31import org.apache.log4j.Logger;
32import org.greenstone.gsdl3.util.GSParams;
33import org.greenstone.gsdl3.util.GSPath;
34import org.greenstone.gsdl3.util.GSXML;
35import org.greenstone.gsdl3.util.UserContext;
36import org.greenstone.gsdl3.util.XMLConverter;
37import org.greenstone.gsdl3.service.Authentication;
38import org.w3c.dom.Document;
39import org.w3c.dom.Element;
40import org.w3c.dom.NodeList;
41
42public class URLFilter implements Filter
43{
44 private FilterConfig _filterConfig = null;
45 private static Logger logger = Logger.getLogger(org.greenstone.gsdl3.core.URLFilter.class.getName());
46
47 //Restricted URLs
48 protected static final String SITECONFIG_URL = "sites/[^/]+/siteConfig.xml";
49 protected static final String USERS_DB_URL = "etc/usersDB/.*";
50 protected static final ArrayList<String> _restrictedURLs;
51 static
52 {
53 ArrayList<String> restrictedURLs = new ArrayList<String>();
54 restrictedURLs.add(SITECONFIG_URL);
55 restrictedURLs.add(USERS_DB_URL);
56 _restrictedURLs = restrictedURLs;
57 }
58
59 //Constants
60 protected static final String DOCUMENT_PATH = "document";
61 protected static final String COLLECTION_PATH = "collection";
62 protected static final String GROUP_PATH = "group";
63 protected static final String PAGE_PATH = "page";
64 protected static final String SYSTEM_PATH = "system";
65 protected static final String BROWSE_PATH = "browse";
66 protected static final String SEARCH_PATH = "search";
67
68 protected static final String METADATA_RETRIEVAL_SERVICE = "DocumentMetadataRetrieve";
69 protected static final String ASSOCIATED_FILE_PATH = "/index/assoc/";
70 protected static final String COLLECTION_FILE_PATH = "/collect/";
71 protected static final String INTERFACE_PATH = "/interfaces/";
72 protected static final String SITES_PATH = "/sites/";
73
74 protected static final String SYSTEM_SUBACTION_CONFIGURE = "configure";
75 protected static final String SYSTEM_SUBACTION_RECONFIGURE = "reconfigure";
76 protected static final String SYSTEM_SUBACTION_ACTIVATE = "activate";
77 protected static final String SYSTEM_SUBACTION_DEACTIVATE = "deactivate";
78
79 // if we are showing terms and conditions to user, this remembers who has
80 // accepted already
81 protected Hashtable<String, UserTimer> verifiedUserMap = null;
82 protected static final int verifiedUserTimeout = 24 * 60 * 60 * 1000;
83
84 public void init(FilterConfig filterConfig) throws ServletException
85 {
86 this._filterConfig = filterConfig;
87 }
88
89 public void destroy()
90 {
91 this._filterConfig = null;
92 }
93
94 @SuppressWarnings("deprecation")
95 public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException
96 {
97 if (!(request instanceof HttpServletRequest)) {
98 // Can this ever happen?
99 logger.error("The request was not an HttpServletRequest");
100 return;
101 }
102
103
104 HttpServletRequest hRequest = ((HttpServletRequest) request);
105 HttpSession hSession = hRequest.getSession();
106 ServletContext context = hSession.getServletContext();
107
108 GSHttpServletRequestWrapper gRequest = new GSHttpServletRequestWrapper(hRequest);
109
110 // this is the part before the ?
111 String url = hRequest.getRequestURI().toString();
112 if (isURLRestricted(url)) {
113
114 // TODO - should we make this a proper HTML page?
115 response.getWriter().println("ERROR: Access to this page is forbidden.");
116 return;
117 }
118
119 // Run security checks on files requested from a collection's index/assoc folder
120 if (url.contains(ASSOCIATED_FILE_PATH)) {
121 // we need to do security checking here in case the documents are private
122 // or if there is a terms and conditions page to be shown.
123 // Also, assoc files urls now contain the library name in them.
124 // e.g. greenstone3/library/sites/localsite/collect/collname/index/assoc/Hashxxx/doc.pdf
125 // so they are not a true link to a file. We remove the
126 // 'library' then forward the request to the new url.
127 securityCheckAssocFiles(url, hRequest, response);
128 return;
129 }
130
131 // if we are asking for an interface file, and it doesn't exist, then
132 // try loading up the interfaceConfig file to find out what the base
133 // interface was, then try looking in that interface for the file.
134 if (url.contains(INTERFACE_PATH))
135 {
136 String fileURL = url.replaceFirst(context.getContextPath(), "");
137 File requestedFile = new File(context.getRealPath(fileURL));
138
139 if (!requestedFile.exists()) {
140 String baseURL = getFileInBaseInterface(fileURL, context);
141 if (baseURL != null) {
142 File baseInterfaceFile = new File(context.getRealPath(baseURL));
143 if (baseInterfaceFile.exists()) {
144 request.getRequestDispatcher(baseURL).forward(request, response);
145 // ServletOutputStream out = response.getOutputStream();
146 // out.write(FileUtils.readFileToByteArray(baseInterfaceFile));
147 // out.flush();
148 // out.close();
149 return;
150 }
151 }
152 }
153 }
154 else
155 {
156 ArrayList<String> keywords = new ArrayList<String>();
157 keywords.add(PAGE_PATH);
158 keywords.add(BROWSE_PATH);
159 keywords.add(SEARCH_PATH);
160 keywords.add(DOCUMENT_PATH);
161 //If we have a jsessionid on the end of our URL we want to ignore it
162 int index;
163 if ((index = url.indexOf(";jsessionid")) != -1)
164 {
165 url = url.substring(0, index);
166 }
167 String[] segments = url.split("/");
168 for (int i = 0; i < segments.length; i++)
169 {
170 String[] additionalParameters = null;
171 String[] defaultParamValues = null;
172 //COLLECTION
173 if (segments[i].equals(COLLECTION_PATH) && (i + 1) < segments.length) {
174 int j=i+1;
175 while(j+1 < segments.length && !keywords.contains(segments[j+1])) {
176 j++;
177 }
178
179 if (j>i+1) {
180 // we had a group part
181 String [] groups = Arrays.copyOfRange(segments, i+1, j);
182 String group = StringUtils.join(groups, "/");
183 gRequest.setParameter(GSParams.GROUP, group);
184 }
185 gRequest.setParameter(GSParams.COLLECTION, segments[j]);
186 }
187 // GROUP
188 else if(segments[i].equals(GROUP_PATH) && (i + 1) < segments.length)
189 {
190 // assume for now, no other path parts for group links
191 int j= segments.length - 1;
192 String group;
193 if (j==i+1) {
194 group = segments[j];
195 } else {
196 String [] groups = Arrays.copyOfRange(segments, i+1, j+1);
197 group = StringUtils.join(groups, "/");
198 }
199 gRequest.setParameter(GSParams.GROUP, group);
200 gRequest.setParameter(GSParams.ACTION, "p");
201 gRequest.setParameter(GSParams.SUBACTION, "home");
202
203 }
204 //DOCUMENT
205 else if (segments[i].equals(DOCUMENT_PATH) && (i + 1) < segments.length)
206 {
207 gRequest.setParameter(GSParams.DOCUMENT, segments[i + 1]);
208
209 additionalParameters = new String[] { GSParams.ACTION };
210 defaultParamValues = new String[] { "d" };
211 if ((i+2) < segments.length && segments[i+2].equals("print")) {
212 gRequest.setParameter(GSParams.SUBACTION, "print");
213 gRequest.setParameter("ed", "1");
214
215 }
216
217 }
218 //PAGE
219 else if (segments[i].equals(PAGE_PATH) && (i + 1) < segments.length)
220 {
221 gRequest.setParameter(GSParams.SUBACTION, segments[i + 1]);
222
223 additionalParameters = new String[] { GSParams.ACTION };
224 defaultParamValues = new String[] { "p" };
225 }
226 //SYSTEM
227 else if (segments[i].equals(SYSTEM_PATH) && (i + 1) < segments.length)
228 {
229 String sa = segments[i + 1];
230 if (sa.equals(SYSTEM_SUBACTION_CONFIGURE) || sa.equals(SYSTEM_SUBACTION_RECONFIGURE))
231 {
232 sa = "c";
233 }
234 else if (sa.equals(SYSTEM_SUBACTION_ACTIVATE))
235 {
236 sa = "a";
237 }
238 else if (sa.equals(SYSTEM_SUBACTION_DEACTIVATE))
239 {
240 sa = "d";
241 }
242
243 if (sa.equals("c") && (i + 2) < segments.length)
244 {
245 gRequest.setParameter(GSParams.SYSTEM_CLUSTER, segments[i + 2]);
246 }
247
248 if (sa.equals("a") && (i + 2) < segments.length)
249 {
250 gRequest.setParameter(GSParams.SYSTEM_MODULE_TYPE, "collection");
251 gRequest.setParameter(GSParams.SYSTEM_MODULE_NAME, segments[i + 2]);
252 }
253
254 if (sa.equals("d") && (i + 2) < segments.length)
255 {
256 gRequest.setParameter(GSParams.SYSTEM_CLUSTER, segments[i + 2]);
257 }
258
259 gRequest.setParameter(GSParams.SUBACTION, sa);
260
261 additionalParameters = new String[] { GSParams.ACTION };
262 defaultParamValues = new String[] { "s" };
263 }
264 //ADMIN
265 else if (segments[i].equals("admin") && (i + 1) < segments.length)
266 {
267 String pageName = segments[i + 1];
268
269 gRequest.setParameter("s1.authpage", pageName);
270
271 additionalParameters = new String[] { GSParams.ACTION, GSParams.REQUEST_TYPE, GSParams.SUBACTION, GSParams.SERVICE };
272 defaultParamValues = new String[] { "g", "r", "authen", "Authentication" };
273 }
274 //BROWSE
275 else if (segments[i].equals(BROWSE_PATH) && (i + 1) < segments.length)
276 {
277 String cl = "";
278 for (int j = 1; (i + j) < segments.length; j++)
279 {
280 String currentSegment = segments[i + j].replace("CL", "").replace("cl", "");
281 if (currentSegment.contains("."))
282 {
283 String[] subsegments = currentSegment.split("\\.");
284 for (String subsegment : subsegments)
285 {
286 subsegment = subsegment.replace("CL", "").replace("cl", "");
287
288 if (cl.length() > 0)
289 {
290 cl += ".";
291 }
292
293 if (subsegment.length() > 0)
294 {
295 cl += subsegment;
296 }
297 }
298 continue;
299 }
300 if (!currentSegment.matches("^(CL|cl)?\\d+$"))
301 {
302 continue;
303 }
304
305 if (cl.length() > 0)
306 {
307 cl += ".";
308 }
309
310 cl += currentSegment;
311 }
312
313 gRequest.setParameter("cl", "CL" + cl);
314
315 additionalParameters = new String[] { GSParams.ACTION, GSParams.REQUEST_TYPE, GSParams.SERVICE };
316 defaultParamValues = new String[] { "b", "s", "ClassifierBrowse" };
317 }
318 //QUERY
319 else if (segments[i].equals(SEARCH_PATH))
320 {
321 String serviceName = "";
322 if ((i + 1) < segments.length)
323 {
324 serviceName = segments[i + 1];
325 gRequest.setParameter("s", serviceName);
326
327 additionalParameters = new String[] { GSParams.ACTION, GSParams.SUBACTION, GSParams.REQUEST_TYPE };
328 defaultParamValues = new String[] { "q", "", "d" };
329 }
330 if ((i + 2) < segments.length)
331 {
332 if (serviceName.equals("TextQuery") || serviceName.equals("RawQuery"))
333 {
334
335 gRequest.setParameter("s1.query", segments[i + 2]);
336 }
337 else if (serviceName.equals("FieldQuery"))
338 {
339 gRequest.setParameter("s1.fqv", segments[i + 2]);
340 }
341 else if (serviceName.equals("AdvancedFieldQuery"))
342 {
343 gRequest.setParameter("s1.fqv", segments[i + 2]);
344 }
345 }
346 }
347 if (additionalParameters != null)
348 {
349 for (int j = 0; j < additionalParameters.length; j++)
350 {
351 if (gRequest.getParameter(additionalParameters[j]) == null)
352 {
353 gRequest.setParameter(additionalParameters[j], defaultParamValues[j]);
354 }
355 }
356 }
357 }
358 }
359
360 chain.doFilter(gRequest, response);
361 }
362
363 private boolean isURLRestricted(String url)
364 {
365 for (String restrictedURL : _restrictedURLs)
366 {
367 if (url.matches(".*" + restrictedURL + ".*"))
368 {
369 return true;
370 }
371 }
372
373 return false;
374 }
375
376 private String getFileInBaseInterface(String fileURL, ServletContext context) {
377 int interfaceNameStart = fileURL.indexOf(INTERFACE_PATH) + INTERFACE_PATH.length();
378 int interfaceNameEnd = fileURL.indexOf("/", interfaceNameStart);
379 String interfaceName = fileURL.substring(interfaceNameStart, interfaceNameEnd);
380 String interfacesDir = fileURL.substring(0, interfaceNameStart);
381 File interfaceConfigFile = new File(context.getRealPath(interfacesDir + interfaceName + "/interfaceConfig.xml"));
382
383 if (interfaceConfigFile.exists()) {
384
385 Document interfaceConfigDoc = XMLConverter.getDOM(interfaceConfigFile);
386
387 String baseInterface = interfaceConfigDoc.getDocumentElement().getAttribute("baseInterface");
388 if (baseInterface.length() > 0)
389 {
390 return fileURL.replace("/" + interfaceName + "/", "/" + baseInterface + "/");
391 }
392 }
393 return null;
394 }
395
396
397 private void securityCheckAssocFiles(String url, HttpServletRequest request, ServletResponse response) throws IOException, ServletException {
398 HttpSession session = request.getSession();
399 String session_id = session.getId();
400 ServletContext context = session.getServletContext();
401
402 // now we need to get library name from the path, which is like
403 // /greenstone3/library/sites/localsite/collect/collname/index/assoc/...
404 String library_name = url.replaceFirst(context.getContextPath(), "");
405 library_name = library_name.substring(0, library_name.indexOf(SITES_PATH));
406 if (library_name.equals("")) {
407 response.getWriter().println("ERROR: Assoc file paths must now contain the library name");
408 return;
409 }
410 // remove initial '/'
411 library_name = library_name.substring(1);
412
413 MessageRouter gsRouter = (MessageRouter) context.getAttribute(library_name+"Router");
414
415 if (gsRouter == null) {
416 logger.error("Receptionist is null, stopping filter");
417 return;
418 }
419 // Sometimes we have a // before the filename - that mucks up the following code, so lets remove them
420 url = url.replaceAll("//","/");
421
422 String dir = null;
423 int dirStart = url.indexOf(ASSOCIATED_FILE_PATH) + ASSOCIATED_FILE_PATH.length();
424 int dirEnd = -1;
425 if (dirStart < url.length() && url.indexOf("/", dirStart) != -1)
426 {
427 dirEnd = url.lastIndexOf("/");
428 }
429 if (dirEnd != -1)
430 {
431 dir = url.substring(dirStart, dirEnd);
432 }
433 if (dir == null)
434 {
435 return;
436 }
437
438 String collection = null;
439 int colStart = url.indexOf(COLLECTION_FILE_PATH) + COLLECTION_FILE_PATH.length();
440 int colEnd = -1;
441 if (colStart < url.length() && url.indexOf("/", colStart) != -1)
442 {
443 colEnd = url.indexOf("/", colStart);
444 }
445 if (colEnd != -1)
446 {
447 collection = url.substring(colStart, colEnd);
448 }
449 if (collection == null)
450 {
451 return;
452 }
453
454 String file_name = url.substring(url.lastIndexOf("/")+1);
455
456
457
458 // Query the MR with a request for the contains metadata for node "dir" - where dir is the assocfilepath
459 // In the jdbm db, have entries like
460 // [HASH1552e]
461 // <contains>HASH1552e3sdlkjf7sdfsdfk
462 // mapping assocfilepath to doc id
463 String document = queryMRforDOCID(gsRouter, collection, dir);
464 if (document == null) {
465 response.getWriter().println("ERROR: Couldn't find the document associated with assocfilepath: "+dir);
466 return;
467 }
468
469 //Query the MR for the security info for this document - can we show it? Or do we need to be logged in?
470 // Or do we need to throw up the verify page?
471
472 // While we are doing this, query the document for its srclinkFile metadata - then we can determine if the
473 // file we are being asked for is the main doc (eg pdf) or just a supporting image on the page
474
475 //Get the security info for this collection
476 Document gsDoc = XMLConverter.newDOM();
477 Element securityMessage = gsDoc.createElement(GSXML.MESSAGE_ELEM);
478 Element securityRequest = GSXML.createBasicRequest(gsDoc, GSXML.REQUEST_TYPE_SECURITY, collection, new UserContext());
479
480 securityMessage.appendChild(securityRequest);
481 securityRequest.setAttribute(GSXML.NODE_OID, document);
482
483 // get the srclinkFile for the document
484 Element metadata_request = GSXML.createBasicRequest(gsDoc, GSXML.REQUEST_TYPE_PROCESS, GSPath.appendLink(collection, "DocumentMetadataRetrieve"), new UserContext());
485 Element param_list = gsDoc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
486 GSXML.addParameterToList(param_list, "metadata", "srclinkFile");
487 metadata_request.appendChild(param_list);
488 Element doc_list = gsDoc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
489 metadata_request.appendChild(doc_list);
490 Element d = gsDoc.createElement(GSXML.DOC_NODE_ELEM);
491 d.setAttribute(GSXML.NODE_ID_ATT, document);
492 doc_list.appendChild(d);
493 securityMessage.appendChild(metadata_request);
494
495
496 Element mr_response = (Element)gsRouter.process(securityMessage);
497 //logger.debug("security response = "+XMLConverter.getPrettyString(mr_response));
498
499 boolean verifiable_file = true;
500 // TODO check for errors
501
502 Element meta_response = (Element) GSXML.getNamedElement(mr_response, GSXML.RESPONSE_ELEM, GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_PROCESS);
503 Element metadata_list = (Element)meta_response.getElementsByTagName(GSXML.METADATA_ELEM+GSXML.LIST_MODIFIER).item(0);
504 String srcdoc = GSXML.getMetadataValue(metadata_list, "srclinkFile");
505 if (!srcdoc.equals(file_name)) {
506 // the specified file is just a supporting file, not the main file.
507 // eg an image in an html doc.
508 verifiable_file = false;
509 }
510
511 Element securityResponse = (Element) GSXML.getNamedElement(mr_response, GSXML.RESPONSE_ELEM, GSXML.TYPE_ATT, GSXML.REQUEST_TYPE_SECURITY);
512 ArrayList<String> groups = GSXML.getGroupsFromSecurityResponse(securityResponse);
513
514 if (!groups.contains(""))
515 {
516 boolean found = false;
517 for (String group : groups)
518 {
519 if (((HttpServletRequest) request).isUserInRole(group))
520 {
521 found = true;
522 break;
523 }
524 }
525
526 if (!found)
527 {
528 // return an error page to the browser
529 String new_url = context.getContextPath()+"/"+ library_name+"?a=p&sa=error&c="+collection+"&ec=wrong_group";
530 ((HttpServletResponse)response).sendRedirect(new_url);
531 return;
532 }
533 }
534 // if got here have no groups that we need to belong to
535 // do we have human verify thing?
536 if (verifiable_file) {
537 String verify = securityResponse.getAttribute(GSXML.VERIFY_ATT);
538 if (!verify.equals("")) {
539 // we are asking for the main document, and we have been asked to verify the user
540 // have we done the test previously?
541 boolean already_verified = false;
542 String hmvf_response = request.getParameter(GSParams.VERIFIED);
543 if (hmvf_response != null && hmvf_response.equals("0")) {
544 // manually force the t&c (user has added hmvf=0 to url)
545 } else if (verify.equals("once")) {
546 // lets check whether they have done it already
547
548 if (verifiedUserMap == null) {
549 // we haven't done this at all, set up the map
550 verifiedUserMap = new Hashtable<String, UserTimer>();
551 } else {
552 // check this map
553 if (verifiedUserMap.containsKey(session_id)) {
554 already_verified = true;
555 }
556 }
557 }
558
559 if (!already_verified) {
560 // have we just done the test?
561 // hmvf param will be set by form if the verify page was submitted
562 if (hmvf_response != null && hmvf_response.equals("1")) {
563 if (!securityResponse.getAttribute(GSXML.SITE_KEY_ATT).equals("")) {
564 String recaptcha_response = request.getParameter(Authentication.RECAPTCHA_RESPONSE_PARAM);
565 String secret_key = securityResponse.getAttribute(GSXML.SECRET_KEY_ATT);
566 int result = Authentication.verifyRecaptcha(secret_key, recaptcha_response);
567 if (result == Authentication.NO_ERROR) {
568 already_verified = true;
569
570 } else {
571 logger.error("something went wrong with recaptcha, error="+result);
572 logger.error(Authentication.getErrorKey(result));
573 // display error page
574 String new_url = context.getContextPath()+"/"+ library_name+"?a=p&sa=error&c="+collection+"&ec=recap_fail";
575 ((HttpServletResponse)response).sendRedirect(new_url);
576
577 return;
578 }
579
580
581
582 }
583 already_verified = true;
584 if (verify.equals("once")) {
585 // store the fact that user has verified
586 UserTimer timer = new UserTimer(verifiedUserTimeout, session_id);
587 verifiedUserMap.put(session_id, timer);
588 timer.start();
589 }
590 } // hmvf = 1
591 }
592
593 if (!already_verified) {
594 // hmvf param is not set - we haven't shown them the form yet
595 // or we have been asked to force the T&C
596 // we need to display the verify page
597 String new_url = context.getContextPath()+"/"+ library_name+"?a=p&sa=verify&c="+collection+"&url="+url;
598 ((HttpServletResponse)response).sendRedirect(new_url);
599 return;
600 }
601 } // end verify is set
602 }// end if verifiable file
603
604
605 // if we got here, we have passed all security checks and just want to view the file.
606 // However, we need to remove the library_name from the URL. As can't change the
607 // existing URL, we need to forward to the new one.
608 // (Can't do redirect as it will come back into this code and fail as there won't be library in the url)
609 // Remove the context and library name parts.
610 // don't know what happens with the rest of the filter chain? Does this bypass that??
611 url = url.replaceFirst(context.getContextPath(), "");
612 url = url.replaceFirst("/"+library_name, "");
613 request.getRequestDispatcher(url).forward(request, response);
614
615 return;
616 }
617
618
619
620
621 private String queryMRforDOCID(MessageRouter gsRouter, String collection, String assocfiledir) {
622 Document gsDoc = XMLConverter.newDOM();
623
624 Element metaMessage = gsDoc.createElement(GSXML.MESSAGE_ELEM);
625 Element metaRequest = GSXML.createBasicRequest(gsDoc, GSXML.REQUEST_TYPE_PROCESS, collection + "/" + METADATA_RETRIEVAL_SERVICE, new UserContext());
626 metaMessage.appendChild(metaRequest);
627
628 Element paramList = gsDoc.createElement(GSXML.PARAM_ELEM + GSXML.LIST_MODIFIER);
629 metaRequest.appendChild(paramList);
630
631 Element param = gsDoc.createElement(GSXML.PARAM_ELEM);
632 param.setAttribute(GSXML.NAME_ATT, "metadata");
633 param.setAttribute(GSXML.VALUE_ATT, "contains");
634 paramList.appendChild(param);
635
636 Element docList = gsDoc.createElement(GSXML.DOC_NODE_ELEM + GSXML.LIST_MODIFIER);
637 metaRequest.appendChild(docList);
638
639 Element doc = gsDoc.createElement(GSXML.DOC_NODE_ELEM);
640 doc.setAttribute(GSXML.NODE_ID_ATT, assocfiledir);
641 docList.appendChild(doc);
642
643 Element metaResponse = (Element) gsRouter.process(metaMessage);
644
645 NodeList metadataList = metaResponse.getElementsByTagName(GSXML.METADATA_ELEM);
646 if (metadataList.getLength() == 0) {
647
648 logger.error("Could not find the document ID related to this url");
649 return null;
650 }
651
652 Element metadata = (Element) metadataList.item(0);
653 String document = metadata.getTextContent();
654 if (document != null && document.equals("")) {
655 document = null;
656 }
657 return document;
658
659
660 }
661
662 private class UserTimer extends Timer implements ActionListener
663 {
664 String id = "";
665
666 public UserTimer(int delay, String id)
667 {
668 super(delay, (ActionListener) null);
669 addActionListener(this);
670 this.id = id;
671 }
672
673 public void actionPerformed(ActionEvent e)
674 {
675 verifiedUserMap.remove(id);
676 stop();
677 }
678
679 }
680
681
682}
Note: See TracBrowser for help on using the repository browser.