package com.opengamma.web.bundle;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * Provides a build stamp consisting of a version and time/date
 * to be appended to resource urls
 */
public class BuildData {

  /** Stamp to be appended to resource urls */
  private static final String s_stamp;
  /** Logger. */
  private static final Logger s_logger = LoggerFactory.getLogger(ScriptTag.class);

  static {
    Properties prop = new Properties();
    String result;
    try {
      String resource = ClassLoader.getSystemResource("com/opengamma/web/bundle/BuifldData.txt").getPath();
      prop.load(new FileInputStream(new File(resource)));
      result = prop.getProperty("version");
      result += prop.getProperty("build.date");

    } catch (IOException e) {
      result = "default";
      s_logger.warn("Failed to load build data for resource urls", e);
    }
    s_stamp = result;
  }

  /** returns the stamp of type String */
  public static String getBuildStamp() {
    return s_stamp;
  }
}

@@ -125,25 +125,84 @@
 ava.
-util.Properties;%0A
+net.URL;%0Aimport java.util.Properties;%0A%0Aimport org.apache.commons.io.IOUtils;
 %0Aimp
@@ -623,24 +623,58 @@
 operties();%0A
+    FileInputStream input = null;%0A
     String r
@@ -773,17 +773,16 @@
 ndle/Bui
-f
 ldData.t
@@ -807,18 +807,16 @@
     
-prop.load(
+input = 
 new 
@@ -850,16 +850,39 @@
 source))
+;%0A      prop.load(input
 );%0A     
@@ -968,17 +968,16 @@
 date%22);%0A
-%0A
     %7D ca
@@ -981,18 +981,16 @@
  catch (
-IO
 Exceptio
@@ -1093,16 +1093,67 @@
 s%22, e);%0A
+    %7D finally %7B%0A      IOUtils.closeQuietly(input);%0A
     %7D%0A  

correct error handling if build data for url fails