[jboss-svn-commits] JBL Code SVN: r29992 - labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Wed Nov 4 19:15:55 EST 2009


Author: michael.neale at jboss.com
Date: 2009-11-04 19:15:55 -0500 (Wed, 04 Nov 2009)
New Revision: 29992

Removed:
   labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/ClientHttpRequest.java
   labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter1.java
   labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter2.java
   labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation.java
   labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation2.java
   labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/WebDavImporter.java
Log:
removing un-needed

Deleted: labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/ClientHttpRequest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/ClientHttpRequest.java	2009-11-04 23:06:27 UTC (rev 29991)
+++ labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/ClientHttpRequest.java	2009-11-05 00:15:55 UTC (rev 29992)
@@ -1,505 +0,0 @@
-package org.jboss.drools.guvnor.importgenerator.xdeleteme;
-
-import java.net.URLConnection;
-import java.net.URL;
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-import java.io.File;
-import java.io.InputStream;
-import java.util.Random;
-import java.io.OutputStream;
-import java.io.FileInputStream;
-import java.util.Iterator;
-
-/**
- * <p>Title: Client HTTP Request class</p>
- * <p>Description: this class helps to send POST HTTP requests with various form data,
- * including files. Cookies can be added to be included in the request.</p>
- *
- * @author Vlad Patryshev
- * @version 1.0
- */
-public class ClientHttpRequest {
-  URLConnection connection;
-  OutputStream os = null;
-  Map cookies = new HashMap();
-
-  protected void connect() throws IOException {
-    if (os == null) os = connection.getOutputStream();
-  }
-
-  protected void write(char c) throws IOException {
-    connect();
-    os.write(c);
-  }
-
-  protected void write(String s) throws IOException {
-    connect();
-    os.write(s.getBytes());
-  }
-
-  protected void newline() throws IOException {
-    connect();
-    write("\r\n");
-  }
-
-  protected void writeln(String s) throws IOException {
-    connect();
-    write(s);
-    newline();
-  }
-
-  private static Random random = new Random();
-
-  protected static String randomString() {
-    return Long.toString(random.nextLong(), 36);
-  }
-
-  public static String boundary = "---------------------------" + randomString() + randomString() + randomString();
-
-  private void boundary() throws IOException {
-    write("--");
-    write(boundary);
-  }
-
-  /**
-   * Creates a new multipart POST HTTP request on a freshly opened URLConnection
-   *
-   * @param connection an already open URL connection
-   * @throws IOException
-   */
-  public ClientHttpRequest(URLConnection connection) throws IOException {
-    this.connection = connection;
-    connection.setDoOutput(true);
-    connection.setRequestProperty("Content-Type",
-                                  "multipart/form-data; boundary=" + boundary);
-  }
-
-  public enum ContentType{
-	  MULTIPART_FORM_DATA("multipart/form-data; boundary=" + ClientHttpRequest.boundary),
-	  TEXT_X_GWT_RPC("text/x-gwt-rpc; charset=utf-8");
-	  public String value;
-	  private ContentType(String value){
-		  this.value=value;
-	  }
-  }
-  public ClientHttpRequest(URLConnection connection, ContentType contentType) throws IOException {
-	    this.connection = connection;
-	    connection.setDoOutput(true);
-	    connection.setRequestProperty("Content-Type", contentType.value);
-	  }
-  /**
-   * Creates a new multipart POST HTTP request for a specified URL
-   *
-   * @param url the URL to send request to
-   * @throws IOException
-   */
-  public ClientHttpRequest(URL url) throws IOException {
-    this(url.openConnection());
-  }
-
-  /**
-   * Creates a new multipart POST HTTP request for a specified URL string
-   *
-   * @param urlString the string representation of the URL to send request to
-   * @throws IOException
-   */
-  public ClientHttpRequest(String urlString) throws IOException {
-    this(new URL(urlString));
-  }
-
-
-//  private void postCookies() {
-//    StringBuffer cookieList = new StringBuffer();
-//
-//    for (Iterator i = cookies.entrySet().iterator(); i.hasNext();) {
-//      Map.Entry entry = (Map.Entry)(i.next());
-//      cookieList.append(entry.getKey().toString() + "=" + entry.getValue());
-//
-//      if (i.hasNext()) {
-//        cookieList.append("; ");
-//      }
-//    }
-//    if (cookieList.length() > 0) {
-//      connection.setRequestProperty("Cookie", cookieList.toString());
-//    }
-//  }
-//
-//  /**
-//   * adds a cookie to the requst
-//   * @param name cookie name
-//   * @param value cookie value
-//   * @throws IOException
-//   */
-//  public void setCookie(String name, String value) throws IOException {
-//    cookies.put(name, value);
-//  }
-//
-//  /**
-//   * adds cookies to the request
-//   * @param cookies the cookie "name-to-value" map
-//   * @throws IOException
-//   */
-//  public void setCookies(Map cookies) throws IOException {
-//    if (cookies == null) return;
-//    this.cookies.putAll(cookies);
-//  }
-//
-//  /**
-//   * adds cookies to the request
-//   * @param cookies array of cookie names and values (cookies[2*i] is a name, cookies[2*i + 1] is a value)
-//   * @throws IOException
-//   */
-//  public void setCookies(String[] cookies) throws IOException {
-//    if (cookies == null) return;
-//    for (int i = 0; i < cookies.length - 1; i+=2) {
-//      setCookie(cookies[i], cookies[i+1]);
-//    }
-//  }
-
-  private void writeName(String name) throws IOException {
-    newline();
-    write("Content-Disposition: form-data; name=\"");
-    write(name);
-    write('"');
-  }
-
-  /**
-   * adds a string parameter to the request
-   * @param name parameter name
-   * @param value parameter value
-   * @throws IOException
-   */
-  public void setParameter(String name, String value) throws IOException {
-    boundary();
-    writeName(name);
-    newline(); newline();
-    writeln(value);
-  }
-
-  private static void pipe(InputStream in, OutputStream out) throws IOException {
-    byte[] buf = new byte[500000];
-    int nread;
-    int navailable;
-    int total = 0;
-    synchronized (in) {
-      while((nread = in.read(buf, 0, buf.length)) >= 0) {
-        out.write(buf, 0, nread);
-        total += nread;
-      }
-    }
-    out.flush();
-    buf = null;
-  }
-
-  /**
-   * adds a file parameter to the request
-   * @param name parameter name
-   * @param filename the name of the file
-   * @param is input stream to read the contents of the file from
-   * @throws IOException
-   */
-  public void setParameter(String name, String filename, InputStream is) throws IOException {
-    boundary();
-    writeName(name);
-    write("; filename=\"");
-    write(filename);
-    write('"');
-    newline();
-    write("Content-Type: ");
-    String type = connection.guessContentTypeFromName(filename);
-    if (type == null) type = "application/octet-stream";
-    writeln(type);
-    newline();
-    pipe(is, os);
-    newline();
-  }
-
-  /**
-   * adds a file parameter to the request
-   * @param name parameter name
-   * @param file the file to upload
-   * @throws IOException
-   */
-  public void setParameter(String name, File file) throws IOException {
-    setParameter(name, file.getPath(), new FileInputStream(file));
-  }
-
-  /**
-   * adds a parameter to the request; if the parameter is a File, the file is uploaded, otherwise the string value of the parameter is passed in the request
-   * @param name parameter name
-   * @param object parameter value, a File or anything else that can be stringified
-   * @throws IOException
-   */
-  public void setParameter(String name, Object object) throws IOException {
-    if (object instanceof File) {
-      setParameter(name, (File) object);
-    } else {
-      setParameter(name, object.toString());
-    }
-  }
-
-  /**
-   * adds parameters to the request
-   * @param parameters "name-to-value" map of parameters; if a value is a file, the file is uploaded, otherwise it is stringified and sent in the request
-   * @throws IOException
-   */
-  public void setParameters(Map parameters) throws IOException {
-    if (parameters == null) return;
-    for (Iterator i = parameters.entrySet().iterator(); i.hasNext();) {
-      Map.Entry entry = (Map.Entry)i.next();
-      setParameter(entry.getKey().toString(), entry.getValue());
-    }
-  }
-
-  /**
-   * adds parameters to the request
-   * @param parameters array of parameter names and values (parameters[2*i] is a name, parameters[2*i + 1] is a value); if a value is a file, the file is uploaded, otherwise it is stringified and sent in the request
-   * @throws IOException
-   */
-  public void setParameters(Object[] parameters) throws IOException {
-    if (parameters == null) return;
-    for (int i = 0; i < parameters.length - 1; i+=2) {
-      setParameter(parameters[i].toString(), parameters[i+1]);
-    }
-  }
-
-  /**
-   * posts the requests to the server, with all the cookies and parameters that were added
-   * @return input stream with the server response
-   * @throws IOException
-   */
-  public InputStream post() throws IOException {
-    boundary();
-    writeln("--");
-    os.close();
-    return connection.getInputStream();
-  }
-
-  /**
-   * posts the requests to the server, with all the cookies and parameters that were added before (if any), and with parameters that are passed in the argument
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameters
-   */
-  public InputStream post(Map parameters) throws IOException {
-    setParameters(parameters);
-    return post();
-  }
-
-  /**
-   * posts the requests to the server, with all the cookies and parameters that were added before (if any), and with parameters that are passed in the argument
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameters
-   */
-  public InputStream post(Object[] parameters) throws IOException {
-    setParameters(parameters);
-    return post();
-  }
-
-  /**
-   * posts the requests to the server, with all the cookies and parameters that were added before (if any), and with cookies and parameters that are passed in the arguments
-   * @param cookies request cookies
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameters
-   * @see setCookies
-   */
-  public InputStream post(Map cookies, Map parameters) throws IOException {
-//    setCookies(cookies);
-    setParameters(parameters);
-    return post();
-  }
-
-  /**
-   * posts the requests to the server, with all the cookies and parameters that were added before (if any), and with cookies and parameters that are passed in the arguments
-   * @param cookies request cookies
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameters
-   * @see setCookies
-   */
-  public InputStream post(String[] cookies, Object[] parameters) throws IOException {
-//    setCookies(cookies);
-    setParameters(parameters);
-    return post();
-  }
-
-  /**
-   * post the POST request to the server, with the specified parameter
-   * @param name parameter name
-   * @param value parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public InputStream post(String name, Object value) throws IOException {
-    setParameter(name, value);
-    return post();
-  }
-
-  /**
-   * post the POST request to the server, with the specified parameters
-   * @param name1 first parameter name
-   * @param value1 first parameter value
-   * @param name2 second parameter name
-   * @param value2 second parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public InputStream post(String name1, Object value1, String name2, Object value2) throws IOException {
-    setParameter(name1, value1);
-    return post(name2, value2);
-  }
-
-  /**
-   * post the POST request to the server, with the specified parameters
-   * @param name1 first parameter name
-   * @param value1 first parameter value
-   * @param name2 second parameter name
-   * @param value2 second parameter value
-   * @param name3 third parameter name
-   * @param value3 third parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public InputStream post(String name1, Object value1, String name2, Object value2, String name3, Object value3) throws IOException {
-    setParameter(name1, value1);
-    return post(name2, value2, name3, value3);
-  }
-
-  /**
-   * post the POST request to the server, with the specified parameters
-   * @param name1 first parameter name
-   * @param value1 first parameter value
-   * @param name2 second parameter name
-   * @param value2 second parameter value
-   * @param name3 third parameter name
-   * @param value3 third parameter value
-   * @param name4 fourth parameter name
-   * @param value4 fourth parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public InputStream post(String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) throws IOException {
-    setParameter(name1, value1);
-    return post(name2, value2, name3, value3, name4, value4);
-  }
-
-  /**
-   * posts a new request to specified URL, with parameters that are passed in the argument
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameters
-   */
-  public static InputStream post(URL url, Map parameters) throws IOException {
-    return new ClientHttpRequest(url).post(parameters);
-  }
-
-  /**
-   * posts a new request to specified URL, with parameters that are passed in the argument
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameters
-   */
-  public static InputStream post(URL url, Object[] parameters) throws IOException {
-    return new ClientHttpRequest(url).post(parameters);
-  }
-
-  /**
-   * posts a new request to specified URL, with cookies and parameters that are passed in the argument
-   * @param cookies request cookies
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setCookies
-   * @see setParameters
-   */
-  public static InputStream post(URL url, Map cookies, Map parameters) throws IOException {
-    return new ClientHttpRequest(url).post(cookies, parameters);
-  }
-
-  /**
-   * posts a new request to specified URL, with cookies and parameters that are passed in the argument
-   * @param cookies request cookies
-   * @param parameters request parameters
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setCookies
-   * @see setParameters
-   */
-  public static InputStream post(URL url, String[] cookies, Object[] parameters) throws IOException {
-    return new ClientHttpRequest(url).post(cookies, parameters);
-  }
-
-  /**
-   * post the POST request specified URL, with the specified parameter
-   * @param name parameter name
-   * @param value parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public static InputStream post(URL url, String name1, Object value1) throws IOException {
-    return new ClientHttpRequest(url).post(name1, value1);
-  }
-
-  /**
-   * post the POST request to specified URL, with the specified parameters
-   * @param name1 first parameter name
-   * @param value1 first parameter value
-   * @param name2 second parameter name
-   * @param value2 second parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public static InputStream post(URL url, String name1, Object value1, String name2, Object value2) throws IOException {
-    return new ClientHttpRequest(url).post(name1, value1, name2, value2);
-  }
-
-  /**
-   * post the POST request to specified URL, with the specified parameters
-   * @param name1 first parameter name
-   * @param value1 first parameter value
-   * @param name2 second parameter name
-   * @param value2 second parameter value
-   * @param name3 third parameter name
-   * @param value3 third parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public static InputStream post(URL url, String name1, Object value1, String name2, Object value2, String name3, Object value3) throws IOException {
-    return new ClientHttpRequest(url).post(name1, value1, name2, value2, name3, value3);
-  }
-
-  /**
-   * post the POST request to specified URL, with the specified parameters
-   * @param name1 first parameter name
-   * @param value1 first parameter value
-   * @param name2 second parameter name
-   * @param value2 second parameter value
-   * @param name3 third parameter name
-   * @param value3 third parameter value
-   * @param name4 fourth parameter name
-   * @param value4 fourth parameter value
-   * @return input stream with the server response
-   * @throws IOException
-   * @see setParameter
-   */
-  public static InputStream post(URL url, String name1, Object value1, String name2, Object value2, String name3, Object value3, String name4, Object value4) throws IOException {
-    return new ClientHttpRequest(url).post(name1, value1, name2, value2, name3, value3, name4, value4);
-  }
-}

