Author: doogie
Date: Sun Aug 3 23:08:42 2008 New Revision: 682266 URL: http://svn.apache.org/viewvc?rev=682266&view=rev Log: Switch most new File(string_with_path_separator) calls to FileUtil.getFile. Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java ofbiz/trunk/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ComponentContainer.java ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/compdoc/CompDocEvents.java Sun Aug 3 23:08:42 2008 @@ -34,6 +34,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; @@ -210,7 +211,7 @@ /* try { - FileOutputStream fos = new FileOutputStream("/home/byersa/pdftest.pdf"); + FileOutputStream fos = new FileOutputStream(FileUtil.getFile("/home/byersa/pdftest.pdf")); fos.write(outByteBuffer.getBytes()); } catch(FileNotFoundException e) { } catch(IOException e) { @@ -284,7 +285,7 @@ /* try { - FileOutputStream fos = new FileOutputStream("/home/byersa/pdftest.pdf"); + FileOutputStream fos = new FileOutputStream(FileUtil.getFile("/home/byersa/pdftest.pdf")); fos.write(outByteBuffer.getBytes()); fos.close(); } catch(FileNotFoundException e) { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/content/UploadContentAndImage.java Sun Aug 3 23:08:42 2008 @@ -31,6 +31,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilDateTime; import org.ofbiz.base.util.UtilHttp; @@ -80,7 +81,7 @@ HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); - ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); + ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp"))); java.util.List lst = null; try { lst = dfu.parseRequest(request); @@ -344,7 +345,7 @@ HttpSession session = request.getSession(); GenericValue userLogin = (GenericValue)session.getAttribute("userLogin"); - ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); + ServletFileUpload dfu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp"))); //if (Debug.infoOn()) Debug.logInfo("[UploadContentAndImage]DiskFileUpload " + dfu, module); java.util.List lst = null; try { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/data/DataResourceWorker.java Sun Aug 3 23:08:42 2008 @@ -41,6 +41,7 @@ import org.apache.commons.fileupload.disk.DiskFileItemFactory; import org.apache.commons.fileupload.servlet.ServletFileUpload; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilHttp; import org.ofbiz.base.util.UtilMisc; @@ -179,7 +180,7 @@ //GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator"); //String idFieldValue = null; - ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); + ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, FileUtil.getFile("runtime/tmp"))); List lst = null; Locale locale = UtilHttp.getLocale(request); @@ -425,7 +426,7 @@ File file = null; if (dataResourceTypeId.equals("LOCAL_FILE") || dataResourceTypeId.equals("LOCAL_FILE_BIN")) { - file = new File(objectInfo); + file = FileUtil.getFile(objectInfo); if (!file.exists()) { throw new FileNotFoundException("No file found: " + (objectInfo)); } @@ -439,7 +440,7 @@ if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; } - file = new File(prefix + sep + objectInfo); + file = FileUtil.getFile(prefix + sep + objectInfo); if (!file.exists()) { throw new FileNotFoundException("No file found: " + (prefix + sep + objectInfo)); } @@ -452,7 +453,7 @@ if (objectInfo.indexOf("/") != 0 && contextRoot.lastIndexOf("/") != (contextRoot.length() - 1)) { sep = "/"; } - file = new File(contextRoot + sep + objectInfo); + file = FileUtil.getFile(contextRoot + sep + objectInfo); if (!file.exists()) { throw new FileNotFoundException("No file found: " + (contextRoot + sep + objectInfo)); } @@ -514,7 +515,7 @@ // check for the latest subdirectory String parentDir = ofbizHome + initialPath; - File parent = new File(parentDir); + File parent = FileUtil.getFile(parentDir); TreeMap dirMap = new TreeMap(desc); if (parent.exists()) { File[] subs = parent.listFiles(); @@ -900,7 +901,7 @@ // TODO: this method assumes the file is a text file, if it is an image we should respond differently, see the comment above for IMAGE_OBJECT type data resource if (dataResourceTypeId.equals("LOCAL_FILE")) { - File file = new File(objectInfo); + File file = FileUtil.getFile(objectInfo); if (!file.isAbsolute()) { throw new GeneralException("File (" + objectInfo + ") is not absolute"); } @@ -915,7 +916,7 @@ if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; } - File file = new File(prefix + sep + objectInfo); + File file = FileUtil.getFile(prefix + sep + objectInfo); int c; FileReader in = new FileReader(file); while ((c = in.read()) != -1) @@ -926,7 +927,7 @@ if (objectInfo.indexOf("/") != 0 && prefix.lastIndexOf("/") != (prefix.length() - 1)) { sep = "/"; } - File file = new File(prefix + sep + objectInfo); + File file = FileUtil.getFile(prefix + sep + objectInfo); int c; FileReader in = null; try { Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/layout/LayoutWorker.java Sun Aug 3 23:08:42 2008 @@ -57,7 +57,7 @@ Map results = FastMap.newInstance(); Map formInput = FastMap.newInstance(); results.put("formInput", formInput); - ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, new File("runtime/tmp"))); + ServletFileUpload fu = new ServletFileUpload(new DiskFileItemFactory(10240, new File(new File("runtime"), "tmp"))); java.util.List lst = null; try { lst = fu.parseRequest(request); Modified: ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java (original) +++ ofbiz/trunk/applications/content/src/org/ofbiz/content/webapp/ftl/LimitedSubContentCacheTransform.java Sun Aug 3 23:08:42 2008 @@ -31,6 +31,7 @@ import javolution.util.FastMap; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.StringUtil; import org.ofbiz.base.util.UtilDateTime; @@ -212,7 +213,7 @@ out.write(wrappedContent); //try { //Profiler.end("Limited"); - //FileOutputStream fw = new FileOutputStream(new File("/usr/local/agi/ofbiz/hot-deploy/sfmp/misc/profile.data")); + //FileOutputStream fw = new FileOutputStream(FileUtil.getFile("/usr/local/agi/ofbiz/hot-deploy/sfmp/misc/profile.data")); //Profiler.print(fw); //fw.close(); //} catch (IOException e) { Modified: ofbiz/trunk/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java (original) +++ ofbiz/trunk/applications/marketing/src/org/ofbiz/sfa/vcard/VCard.java Sun Aug 3 23:08:42 2008 @@ -30,6 +30,7 @@ import java.util.Map; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -216,7 +217,7 @@ saveToDirectory = System.getProperty("ofbiz.home"); } String saveToFilename = fullName + ".vcf"; - file = new File(saveToDirectory + "/" + saveToFilename); + file = FileUtil.getFile(saveToDirectory + "/" + saveToFilename); FileOutputStream outputStream = new FileOutputStream(file); marshaller.marshallContact(outputStream, contact); outputStream.close(); @@ -231,4 +232,4 @@ } return ServiceUtil.returnSuccess(); } -} \ No newline at end of file +} Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ComponentContainer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ComponentContainer.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ComponentContainer.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/container/ComponentContainer.java Sun Aug 3 23:08:42 2008 @@ -31,6 +31,7 @@ import org.ofbiz.base.component.ComponentLoaderConfig; import org.ofbiz.base.start.Classpath; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilValidate; /** @@ -103,7 +104,7 @@ String parentPath; try { - parentPath = new File(System.getProperty("ofbiz.home")).getCanonicalFile().toString().replaceAll("\\\\", "/"); + parentPath = FileUtil.getFile(System.getProperty("ofbiz.home")).getCanonicalFile().toString().replaceAll("\\\\", "/"); } catch (MalformedURLException e) { throw new ComponentException(e.getMessage(), e); } catch (IOException e) { @@ -155,7 +156,7 @@ private void loadComponentDirectory(String directoryName) { Debug.logInfo("Auto-Loading component directory : [" + directoryName + "]", module); - File parentPath = new File(directoryName); + File parentPath = FileUtil.getFile(directoryName); if (!parentPath.exists() || !parentPath.isDirectory()) { Debug.logError("Auto-Load Component directory not found : " + directoryName, module); } else { @@ -178,11 +179,11 @@ } else { for (String sub: parentPath.list()) { try { - File componentPath = new File(parentPath.getCanonicalPath() + "/" + sub); + File componentPath = FileUtil.getFile(parentPath.getCanonicalPath() + "/" + sub); if (componentPath.isDirectory() && !sub.equals("CVS") && !sub.equals(".svn")) { // make sure we have a component configuraton file String componentLocation = componentPath.getCanonicalPath(); - File configFile = new File(componentLocation + "/ofbiz-component.xml"); + File configFile = FileUtil.getFile(componentLocation + "/ofbiz-component.xml"); if (configFile.exists()) { ComponentConfig config = null; try { @@ -236,7 +237,7 @@ // strip off the slash splat dirLoc = location.substring(0, location.length() - 2); } - File path = new File(configRoot + dirLoc); + File path = FileUtil.getFile(configRoot + dirLoc); if (path.exists()) { if (path.isDirectory()) { // load all .jar and .zip files in this directory Modified: ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java (original) +++ ofbiz/trunk/framework/base/src/base/org/ofbiz/base/util/KeyStoreUtil.java Sun Aug 3 23:08:42 2008 @@ -48,7 +48,7 @@ public static void storeComponentKeyStore(String componentName, String keyStoreName, KeyStore store) throws IOException, GenericConfigException, NoSuchAlgorithmException, CertificateException, KeyStoreException { ComponentConfig.KeystoreInfo ks = ComponentConfig.getKeystoreInfo(componentName, keyStoreName); - File file = new File(ks.createResourceHandler().getFullLocation()); + File file = FileUtil.getFile(ks.createResourceHandler().getFullLocation()); FileOutputStream out = new FileOutputStream(file); store.store(out, ks.getPassword().toCharArray()); } @@ -82,11 +82,11 @@ KeyStore ks = KeyStore.getInstance("jks"); File keyFile = null; if (fileName != null) { - keyFile = new File(fileName); + keyFile = FileUtil.getFile(fileName); } else { - keyFile = new File(javaHome + "/lib/security/jssecacerts"); + keyFile = FileUtil.getFile(javaHome + "/lib/security/jssecacerts"); if (!keyFile.exists() || !keyFile.canRead()) { - keyFile = new File(javaHome + "/lib/security/cacerts"); + keyFile = FileUtil.getFile(javaHome + "/lib/security/cacerts"); } } Modified: ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java (original) +++ ofbiz/trunk/framework/entityext/src/org/ofbiz/entityext/data/EntityDataServices.java Sun Aug 3 23:08:42 2008 @@ -32,6 +32,7 @@ import org.ofbiz.entity.util.EntityListIterator; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilURL; import org.ofbiz.base.util.UtilMisc; @@ -202,7 +203,7 @@ String filePath = file.getPath().replace('\\', '/'); String[] header = null; - File headerFile = new File(filePath.substring(0, filePath.lastIndexOf('/')), "_" + file.getName()); + File headerFile = new File(FileUtil.getFile(filePath.substring(0, filePath.lastIndexOf('/'))), "_" + file.getName()); boolean uniqueHeaderFile = true; BufferedReader reader = null; Modified: ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java?rev=682266&r1=682265&r2=682266&view=diff ============================================================================== --- ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java (original) +++ ofbiz/trunk/framework/webapp/src/org/ofbiz/webapp/view/ApacheFopWorker.java Sun Aug 3 23:08:42 2008 @@ -38,6 +38,7 @@ import org.ofbiz.base.location.FlexibleLocation; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.FileUtil; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; @@ -73,7 +74,7 @@ try { String fopPath = UtilProperties.getPropertyValue("fop.properties", "fop.path", "framework/webapp/config"); - File userConfigFile = new File(fopPath + "/fop.xconf"); + File userConfigFile = FileUtil.getFile(fopPath + "/fop.xconf"); fopFactory.setUserConfig(userConfigFile); String fopFontBaseUrl = fopFactory.getFontBaseURL(); if (fopFontBaseUrl == null) { |
Free forum by Nabble | Edit this page |