class to get version of gsa
diff --git a/src/com/google/enterprise/adaptor/GsaVersion.java b/src/com/google/enterprise/adaptor/GsaVersion.java
new file mode 100644
index 0000000..3a9024e
--- /dev/null
+++ b/src/com/google/enterprise/adaptor/GsaVersion.java
@@ -0,0 +1,77 @@
+// Copyright 2013 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.enterprise.adaptor;
+
+import com.google.common.annotations.VisibleForTesting;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.net.URLConnection;
+import java.nio.charset.Charset;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Acquires and provides GSA's version . */
+public final class GsaVersion {
+  private static final Charset charset = Charset.forName("UTF-8");
+
+  private String ver;  // example: 7.2.1-1
+  private int parts[] = new int[4];
+
+  private static final Pattern VERSION_FORMAT
+      = Pattern.compile("^(\\d+)\\.(\\d+)\\.(\\d+)\\-(\\d+)$");
+ 
+  @VisibleForTesting 
+  GsaVersion(String version) {
+    ver = version;
+    Matcher m = VERSION_FORMAT.matcher(ver);
+    if (!m.matches()) {
+      throw new IllegalArgumentException("not to format: " + ver);
+    }
+    parts[0] = Integer.parseInt(m.group(1));
+    parts[1] = Integer.parseInt(m.group(2));
+    parts[2] = Integer.parseInt(m.group(3));
+    parts[3] = Integer.parseInt(m.group(4));
+  }
+
+  /* Requsts entire detailed version string and returns it. */
+  public static GsaVersion get(String host) throws IOException {
+    URL url = new URL("http", host, "sw_version.txt");
+    URLConnection conn = url.openConnection();
+    InputStream in = conn.getInputStream();
+    String ver = IOHelper.readInputStreamToString(in, charset);
+    return new GsaVersion(ver);
+  }
+
+  /** Provides entire version string gotten from GSA, eg. 7.2.1-1 */
+  public String toString() {
+    return ver;
+  } 
+
+  public boolean atLeast(String minimum) {
+    GsaVersion min = new GsaVersion(minimum);
+    for (int i = 0; i < parts.length; i++) {
+      if (parts[i] < min.parts[i]) {
+        return false;
+      }
+      if (parts[i] > min.parts[i]) {
+        return true;
+      }
+      // parts[i] == min.parts[i] are equal
+    }
+    return true;  // all parts were the same
+  }
+}
diff --git a/test/com/google/enterprise/adaptor/GsaVersionTest.java b/test/com/google/enterprise/adaptor/GsaVersionTest.java
new file mode 100644
index 0000000..65401a9
--- /dev/null
+++ b/test/com/google/enterprise/adaptor/GsaVersionTest.java
@@ -0,0 +1,61 @@
+// Copyright 2013 Google Inc. All Rights Reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//      http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package com.google.enterprise.adaptor;
+
+import static org.junit.Assert.*;
+
+import org.junit.*;
+import org.junit.rules.ExpectedException;
+
+/** Tests for {@link GsaVersion}. */
+public class GsaVersionTest {
+  @Rule
+  public ExpectedException thrown = ExpectedException.none();
+
+  private GsaVersion base = new GsaVersion("7.2.1-1");
+
+  @Test
+  public void testConstructorNotEnough() {
+    thrown.expect(IllegalArgumentException.class);
+    new GsaVersion("7.2.1");
+  }
+
+  @Test
+  public void testConstructorBadFormat() {
+    thrown.expect(IllegalArgumentException.class);
+    new GsaVersion("7.2.1.1");
+  }
+
+  @Test
+  public void testConstructorToomuch() {
+    thrown.expect(IllegalArgumentException.class);
+    new GsaVersion("7.2.1.1-1");
+  }
+
+  @Test
+  public void testAtLeastWithBigger() {
+    assertFalse(base.atLeast("7.4.0-1"));
+  }
+
+  @Test
+  public void testAtLeastWithSmaller() {
+    assertTrue(base.atLeast("6.14.36-155"));
+  }
+
+  @Test
+  public void testAtLeastWithEqual() {
+    assertTrue(base.atLeast("7.2.1-1"));
+  }
+}