Author: lzoubek(a)redhat.com
Date: 2011-08-01 09:39:09 -0400 (Mon, 01 Aug 2011)
New Revision: 33413
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
Log:
forgotten class
Modified:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2011-08-01
12:43:50 UTC (rev 33412)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/Annotations.java 2011-08-01
13:39:09 UTC (rev 33413)
@@ -103,7 +103,7 @@
*/
boolean required() default true;
/**
- * state (default (default {@link ServerState#ALL}))
+ * state (default (default {@link ServerState#Running}))
* @return
*/
ServerState state() default ServerState.Running;
@@ -113,7 +113,7 @@
*/
ServerType type() default ServerType.ALL;
/**
- * server location (derfault {@link ServerLocation#Any})
+ * server location (default {@link ServerLocation#Any})
* @return
*/
ServerLocation location() default ServerLocation.Any;
Added:
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java
===================================================================
---
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java
(rev 0)
+++
trunk/tests/plugins/org.jboss.tools.ui.bot.ext/src/org/jboss/tools/ui/bot/ext/config/RuntimeBean.java 2011-08-01
13:39:09 UTC (rev 33413)
@@ -0,0 +1,93 @@
+package org.jboss.tools.ui.bot.ext.config;
+
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.RandomAccessFile;
+import java.net.HttpURLConnection;
+import java.net.URL;
+
+import org.apache.log4j.Logger;
+
+public class RuntimeBean {
+ protected static final Logger log = Logger.getLogger(RuntimeBean.class);
+ protected String key;
+ public String version;
+ public String runtimeHome;
+
+ protected static RuntimeBean fromString(String propValue, RuntimeBean bean) throws
Exception{
+ try {
+ if (propValue==null) {
+ return null;
+ }
+ String[] params = propValue.split(",");
+ bean.runtimeHome=params[1];
+ bean.version=params[0];
+ return bean;
+ }
+ catch (Exception ex) {
+ throw new Exception("Cannot parse "+bean.key+" property
line",ex);
+ }
+ }
+ @Override
+ public String toString() {
+ return String.format("%s runtime version=%s, home=%s",this.key,
+ this.version, this.runtimeHome);
+ }
+ public static String downloadRuntime(String url) {
+ BufferedInputStream in = null;
+ RandomAccessFile raf = null;
+ String outputFile =
System.getProperty("java.io.tmpdir")+System.getProperty("file.separator")+url.replaceAll(".*/",
"");
+ log.info(String.format("Downloading %s to %s",url,outputFile));
+ if (new File(outputFile).exists()) {
+ log.info("Output file already exists, skipping");
+ return outputFile;
+ }
+ int BUFFER_SIZE=8196;
+ try {
+ // open Http connection to URL
+ HttpURLConnection conn = (HttpURLConnection)new URL(url).openConnection();
+ // connect to server
+ conn.connect();
+
+ // Make sure the response code is in the 200 range.
+ if (conn.getResponseCode() != 200) {
+ log.error("Cannot download file, server returned
"+conn.getResponseCode()+" : "+conn.getResponseMessage());
+ return null;
+ }
+
+ // get the input stream
+ in = new BufferedInputStream(conn.getInputStream());
+
+ // open the output file and seek to the start location
+ raf = new RandomAccessFile(outputFile, "rw");
+
+ byte data[] = new byte[BUFFER_SIZE];
+ int numRead;
+ while(((numRead = in.read(data,0,BUFFER_SIZE)) != -1))
+ {
+ // write to buffer
+ raf.write(data,0,numRead);
+ }
+ log.info("DONE");
+ return outputFile;
+
+ } catch (IOException e) {
+ log.error(e);
+ return null;
+ } finally {
+ if (raf != null) {
+ try {
+ raf.close();
+ } catch (IOException e) {}
+ }
+
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {}
+ }
+ }
+ }
+
+}
Show replies by date