[jboss-svn-commits] JBL Code SVN: r21214 - in labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools: src/org/guvnor/tools/utils/webdav and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Thu Jul 24 11:45:02 EDT 2008


Author: john.graham at jboss.org
Date: 2008-07-24 11:45:01 -0400 (Thu, 24 Jul 2008)
New Revision: 21214

Modified:
   labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/META-INF/MANIFEST.MF
   labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/WebDavClient.java
   labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/wizards/AddResourceWizard.java
Log:
Address slowness when adding resources to Guvnor

Modified: labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/META-INF/MANIFEST.MF
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/META-INF/MANIFEST.MF	2008-07-24 12:25:05 UTC (rev 21213)
+++ labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/META-INF/MANIFEST.MF	2008-07-24 15:45:01 UTC (rev 21214)
@@ -2,7 +2,7 @@
 Bundle-ManifestVersion: 2
 Bundle-Name: %plugin.name
 Bundle-SymbolicName: org.guvnor.tools;singleton:=true
-Bundle-Version: 0.6.0.200807211507
+Bundle-Version: 0.6.0.200807241144
 Bundle-Activator: org.guvnor.tools.Activator
 Bundle-Vendor: %plugin.provider
 Bundle-Localization: plugin

Modified: labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/WebDavClient.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/WebDavClient.java	2008-07-24 12:25:05 UTC (rev 21213)
+++ labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/utils/webdav/WebDavClient.java	2008-07-24 15:45:01 UTC (rev 21214)
@@ -281,12 +281,12 @@
 					throw new WebDavException(response);
 				}
 			}
-			return res;
 		} finally {
 			if (response != null) {
 				response.close();
 			}
 		}
+		return res;
 	}
 	
 	/*
@@ -299,7 +299,8 @@
 			ILocator locator = WebDAVFactory.locatorFactory.newLocator(resource);
 			response = client.put(locator, createContext(), is);
 			if (response.getStatusCode() != IResponse.SC_OK
-		       && response.getStatusCode() != IResponse.SC_NO_CONTENT) {
+		       && response.getStatusCode() != IResponse.SC_NO_CONTENT
+		       && response.getStatusCode() != IResponse.SC_CREATED) {
 				throw new WebDavException(response);
 			}
 		} finally {

Modified: labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/wizards/AddResourceWizard.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/wizards/AddResourceWizard.java	2008-07-24 12:25:05 UTC (rev 21213)
+++ labs/jbossrules/trunk/drools-eclipse/org.guvnor.tools/src/org/guvnor/tools/wizards/AddResourceWizard.java	2008-07-24 15:45:01 UTC (rev 21214)
@@ -1,5 +1,6 @@
 package org.guvnor.tools.wizards;
 
+import java.io.ByteArrayInputStream;
 import java.net.URL;
 import java.util.Iterator;
 
@@ -96,10 +97,16 @@
 				WebDavServerCache.cacheWebDavClient(model.getRepLocation(), client);
 			}
 			try {
-				res = client.createResource(fullPath, selectedFile.getContents(), false);
+				// Hack: When creating a file, if the actual contents are passed first,
+				// the client hangs for about 20 seconds when closing the InputStream.
+				// Don't know why...
+				// But, if the file is created with empty contents, and then the contents
+				// set, the operation is fast (less than a couple of seconds)
+				res = client.createResource(fullPath, new ByteArrayInputStream(new byte[0]), false);
 				if (!res) {
 					setDuplicateFileError(selectedFile);
 				}
+				client.putResource(fullPath, selectedFile.getContents());
 			} catch (WebDavException wde) {
 				if (wde.getErrorCode() != IResponse.SC_UNAUTHORIZED) {
 					// If not an authentication failure, we don't know what to do with it
@@ -108,10 +115,12 @@
 				boolean retry = PlatformUtils.getInstance().
 									authenticateForServer(model.getRepLocation(), client); 
 				if (retry) {
-					res = client.createResource(fullPath, selectedFile.getContents());
+					// See Hack note immediately above...
+					res = client.createResource(fullPath, new ByteArrayInputStream(new byte[0]), false);
 					if (!res) {
 						setDuplicateFileError(selectedFile);
 					}
+					client.putResource(fullPath, selectedFile.getContents());
 				}
 			}
 			if (res) {




More information about the jboss-svn-commits mailing list