--- /dev/null
+//{{SERVLET_IMPORT_STMTS\r\r
+package FAQ_Factory.TaggingDriver;\r\r
+import versata.vfc.html.*;\r\r
+import versata.vfc.html.servlet.*;\r\r
+import versata.vfc.html.common.*;\r\r
+import versata.common.*;\r\r
+import versata.vls.*;\r\r
+import java.util.*;\r\r
+import java.math.BigDecimal;\r\r
+import java.io.*;\r\r
+import javax.servlet.*;\r\r
+import javax.servlet.http.*;\r\r
+import java.rmi.RemoteException;\r\r
+\r\r
+//END_SERVLET_IMPORT_STMTS}}\r\r
+import support.*;\r
+\r\r
+//{{SERVLET_CLASS_DECL\r\r
+public class TaggingDriverServlet extends TaggingDriverBaseServlet\r\r
+//END_SERVLET_CLASS_DECL}}\r\r
+{\r\r
+ JustAskConstants constants = new JustAskConstants();\r
+ //private static final String[] legalImageExtensions = \r
+ // new String[] { ".bmp", ".emf", ".gif", ".jpg", ".pcx", ".psp", ".tif", ".tiff", ".wmf", ".wpg" };\r
+ //private static final String[] legalFileExtensions = \r
+ // new String[] { ".doc", ".htm", ".pdf", ".txt" };\r
+ // TaggingDriverServlet Class Constructor\r\r
+ //{{SERVLET_CLASS_CTOR\r\r
+ public TaggingDriverServlet ()\r\r
+ //END_SERVLET_CLASS_CTOR}}\r\r
+ {\r\r
+ super();\r\r
+ }\r\r
+ \r\r
+ public void loadLoginPage(boolean failed, HttpServletResponse res, HttpServletRequest req, String msg)\r\r
+ throws IOException \r\r
+ {\r\r
+ //{{SERVLET_LOADLOGINPAGE\r\r
+ // Load login page. If previous attempt failed, load page with failed message.\r\r
+ // This method will be generated in gen'd servlet and user can\r\r
+ // add code for custom login there, or it can be gen'd to supress login\r\r
+ super.loadLoginPage(failed, res, req,msg);\r\r
+ PrintWriter toClient = res.getWriter();\r\r
+ String params = req.getQueryString();\r\r
+ \r\r
+ //END_SERVLET_LOADLOGINPAGE}}\r\r
+ }\r\r
+\r\r
+\r\r
+ public String getFileLocation()\r\r
+ {\r\r
+ return getDefaultFileLocation();\r\r
+ \r\r
+ }\r\r
+\r\r
+ public String getBaseURL(HttpServletRequest req, String packageName, String clientAppName)\r\r
+ {\r\r
+ return super.getBaseURL(req, packageName, clientAppName);\r\r
+ }\r\r
+ public String getServletURL(HttpServletRequest req)\r\r
+ {\r\r
+ return HttpUtils.getRequestURL(req).toString();\r\r
+ \r\r
+ }\r\r
+\r\r
+ public PLSORBSession doLogin(HttpServletRequest req)\r\r
+ throws TierSessionLimitException, RemoteException\r\r
+ {\r\r
+ return doDefaultLogin(req);\r\r
+ }\r\r
+\r\r
+ public void loadStartPage()\r\r
+ {\r\r
+ // Right now, this is done by calling session.start, which calls app.start.\r\r
+ // We may want this here for the case when developer wants to customize.\r\r
+ }\r
+ \r
+///////////////////////////////////////////////////////////////////\r\r
+ // This method handles the POST'ing of form data.\r\r
+ // This is for the purpose of allowing users to have INPUT controls\r\r
+ // of type FILE. When a form contains such a control, the data must be\r\r
+ // posted in multipart format, which Jade does not handle by default.\r\r
+ // The strategy is to catch the POST. If it is a regular post, just pass\r\r
+ // it to super. \r\r
+ // If it is a multipart post, we parse the binary stream and build a new\r\r
+ // HttpServletRequest containing all the parameters except of course\r\r
+ // the contents of the files, and submit that request to super.\r\r
+ //\r\r
+ // Remember that this method is invoked for every post, i.e. anytime the\r\r
+ // user clicks any button. Since we typically want special action only\r\r
+ // for a save, we look at the query_string parameter to determine whether\r\r
+ // the query is a save query. If it's not, we ignore all the file-related\r\r
+ // fields.\r\r
+ //\r\r
+ // The form can have any number of FILE inputs. For each such input, this\r\r
+ // will read the file into a temporary file. The name of that temporary file\r\r
+ // will be put in a field whose is that of the FILE input with "_ServerFileName"\r\r
+ // appended. The name of the file on the client will be put in a field whose\r\r
+ // name is that of the FILE input with "_ClientFileName" appended.\r\r
+ //\r\r
+ // Note that there is no way (apparently) to set the value of a FILE input,\r\r
+ // which is why the client-side file name is returned in a separate field.\r\r
+ public void doPost(javax.servlet.http.HttpServletRequest req,\r\r
+ javax.servlet.http.HttpServletResponse res)\r\r
+ throws javax.servlet.ServletException,\r\r
+ java.io.IOException\r\r
+ {\r
+ String contentType = req.getContentType();\r\r
+ //String postedOrgID = "didntgetit";\r\r
+ //boolean gotStartOfOrg = false;\r\r
+ // If this is a regular POST, let super handle it\r\r
+ if(contentType.startsWith("application/x-www-form-urlencoded"))\r\r
+ {\r\r
+ super.doPost(req, res);\r\r
+ return;\r\r
+ }\r\r
+ // If it's not a regular post, it better be multipart\r\r
+ if( ! contentType.startsWith("multipart/form-data"))\r\r
+ {\r\r
+ throw new ServletException("POST content type was neither "\r\r
+ + "application/x-www-form-urlencoded nor "\r\r
+ + "multipart/form-data, which is impossible");\r\r
+ }\r\r
+ // Figure out the directory where the images are placed\r
+ String tmpDir = constants.getImageDir();\r
+// String tmpDir = "C:\\Program Files\\Vision\\Jade4.1\\JWS\\public_html\\FAQ_Factory\\FAQ\\images\\";\r\r
+ System.err.println("**Temporary dir is : " + tmpDir);\r\r
+ // First read the separator from the contentType, which looks\r\r
+ // like "multipart/form-data; boundary=---------------------------7cf3065520250"\r\r
+ // Be careful : the number of dashes is not exactly as shown in the\r\r
+ // contentType, it actually has two more\r\r
+ int sepIndex = contentType.lastIndexOf('=');\r\r
+ if(sepIndex == -1)\r\r
+ throw new ServletException("Multipart POST does not have " +\r\r
+ "a valid contentType");\r\r
+ String separator = contentType.substring(sepIndex + 1);\r\r
+ if( ! separator.startsWith("----------"))\r\r
+ throw new ServletException("Multipart POST contentType "\r\r
+ + "does not have a valid separator");\r\r
+ separator = "--" + separator;\r\r
+ System.out.println("***Separator is : " + separator);\r\r
+ // We store the name and value of all the parameters in this\r\r
+ // hashtable, which is then given to the FileServletRequest.\r\r
+ Hashtable reqHash = new Hashtable();\r\r
+ // Read the total length of the binary stream, we'll use that\r\r
+ // to make sure we're reading the right amount.\r\r
+ // Note : this can be -1 in some cases, in which case\r\r
+ // you just have to read 'til you can't read no more\r\r
+ int contentLength = req.getContentLength();\r\r
+ System.out.println("***getContentLength: " + contentLength);\r\r
+ // Now read the parameters. Each parameter has the format :\r\r
+ // Separator : -----123456\r\r
+ // Parameter name\r\r
+ // Blank line\r\r
+ // Parameter value (can be multiple lines, ends with next separator)\r\r
+ // The last parameter ends with a separator.\r\r
+ System.out.println("***InputStream :");\r\r
+ ServletInputStream inStr = req.getInputStream();\r\r
+ byte buf[] = new byte[1000];\r\r
+ int byteCount = 0;\r\r
+ int numRead;\r\r
+ String currentAttribName;\r\r
+ boolean isSaveQuery = false;\r
+ boolean isUnique = true;\r
+ boolean isDocManage = false;\r\r
+ // Read the first separator\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ byteCount += numRead;\r\r
+ String strLine = new String(buf, 0, numRead);\r\r
+ if( ! strLine.startsWith(separator))\r\r
+ {\r\r
+ throw new ServletException("POST does not "\r\r
+ + "start with separator line, byte " + byteCount);\r\r
+ }\r\r
+ // Now go over the parameters\r\r
+ while (numRead > 0)\r\r
+ {\r\r
+ // Last one ? ContentLength could be -1\r\r
+ if(byteCount == contentLength)\r\r
+ break;\r\r
+ // Read the raw parameter name\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ if(numRead == -1)\r\r
+ break;\r\r
+ byteCount += numRead;\r\r
+ strLine = new String(buf, 0, numRead);\r\r
+ System.out.println("***Raw parameter name : " + strLine);\r\r
+ // Figure out if the parameter is a FILE input. The name of\r\r
+ // the parameter looks like :\r\r
+ // Content-Disposition: form-data; name="txtT1DocName"\r\r
+ // or in the case of a file parameter :\r\r
+ // Content-Disposition: form-data; name="fileContents"; filename="c:\temp\foo.txt"\r\r
+ boolean isFileAttrib = false;\r\r
+ int semiColIndex = strLine.lastIndexOf(';');\r\r
+ if(semiColIndex == -1)\r\r
+ throw new ServletException("POST - bad parameter name");\r\r
+ String localFileName = "";\r\r
+ String newLocalFileName = "";\r
+\r\r
+ if(strLine.substring(semiColIndex, semiColIndex + 6).compareTo("; file") == 0)\r\r
+ {\r\r
+ isFileAttrib = true;\r\r
+ int filenameIndex = strLine.lastIndexOf("; filename=\"");\r\r
+ //if(filenameIndex == -1)\r\r
+ // throw new ServletException("POST : no local file name");\r\r
+ localFileName = strLine.substring(filenameIndex + 12,\r\r
+ strLine.length() - 3);\r\r
+ System.out.println("**Param is a file, local file : " + localFileName);\r\r
+ if(localFileName.length() == 0)\r\r
+ {\r\r
+ System.out.println("***There is no file name");\r\r
+// localFileName = "xyz";\r\r
+// isFileAttrib = false;\r
+// break;\r\r
+ }\r\r
+ // JGW\r\r
+ // after we have the local file name. Just pull out the filename and append a rnd\r\r
+ // value to the file\r\r
+ int lastdash = 0;\r\r
+ int lfl = localFileName.length();\r\r
+ for (int ctr=1; ctr < (lfl - 3); ctr++)\r\r
+ {\r\r
+ if(localFileName.substring(ctr,ctr+1).compareTo("\\") == 0)\r\r
+ {\r\r
+ System.out.println("++++lastdash = "+ctr); \r\r
+ lastdash = ctr;\r\r
+ }\r\r
+ System.out.println(ctr + " " +lfl);\r\r
+ }\r
+ int subval = 0;\r
+ if(lastdash == 0)\r\r
+ subval = localFileName.length();\r
+ else\r
+ subval = (localFileName.length() - lastdash) - 1;\r\r
+\r\r
+ if(localFileName.length() > 0)\r\r
+ {\r\r
+ File fp = null; \r
+ newLocalFileName = localFileName.substring(lfl - subval, lfl);\r\r
+ // end JGW\r
+ fp = new File(tmpDir + newLocalFileName);\r
+ if(fp.exists() && !isDocManage)\r
+ { \r
+ res.setContentType("text/html");\r\r
+\r\r
+ PrintWriter toClient = res.getWriter();\r\r
+\r\r
+ String myJscript ="<h3><center><script language=Javascript>";\r\r
+ myJscript = myJscript + " alert('This file already exists.');"; \r\r
+ myJscript = myJscript + " </script>";\r\r
+ myJscript = myJscript + " </center></h3>";\r\r
+\r\r
+ toClient.println(myJscript);\r\r
+\r
+ isUnique = false;\r
+ }\r
+ } \r\r
+ } \r\r
+ // Extract the name of the parameter from the line\r\r
+ int openQuoteIndex = strLine.indexOf('=') + 2;\r\r
+ if(openQuoteIndex == -1)\r\r
+ throw new ServletException("POST : could not find "\r\r
+ + "beginning of name of parameter");\r\r
+ int closeQuoteIndex = strLine.indexOf('"', openQuoteIndex);\r\r
+ if(closeQuoteIndex == -1)\r\r
+ throw new ServletException("POST : could not find "\r\r
+ + "end of name of parameter");\r\r
+ currentAttribName = strLine.substring(openQuoteIndex, closeQuoteIndex);\r\r
+ System.out.println("***New attrib name : " + currentAttribName);\r\r
+ // Different behavior between Netscape and IE : IE will\r\r
+ // still send a content type descriptor if there is no file,\r\r
+ // but Netscape won't.\r\r
+ // Our strategy to cope with this is, if the file name is empty,\r\r
+ // we just skip over the contents of the file parameter\r\r
+ if(isFileAttrib && (localFileName.length() == 0))\r\r
+ {\r\r
+ while (true)\r\r
+ {\r\r
+ // Ignore everything until the market\r\r
+ byte buf2[] = new byte[1000];\r\r
+ int numRead2 = inStr.readLine(buf2, 0, 1000);\r\r
+ byteCount += numRead2;\r\r
+ String attVal2 = new String(buf2, 0, numRead2);\r\r
+ if(attVal2.startsWith(separator))\r\r
+ break;\r\r
+ }\r\r
+ }\r\r
+ // Read the value. If it's a file, there could be a\r\r
+ // massive amount of data\r\r
+ else if(isFileAttrib && (localFileName.length() > 0))\r\r
+ {\r\r
+ // Read the content type descriptor\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ byteCount += numRead;\r\r
+ strLine = new String(buf, 0, numRead);\r\r
+ if( ! strLine.startsWith("Content-Type:"))\r\r
+ {\r\r
+ throw new ServletException("POST : expected content type "\r\r
+ + "descriptor");\r\r
+ }\r\r
+ // Read the blank line\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ byteCount += numRead;\r\r
+ if(numRead > 2)\r\r
+ {\r\r
+ throw new ServletException("POST : unexpected data in "\r\r
+ + "file parameter line (not blank)");\r\r
+ }\r\r
+\r
+ String fullFileName = tmpDir + newLocalFileName;\r\r
+ System.out.println("**Reading file attribute into : " + fullFileName); \r\r
+ BufferedOutputStream outFile = null;\r\r
+ try {\r\r
+ if(isSaveQuery && isUnique)\r\r
+ {\r\r
+ FileOutputStream outStr = new FileOutputStream(fullFileName);\r\r
+ outFile = new BufferedOutputStream(outStr);\r\r
+ }\r\r
+ }\r\r
+ catch (IOException e)\r\r
+ {\r\r
+ throw new ServletException("POST : error while opening data file : " + fullFileName);\r\r
+ }\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ while (true)\r\r
+ {\r\r
+ //System.out.println("**Reading file value");\r\r
+ byteCount += numRead;\r\r
+ if(numRead < 0)\r\r
+ throw new ServletException("POST : data for file "\r\r
+ + "was incomplete");\r\r
+ byte buf2[] = new byte[1000];\r\r
+ int numRead2 = inStr.readLine(buf2, 0, 1000);\r\r
+ String attVal2 = new String(buf2, 0, numRead2);\r\r
+ // If this is the last line (because it's followed\r\r
+ // by a separator), trim off the last CR/LF\r\r
+ if(attVal2.startsWith(separator))\r\r
+ {\r\r
+ if(isSaveQuery && isUnique)\r\r
+ {\r\r
+ outFile.write(buf, 0, numRead - 2);\r\r
+ outFile.flush();\r\r
+ }\r\r
+ break;\r\r
+ }\r\r
+ else\r\r
+ {\r\r
+ if(isSaveQuery && isUnique)\r\r
+ {\r\r
+ outFile.write(buf, 0, numRead);\r\r
+ outFile.flush();\r\r
+ }\r\r
+ }\r\r
+ buf = buf2; // Thank goodness for garbage collection !\r\r
+ numRead = numRead2;\r\r
+ }\r\r
+ // Save the name of the file into the parameter\r\r
+ if(isSaveQuery)\r\r
+ {\r\r
+ // The value doesn't make it back into the file input\r\r
+ reqHash.put(currentAttribName, localFileName);\r\r
+ reqHash.put(currentAttribName + "_ClientFileName", localFileName);\r\r
+ reqHash.put(currentAttribName + "_ServerFileName", fullFileName);\r\r
+ }\r\r
+ }\r\r
+ else // Not a file : just a regular parameter\r\r
+ {\r\r
+ System.out.println("***Reading value of parameter");\r\r
+ // Read the blank line\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ byteCount += numRead;\r\r
+ String s = new String(buf, 0, numRead);\r\r
+ System.out.println("**First param value line : " + s);\r\r
+ if(numRead > 2)\r\r
+ {\r\r
+ throw new ServletException("POST : unexpected data in "\r\r
+ + "parameter line (not blank)");\r\r
+ }\r\r
+ numRead = inStr.readLine(buf, 0, 1000);\r\r
+ String attVal = "";\r\r
+ // Is this a Save query ? Remember that for processing of files\r\r
+ String tmpVal = new String(buf, 0, numRead);\r\r
+ if(tmpVal.indexOf("UploadFile=") != -1)\r\r
+ {\r\r
+ System.out.println("***********************************This is a save query");\r\r
+ isSaveQuery = true;\r\r
+ }\r\r
+ while (true)\r\r
+ {\r\r
+ System.out.println("**Reading parameter value");\r\r
+ byteCount += numRead;\r\r
+ if(numRead < 0)\r\r
+ throw new ServletException("POST : data for parameter "\r\r
+ + "was incomplete");\r\r
+ byte buf2[] = new byte[1000];\r\r
+ int numRead2 = inStr.readLine(buf2, 0, 1000);\r\r
+ String attVal2 = new String(buf2, 0, numRead2);\r\r
+ // If this is the last line (because it's followed\r\r
+ // by a separator), trim off the last CR/LF\r\r
+ if(attVal2.startsWith(separator))\r\r
+ {\r\r
+ attVal += new String(buf, 0, numRead - 2);\r\r
+ break;\r\r
+ }\r\r
+ else\r\r
+ {\r\r
+ attVal += new String(buf, 0, numRead);\r\r
+ }\r\r
+ buf = buf2; // Thank goodness for garbage collection !\r\r
+ numRead = numRead2;\r\r
+ }\r\r
+ // Skip the pseudo-fields that are filled with the\r\r
+ // names of the file\r\r
+ if(isSaveQuery)\r\r
+ {\r\r
+ if( ! ((currentAttribName.endsWith("_ClientFileName")) ||\r\r
+ (currentAttribName.endsWith("_ServerFileName"))))\r\r
+ {\r\r
+ reqHash.put(currentAttribName, attVal);\r\r
+ }\r\r
+ }\r\r
+ else\r
+ {\r\r
+ reqHash.put(currentAttribName, attVal);\r
+ }\r\r
+ System.out.println("**New attrib val : " + attVal);\r
+ if(attVal.length() > 5 && attVal.substring(0,6).equals("sysdir"))\r
+ {\r
+ int endIndex = attVal.indexOf('&');\r
+ System.out.println("sysdir " + attVal.substring(7,endIndex) + "\\");\r
+ tmpDir = tmpDir + attVal.substring(7,endIndex) + "\\";\r
+\r
+ if(attVal.substring(7,endIndex).indexOf("/") != -1)\r
+ isDocManage = true;\r
+ System.out.println("dir " + tmpDir);\r
+ System.out.println("doc management " + isDocManage);\r
+ File fp = new File(tmpDir);\r
+ if(!fp.exists())\r
+ {\r
+ System.out.println("doesn't exist");\r
+ fp.mkdirs();\r
+ System.out.println("created");\r
+ }\r
+ } \r\r
+ }\r\r
+ }\r
+ if(!isUnique)\r\r
+ {\r\r
+ reqHash.put("txtT1ImageUpload", "");\r\r
+ }\r\r
+ System.out.println("***End of InputStream : bytes " + byteCount);\r\r
+ System.out.println("***req " + req.toString());\r
+ System.out.println("***hash " + reqHash.toString());\r\r
+ FileServletRequest newRequest = new FileServletRequest(req, reqHash);\r\r
+ super.doPost(newRequest, res);\r\r
+ }\r
+ \r
+ public void doGet(javax.servlet.http.HttpServletRequest req,\r\r
+ javax.servlet.http.HttpServletResponse res)\r
+ throws javax.servlet.ServletException,\r\r
+ java.io.IOException\r\r
+ {\r
+ if(req.getParameter("GetImages") != null &&\r
+ req.getParameter("ImageExtensions") != null)\r
+ {\r
+ // Get the image extensions from the request\r
+ Vector legalImageExtensions = new Vector();\r
+ StringTokenizer tok = new StringTokenizer(req.getParameter("ImageExtensions"), ":");\r\r
+ while (tok.hasMoreTokens())\r
+ {\r
+ legalImageExtensions.addElement(tok.nextToken());\r
+ } \r
+ \r\r
+ // Return the directory listing\r
+ String currentSystem = req.getParameter("GetImages");\r
+ ObjectOutputStream out = new ObjectOutputStream(res.getOutputStream());\r
+ File dir = new File(constants.getImageDir() + currentSystem);\r
+ // For some reason implementing a FileNameFilter throws an IO exception\r
+ // even if it only returns true. So we implement one ourselves.\r\r
+ String[] validImageFiles = getValidImageFiles(dir.list(), legalImageExtensions);\r
+ if(validImageFiles != null)\r
+ {\r\r
+ out.writeObject(validImageFiles);\r
+ }\r\r
+ out.flush();\r\r
+ out.close();\r\r
+ }\r
+ else if(req.getParameter("GetFiles") != null &&\r
+ req.getParameter("FileExtensions") != null)\r
+ {\r
+ // Get the file extensions from the request\r
+ Vector legalFileExtensions = new Vector();\r
+ StringTokenizer tok = new StringTokenizer(req.getParameter("FileExtensions"), ":");\r\r
+ while (tok.hasMoreTokens())\r
+ {\r
+ legalFileExtensions.addElement(tok.nextToken());\r
+ }\r
+ \r
+ // Return the directory listing\r
+ String currentSystem = req.getParameter("GetFiles");\r
+ ObjectOutputStream out = new ObjectOutputStream(res.getOutputStream());\r
+ File dir = new File(constants.getImageDir() + currentSystem);\r
+ // For some reason implementing a FileNameFilter throws an IO exception\r
+ // even if it only returns true. So we implement one ourselves.\r\r
+ String[] validFiles = getValidFiles(dir.list(), legalFileExtensions);\r
+ if(validFiles != null)\r
+ {\r\r
+ out.writeObject(validFiles);\r
+ }\r\r
+ out.flush();\r\r
+ out.close();\r\r
+ }\r
+ else\r
+ {\r
+ super.doGet(req, res);\r
+ }\r
+ }\r
+ \r
+ private String[] getValidImageFiles(String[] files, Vector legalImageExtensions)\r
+ {\r
+\r
+ Vector validImageVector = new Vector();\r
+ for ( int fileIndex=0; fileIndex < files.length; fileIndex++)\r
+ {\r
+ for ( int i=0; i < legalImageExtensions.size(); i++)\r
+ {\r
+ if(files[fileIndex].endsWith((String)legalImageExtensions.elementAt(i)))\r
+ {\r
+ validImageVector.addElement(files[fileIndex]);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if(validImageVector.isEmpty())\r
+ {\r
+ return null;\r
+ }\r
+ else\r
+ {\r
+ String[] result = new String[validImageVector.size()];\r
+ int i2 = 0;\r
+ Enumeration theFiles = validImageVector.elements();\r
+ while (theFiles.hasMoreElements())\r
+ {\r
+ result[i2++] = ((String)theFiles.nextElement());\r
+ }\r
+ return result;\r
+ }\r
+ }\r\r
+\r\r
+ private String[] getValidFiles(String[] files, Vector legalFileExtensions)\r
+ {\r
+\r
+ Vector validFileVector = new Vector();\r
+ for ( int fileIndex=0; fileIndex < files.length; fileIndex++)\r
+ {\r
+ for ( int i=0; i < legalFileExtensions.size(); i++)\r
+ {\r
+ if(files[fileIndex].endsWith((String)legalFileExtensions.elementAt(i)))\r
+ {\r
+ validFileVector.addElement(files[fileIndex]);\r
+ break;\r
+ }\r
+ }\r
+ }\r
+ if(validFileVector.isEmpty())\r
+ {\r
+ return null;\r
+ }\r
+ else\r
+ {\r
+ String[] result = new String[validFileVector.size()];\r
+ int i2 = 0;\r
+ Enumeration theFiles = validFileVector.elements();\r
+ while (theFiles.hasMoreElements())\r
+ {\r
+ result[i2++] = ((String)theFiles.nextElement());\r
+ }\r
+ return result;\r
+ }\r
+ }\r\r
+\r\r
+\r\r
+}\r
+\r