Your browser does not support JavaScript and this site utilizes JavaScript to build content and provide links to additional information. You should either enable JavaScript in your browser settings or use a browser that supports JavaScript in order to take full advantage of this site.
1 19 20 package org.efs.openreports.providers; 21 22 import com.opensymphony.webwork.ServletActionContext; 23 import com.opensymphony.webwork.config.Configuration; 24 import com.opensymphony.xwork.ActionContext; 25 import com.opensymphony.xwork.interceptor.component.ComponentManager; 26 27 import org.apache.log4j.Logger; 28 import org.efs.openreports.objects.ORProperty; 29 30 public class DirectoryProvider implements PropertiesProviderAware 31 { 32 protected static Logger log = Logger.getLogger(DirectoryProvider.class.getName()); 33 34 private String reportDirectory; 35 private String reportImageDirectory; 36 private String tempDirectory; 37 private String separator = System.getProperty("file.separator"); 38 39 private PropertiesProvider propertiesProvider; 40 41 public DirectoryProvider(PropertiesProvider propertiesProvider) throws ProviderException 43 { 44 this.propertiesProvider = propertiesProvider; 45 init(); 46 } 47 48 public DirectoryProvider() throws ProviderException 50 { 51 ComponentManager container = (ComponentManager) ActionContext.getContext().get( 53 "com.opensymphony.xwork.interceptor.component.ComponentManager"); 54 55 container.initializeObject(this); 56 57 init(); 58 } 59 60 protected void init() throws ProviderException 61 { 62 log.info("Loading BaseDirectory from OR_PROPERTIES table."); 63 64 String baseDirectory = null; 65 66 ORProperty property = propertiesProvider.getProperty(ORProperty.BASE_DIRECTORY); 67 if (property != null) baseDirectory = property.getValue(); 68 69 if (baseDirectory == null || baseDirectory.trim().length() < 1) 70 { 71 log.info("BaseDirectory not set in OR_PROPERTIES table. Trying to get path from ServletContext."); 72 73 try 74 { 75 baseDirectory = ServletActionContext.getServletContext().getRealPath(""); 76 baseDirectory = baseDirectory + separator + "reports"; 77 } 78 catch (NullPointerException npe) 79 { 80 log.info("ServletActionContext not available."); 81 baseDirectory = "."; 82 } 83 } 84 85 log.info("BaseDirectory: " + baseDirectory); 86 87 reportDirectory = baseDirectory + separator; 88 reportImageDirectory = reportDirectory + "images" + separator; 89 90 Configuration.set("webwork.multipart.saveDir", baseDirectory); 92 93 property = propertiesProvider.getProperty(ORProperty.TEMP_DIRECTORY); 95 if (property != null && property.getValue() != null && property.getValue().trim().length() > 0) 96 { 97 tempDirectory = property.getValue(); 98 log.info("TempDirectory: " + tempDirectory); 99 } 100 101 log.info("Created"); 102 } 103 104 public String getReportDirectory() 105 { 106 return reportDirectory; 107 } 108 109 public void setReportDirectory(String reportDirectory) 110 { 111 this.reportDirectory = reportDirectory; 112 reportImageDirectory = reportDirectory + "images" + separator; 113 } 114 115 public String getReportImageDirectory() 116 { 117 return reportImageDirectory; 118 } 119 120 public String getReportImageTempDirectory() 121 { 122 return reportImageDirectory + "temp" + separator; 123 } 124 125 public String getTempDirectory() 126 { 127 return tempDirectory; 128 } 129 130 public void setTempDirectory(String tempDirectory) 131 { 132 this.tempDirectory = tempDirectory; 133 } 134 135 public void setPropertiesProvider(PropertiesProvider propertiesProvider) 136 { 137 this.propertiesProvider = propertiesProvider; 138 } 139 140 }
| Popular Tags
|