Deleted: labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter1.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter1.java	2009-11-04 23:06:27 UTC (rev 29991)
+++ labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter1.java	2009-11-05 00:15:55 UTC (rev 29992)
@@ -1,171 +0,0 @@
-package org.jboss.drools.guvnor.importgenerator.xdeleteme;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.Map;
-
-//import org.apache.commons.vfs.CacheStrategy;
-//import org.apache.commons.vfs.FileObject;
-//import org.apache.commons.vfs.FileSelector;
-//import org.apache.commons.vfs.FileSystemManager;
-//import org.apache.commons.vfs.FileSystemOptions;
-//import org.apache.commons.vfs.VFS;
-//import org.apache.commons.vfs.impl.StandardFileSystemManager;
-//import org.apache.commons.vfs.impl.VirtualFileSystem;
-//import org.apache.commons.vfs.util.FileObjectUtils;
-
-//import sun.misc.BASE64Encoder;
-
-/**
- * my own HTTP POST impl
- * @author mallen
- *
- */
-public class HTTPUploadImporter1 {
-	// "http://localhost:8080/drools-guvnor/org.drools.guvnor.Guvnor/package"
-	String protocol = "http";
-	String server = "localhost";
-	String port = "8080";
-	String path = "drools-guvnor/org.drools.guvnor.Guvnor";
-	String page = "package";
-	String fullPath = protocol + "://" + server + ":" + port + "/" + path + "/" + page;
-	String INPUT_FILE_LOCATION = "/home/mallen/workspace/drools-importer/rules/approval/route/refundcasestatus/1.0.0.SNAPSHOT/refundCaseStatus.drl";
-
-	private byte[] getFileData() throws FileNotFoundException, IOException {
-		File f = new File(INPUT_FILE_LOCATION);
-		byte[] contents = new byte[(int) f.length()]; // assuming no file will
-		// break the integer
-		// file size
-		BufferedInputStream is = new BufferedInputStream(new FileInputStream(f));
-		is.read(contents);
-		return contents;
-	}
-	
-	private String getFileContent() throws IOException, FileNotFoundException{
-		File f=new File(INPUT_FILE_LOCATION);
-		BufferedReader br=new BufferedReader(new FileReader(f));
-		StringBuffer sb=new StringBuffer();
-		String line="";
-		while ((line=br.readLine())!=null){
-			sb.append(line).append("\r\n");
-		}
-		return sb.toString();
-	}
-
-	public void run() {
-		try {
-
-			URL url = new URL(fullPath);
-			URLConnection cnn = url.openConnection();
-			//String data = URLEncoder.encode("classicDRLFile", "UTF-8") + "=" + URLEncoder.encode(getFileData().toString(), "UTF-8");
-			String fileContent=getFileContent();
-			String boundary = "---------------------------29772313742742";
-			cnn.setRequestProperty("POST", path+page +" HTTP/1.0");
-			cnn.setRequestProperty("Connection", "keep-alive");
-			cnn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + boundary);
-			cnn.setRequestProperty("Content-length", String.valueOf(fileContent.length()));
-			
-			cnn.setDoOutput(true);
-			cnn.setUseCaches(false);
-			DataOutputStream out = new DataOutputStream(cnn.getOutputStream());
-			
-			out.writeBytes(boundary);
-			String CRLF="\r\n";
-			out.writeBytes("Content-Disposition: form-data; name=\"classicDRLFile\"; filename=\"classicDRLFile\""+CRLF);
-			out.writeBytes("Content-type: text/plain"+CRLF);
-			out.writeBytes(fileContent+CRLF);
-			out.writeBytes(boundary +"--");
-			out.flush();
-			out.close();
-			
-			BufferedReader rd = new BufferedReader(new InputStreamReader(cnn.getInputStream()));
-			String line;
-			while ((line = rd.readLine()) != null) {
-				// do something with the response line
-				System.out.println(line);
-			}
-			//wr.close();
-			rd.close();
-			System.out.println("Done");
-
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-	private class RuleDetails {
-		private String title;
-		private String content;
-
-		public RuleDetails(String title, String content) {
-			this.title = title;
-			this.content = content;
-		}
-
-		public String getTitle() {
-			return title;
-		}
-
-		public String getContent() {
-			return content;
-		}
-
-		public void setContent(String content) {
-			this.content = content;
-		}
-	}
-
-	private class PackageDetails {
-		private String creator;
-		private String description;
-		private String imports;
-		private Map<String, RuleDetails> rules = new HashMap<String, RuleDetails>();
-
-		public PackageDetails(String creator, String imports, String description) {
-			this.creator = creator;
-			this.imports = imports;
-			this.description = description;
-
-		}
-
-		public String getCreator() {
-			return creator;
-		}
-
-		public String getDescription() {
-			return description;
-		}
-
-		public String getImports() {
-			return imports;
-		}
-
-		public Map<String, RuleDetails> getRules() {
-			return rules;
-		}
-
-		public void setRules(Map<String, RuleDetails> rules) {
-			this.rules = rules;
-		}
-	}
-
-	public static void main(String[] args) {
-		HTTPUploadImporter1 i = new HTTPUploadImporter1();
-		try {
-			i.run();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-
-	}
-}

Deleted: labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter2.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter2.java	2009-11-04 23:06:27 UTC (rev 29991)
+++ labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/HTTPUploadImporter2.java	2009-11-05 00:15:55 UTC (rev 29992)
@@ -1,153 +0,0 @@
-package org.jboss.drools.guvnor.importgenerator.xdeleteme;
-
-import java.io.BufferedInputStream;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.Map;
-
-
-
-/**
- * another HTTP POST - this time it works, now hitting gtw security issues
- * @author mallen
- *
- */
-public class HTTPUploadImporter2 {
-	String protocol = "http";
-	String server = "localhost";
-	String port = "8080";
-	String path = "drools-guvnor/org.drools.guvnor.Guvnor";
-	String page = "package";
-	String fullPath = protocol + "://" + server + ":" + port + "/" + path + "/" + page;
-	String XINPUT_FILE_LOCATION = "/home/mallen/workspace/drools-importer/rules/approval/route/firststage/1.0.0.SNAPSHOT/firstStageApproval.drl";
-	String INPUT_FILE_LOCATION = "/home/mallen/workspace/drools-importer/rules/approval/determine/valueapprovallimits/1.0.0.SNAPSHOT/valueApprovalLimits.xls";
-//
-//	private byte[] getFileData() throws FileNotFoundException, IOException {
-//		File f = new File(INPUT_FILE_LOCATION);
-//		byte[] contents = new byte[(int) f.length()]; // assuming no file will
-//		// break the integer
-//		// file size
-//		BufferedInputStream is = new BufferedInputStream(new FileInputStream(f));
-//		is.read(contents);
-//		return contents;
-//	}
-//	
-//	private String getFileContent() throws IOException, FileNotFoundException{
-//		File f=new File(INPUT_FILE_LOCATION);
-//		BufferedReader br=new BufferedReader(new FileReader(f));
-//		StringBuffer sb=new StringBuffer();
-//		String line="";
-//		while ((line=br.readLine())!=null){
-//			sb.append(line).append("\r\n");
-//		}
-//		return sb.toString();
-//	}
-
-	public void run() {
-		try {
-			String fullPath = protocol + "://" + server + ":" + port + "/" + path + "/" + page;
-			//ClientHttpRequest req=new ClientHttpRequest(new URL(fullPath).openConnection());
-			
-//			//login???
-//			String fullPathSec = protocol + "://" + server + ":" + port + "/drools-guvnor/org.drools.guvnor.Guvnor/securityService";
-//			ClientHttpRequest sec=new ClientHttpRequest(new URL(fullPathSec).openConnection(), ContentType.TEXT_X_GWT_RPC);
-//			sec.post(new Object[]{"userName", "admin", "pswd", "admin"});
-			
-			//new com.google.gwt.user.server.rpc.RemoteServiceServlet().
-			
-			URL url = new URL(fullPath);
-			URLConnection cnn = url.openConnection();
-			//upload file
-			ClientHttpRequest http=new ClientHttpRequest(cnn);
-			InputStream in=http.post(new Object[]{"fred.drl", new File(INPUT_FILE_LOCATION)});
-			//in.read();
-			BufferedReader rd = new BufferedReader(new InputStreamReader(in));
-			String line;
-			while ((line = rd.readLine()) != null) {
-				// do something with the response line
-				System.out.println(line);
-			}
-			
-			System.out.println("Done");
-
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-	}
-
-
-	private class RuleDetails {
-		private String title;
-		private String content;
-
-		public RuleDetails(String title, String content) {
-			this.title = title;
-			this.content = content;
-		}
-
-		public String getTitle() {
-			return title;
-		}
-
-		public String getContent() {
-			return content;
-		}
-
-		public void setContent(String content) {
-			this.content = content;
-		}
-	}
-
-	private class PackageDetails {
-		private String creator;
-		private String description;
-		private String imports;
-		private Map<String, RuleDetails> rules = new HashMap<String, RuleDetails>();
-
-		public PackageDetails(String creator, String imports, String description) {
-			this.creator = creator;
-			this.imports = imports;
-			this.description = description;
-
-		}
-
-		public String getCreator() {
-			return creator;
-		}
-
-		public String getDescription() {
-			return description;
-		}
-
-		public String getImports() {
-			return imports;
-		}
-
-		public Map<String, RuleDetails> getRules() {
-			return rules;
-		}
-
-		public void setRules(Map<String, RuleDetails> rules) {
-			this.rules = rules;
-		}
-	}
-
-	public static void main(String[] args) {
-		HTTPUploadImporter2 i = new HTTPUploadImporter2();
-		try {
-			i.run();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-
-	}
-}

Deleted: labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation.java	2009-11-04 23:06:27 UTC (rev 29991)
+++ labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation.java	2009-11-05 00:15:55 UTC (rev 29992)
@@ -1,162 +0,0 @@
-package org.jboss.drools.guvnor.importgenerator.xdeleteme;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.DataOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.FileReader;
-import java.io.InputStreamReader;
-import java.io.ObjectOutput;
-import java.io.ObjectOutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Properties;
-
-import org.apache.commons.codec.binary.Base64;
-import org.codehaus.janino.util.resource.FileResource;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatelessSession;
-import org.drools.StatelessSessionResult;
-import org.drools.agent.RuleAgent;
-import org.drools.commons.jci.compilers.CompilationResult;
-import org.drools.commons.jci.compilers.EclipseJavaCompiler;
-import org.drools.commons.jci.compilers.EclipseJavaCompilerSettings;
-import org.drools.commons.jci.compilers.JaninoCompilationProblem;
-import org.drools.commons.jci.compilers.JaninoJavaCompiler;
-import org.drools.commons.jci.compilers.JaninoJavaCompilerSettings;
-import org.drools.commons.jci.compilers.JavaCompiler;
-import org.drools.commons.jci.compilers.JavaCompilerFactory;
-import org.drools.commons.jci.problems.CompilationProblem;
-import org.drools.commons.jci.readers.MemoryResourceReader;
-import org.drools.commons.jci.readers.ResourceReader;
-import org.drools.commons.jci.stores.ResourceStore;
-import org.drools.compiler.PackageBuilder;
-//import org.drools.guvnor.server.builder.BRMSPackageBuilder;
-//import org.drools.guvnor.server.contenthandler.ContentHandler;
-//import org.drools.guvnor.server.contenthandler.ContentManager;
-//import org.drools.guvnor.server.contenthandler.DRLFileContentHandler;
-import org.drools.repository.AssetItem;
-import org.drools.template.model.DRLOutput;
-import org.jboss.drools.guvnor.importgenerator.utils.FileIO;
-
-public class TestRuleCompilation {
-	public static void main(String[] args){
-		new TestRuleCompilation().run();
-	}
-	
-	public void run(){
-		try {
-			String fileLocation = "rules/approval/determine/initialize/1.0.0.SNAPSHOT/resetCaseApproval.drl";
-			PackageBuilder builder = new PackageBuilder();
-			builder.addPackageFromDrl(new InputStreamReader(new FileInputStream(new File(fileLocation))));
-			org.drools.rule.Package pkg = builder.getPackage();
-			RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-			ruleBase.addPackage(pkg);
-			ByteArrayOutputStream baout=new ByteArrayOutputStream();
-			ObjectOutputStream out=new ObjectOutputStream(baout);
-			ruleBase.writeExternal(out);
-			byte[] bytes=baout.toByteArray();
-		  byte[] base64bytes=Base64.encodeBase64(bytes);
-		  String base64String=new String(base64bytes, "utf-8");
-			System.out.println(base64String.substring(0, 100));
-			
-			new BufferedInputStream(new FileInputStream(fileLocation)).read(bytes);
-      System.out.println(FileIO.toBase64(bytes).substring(0, 100));
-      
-      byte[] compfile=FileIO.readAll(new File("binaryfile.bin"));
-      System.out.println(new String(compfile, "utf-8").substring(0, 100));
-			
-      System.out.println(FileIO.fromBase64(compfile).substring(0, 800));
-      
-      JaninoJavaCompiler compiler=new JaninoJavaCompiler();
-      MemoryResourceReader rr=new MemoryResourceReader();
-      
-      rr.add("fred", FileIO.readAll(new File(fileLocation)));
-      ResourceStore arg2=new ResourceStore(){
-        public void remove(String x){
-          System.out.println(x);
-        }
-        public void write(String x, byte[] b){
-          System.out.println(x);
-        }
-        public byte[] read(String arg0) {
-          return null;
-        }
-      };
-      CompilationResult r=compiler.compile(new String[]{"fred"}, rr, arg2, this.getClass().getClassLoader(), new JaninoJavaCompilerSettings());
-      CompilationProblem[] errors=r.getErrors();
-      for (CompilationProblem e : errors) {
-        System.out.println(e);
-      }
-      
-//      DRLFileContentHandler h=new DRLFileContentHandler();
-//      BRMSPackageBuilder b=new BRMSPackageBuilder();
-//      AssetItem a=new AssetItem();
-//      a.getRulesRepository().importRulesRepositoryFromStream(new FileInputStream(new File(fileLocation)));
-//      h.compile(b, a, null);
-      
-      //from guvnor code
-//      Properties ps = new Properties();
-//      AssetItemIterator iter = pkg.listAssetsByFormat(new String[] {"properties", "conf"});
-//      while(iter.hasNext()) {
-//          AssetItem conf = iter.next();
-//          conf.getContent();
-//          Properties p = new Properties();
-//          p.load(conf.getBinaryContentAttachment());
-//          ps.putAll(p);
-//      }
-//      
-//      ps.setProperty( DefaultPackageNameOption.PROPERTY_NAME, this.pkg.getName() );
-//      builder = BRMSPackageBuilder.getInstance(BRMSPackageBuilder.getJars(pkg), ps);
-//
-//      if (compile && preparePackage()) {
-//        ContentHandler h = ContentManager.getHandler(asset.getFormat());
-//        IRuleAsset
-//        
-//        buildPackage();
-//      }
-      
-      
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-		
-		if (true) return;
-		RuleAgent agent=RuleAgent.newRuleAgent(getProps("package1"));
-		StatelessSession s=agent.getRuleBase().newStatelessSession();
-		Collection<Object> facts=new LinkedList<Object>();
-		facts.add("ping");
-		StatelessSessionResult result=s.executeWithResults(facts);
-		
-		Iterator it=result.iterateObjects();
-		boolean worked=false;
-		while(it.hasNext()) {
-			Object o=it.next();
-			if (o instanceof String){
-				if (((String)o).equals("pong")){
-					worked=true;
-				}
-			}
-		}
-		if (worked){
-			System.out.println("SUCCESS!!!!");
-		}else
-			System.out.println("FAILED :-(");
-	}
-	
-	private Properties getProps(String packageName){
-		Properties r=new Properties();
-		//r.put("url", System.getProperty("drools.package.url") + packageName);
-		//r.put("dir", System.getProperty("drools.package.dir") + packageName);
-		r.put("url", "http://");
-		r.put("name", "ORS");
-		r.put("poll", "30");
-		r.put("localCacheDir", "/tmp");
-		r.put("newInstance", "true");
-		return r;
-	}
-}

Deleted: labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation2.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation2.java	2009-11-04 23:06:27 UTC (rev 29991)
+++ labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/TestRuleCompilation2.java	2009-11-05 00:15:55 UTC (rev 29992)
@@ -1,235 +0,0 @@
-package org.jboss.drools.guvnor.importgenerator.xdeleteme;
-
-import java.io.BufferedInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.Properties;
-
-import org.apache.commons.codec.binary.Base64;
-import org.drools.KnowledgeBase;
-import org.drools.KnowledgeBaseFactory;
-import org.drools.RuleBase;
-import org.drools.RuleBaseFactory;
-import org.drools.StatefulSession;
-import org.drools.StatelessSession;
-import org.drools.StatelessSessionResult;
-import org.drools.agent.RuleAgent;
-import org.drools.builder.KnowledgeBuilder;
-import org.drools.builder.KnowledgeBuilderError;
-import org.drools.builder.KnowledgeBuilderFactory;
-import org.drools.builder.ResourceType;
-import org.drools.common.InternalRuleBase;
-import org.drools.common.WorkingMemoryAction;
-import org.drools.commons.jci.compilers.CompilationResult;
-import org.drools.commons.jci.compilers.JaninoJavaCompiler;
-import org.drools.commons.jci.compilers.JaninoJavaCompilerSettings;
-import org.drools.commons.jci.problems.CompilationProblem;
-import org.drools.commons.jci.readers.MemoryResourceReader;
-import org.drools.commons.jci.stores.ResourceStore;
-import org.drools.compiler.DroolsParserException;
-import org.drools.compiler.PackageBuilder;
-import org.drools.compiler.PackageBuilderConfiguration;
-import org.drools.compiler.RuleBaseLoader;
-import org.drools.io.Resource;
-import org.drools.io.ResourceFactory;
-import org.drools.io.impl.ClassPathResource;
-import org.drools.repository.AssetItem;
-import org.drools.reteoo.ReteooStatefulSession;
-import org.drools.reteoo.ReteooWorkingMemory;
-import org.drools.reteoo.ReteooWorkingMemory.WorkingMemoryReteAssertAction;
-import org.drools.rule.Package;
-import org.drools.rule.builder.RuleBuildContext;
-import org.drools.rule.builder.RuleBuilder;
-import org.drools.rule.builder.dialect.java.JavaDialectConfiguration;
-import org.drools.runtime.rule.FactHandle;
-import org.drools.runtime.rule.WorkingMemory;
-import org.jboss.drools.guvnor.importgenerator.utils.FileIO;
-
-public class TestRuleCompilation2 {
-  public static void main(String[] args) {
-    new TestRuleCompilation2().run();
-  }
-  
-  private void writeExternal(String name, java.io.Externalizable o) throws IOException{
-    ByteArrayOutputStream baout = new ByteArrayOutputStream();
-    ObjectOutputStream out = new ObjectOutputStream(baout);
-    o.writeExternal(out);
-    byte[] base64bytes = Base64.encodeBase64(baout.toByteArray());
-    String base64String = new String(base64bytes, "utf-8");
-    System.out.println(base64String.substring(0, 75)+" - "+name);
-    System.out.println(FileIO.fromBase64(base64bytes).substring(0, 500));
-  }
-  
-  private void buildDRLtoPKG(String path, String outputPackageFile){
-    try {
-      KnowledgeBase kBase = KnowledgeBaseFactory.newKnowledgeBase();
-      KnowledgeBuilder kBuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
-      Resource resource=ResourceFactory.newFileResource(path);
-      kBuilder.add(resource, ResourceType.DRL);
-      if (kBuilder.hasErrors()) {
-        for (KnowledgeBuilderError err : kBuilder.getErrors()) {
-          System.out.println(err.toString());
-        }
-        throw new IllegalStateException("DRL errors");
-      }
-      OutputStream os = new FileOutputStream(outputPackageFile);
-      ObjectOutputStream oos = new ObjectOutputStream(os);
-
-      oos.writeObject(kBuilder.getKnowledgePackages());
-    } catch (IOException e) {
-      e.printStackTrace();
-    }
-  }
-
-  public void run() {
-    try {
-      String fileLocation = "rules/approval/determine/initialize/1.0.0.SNAPSHOT/resetCaseApproval.drl";
-      String pkgFileLocation = "rules/approval/determine/initialize/1.0.0.SNAPSHOT/resetCaseApproval.pkg";
-      String originalFileLocation = "binaryfile.bin";
-      PackageBuilder builder = new PackageBuilder();
-      
-      buildDRLtoPKG(fileLocation, pkgFileLocation);
-      if (true) return;
-//      byte[] b=FileIO.readAll(new File(originalFileLocation));
-//      ObjectInputStream in=new ObjectInputStream(new ByteArrayInputStream(Base64.decodeBase64(b)));
-//      int x=in.available();
-//      Object o=in.readObject();
-//      System.out.println(o);
-      
-      //builder.addPackageFromDrl(new InputStreamReader(new FileInputStream(new File(fileLocation))));
-      
-      //Package
-      writeExternal("package object", builder.getPackage());
-      
-//      //RuleBase
-//      RuleBase rb=RuleBaseFactory.newRuleBase();
-//      rb.addPackage(builder.getPackage());
-//      writeExternal("ruleBase object", rb);
-      
-      //original file
-      byte[] compfile=FileIO.readAll(new File("binaryfile.bin"));
-      System.out.println(new String(compfile, "utf-8").substring(0, 75) +" - original base64 file");
-      
-      System.out.println(FileIO.fromBase64(compfile).substring(0, 500) + " - original raw file");
-      
-      //ruleBase.writeExternal(out);
-      
-      //RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-//      ReteooStatefulSession m=(ReteooStatefulSession)ruleBase.newStatefulSession();
-//      m.insert(new String("say "));
-      //ruleBase.addPackage(pkg);
-      
-//      JavaDialectConfiguration javaDialectConf = new JavaDialectConfiguration();
-//      javaDialectConf.setCompiler(JavaDialectConfiguration.JANINO);
-//      javaDialectConf.setJavaLanguageLevel("1.5");
-//      PackageBuilderConfiguration conf = javaDialectConf.getPackageBuilderConfiguration();
-//      PackageBuilder builder = new PackageBuilder(conf);
-      
-//      try {
-//        builder.addPackageFromDrl(new InputStreamReader(new FileInputStream(new File(fileLocation))));
-//        builder.compileAll();
-//        if (builder.hasErrors()) {
-//          System.out.println(builder.getErrors().toString());
-//          throw new RuntimeException("Unable to compile \""+new File(fileLocation).getName()+"\".");
-//        }
-//
-//        // get the compiled package (which is serializable)
-//        org.drools.rule.Package pkg = builder.getPackage();
-//
-//        // add the package to a rulebase (deploy the rule package).
-//        RuleBase ruleBase = RuleBaseFactory.newRuleBase();
-//        ruleBase.addPackage(pkg);
-//
-//        StatefulSession session = ruleBase.newStatefulSession();
-//
-//        session.insert(new String("say "));
-//
-//        session.fireAllRules();
-//      } catch (Exception e) {
-//        e.printStackTrace();
-//      }
-
-      // ruleBase.addPackage(pkg);
-      // ByteArrayOutputStream baout = new ByteArrayOutputStream();
-      // ObjectOutputStream out = new ObjectOutputStream(baout);
-      // ruleBase.writeExternal(out);
-      // byte[] bytes = baout.toByteArray();
-      // byte[] base64bytes = Base64.encodeBase64(bytes);
-      // String base64String = new String(base64bytes, "utf-8");
-      // System.out.println(base64String.substring(0, 100));
-
-    } catch (Exception e) {
-      e.printStackTrace();
-    }
-
-  }
-//
-//  public void testCompile() throws Exception {
-//    WorkingMemory localWorkingMemory = loadDrlRulesFromFile("myDrlFile.drl").newWorkingMemory();
-//    new WorkingMemoryReteAssertAction().
-//
-//    // Place the Java Bean in the working memory , keep a handle to it
-//    FactHandle currentHandle = localWorkingMemory.assertObject(new SearchModel());
-//
-//    // use Drools *without* any Java intervention
-//    localWorkingMemory.fireAllRules();
-//    localWorkingMemory.retract(currentHandle);
-//    System.out.println("SUCCESS");
-//  }
-//
-//  private RuleBase loadDrlRulesFromFile(String drlFileName) {
-//    RuleBase returnRuleBase = null;
-//    InputStream iStreamRules = getFileIfExists(drlFileName);
-//
-//    // Convert the Stream into a reader that Drools uses to parse files
-//    InputStreamReader drl = new InputStreamReader(iStreamRules);
-//
-//    System.out.println("Reading Rules from drl:" + drlFileName);
-//    PackageBuilder builder = new PackageBuilder();
-//    builder.addPackageFromDrl(drl);
-//    Package pkg = builder.getPackage();
-//
-//    if (pkg != null) {
-//      returnRuleBase = RuleBaseFactory.newRuleBase();
-//      returnRuleBase.addPackage(pkg);
-//    }
-//    return returnRuleBase;
-//  }
-//
-//  private InputStream getFileIfExists(String fileName) throws Exception {
-//    InputStream rIStream = null;
-//    System.out.println("Searching for File name:" + fileName);
-//    try {
-//      rIStream = new FileInputStream(fileName);
-//    } catch (FileNotFoundException fnfe1) {
-//      // log.debug("Could not find resource as file - attempting the classpath");
-//      try {
-//        ClassPathResource myClassPathReader = new ClassPathResource(fileName);
-//        rIStream = myClassPathReader.getInputStream();
-//        // log.debug("Found File via Classpath at path:" +
-//        // myClassPathReader.getPath() + " file:" +
-//        // myClassPathReader.getFile());
-//      } catch (Exception fnfe2) {
-//        fnfe2.printStackTrace();
-//
-//      }
-//    }
-//
-//    return rIStream;
-//
-//  }
-
-}

Deleted: labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/WebDavImporter.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/WebDavImporter.java	2009-11-04 23:06:27 UTC (rev 29991)
+++ labs/jbossrules/trunk/drools-guvnor/bulk-importer-util/guvnor-importer/src/main/java/org/jboss/drools/guvnor/importgenerator/xdeleteme/WebDavImporter.java	2009-11-05 00:15:55 UTC (rev 29992)
@@ -1,133 +0,0 @@
-package org.jboss.drools.guvnor.importgenerator.xdeleteme;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-//import org.apache.commons.vfs.CacheStrategy;
-//import org.apache.commons.vfs.FileObject;
-//import org.apache.commons.vfs.FileSelector;
-//import org.apache.commons.vfs.FileSystemManager;
-//import org.apache.commons.vfs.FileSystemOptions;
-//import org.apache.commons.vfs.VFS;
-//import org.apache.commons.vfs.impl.StandardFileSystemManager;
-//import org.apache.commons.vfs.impl.VirtualFileSystem;
-//import org.apache.commons.vfs.util.FileObjectUtils;
-
-/**
- * attempts at using apache webdav library
- * @author mallen
- *
- */
-public class WebDavImporter {
-	String protocol = "webdav";
-	String server = "admin:admin at localhost";
-	String port = "8080";
-	String path = "drools-guvnor/org.drools.guvnor.Guvnor/webdav";
-	String fullPath = protocol + "://" + server + ":" + port + "/" + path;
-	
-	public void run() {
-		try {
-//			StandardFileSystemManager fs = new StandardFileSystemManager();
-//
-//			fs.setCacheStrategy(CacheStrategy.ON_RESOLVE);
-//			fs.init();
-//
-//			FileSystemOptions fileoptions = new FileSystemOptions();
-//			FileObject root = fs.resolveFile(fullPath, fileoptions);
-//			FileObject packages = fs.resolveFile(fullPath + "/packages", fileoptions);
-//			FileObject packages2=root.getChildren()[0];
-//			
-//			File packageName = new File(packages.getName() + "/rules");
-//			packageName.createNewFile();
-//			
-//			File drl = new File(packageName.getName() +"/mjatest.drl");
-//			FileObject drlFO=fs.toFileObject(drl);
-//			drlFO.createFile();
-//
-//			Writer w = new FileWriter(drl);
-//			w.write("import java.util.Date");
-//			w.flush();
-//			w.close();
-//
-//			long size = drl.length();
-//			System.out.println(size);
-//			drlFO.close();
-//			
-//			System.out.println("Done.");
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-
-	}
-	
-
-
-
-
-	private class RuleDetails {
-		private String title;
-		private String content;
-
-		public RuleDetails(String title, String content) {
-			this.title = title;
-			this.content = content;
-		}
-
-		public String getTitle() {
-			return title;
-		}
-
-		public String getContent() {
-			return content;
-		}
-
-		public void setContent(String content) {
-			this.content = content;
-		}
-	}
-
-	private class PackageDetails {
-		private String creator;
-		private String description;
-		private String imports;
-		private Map<String, RuleDetails> rules = new HashMap<String, RuleDetails>();
-
-		public PackageDetails(String creator, String imports, String description) {
-			this.creator = creator;
-			this.imports = imports;
-			this.description = description;
-
-		}
-
-		public String getCreator() {
-			return creator;
-		}
-
-		public String getDescription() {
-			return description;
-		}
-
-		public String getImports() {
-			return imports;
-		}
-
-		public Map<String, RuleDetails> getRules() {
-			return rules;
-		}
-
-		public void setRules(Map<String, RuleDetails> rules) {
-			this.rules = rules;
-		}
-	}
-
-	public static void main(String[] args) {
-		WebDavImporter i = new WebDavImporter();
-		try {
-			i.run();
-		} catch (Exception e) {
-			e.printStackTrace();
-		}
-
-	}
-}



More information about the jboss-svn-commits mailing list