[jboss-svn-commits] JBL Code SVN: r29535 - labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 5 09:29:21 EDT 2009


Author: Rikkola
Date: 2009-10-05 09:29:20 -0400 (Mon, 05 Oct 2009)
New Revision: 29535

Modified:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ModelContentHandler.java
Log:
GUVNOR-453 : Uploading more than one model jar does not automatically update imported types

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ModelContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ModelContentHandler.java	2009-10-05 13:01:29 UTC (rev 29534)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ModelContentHandler.java	2009-10-05 13:29:20 UTC (rev 29535)
@@ -34,51 +34,56 @@
  */
 public class ModelContentHandler extends ContentHandler {
 
-	public void retrieveAssetContent(RuleAsset asset, PackageItem pkg,
-			AssetItem item) throws SerializableException {
-		// do nothing, as we have an attachment
-	}
+    public void retrieveAssetContent(RuleAsset asset,
+                                     PackageItem pkg,
+                                     AssetItem item) throws SerializableException {
+        // do nothing, as we have an attachment
+    }
 
-	public void storeAssetContent(RuleAsset asset, AssetItem repoAsset)
-			throws SerializableException {
-		// do nothing, as we have an attachment
-	}
+    public void storeAssetContent(RuleAsset asset,
+                                  AssetItem repoAsset) throws SerializableException {
+        // do nothing, as we have an attachment
+    }
 
-	/**
-	 * This is called when a model jar is attached, it will peer into it, and then automatically add imports
-	 * if there aren't any already in the package header configuration.
-	 */
-	public void modelAttached(AssetItem asset) throws IOException {
-		InputStream in = asset.getBinaryContentAttachment();
+    /**
+     * This is called when a model jar is attached, it will peer into it, and then automatically add imports
+     * if there aren't any already in the package header configuration.
+     */
+    public void modelAttached(AssetItem asset) throws IOException {
+        InputStream in = asset.getBinaryContentAttachment();
 
-		PackageItem pkg = asset.getPackage();
-		String header = ServiceImplementation.getDroolsHeader(pkg);
-		if ( header == null || "".equals(header.trim())) {
-			StringBuilder buf = new StringBuilder();
+        PackageItem pkg = asset.getPackage();
+        String header = ServiceImplementation.getDroolsHeader( pkg );
+        StringBuilder buf = new StringBuilder();
 
-			JarInputStream jis = new JarInputStream(in);
-			JarEntry entry = null;
-			while ((entry = jis.getNextJarEntry()) != null) {
-				if (!entry.isDirectory()) {
-					if (entry.getName().endsWith(".class") && entry.getName().indexOf('$') == -1) {
-						 buf.append("import " + convertPathToName(entry.getName()));
-						 buf.append("\n");
-					}
-				}
-			}
+        if ( header != null ) {
+            buf.append( header );
+        }
 
-			ServiceImplementation.updateDroolsHeader(buf.toString(), pkg);
+        JarInputStream jis = new JarInputStream( in );
+        JarEntry entry = null;
+        while ( (entry = jis.getNextJarEntry()) != null ) {
+            if ( !entry.isDirectory() ) {
+                if ( entry.getName().endsWith( ".class" ) && entry.getName().indexOf( '$' ) == -1 ) {
+                    buf.append( "import " + convertPathToName( entry.getName() ) );
+                    buf.append( "\n" );
+                }
+            }
+        }
 
-			//pkg.updateHeader(buf.toString());
+        ServiceImplementation.updateDroolsHeader( buf.toString(),
+                                                  pkg );
 
-			pkg.checkin("Imports setup automatically on model import.");
+        //pkg.updateHeader(buf.toString());
 
-		}
-	}
+        pkg.checkin( "Imports setup automatically on model import." );
 
+    }
 
-	public static String convertPathToName(String name) {
-		return name.replace(".class", "").replace("/", ".");
-	}
+    public static String convertPathToName(String name) {
+        return name.replace( ".class",
+                             "" ).replace( "/",
+                                           "." );
+    }
 
 }
\ No newline at end of file



More information about the jboss-svn-commits mailing list