<%@ page language="java" import="java.util.*,java.text.*,java.io.*" %> <%@page import="org.apache.xerces.parsers.*" %> <%@page import="org.w3c.dom.*" %> <%@page import="org.xml.sax.SAXException" %> <%! /***********************************************UNWANTED LINES **********************************************************************************/ final static int DETAIL = 2; final static int CLEAN = 1; final static int NO = 0; int debug = NO; // change this debug flag value to have different debugging levels // the StringTokenizer delimiter String delimiter = " \t\n\r\f~`!@#$%^&*()_-+={}[]|\\:;\"',.?"; String str_error_detail = ""; Vector parseFields(String str_fields) { Vector fields = null; if(str_fields != null && str_fields.length() > 0) { StringTokenizer t_fields = new StringTokenizer( str_fields, ", " ); fields = new Vector(); while(t_fields.hasMoreTokens()) { String key = t_fields.nextToken().toString(); fields.add(key); } } // if(debug >= DETAIL) System.out.println("parse fields:" + fields); return fields; } void setError(String msg) { if ( !str_error_detail.equals("") ) str_error_detail += "
"; str_error_detail += msg; } boolean findExact(String line, String key) { boolean found = false; line=removeHTMLTags(line); StringTokenizer words = new StringTokenizer(line, delimiter); while(words.hasMoreTokens()) { String word = words.nextToken(); if(line.indexOf("href")!=-1) return found; if(indexOf(line, "src=",true) != -1) return found; if(indexOf(line, "title",true) != -1) return found; if(indexOf(line, "window.",true) != -1) return found; if(word.equalsIgnoreCase(key)) { found = true; break; } } return found; } boolean fileFind(String fileName, String key) throws Exception { boolean found = false; BufferedReader file = new BufferedReader(new FileReader(fileName)); try { String line = null; while((line = file.readLine())!= null) { found = find(line, key); if(found == true) break; } } catch (IOException ioe) { throw new Exception("IOException: " + ioe.getMessage()); } finally { file.close(); } return found; } int count(String line, String key) { int count = 0; StringTokenizer words = new StringTokenizer(line, delimiter); while(words.hasMoreTokens()) { String word = words.nextToken(); if(word.equalsIgnoreCase(key)) count++; } return count; } int fileCount(String fileName, String key) throws Exception { int count = 0; BufferedReader file = new BufferedReader(new FileReader(fileName)); try { String line = null; while((line = file.readLine())!= null) { count += count(line, key); } } catch (IOException ioe) { throw new Exception("IOException: " + ioe.getMessage()); } finally { file.close(); } return count; } String getHead(String fileName) throws Exception { StringBuffer entireHead = new StringBuffer(); BufferedReader file = new BufferedReader(new FileReader(fileName)); try { String line = null; boolean startHead = false; boolean endHead = false; while(!endHead && (line = file.readLine())!= null ) { int start = 0; int end = line.length(); int headIndex = indexOf(line, "", true); if( headIndex != -1 ) { start = headIndex + 6; startHead = true; } int endHeadIndex = indexOf(line, "", true); if(endHeadIndex != -1) { end = endHeadIndex; endHead = true; } if(startHead) entireHead.append(line.substring(start, end)); } // if(debug >= DETAIL) System.out.println("head is:" + entireHead); } catch (IOException ioe) { throw new Exception("IOException: " + ioe.getMessage()); } finally { file.close(); } return entireHead.toString(); } String getTitle(String head) { String title = ""; int start = indexOf(head, "", true); int end = indexOf(head, "", true); try { title = head.substring(start+7, end); } catch (IndexOutOfBoundsException ie) { // if(debug >= DETAIL) System.out.println("head without title."); } //if(debug >= DETAIL) System.out.println("Title: " + title); return title; } HashMap getMETA(String head) { HashMap metas = new HashMap(); String left = head; do { int start = indexOf(left, "", start, true); if(start == -1 || end == -1) break; // got all metas String meta = left.substring(start+5, end); if(indexOf(meta, "NAME=", true) != -1 && indexOf(meta, "CONTENT=", true) != -1) { StringTokenizer st = new StringTokenizer(meta, "=\""); String name = null; String content = null; if(st.hasMoreTokens()) { String word = st.nextToken().trim(); if(word.equalsIgnoreCase("NAME")) { if(st.hasMoreTokens()) { name = st.nextToken().trim(); } } if(st.hasMoreTokens()) { String word2 = st.nextToken().trim(); if(word2.equalsIgnoreCase("CONTENT")) { if(st.hasMoreTokens()) { content = st.nextToken().trim(); } } } } if(name != null && content != null) metas.put(name.toUpperCase(), content); } left = left.substring(end); } while (left.length()>0); //if(debug >= DETAIL) System.out.println("META HashMap: " + metas); return metas; } int getPercentageInANDFind (HashMap result) { float count = 0; for(Iterator i = result.values().iterator(); i.hasNext(); ) { Boolean value = (Boolean)i.next(); if(value.booleanValue()== true) count++; } int percentage = Math.round(100*count/result.size()); return percentage; } /*******************************************************************************************************************************************/ /************************************************** COMMON Functions Recursively remove HTML Tags (Supriya) ****************************************************/ String removeHTMLTags(String line) { if(line.indexOf("href")!=-1) return ""; if(line.indexOf("RZ")!=-1) return ""; if(line.indexOf("")==-1)) return line; if(line.indexOf("<")!=-1) { int start=line.indexOf("<"); int end=line.substring(start,line.length()).indexOf(">"); if(end!=-1) end=start+end; else end=line.length(); int length=end-start; String exclude=line.substring(start,end); int excludestart=line.indexOf(exclude); int excludeend=excludestart+length; line=line.substring(0,excludestart)+line.substring(excludeend,line.length()); line=removeHTMLTags(line); } if(line.indexOf(">")==-1) line=line.replaceAll(">",""); return line; } int indexOf(String s, String target, boolean ignoreCase) { return indexOf(s, target, 0, ignoreCase); } int indexOf(String s, String target, int start, boolean ignoreCase) { int index = -1; if(ignoreCase) { String sUpperCase = s.toUpperCase(); String tUpperCase = target.toUpperCase(); index = sUpperCase.indexOf(tUpperCase, start); } else { index = s.indexOf(target, start); } return index; } HashMap constructResult(String filePathName, Integer percentage,Vector keys) throws Exception { String line=returnLine(filePathName,keys); HashMap finalResult = new HashMap(); if((line!=null)&&(line.length()>0)) { finalResult.put("TITLE", line); finalResult.put("PERCENTAGE", percentage); } else { finalResult.put("TITLE", ""); finalResult.put("PERCENTAGE",new Integer(0)); } finalResult.put("DESCRIPTION",""); return finalResult; } HashMap constructResult(String filePathName, Integer percentage,Vector keys,String exact) throws Exception { String line=returnExactLine(filePathName,keys); HashMap finalResult = new HashMap(); if((line!=null)&&(line.length()>0)) { finalResult.put("TITLE", line); finalResult.put("PERCENTAGE", percentage); } else { finalResult.put("TITLE", ""); finalResult.put("PERCENTAGE",new Integer(0)); } finalResult.put("DESCRIPTION",""); return finalResult; } String returnLine(String fileName, Vector keys) throws Exception { boolean bodytagfound=false; BufferedReader file = new BufferedReader(new FileReader(fileName)); String line = ""; try { while((line = file.readLine())!= null) { if(line.toLowerCase().indexOf("349) line=line.substring(startindex-30,line.length()); //line=line.substring(startindex,line.length()); if(line.length()>350) line=line.substring(0,349)+"..."; line=line.replaceAll(" "," "); line=line.replaceAll(">"," "); String nonkeyfontsize="2"; //default non key word size String nonkeyfontcolor="black"; //default non key word color String keyfontsize="2"; //default key word size String keyfontcolor="green"; //default key word color Properties props=new Properties(); try{ props.load(new FileInputStream("../www/revize/util/search.properties")); if(props.getProperty("nonkeyfontsize")!=null) nonkeyfontsize=props.getProperty("nonkeyfontsize"); if(props.getProperty("nonkeyfontcolor")!=null) nonkeyfontcolor=props.getProperty("nonkeyfontcolor"); if(props.getProperty("keyfontsize")!=null) keyfontsize=props.getProperty("keyfontsize"); if(props.getProperty("keyfontcolor")!=null) keyfontcolor=props.getProperty("keyfontcolor"); } catch(Exception ex){} line=""+line+""; for(Iterator iter = keys.iterator(); iter.hasNext();) { String keyed = iter.next().toString().toLowerCase(); line=line.toLowerCase().replaceAll(keyed,(""+keyed+"")); } int filepathindex=fileName.indexOf("revize/"); if(filepathindex!=-1) { fileName=fileName.substring(filepathindex+22,fileName.length()); return line + "["+fileName+"]"; } else return line; } } } } } catch (IOException ioe) { throw new Exception("Exception: " + ioe.getMessage()); } finally { file.close(); } return line; } String returnExactLine (String fileName, Vector keys) throws Exception { boolean bodytagfound=false; BufferedReader file = new BufferedReader(new FileReader(fileName)); String line = null; try { while((line = file.readLine())!= null) { if(line.indexOf("200) line=line.substring(0,199); line=line.replaceAll(">",""); line=line.replaceAll(" "," "); return line; } } } } } catch (IOException ioe) { throw new Exception("Exception: " + ioe.getMessage()); } finally { file.close(); } return ""; } /*************************************************************************************************************************** OR SEARCH RETURNS A HASHMAP OF FILES FOUND, and display text BASED ON KEYS ***************************************************************************************************************************/ HashMap filePathORFind(String filePathName, Vector keys, Vector includes, Vector excludeFiles, Vector excludeDirs, boolean isTop, boolean includeSubDir) throws Exception { HashMap filesFound = new HashMap(); File file = new File(filePathName); if(!file.exists()) throw new Exception("File not exist"); //Recursively digs subdirs till file is found if(file.isDirectory()) { if(excludeDirs == null || !isDirInList(filePathName, excludeDirs)) { if(includeSubDir || isTop) { File[] subFiles = file.listFiles(); for(int i = 0; i < subFiles.length; i++) { HashMap found = filePathORFind(subFiles[i].getAbsolutePath(), keys, includes, excludeFiles, excludeDirs, false, includeSubDir); filesFound.putAll(found); } } } } else if(file.isFile()) { if((includes == null || isFileInList(filePathName, includes) == true) && (excludeFiles == null || isFileInList(filePathName, excludeFiles) == false)) { boolean result = fileORFind(filePathName, keys); if(result == true) { HashMap finalResult = constructResult(filePathName, new Integer(100),keys); filesFound.put(filePathName, finalResult); } } } return filesFound; } boolean fileORFind(String fileName, Vector keys) throws Exception { boolean found = false; boolean bodytagfound=false; BufferedReader file = new BufferedReader(new FileReader(fileName)); try { String line = null; while(!found && (line = file.readLine())!= null) { if(line.toLowerCase().indexOf(" 0) { HashMap finalResult = constructResult(filePathName, percentage,keys); filesFound.put(filePathName, finalResult); } } } return filesFound; } HashMap fileANDFind(String fileName, Vector keys) throws Exception { boolean bodytagfound=false; HashMap found = new HashMap(); initHashMap(found, keys); BufferedReader file = new BufferedReader(new FileReader(fileName)); String line = null; try { while((line = file.readLine())!= null) { if(line.toLowerCase().indexOf("= DETAIL) System.out.println("file name [" + fileName + "] in filter: " + match); return match; } /** * check if the file is listed in the file list * this supports exact file name match and file type match. It does not support wild card match * @param fileName the file name * @param fileList a Vector of file names * @return boolean true if the file is listed in the list */ boolean isFileInList(String fileName, Vector fileList) throws Exception { boolean isInList = false; for(int i = 0; i < fileList.size(); i++) { String match = (String)fileList.elementAt(i); if(match.equals("*.*")) { // all types *.* isInList = true; // if(debug >= DETAIL) System.out.println("file is included in *.*"); break; } else if(match.indexOf("*") == -1) { // exact match xxx.yyy if(fileName.equals(match)) { isInList = true; // if(debug >= DETAIL) System.out.println("file is of exact name " + match); break; } } else if(match.startsWith("*.") && match.lastIndexOf("*") == 0) { // *.yyy String matchFileType = match.substring(2); if(fileName.endsWith(matchFileType)) { isInList = true; // if(debug >= DETAIL) System.out.println("file is of type " + match); break; } } else if(match.startsWith(".") || match.endsWith(".")) { throw new Exception("Error: incorrect file name specified."); } else { // wild card match xxx*yyy.aaa*bbb isInList = wildCardMatchFileName(fileName, match); } } return isInList; } /** * check if the directory is in the directory list * @param dir a directory name * @param dirList a Vector of directory names * @return boolean true if the directory is listed in the list */ boolean isDirInList(String dir, Vector dirList) { boolean isInList = false; dir = dir.replace('/','\\'); for(int i = 0; i < dirList.size(); i++) { String ex = (String)dirList.elementAt(i); ex=ex.replace('/','\\'); if(dir.equals(ex)) { isInList = true; // System.out.println(ex); break; } } // if(debug >= DETAIL) System.out.println("dir is in List [" + dirList + "]: " + isInList); return isInList; } String constructRealPath(String prefixPath, String relativePath) { String realPath = prefixPath; //if(!prefixPath.endsWith(System.getProperty("file.separator"))) // realPath += System.getProperty("file.separator"); //System.out.println(realPath); if(relativePath.startsWith("/") || relativePath.startsWith("\\")) relativePath= relativePath.substring(1); //System.out.println(relativePath); realPath += relativePath; return realPath; } long getNumOfFiles(String dir, boolean isTop, boolean includeSubDir) { long n = 0; File parent = new File(dir); if(parent.isDirectory()) { if(includeSubDir || isTop) { File[] children = parent.listFiles(); for(int i = 0; i < children.length; i++) { n += getNumOfFiles(children[i].getAbsolutePath(), false, includeSubDir); } } } else if(parent.isFile()) { n = 1; } return n; } Vector getNodeVector(HashMap hsh) { Vector nodes = new Vector(); Iterator iter = hsh.keySet().iterator(); while (iter.hasNext()) { Object key = iter.next(); HashMap node = new HashMap(1); node.put(key, hsh.get(key)); nodes.add(node); } return nodes; } void sort(Vector nodes, int low, int high) { int lo_ind = low; int hi_ind = high; //each node of the vector is a hashmap containing only one pair -- //key: file_name, value: another HashMap containing PERCENTAGE/value pair, among other pairs. if (lo_ind >= hi_ind) return; else if (lo_ind == hi_ind - 1) { // sort a two element list by swapping if necessary HashMap lo_node = (HashMap) nodes.get(lo_ind); HashMap lo_node_inner = (HashMap) lo_node.values().iterator().next(); int lo_percent = ((Integer) lo_node_inner.get("PERCENTAGE")).intValue(); HashMap hi_node = (HashMap) nodes.get(hi_ind); HashMap hi_node_inner = (HashMap) hi_node.values().iterator().next(); int hi_percent = ((Integer) hi_node_inner.get("PERCENTAGE")).intValue(); if (lo_percent > hi_percent) { Object node = nodes.get(lo_ind); nodes.set(lo_ind, nodes.get(hi_ind)); nodes.set(hi_ind, node); } return; } //Pick a pivot and move it out of the way int pivot_ind = (lo_ind + hi_ind) / 2; HashMap pivot_node = (HashMap) nodes.get(pivot_ind); HashMap pivot_node_inner = (HashMap) pivot_node.values().iterator().next(); int pivot_percent = ((Integer) pivot_node_inner.get("PERCENTAGE")).intValue(); nodes.set(pivot_ind, nodes.get(hi_ind)); nodes.set(hi_ind, pivot_node); while (lo_ind < hi_ind) { //Search forward from lo until an element is found that //is greater than the pivot or lo >= hi HashMap lo_node = (HashMap) nodes.get(lo_ind); HashMap lo_node_inner = (HashMap) lo_node.values().iterator().next(); int lo_percent = ((Integer) lo_node_inner.get("PERCENTAGE")).intValue(); while (lo_percent <= pivot_percent && lo_ind < hi_ind) { lo_ind++; lo_node = (HashMap) nodes.get(lo_ind); lo_node_inner = (HashMap) lo_node.values().iterator().next(); lo_percent = ((Integer) lo_node_inner.get("PERCENTAGE")).intValue(); } //Search backward from hi until element is found that //is less than the pivot, or lo >= hi HashMap hi_node = (HashMap) nodes.get(hi_ind); HashMap hi_node_inner = (HashMap) hi_node.values().iterator().next(); int hi_percent = ((Integer) hi_node_inner.get("PERCENTAGE")).intValue(); while (pivot_percent <= hi_percent && lo_ind < hi_ind) { hi_ind--; hi_node = (HashMap) nodes.get(hi_ind); hi_node_inner = (HashMap) hi_node.values().iterator().next(); hi_percent = ((Integer) hi_node_inner.get("PERCENTAGE")).intValue(); } //Swap elements lo and hi if (lo_ind < hi_ind) { Object node = nodes.get(lo_ind); nodes.set(lo_ind, nodes.get(hi_ind)); nodes.set(hi_ind, node); } } //Put the median in the "center" of the list nodes.set(high, nodes.get(hi_ind)); nodes.set(hi_ind, pivot_node); sort(nodes, low, lo_ind - 1); sort(nodes, hi_ind + 1, high); } String replaceAll(String inputString, String toReplace, String toSubstitute) { String parsedString = inputString; int startReplaceIndex = parsedString.indexOf(toReplace); while (startReplaceIndex != -1 && startReplaceIndex < parsedString.length()) { parsedString = new StringBuffer(parsedString).replace(startReplaceIndex, startReplaceIndex + toReplace.length(), toSubstitute).toString(); startReplaceIndex = parsedString.indexOf(toReplace, startReplaceIndex + toSubstitute.length()); } return parsedString; } // get text content from xml node String getText(Node node) { // We need to retrieve the text from elements, entity // references, CDATA sections, and text nodes; but not // comments or processing instructions int type = node.getNodeType(); if (type == Node.COMMENT_NODE || type == Node.PROCESSING_INSTRUCTION_NODE) return ""; StringBuffer text = new StringBuffer(); String value = node.getNodeValue(); if (value != null) text.append(value); if (node.hasChildNodes()) { NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { Node child = children.item(i); text.append(getText(child)); } } return text.toString(); } ////////////////////////// end of declarations //////////////////////////// %> <% /***************************************************************************************************** * * * * * JSP SEARCH PROCESSING STARTS HERE * * * * STEP 1 SETUP DEFAULTS * * * ******************************************************************************************************/ // Don't disable cache so back button works after clicking on a link str_error_detail = ""; //clear prior error messages //----- Get search parameters String str_keywords = request.getParameter("RZkeywords"); // search words typed in String str_option = request.getParameter("RZoption"); // OR String str_scope = request.getParameter("RZscope"); // File String str_excludeDirs = request.getParameter("RZexclude_dirs"); // revize,revizelogin,setup,pdm String str_pathOption = request.getParameter("RZpath_option"); // URL String str_subfolders = request.getParameter("RZsubfolders"); // true String str_filenames = request.getParameter("RZfilenames"); // *.htm /***************************************************************************** USELESS JUNK *****************************************************************************/ String str_base_url = request.getParameter("RZbase_url_override"); // EMPTY String str_base_dir = request.getParameter("RZbase_dir_override"); // EMPTY String str_location = request.getParameter("RZlocation_override") == null ? "/" : request.getParameter("RZlocation_override"); //EMPTY String str_excludeFiles = request.getParameter("RZexclude_files"); // EMPTY String str_linkTarget = request.getParameter("RZtarget"); // EMPTY String str_subscope = request.getParameter("RZsubscope"); // EMPTY String str_metaName = request.getParameter("RZmeta_name"); // EMPTY String str_xmlfile = request.getParameter("RZxmlfile"); // EMPTY /*****************************************************************************/ if (str_base_url == null || str_base_url.equals("")) { String requestURL = request.getRequestURL().toString(); int separatorIndex = requestURL.lastIndexOf("/"); if (separatorIndex != -1) str_base_url = requestURL.substring(0, separatorIndex); } if (str_base_dir == null || str_base_dir.equals("") && request.getServletPath() != null) { String servletPath = request.getServletPath(); int separatorIndex = servletPath.lastIndexOf("/"); if (separatorIndex >= 0) servletPath = servletPath.substring(0, separatorIndex); servletPath = replaceAll(servletPath, "/", File.separator); str_base_dir = application.getRealPath("/")+ (servletPath.length() > 1 ? servletPath.substring(1) : ""); } //----- Set Nullable Defaults to Empty Strings if (str_keywords == null) str_keywords = ""; if (str_scope == null) str_scope = ""; if (str_subscope == null) str_subscope = ""; if (str_metaName == null) str_metaName = ""; if (str_option == null) str_option = ""; if (str_pathOption == null) str_pathOption = ""; if (str_base_url == null) str_base_url = ""; if (str_base_dir == null) str_base_dir = ""; if (str_location == null) str_location = ""; if (str_filenames == null) str_filenames = ""; if (str_excludeFiles == null) str_excludeFiles = ""; if (str_excludeDirs == null) str_excludeDirs = ""; if (str_linkTarget == null) str_linkTarget = ""; if (str_subfolders == null) str_subfolders = ""; if (str_xmlfile == null) str_xmlfile = ""; //------ Change File Path separators str_base_url = str_base_url.replace('\\','/'); str_base_dir = str_base_dir.replace('\\','/'); str_location = str_location.replace('\\','/'); str_filenames = str_filenames.replace('\\','/'); str_xmlfile = str_xmlfile.replace('\\','/'); if (str_base_url.length() > 0 && !str_base_url.endsWith("/") ) str_base_url += "/"; if (str_base_dir.length() > 0 && !str_base_dir.endsWith("/") ) str_base_dir += "/"; if (str_location.length() > 0 && !str_location.endsWith("/") ) str_location += "/"; if(str_option.length() == 0) str_option = "AND"; if(str_pathOption.length() == 0) str_pathOption = "URL"; if(str_scope.length() == 0) str_scope = "FILE"; if(str_subscope.length() == 0) str_subscope = "KEYWORDS"; if(str_linkTarget.length() == 0) str_linkTarget = "_self"; //----- Set the subscope if scope is HEAD String subscope = null; if(str_scope.equals("HEAD")) { if(str_subscope.equals("OTHER")) subscope = str_metaName; else subscope = str_subscope; } //----- Set the option to include subfolders or not boolean includeSubDir = true; if(str_subfolders.length() == 0) includeSubDir = false; //----- Set the exact keyword if search option is EXACT String exactKeyword = null; if(str_option.equals("EXACT")) { exactKeyword = str_keywords; if(exactKeyword != null) exactKeyword = exactKeyword.trim(); } String searchPath = null; if(str_location.length() >0) { searchPath = str_location.trim(); if(str_pathOption.toUpperCase().equals("URL")) { if(str_base_dir.length() > 0) { if(searchPath.equals("/") ) //treat as absolute reference searchPath = str_base_dir; else searchPath = str_base_dir + searchPath; } else { setError("Invalid Search Configuration - Base server dir not specified."); searchPath = null; } } } Vector excludeDirs = parseFields(str_excludeDirs); Vector excludeRealDirs = null; if(searchPath != null && excludeDirs != null) { excludeRealDirs = new Vector(); for(int i = 0; i < excludeDirs.size(); i++) { String realPath = constructRealPath(searchPath, (String)excludeDirs.elementAt(i)); if(new File(realPath).exists()) excludeRealDirs.add(realPath); else setError("The excluded directory does not exist: " + realPath); } } String separator = System.getProperty("file.separator"); //----- Create more vectors Vector rawKeywords = parseFields(str_keywords); Vector fileNames = parseFields(str_filenames); Vector excludeFiles = parseFields(str_excludeFiles); /***************************************************************************************************** * * * * * JSP SEARCH PROCESSING STARTS HERE * * * * STEP 2 DEFAULTS READY * * * ******************************************************************************************************/ HashMap finalMatchings = new HashMap(); //System.out.println("Search Path"+ searchPath); if (str_filenames.length()>0 && rawKeywords !=null && searchPath != null ) { /************************************************************************************ * * * EXACT SEARCH STARTS HERE * * * ***********************************************************************************/ if(str_option.equals("EXACT")) { try { finalMatchings = filePathEXACTFind(searchPath, exactKeyword, fileNames, excludeFiles, excludeRealDirs, true, includeSubDir); } catch (Exception e) {} } else { Vector keywords = new Vector(); Vector notKeywords = new Vector(); for(int i = 0; i < rawKeywords.size(); i++) { String key = (String)rawKeywords.elementAt(i); keywords.add(key); } HashMap matchings = null; HashMap matchingsNOT = null; if(keywords.size() > 0) { try { /********************************************************************************** * * * AND SEARCH STARTS HERE * * * ***********************************************************************************/ if(str_option.equals("AND") && str_scope.equals("FILE")) matchings = filePathANDFind(searchPath, keywords, fileNames, excludeFiles, excludeRealDirs, true, includeSubDir); /********************************************************************************** * * * OR SEARCH STARTS HERE * * * ***********************************************************************************/ else if(str_option.equals("OR") && str_scope.equals("FILE")) matchings = filePathORFind(searchPath, keywords, fileNames, excludeFiles, excludeRealDirs, true, includeSubDir); } catch (Exception e) {} } if(matchings != null) finalMatchings.putAll(matchings); } } /***************************************************************************************************** * * * * * JSP SEARCH PROCESSING ENDS HERE * * * * STEP 3 SHOW RESULTS * * * ******************************************************************************************************/ if(finalMatchings != null) { if(str_option.equals("OR") || str_pathOption.equals("URL")) { for(Iterator i = finalMatchings.entrySet().iterator(); i.hasNext(); ) { Map.Entry entry = (Map.Entry)i.next(); String filePathName = (String)entry.getKey(); HashMap result = (HashMap)entry.getValue(); int percentage = ((Integer)result.get("PERCENTAGE")).intValue(); if(str_option.equals("OR")) result.put("PERCENTAGE", new Integer(100)); if(str_pathOption.equals("URL")) { if(str_base_url.length() > 0 && str_base_dir.length() > 0) { String fileURI = filePathName.replace('\\','/'); if( fileURI.indexOf(str_base_dir) != -1 ) fileURI = fileURI.substring(str_base_dir.length()); String fileURL = str_base_url + fileURI; result.put("URL", fileURL); } } } } } Vector sortedMatchings = getNodeVector(finalMatchings); if(str_option.equals("AND")) sort(sortedMatchings, 0, sortedMatchings.size() - 1); //if (str_keywords == null || str_keywords.equals("")) // str_keywords = "** No search keywords **"; /***************************************************************************************************/ //test %>