Changes for page Development-Excel Generation
Last modified by Pascal Robert on 2010/09/13 00:35
From version 3.1
edited by Quinton Dolan
on 2007/07/12 20:44
on 2007/07/12 20:44
Change comment:
There is no comment for this version
To version 2.1
edited by smmccraw
on 2007/07/08 09:45
on 2007/07/08 09:45
Change comment:
There is no comment for this version
Summary
-
Page properties (2 modified, 0 added, 0 removed)
Details
- Page properties
-
- Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. qdolan1 +XWiki.smmccraw - Content
-
... ... @@ -1,305 +1,280 @@ 1 1 For a "clean" copy of this file, head over to http:~/~/www.overhyped.com./downloads/OTCPOIArchive.java 2 2 3 -{{ code}}3 +{{panel}} 4 4 5 -/* 6 -Copyright (c) 2003 Overhyped Technologies, LLC. 7 - 8 -Permission is hereby granted, free of charge, to any person obtaining a copy 9 -of this software and associated documentation files (the "Software"), to deal 10 -in the Software without restriction, including without limitation the rights 11 -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 -copies of the Software, and to permit persons to whom the Software is 13 -furnished to do so, subject to the following conditions: The above copyright 14 -notice and this permission notice shall be included in all copies or 15 -substantial portions of the Software. 16 - 17 -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 -SOFTWARE. */ 24 - 25 -package com.overhyped.webobjects; 26 - 27 -import com.webobjects.foundation.*; 28 -import com.webobjects.appserver.*; 29 -import com.webobjects.eocontrol.*; 30 -import com.webobjects.eoaccess.*; 31 -import com.webobjects.directtoweb.*; 32 - 33 -import java.io.*; 34 -import java.util.Date; 35 - 36 -import org.apache.poi.hssf.usermodel.*; 37 - 38 -public class OTCPOIArchive extends Object { 39 - protected D2WContext d2wContext; 40 - protected EOEnterpriseObject object; 41 - static String _fileUploadPath = null; 42 - 43 - /** Returns the current D2WContext. */ 44 - public D2WContext d2wContext() { 45 - return d2wContext; 46 - } 47 - /** Sets the current D2WContext. */ 48 - public void setLocalContext(D2WContext d2w) { 49 - d2wContext = d2w; 50 - } 5 + /* 6 + Copyright (c) 2003 Overhyped Technologies, LLC. 51 51 52 - /** Returns the current EOEnterpriseObject. */ 53 - public EOEnterpriseObject object() { 54 - return object; 55 - } 56 - /** Sets the current EOEnterpriseObject. */ 57 - public void setObject(EOEnterpriseObject newEO) { 58 - object = newEO; 59 - } 8 + Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 9 + The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 60 60 61 - /** Creates an Excel Spreadsheet using Apache's POI project. If the objectArray 62 - * is null or empty, this method will fetch all objects from the database for 63 - * the given entityNameForArchive. If the entityNameForArchive is null or 64 - * empty, this method will fetch all entities and iterate over them, while 65 - * fetching all objects for each entityName. This method will use aKey to set 66 - * an Integer into the target, allowing for feedback while the calculation is 67 - * occurring. The resulting file can be found in the /excel/ directory of the 68 - * WebServer. */ 69 - public String calculate(NSArray objectArray, String entityNameForArchive, String aKey, WOComponent target) { 70 - 71 - try { 72 - EOEditingContext ec; 73 - HSSFWorkbook wb; 74 - NSArray entities; 75 - java.util.Enumeration entityEnum, attributeEnum, eoEnum; 76 - int sCount; 77 - String eName; 78 - HSSFSheet sheet; 79 - NSArray attributes; 80 - short col; 81 - HSSFRow row; 82 - String attribute, attribute2, value; 83 - short r; 84 - EOEnterpriseObject item; 85 - 86 - // set up the d2wcontext 87 - if (d2wContext() == null) setLocalContext( new D2WContext(target.session()) ); 88 - // set the task for archive 89 - d2wContext().setTask("archive"); 90 - // get an EditingContext 91 - ec = target.session().defaultEditingContext(); 92 - // create a workbook 93 - wb = new HSSFWorkbook(); 94 - // get the entities 95 - if ((entityNameForArchive == null) || (entityNameForArchive.length() == 0)) { 96 - entities = D2WUtils.allEntities(); 97 - objectArray = null; // if there's no entity name, we'd better clear out any objects. 98 - } 99 - else { 100 - entities = new NSArray(EOUtilities.entityNamed(ec,entityNameForArchive)); 101 - } 102 - // create an enumerator 103 - entityEnum = entities.objectEnumerator(); 104 - // count the sheets 105 - sCount = 0; 106 - // enumerate 107 - while (entityEnum.hasMoreElements()) { 108 - // get the next entity 109 - eName = ((EOEntity)entityEnum.nextElement()).name(); 110 - // set the entity into the D2WContext 111 - d2wContext().setEntity(EOUtilities.entityNamed(ec, eName)); 112 - // get all objects for this entity 113 - if ((objectArray == null) || (objectArray.count() == 0)) objectArray = EOUtilities.objectsForEntityNamed(ec, eName); 114 - // check if there are any objects 115 - if ((objectArray == null) || (objectArray.count() == 0)) continue; 116 - // create a worksheet 117 - sheet = wb.createSheet(displayName()); 118 - // get the propertyKeys for this entity 119 - attributes = (NSArray) d2wContext().valueForKey("displayPropertyKeys"); 120 - // Label the columns 121 - attributeEnum = attributes.objectEnumerator(); 122 - // zero out the column count 123 - col = 0; 124 - // Create a row and put some cells in it. Rows are 0 based. 125 - row = sheet.createRow((short)0); 126 - // iterate the attributes 127 - while ( attributeEnum.hasMoreElements() ) { 128 - // get the next attribute 129 - attribute = (String) attributeEnum.nextElement(); 130 - // set the property into the D2WContext 131 - d2wContext().setPropertyKey(attribute); 132 - // insert it at the appropriate column 133 - // add the cell to the worksheet 134 - row.createCell(col).setCellValue(d2wContext().displayNameForProperty()); 135 - // move to the next column 136 - col++; 137 - } 138 - // Insert the Rows 139 - // make sure we start at row 1, otherwise we'll lose the column headings 140 - r = 1; 141 - // set up to iterate the EOs 142 - eoEnum = objectArray.objectEnumerator(); 143 - // iterate the EOs 144 - while ( eoEnum.hasMoreElements() ) { 145 - try { 146 - // zero out the column count 147 - col = 0; 148 - // create a new row 149 - row = sheet.createRow(r); 150 - // an EO 151 - item = (EOEnterpriseObject) eoEnum.nextElement(); 152 - // set it into the D2W page 153 - setObject(item); 154 - // set up to iterate the attributes again... 155 - attributeEnum = attributes.objectEnumerator(); 156 - // iterate the attributes again... 157 - while ( attributeEnum.hasMoreElements() ) { 158 - // the attribute 159 - attribute2 = (String) attributeEnum.nextElement(); 160 - // set the property into the D2WContext 161 - d2wContext().setPropertyKey(attribute2); 162 - try { 163 - // the final value to insert from the current object based on the d2wcontext 164 - value = currentValue(); 165 - // create the cell for the spreadsheet 166 - row.createCell(col).setCellValue(value); 167 - } 168 - catch (Exception e1) { 169 - System.err.println(e1); 170 - } 171 - // move over a column 172 - col++; 173 - } 174 - } 175 - catch (Exception e2) { 176 - System.err.println(e2); 177 - } 178 - // move down a row, since there's a new object 179 - r++; 180 - target.takeValueForKey(new Integer(r),aKey); 181 - } 182 - // add another worksheet to the spreadsheet, since there's another entity 183 - sCount++; 184 - // clear out the objectArray, since there's another entity 185 - objectArray = null; 186 - 187 - // System.out.println("POIArchive: calculate: Completed Archive: " + eName); 188 - } 189 - // All sheets and cells added. Now write out the workbook 190 - String fn = fileUploadPath() + File.separator + "POI" + new NSTimestamp().getTime() + ".xls"; 191 - File file = new File(fn); 192 - FileOutputStream fileOut = new FileOutputStream(file); 193 - wb.write(fileOut); 194 - fileOut.close(); 195 - 196 - objectArray = null; 197 - entityNameForArchive = null; 198 - 199 - System.out.println("POI @ " + fn); 200 - return fn; 201 - } 202 - catch (Exception e) { 203 - ByteArrayOutputStream baos = new ByteArrayOutputStream(); 204 - e.printStackTrace(new PrintStream(baos)); 205 - System.out.println("POIArchive: archive(): error:" + baos.toString()); 206 - return null; 207 - } 208 - } 11 + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 + */ 209 209 210 - /** Returns the current value provided by the d2wContext. Found objects use 211 - * the d2wContext for timestamp formatting, relationships, etc. If a 212 - * relationship fo an EOEnterpriseObject is resolved, and no keyForRelationship 213 - * is found, this method will use the EO's userPresentableDescription. */ 214 - public String currentValue() { 215 - Object o = null; 216 - try { 217 - if (d2wContext().propertyKeyIsKeyPath()) { 218 - o = NSKeyValueCodingAdditions.Utility.valueForKeyPath(object(), d2wContext().propertyKey()); 219 - } else { 220 - o = NSKeyValueCoding.DefaultImplementation.valueForKey(object(), d2wContext().propertyKey()); 221 - } 222 - if ( (o != null) && (o instanceof EOEnterpriseObject) ) { 223 - o = ((EOEnterpriseObject) o).valueForKey(d2wContext().keyWhenRelationship()); 224 - if ( (o != null) && (o instanceof EOEnterpriseObject) ) { 225 - try { 226 - return ((EOEnterpriseObject)o).userPresentableDescription(); 227 - } 228 - catch (Exception ex) { 229 - ByteArrayOutputStream baos = new ByteArrayOutputStream(); 230 - ex.printStackTrace(new PrintStream(baos)); 231 - System.out.println("POIArchive: currentValue(): error" + baos.toString()); 232 - return o.toString(); 233 - } 234 - } 235 - } 236 - if ( (o != null) && (o instanceof NSArray) ) { 237 - /***** ENHANCE ME: could use componentsSeparatedByString along with userPresentableDescription. jpaul. *****/ 238 - int count; 239 - count = ((NSArray) o).count(); 240 - if (count == 0) return "0"; 241 - return " " + count; 242 - } 243 - if ( (o != null) && (o instanceof NSTimestamp) ) { 244 - NSTimestampFormatter formatter = new NSTimestampFormatter((String) d2wContext().valueForKey(D2WModel.FormatterKey)); 245 - return formatter.format((NSTimestamp) o); 246 - } 247 - if ( (o != null) && (o instanceof java.lang.Number) ) { 248 - NSNumberFormatter formatter; 249 - String pattern = (String) d2wContext().valueForKey(D2WModel.FormatterKey); 250 - if ((pattern != null) && (pattern.length() > 0)) { 251 - formatter = new NSNumberFormatter(pattern); 252 - } 253 - else { 254 - formatter = new NSNumberFormatter(); 255 - } 256 - return formatter.stringForObjectValue(o); 257 - } 258 - if (o != null) return o.toString(); 259 - return ""; 260 - } 261 - catch (Exception e) { 262 - return "(Binary Data)"; 263 - } 264 - } 14 + package com.overhyped.webobjects; 265 265 266 - /** Returns an EOEnterpriseObject's'displayNameForEntity',using thed2wContext.267 - * Ifit is notfound, themethod will checkthe userInfoDictionary for268 - * displayName. If all else fails, it will return theentity'sname./269 - p ublicString displayName() {270 - Strings;16 + import com.webobjects.foundation.*; 17 + import com.webobjects.appserver.*; 18 + import com.webobjects.eocontrol.*; 19 + import com.webobjects.eoaccess.*; 20 + import com.webobjects.directtoweb.*; 271 271 272 - s = (String) d2wContext().valueForKey("displayNameForEntity"); 273 - if (s == null) { 274 - s = (String) d2wContext().entity().userInfo().objectForKey("displayName"); 275 - if (s != null) return s; 276 - return (String) d2wContext().entity().name(); 22 + import java.io.*; 23 + import java.util.Date; 24 + 25 + import org.apache.poi.hssf.usermodel.*; 26 + 27 + public class OTCPOIArchive extends Object { 28 + protected D2WContext d2wContext; 29 + protected EOEnterpriseObject object; 30 + static String _fileUploadPath = null; 31 + 32 + /** Returns the current D2WContext. */ 33 + public D2WContext d2wContext() { 34 + return d2wContext; 35 + } 36 + /** Sets the current D2WContext. */ 37 + public void setLocalContext(D2WContext d2w) { 38 + d2wContext = d2w; 39 + } 40 + 41 + /** Returns the current EOEnterpriseObject. */ 42 + public EOEnterpriseObject object() { 43 + return object; 44 + } 45 + /** Sets the current EOEnterpriseObject. */ 46 + public void setObject(EOEnterpriseObject newEO) { 47 + object = newEO; 48 + } 49 + 50 + /** Creates an Excel Spreadsheet using Apache's POI project. If the objectArray is null or empty, this method will fetch all objects from the database for the given entityNameForArchive. If the entityNameForArchive is null or empty, this method will fetch all entities and iterate over them, while fetching all objects for each entityName. This method will use aKey to set an Integer into the target, allowing for feedback while the calculation is occurring. The resulting file can be found in the /excel/ directory of the WebServer. */ 51 + public String calculate(NSArray objectArray, String entityNameForArchive, String aKey, WOComponent target) { 52 + 53 + try { 54 + EOEditingContext ec; 55 + HSSFWorkbook wb; 56 + NSArray entities; 57 + java.util.Enumeration entityEnum, attributeEnum, eoEnum; 58 + int sCount; 59 + String eName; 60 + HSSFSheet sheet; 61 + NSArray attributes; 62 + short col; 63 + HSSFRow row; 64 + String attribute, attribute2, value; 65 + short r; 66 + EOEnterpriseObject item; 67 + 68 + // set up the d2wcontext 69 + if (d2wContext() == null) setLocalContext( new D2WContext(target.session()) ); 70 + // set the task for archive 71 + d2wContext().setTask("archive"); 72 + // get an EditingContext 73 + ec = target.session().defaultEditingContext(); 74 + // create a workbook 75 + wb = new HSSFWorkbook(); 76 + // get the entities 77 + if ((entityNameForArchive h1. null) || (entityNameForArchive.length() 0)) { 78 + entities = D2WUtils.allEntities(); 79 + objectArray = null; // if there's no entity name, we'd better clear out any objects. 80 + } 81 + else { 82 + entities = new NSArray(EOUtilities.entityNamed(ec,entityNameForArchive)); 83 + } 84 + // create an enumerator 85 + entityEnum = entities.objectEnumerator(); 86 + // count the sheets 87 + sCount = 0; 88 + // enumerate 89 + while (entityEnum.hasMoreElements()) { 90 + // get the next entity 91 + eName = ((EOEntity)entityEnum.nextElement()).name(); 92 + // set the entity into the D2WContext 93 + d2wContext().setEntity(EOUtilities.entityNamed(ec, eName)); 94 + // get all objects for this entity 95 + if ((objectArray h1. null) || (objectArray.count() 0)) objectArray = EOUtilities.objectsForEntityNamed(ec, eName); 96 + // check if there are any objects 97 + if ((objectArray h1. null) || (objectArray.count() 0)) continue; 98 + // create a worksheet 99 + sheet = wb.createSheet(displayName()); 100 + // get the propertyKeys for this entity 101 + attributes = (NSArray) d2wContext().valueForKey("displayPropertyKeys"); 102 + // Label the columns 103 + attributeEnum = attributes.objectEnumerator(); 104 + // zero out the column count 105 + col = 0; 106 + // Create a row and put some cells in it. Rows are 0 based. 107 + row = sheet.createRow((short)0); 108 + // iterate the attributes 109 + while ( attributeEnum.hasMoreElements() ) { 110 + // get the next attribute 111 + attribute = (String) attributeEnum.nextElement(); 112 + // set the property into the D2WContext 113 + d2wContext().setPropertyKey(attribute); 114 + // insert it at the appropriate column 115 + // add the cell to the worksheet 116 + row.createCell(col).setCellValue(d2wContext().displayNameForProperty()); 117 + // move to the next column 118 + col++; 119 + } 120 + // Insert the Rows 121 + // make sure we start at row 1, otherwise we'll lose the column headings 122 + r = 1; 123 + // set up to iterate the EOs 124 + eoEnum = objectArray.objectEnumerator(); 125 + // iterate the EOs 126 + while ( eoEnum.hasMoreElements() ) { 127 + try { 128 + // zero out the column count 129 + col = 0; 130 + // create a new row 131 + row = sheet.createRow(r); 132 + // an EO 133 + item = (EOEnterpriseObject) eoEnum.nextElement(); 134 + // set it into the D2W page 135 + setObject(item); 136 + // set up to iterate the attributes again... 137 + attributeEnum = attributes.objectEnumerator(); 138 + // iterate the attributes again... 139 + while ( attributeEnum.hasMoreElements() ) { 140 + // the attribute 141 + attribute2 = (String) attributeEnum.nextElement(); 142 + // set the property into the D2WContext 143 + d2wContext().setPropertyKey(attribute2); 144 + try { 145 + // the final value to insert from the current object based on the d2wcontext 146 + value = currentValue(); 147 + // create the cell for the spreadsheet 148 + row.createCell(col).setCellValue(value); 149 + } 150 + catch (Exception e1) { 151 + System.err.println(e1); 152 + } 153 + // move over a column 154 + col++; 155 + } 156 + } 157 + catch (Exception e2) { 158 + System.err.println(e2); 159 + } 160 + // move down a row, since there's a new object 161 + r++; 162 + target.takeValueForKey(new Integer(r),aKey); 163 + } 164 + // add another worksheet to the spreadsheet, since there's another entity 165 + sCount++; 166 + // clear out the objectArray, since there's another entity 167 + objectArray = null; 168 + 169 + // System.out.println("POIArchive: calculate: Completed Archive: " + eName); 170 + } 171 + // All sheets and cells added. Now write out the workbook 172 + String fn = fileUploadPath() + File.separator + "POI" + new NSTimestamp().getTime() + ".xls"; 173 + File file = new File(fn); 174 + FileOutputStream fileOut = new FileOutputStream(file); 175 + wb.write(fileOut); 176 + fileOut.close(); 177 + 178 + objectArray = null; 179 + entityNameForArchive = null; 180 + 181 + System.out.println("POI @ " + fn); 182 + return fn; 183 + } 184 + catch (Exception e) { 185 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); 186 + e.printStackTrace(new PrintStream(baos)); 187 + System.out.println("POIArchive: archive(): error:" + baos.toString()); 188 + return null; 189 + } 190 + } 191 + 192 + /** Returns the current value provided by the d2wContext. Found objects use the d2wContext for timestamp formatting, relationships, etc. If a relationship fo an EOEnterpriseObject is resolved, and no keyForRelationship is found, this method will use the EO's userPresentableDescription. */ 193 + public String currentValue() { 194 + Object o = null; 195 + try { 196 + if (d2wContext().propertyKeyIsKeyPath()) { 197 + o = NSKeyValueCodingAdditions.Utility.valueForKeyPath(object(), d2wContext().propertyKey()); 198 + } else { 199 + o = NSKeyValueCoding.DefaultImplementation.valueForKey(object(), d2wContext().propertyKey()); 200 + } 201 + if ( (o !=_null)_&&_(o_instanceof_EOEnterpriseObject)_)_{ 202 +________o_=_((EOEnterpriseObject)_o).valueForKey(d2wContext().keyWhenRelationship()); 203 +________if_(_(o_!= null) && (o instanceof EOEnterpriseObject) ) { 204 + try { 205 + return ((EOEnterpriseObject)o).userPresentableDescription(); 206 + } 207 + catch (Exception ex) { 208 + ByteArrayOutputStream baos = new ByteArrayOutputStream(); 209 + ex.printStackTrace(new PrintStream(baos)); 210 + System.out.println("POIArchive: currentValue(): error" + baos.toString()); 211 + return o.toString(); 212 + } 213 + } 214 + } 215 + if ( (o !=_null)_&&_(o_instanceof_NSArray)_)_{ 216 +________/*****_ENHANCE_ME:_could_use_componentsSeparatedByString_along_with_userPresentableDescription._jpaul._*****/ 217 +________int_count; 218 +________count_=_((NSArray)_o).count(); 219 +________if_(count_==_0)_return_"0"; 220 +________return_"_"_+_count; 221 +________} 222 +________if_(_(o_!= null) && (o instanceof NSTimestamp) ) { 223 + NSTimestampFormatter formatter = new NSTimestampFormatter((String) d2wContext().valueForKey(D2WModel.FormatterKey)); 224 + return formatter.format((NSTimestamp) o); 225 + } 226 + if ( (o !=_null)_&&_(o_instanceof_java.lang.Number)_)_{ 227 +________NSNumberFormatter_formatter; 228 +________String_pattern_=_(String)_d2wContext().valueForKey(D2WModel.FormatterKey); 229 +________if_((pattern_!= null) && (pattern.length() > 0)) { 230 + formatter = new NSNumberFormatter(pattern); 231 + } 232 + else { 233 + formatter = new NSNumberFormatter(); 234 + } 235 + return formatter.stringForObjectValue(o); 236 + } 237 + if (o !=_null)_return_o.toString(); 238 +________return_""; 239 +____} 240 +____catch_(Exception_e)_{ 241 +________return_"(Binary_Data)"; 242 +____} 243 +____} 244 +____ 245 +____/**_Returns_an_EOEnterpriseObject's_'displayNameForEntity',_using_the_d2wContext._If_it_is_not_found,_the_method_will_check_the_userInfoDictionary_for__displayName._If_all_else_fails,_it_will_return_the_entity's_name._*/ 246 +____public_String_displayName()_{ 247 +____String_s; 248 +____ 249 +____s_=_(String)_d2wContext().valueForKey("displayNameForEntity"); 250 +____if_(s_==_null)_{ 251 +________s_=_(String)_d2wContext().entity().userInfo().objectForKey("displayName"); 252 +________if_(s_!= null) return s; 253 + return (String) d2wContext().entity().name(); 254 + } 255 + return s; 256 + } 257 + 258 + /** 259 + * Returns the directory where uploaded files will be written to disk. 260 + */ 261 + public static String fileUploadPath() { 262 + if (_fileUploadPath == null) { 263 + String tmpdir = System.getProperty("OTCUploadDirectory"); 264 + if (tmpdir != null) { 265 + File tmpPath = new File(tmpdir); 266 + if (tmpPath.exists()) { 267 + _fileUploadPath = tmpPath.getAbsolutePath(); 268 + } 269 + } 270 + if (_fileUploadPath == null) { 271 + NSLog.err.appendln("FileUpload: 'OTCUploadDirectory' does not exist. Please launch this application again with the 'OTCUploadDirectory' System Property set to a directory to which you have write permission."); 272 + } 273 + } 274 + return _fileUploadPath; 275 + } 277 277 } 278 - return s; 279 - } 280 280 281 - /** 282 - * Returns the directory where uploaded files will be written to disk. 283 - */ 284 - public static String fileUploadPath() { 285 - if (_fileUploadPath == null) { 286 - String tmpdir = System.getProperty("OTCUploadDirectory"); 287 - if (tmpdir != null) { 288 - File tmpPath = new File(tmpdir); 289 - if (tmpPath.exists()) { 290 - _fileUploadPath = tmpPath.getAbsolutePath(); 291 - } 292 - } 293 - if (_fileUploadPath == null) { 294 - NSLog.err.appendln("FileUpload: 'OTCUploadDirectory' does not exist." 295 - + " Please launch this application again with the 'OTCUploadDirectory'" 296 - + " System Property set to a directory to which you have write permission."); 297 - } 298 - } 299 - return _fileUploadPath; 300 - } 301 -} 278 +{{/panel}} 302 302 303 -{{/code}} 304 - 305 305 Category:WebObjects