1 46 package org.tigris.scarab.migration.b18b19; 47 48 import java.io.BufferedOutputStream ; 49 import java.io.FileOutputStream ; 50 import java.io.IOException ; 51 import java.io.PrintWriter ; 52 import java.io.Writer ; 53 54 import org.apache.tools.ant.BuildException; 55 import org.apache.tools.ant.Task; 56 57 public class MigrateProperties extends Task 58 { 59 private static String [] propertyMap = new String [0]; 63 64 static 65 { 66 synchronized(propertyMap) 67 { 68 if (propertyMap.length == 0) { 69 propertyMap = new String [] { 80 82 "scarab.site.name", "scarab.site.name", 84 "scarab.http.domain", "scarab.http.domain", 85 "scarab.http.scheme", "scarab.http.scheme", 86 "scarab.http.scriptname", "scarab.http.scriptname", 87 "scarab.http.port", "scarab.http.port", 88 "scarab.automatic.role.approval", "scarab.automatic.role.approval", 89 "scarab.timezone", "scarab.timezone", 90 "scarab.email.encoding", "scarab.email.encoding", 91 "scarab.email.default.fromName", "scarab.email.default.fromName", 92 "scarab.email.default.fromAddress", "scarab.email.default.fromAddress", 93 "scarab.register.email.checkValidA", "scarab.register.email.checkValidA", 94 "scarab.register.email.badEmails", "scarab.register.email.badEmails", 95 "scarab.email.register.fromName", "scarab.email.register.fromName", 96 "scarab.email.register.fromAddress", "scarab.email.register.fromAddress", 97 "scarab.email.forgotpassword.fromName", "scarab.email.forgotpassword.fromName", 98 "scarab.email.forgotpassword.fromAddress", "scarab.email.forgotpassword.fromAddress", 99 "scarab.attachments.repository", "scarab.attachments.path", 100 "searchindex.path", "scarab.lucene.index.path", 101 "services.TorqueService.classname", "scarab.torque.service", 102 "services.DatabaseInitializer.classname", "scarab.dbinit.service", 103 "torque.managed_class.org.tigris.scarab.om.Module.manager", "scarab.module.service", 104 "torque.managed_class.org.tigris.scarab.om.ScarabUser.manager", "scarab.user.service", 105 "scarab.dataexport.encoding", "scarab.dataexport.encoding", 106 107 "turbine.mode", "scarab.mode", 109 "template.homepage", "scarab.homepage", 110 "session.timeout", "scarab.session.timeout", 111 "system.mail.host", "scarab.system.mail.host", 112 "services.LocalizationService.locale.default.language", "scarab.locale.default.language", 113 "services.LocalizationService.locale.default.country", "scarab.locale.default.country", 114 "services.UploadService.repository", "scarab.file.upload.path", 115 "services.UploadService.size.max", "scarab.file.max.size", 116 "resolver.cache.template", "scarab.template.cache", 117 "resolver.cache.module", "scarab.template.cache", 118 "services.VelocityService.file.resource.loader.cache", "scarab.template.cache", 119 "services.EmailService.file.resource.loader.cache", "scarab.template.cache", 120 "services.VelocityService.file.resource.loader.path", "template.path+/templates", 121 "services.EmailService.file.resource.loader.path", "template.path+/templates", 122 "module.packages", "scarab.module.packages", 123 124 "services.LocalizationService.classname", "scarab.localization.service", 125 "torque.manager.useCache", "scarab.torque.manager.cache", 126 "action.sessionvalidator", "scarab.sessionvalidator", 127 "pipeline.default.descriptor", "scarab.default.pipeline.descriptor", 128 "exceptionHandler.default", "scarab.request.error.handler", 129 "services.PullService.tool.request.link", "scarab.pull.link", 130 "services.PullService.tool.request.staticLink", "scarab.pull.staticlink", 131 "services.SecurityService.user.manager", "scarab.security.user.manager", 132 "services.IntakeService.serialize.path", "scarab.intake.serialize.file", 133 134 "log4j.category.default", "scarab.log.level.turbine+, turbine", 135 "log4j.category.org.tigris.scarab", "scarab.log.level.scarab+, scarab", 136 "log4j.appender.scarab.file", "scarab.log.file.scarab", 137 "log4j.appender.scarab.layout.conversionPattern", "scarab.log.pattern", 138 "log4j.appender.scarab.append", "scarab.log.append.scarab", 139 "log4j.category.org.tigris.scarab.util.xmlissues", "scarab.log.level.scarabxmlimport+, scarabxmlimport", 140 "log4j.appender.scarabxmlimport.file", "scarab.log.file.scarabxmlimport", 141 "log4j.appender.scarabxmlimport.layout.conversionPattern", "scarab.log.pattern", 142 "log4j.appender.scarabxmlimport.append", "scarab.log.append.scarabxmlimport", 143 "log4j.category.org.apache.turbine", "scarab.log.level.turbine+, turbine", 144 "log4j.appender.turbine.file", "scarab.log.file.turbine", 145 "log4j.appender.turbine.layout.conversionPattern", "scarab.log.pattern", 146 "log4j.appender.turbine.append", "scarab.log.append.turbine", 147 "log4j.category.org.apache.torque", "scarab.log.level.torque+, torque", 148 "log4j.appender.torque.file", "scarab.log.file.torque", 149 "log4j.appender.torque.layout.conversionPattern", "scarab.log.pattern", 150 "log4j.appender.torque.append", "scarab.log.append.torque", 151 "log4j.category.org.apache.fulcrum", "scarab.log.level.fulcrum+, services", 152 "log4j.appender.services.file", "scarab.log.file.fulcrum", 153 "log4j.appender.services.layout.conversionPattern", "scarab.log.pattern", 154 "log4j.appender.services.append", "scarab.log.append.fulcrum", 155 "log4j.category.org.apache.stratum", "scarab.log.level.stratum+, stratum", 156 "log4j.appender.stratum.file", "scarab.log.file.stratum", 157 "log4j.appender.stratum.layout.conversionPattern", "scarab.log.pattern", 158 "log4j.appender.stratum.append", "scarab.log.append.stratum", 159 "log4j.category.org.apache.jcs", "scarab.log.level.jcs+, jcs", 160 "log4j.appender.jcs.file", "scarab.log.file.jcs", 161 "log4j.appender.jcs.layout.conversionPattern", "scarab.log.pattern", 162 "log4j.appender.jcs.append", "scarab.log.append.jcs", 163 "log4j.category.org.apache.fulcrum.db", "scarab.log.level.torque+, torque", 164 "log4j.category.org.apache.commons", "scarab.log.level.turbine+, turbine", 165 "log4j.category.org.apache.commons.beanutils", "scarab.log.level.beanutils+, turbine", 166 "log4j.category.org.apache.velocity", "scarab.log.level.velocity+, velocity", 167 "log4j.appender.velocity.file", "scarab.log.file.velocity", 168 "log4j.appender.velocity.layout.conversionPattern", "scarab.log.pattern", 169 "log4j.appender.velocity.append", "scarab.log.append.velocity" 170 }; 171 } 172 } 173 } 174 175 private String outputFile = "CustomSettings.properties"; 176 177 public void execute() throws BuildException 178 { 179 PrintWriter writer = null; 180 try 181 { 182 writer = new PrintWriter ( 186 new BufferedOutputStream ( 187 new FileOutputStream (this.outputFile))); 188 189 for (int i = 0; i < propertyMap.length; i += 2) 195 { 196 String outProperty = propertyMap[i]; 204 String inProperty = propertyMap[i + 1]; 205 String appendString = ""; 206 int splitPos = inProperty.indexOf('+'); 207 if (splitPos >= 0) 208 { 209 appendString = inProperty.substring(splitPos + 1); 210 inProperty = inProperty.substring(0, splitPos); 211 } 212 213 String antPropertyValue = getProject().getProperty(inProperty); 214 if (antPropertyValue != null) 215 { 216 splitPos = antPropertyValue.indexOf('='); 224 if (splitPos >= 0) 225 { 226 antPropertyValue = 227 antPropertyValue.substring(splitPos + 1); 228 } 229 230 writer.println(outProperty + '=' 235 + antPropertyValue 236 + appendString); 237 } 238 } 239 } 240 catch (IOException ex) 241 { 242 throw new BuildException(ex); 243 } 244 finally 245 { 246 writer.close(); 247 } 248 } 249 250 public void setOutput(String filename) 251 { 252 this.outputFile = filename; 253 } 254 } 255 | Popular Tags |