1/******************************************************************************* 2 * Copyright (c) 2000, 2006 IBM Corporation and others. 3 * All rights reserved. This program and the accompanying materials 4 * are made available under the terms of the Eclipse Public License v1.0 5 * which accompanies this distribution, and is available at 6 * http://www.eclipse.org/legal/epl-v10.html 7 * 8 * Contributors: 9 * IBM Corporation - initial API and implementation 10 *******************************************************************************/ 11package org.eclipse.releng; 12 13import java.io.*; 14import java.util.Properties; 15 16/** 17 * Class that stores build identification information taken from monitor. 18 * properties as String objects 19 */ 20public class BuildProperties { 21 // recipients key value setting. Comma separated list of email addresses of those who should 22 // receive build information 23 private String toRecipientList = ""; 24 25 // text message notification list 26 private String textRecipientList = ""; 27 28 // email address of the sender 29 private String sender = ""; 30 // mail server name 31 private String host = ""; 32 33 // default name of the build log file used with listener 34 private String logFile = "index.php"; 35 36 // the prefix prepended to the subject of build related emails 37 private String buildSubjectPrefix="[build]"; 38 39 // the build id, typically <buildType><build date> 40 private String buildid; 41 // the date and time of the build 42 private String timestamp; 43 // the name of the directory containing the builds, typically <buildType>-<buildType><build date>-<timestamp> 44 private String buildLabel; 45 46 // the http download URL 47 private String httpUrl; 48 49 // the ftp download URL 50// private String ftpUrl; 51 52 // the Object that holds the key value pairs in monitor.properties 53 private Properties buildProperties; 54 55 public BuildProperties (){ 56 this("monitor.properties"); 57 } 58 59 60 public BuildProperties(String monitorProperties) { 61 buildProperties = new Properties(); 62 // retrieve information from monitor.properties file. 63 // This file should reside in the same directory as the startup.jar at build time. 64 try { 65 buildProperties.load( 66 new FileInputStream(new File(monitorProperties))); 67 68 try { 69 buildSubjectPrefix = buildProperties.get("buildSubjectPrefix").toString(); 70 } catch (NullPointerException e) { 71 System.out.println( 72 "Value for buildSubjectPrefix not found in monitor.properties"); 73 System.out.println( 74 "Default value, buildSubjectPrefix=[build] will be used."); 75 76 } 77 78 try { 79 httpUrl = buildProperties.get("httpUrl").toString(); 80 } catch (NullPointerException e) { 81 System.out.println( 82 "Value for httpUrl not found in monitor.properties"); 83 } 84 85 /*try { 86 ftpUrl = buildProperties.get("ftpUrl").toString(); 87 } catch (NullPointerException e) { 88 System.out.println( 89 "Value for ftpUrl not found in monitor.properties"); 90 }*/ 91 92 try { 93 buildid = buildProperties.get("buildId").toString(); 94 } catch (NullPointerException e) { 95 System.out.println( 96 "Value for buildId not found in monitor.properties"); 97 } 98 99 try { 100 buildLabel = buildProperties.get("buildLabel").toString(); 101 } catch (NullPointerException e) { 102 System.out.println( 103 "Value for buildLabel not found in monitor.properties"); 104 } 105 try { 106 timestamp = buildProperties.get("timestamp").toString(); 107 } catch (NullPointerException e) { 108 System.out.println( 109 "Value for timestamp not found in monitor.properties"); 110 } 111 112 try { 113 toRecipientList = buildProperties.get("recipients").toString(); 114 } catch (NullPointerException e) { 115 System.out.println( 116 "Value for recipients not found in monitor.properties"); 117 118 } 119 120 try { 121 textRecipientList = buildProperties.get("textRecipients").toString(); 122 } catch (NullPointerException e) { 123 System.out.println( 124 "Value for textRecipients not found in monitor.properties"); 125 126 } 127 128 try { 129 sender = buildProperties.get("sender").toString(); 130 } catch (NullPointerException e) { 131 System.out.println( 132 "Value for sender not found in monitor.properties"); 133 } 134 135 try { 136 host = buildProperties.get("host").toString(); 137 } catch (NullPointerException e) { 138 System.out.println( 139 "Value for host not found in monitor.properties"); 140 } 141 142 try { 143 logFile = buildProperties.get("log").toString(); 144 } catch (NullPointerException e) { 145 System.out.println( 146 "Value for log not found in monitor.properties"); 147 System.out.println( 148 "Default value, log=index.php will be used."); 149 150 } 151 152 } catch (IOException e) { 153 e.printStackTrace(); 154 } 155 156 } 157 158 159 public static void main(String args[]) { 160 new BuildProperties(); 161 } 162 163 164 /** 165 * Returns the buildLabel. 166 * @return String 167 */ 168 public String getBuildLabel() { 169 return buildLabel; 170 } 171 172 /** 173 * Sets the buildLabel. 174 * @param buildLabel The buildLabel to set 175 */ 176 public void setBuildLabel(String buildLabel) { 177 this.buildLabel = buildLabel; 178 } 179 180 /** 181 * Returns the logFile. 182 * @return String 183 */ 184 public String getLogFile() { 185 return logFile; 186 } 187 188 /** 189 * Sets the logFile. 190 * @param logFile The logFile to set 191 */ 192 public void setLogFile(String logFile) { 193 this.logFile = logFile; 194 } 195 196 /** 197 * Returns the buildid. 198 * @return String 199 */ 200 public String getBuildid() { 201 return buildid; 202 } 203 204 /** 205 * Returns the timestamp. 206 * @return String 207 */ 208 public String getTimestamp() { 209 return timestamp; 210 } 211 212 /** 213 * Sets the buildid. 214 * @param buildid The buildid to set 215 */ 216 public void setBuildid(String buildid) { 217 this.buildid = buildid; 218 } 219 220 /** 221 * Sets the timestamp. 222 * @param timestamp The timestamp to set 223 */ 224 public void setTimestamp(String timestamp) { 225 this.timestamp = timestamp; 226 } 227 228 /** 229 * Returns the host. 230 * @return String 231 */ 232 public String getHost() { 233 return host; 234 } 235 236 /** 237 * Returns the recipientList. 238 * @return String 239 */ 240 public String getToRecipientList() { 241 return toRecipientList; 242 } 243 244 /** 245 * Returns the sender. 246 * @return String 247 */ 248 public String getSender() { 249 return sender; 250 } 251 252 /** 253 * Sets the host. 254 * @param host The host to set 255 */ 256 public void setHost(String host) { 257 this.host = host; 258 } 259 260 /** 261 * Sets the recipientList. 262 * @param recipientList The recipientList to set 263 */ 264 public void setRecipientList(String recipientList) { 265 this.toRecipientList = recipientList; 266 } 267 268 /** 269 * Sets the sender. 270 * @param sender The sender to set 271 */ 272 public void setSender(String sender) { 273 this.sender = sender; 274 } 275 276 /** 277 * Returns the buildSubjectPrefix. 278 * @return String 279 */ 280 public String getBuildSubjectPrefix() { 281 return buildSubjectPrefix; 282 } 283 284 /** 285 * Sets the buildSubjectPrefix. 286 * @param buildSubjectPrefix The buildSubjectPrefix to set 287 */ 288 public void setBuildSubjectPrefix(String buildSubjectPrefix) { 289 this.buildSubjectPrefix = buildSubjectPrefix; 290 } 291 292 /** 293 * Returns the httpUrl. 294 * @return String 295 */ 296 public String getHttpUrl() { 297 return httpUrl; 298 } 299 300 /** 301 * Sets the httpUrl. 302 * @param httpUrl The httpUrl to set 303 */ 304 public void setHttpUrl(String downloadUrl) { 305 this.httpUrl = downloadUrl; 306 } 307 308 /** 309 * Returns the ftpUrl. 310 * @return String 311 *//* 312 public String getftpUrl() { 313 return ftpUrl; 314 }*/ 315 316 /** 317 * Sets the ftpUrl. 318 * @param ftpUrl The httpUrl to set 319 *//* 320 public void setftpUrl(String downloadUrl) { 321 this.ftpUrl = downloadUrl; 322 }*/ 323 324 325 public String getTextRecipientList() { 326 return textRecipientList; 327 } 328 329 330 public void setTextRecipientList(String textRecipientList) { 331 this.textRecipientList = textRecipientList; 332 } 333 334} 335