[jboss-svn-commits] JBL Code SVN: r35963 - in labs/jbossrules/trunk: drools-guvnor/src/main/java/org/drools/guvnor/server/builder and 3 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sat Nov 13 13:15:30 EST 2010


Author: Rikkola
Date: 2010-11-13 13:15:29 -0500 (Sat, 13 Nov 2010)
New Revision: 35963

Modified:
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentAssemblyError.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BPMN2ProcessHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BRLContentHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DRLFileContentHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DSLRuleContentHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DecisionTableXLSHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/EnumerationContentHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ICompilable.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/IValidating.java
   labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/RuleFlowHandler.java
   labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/builder/ContentPackageAssemblerTest.java
   labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java
Log:
GUVNOR-681 :Create a new top component to display and run the Guided Editor (RuleModeller) and all the things it needs in a "standalone" way
-Fix for validate

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/ServiceImplementation.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -116,7 +116,6 @@
 import org.drools.guvnor.server.util.TableDisplayHandler;
 import org.drools.ide.common.client.modeldriven.SuggestionCompletionEngine;
 import org.drools.ide.common.client.modeldriven.testing.Scenario;
-import org.drools.ide.common.server.util.GuidedDTDRLPersistence;
 import org.drools.lang.descr.PackageDescr;
 import org.drools.lang.descr.TypeDeclarationDescr;
 import org.drools.repository.AssetHistoryIterator;
@@ -1787,10 +1786,10 @@
         for ( int i = 0; i < result.length; i++ ) {
             ContentAssemblyError err = asm.getErrors().get( i );
             BuilderResultLine res = new BuilderResultLine();
-            res.assetName = err.itemInError.getName();
-            res.assetFormat = err.itemInError.getFormat();
-            res.message = err.errorReport;
-            res.uuid = err.itemInError.getUUID();
+            res.assetName = err.getName();
+            res.assetFormat = err.getFormat();
+            res.message = err.getErrorReport();
+            res.uuid = err.getUUID();
             result[i] = res;
         }
         return result;
@@ -1837,7 +1836,6 @@
             if ( asset.metaData.isBinary() ) {
                 AssetItem item = repository.loadAssetByUUID( asset.uuid );
 
-                // AssetContentFormatHandler();
                 handler.storeAssetContent( asset,
                                            item );
                 ((IRuleAsset) handler).assembleDRL( builder,
@@ -1865,23 +1863,41 @@
 
         try {
 
-            AssetItem item = repository.loadAssetByUUID( asset.uuid );
+            ContentHandler handler = ContentManager.getHandler( asset.metaData.format );
 
-            ContentHandler handler = ContentManager.getHandler( item.getFormat() );// new
-            // AssetContentFormatHandler();
-            handler.storeAssetContent( asset,
-                                       item );
+            if ( asset.metaData.isBinary() ) {
+                AssetItem item = repository.loadAssetByUUID( asset.uuid );
 
-            if ( handler instanceof IValidating ) {
-                return ((IValidating) handler).validateAsset( item );
-            } else {
+                handler.storeAssetContent( asset,
+                                           item );
 
-                ContentPackageAssembler asm = new ContentPackageAssembler( item );
-                if ( !asm.hasErrors() ) {
-                    return null;
+                if ( handler instanceof IValidating ) {
+                    return ((IValidating) handler).validateAsset( item );
                 } else {
-                    result.lines = generateBuilderResults( asm );
+
+                    ContentPackageAssembler asm = new ContentPackageAssembler( item );
+                    if ( !asm.hasErrors() ) {
+                        return null;
+                    } else {
+                        result.lines = generateBuilderResults( asm );
+                    }
                 }
+            } else {
+                if ( handler instanceof IValidating ) {
+                    return ((IValidating) handler).validateAsset( asset );
+                } else {
+
+                    PackageItem packageItem = repository.loadPackageByUUID( asset.metaData.packageUUID );
+
+                    ContentPackageAssembler asm = new ContentPackageAssembler( asset,
+                                                                               packageItem );
+                    if ( !asm.hasErrors() ) {
+                        return null;
+                    } else {
+                        result.lines = generateBuilderResults( asm );
+                    }
+                }
+
             }
         } catch ( Exception e ) {
             log.error( "Unable to build asset.",

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentAssemblyError.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentAssemblyError.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentAssemblyError.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,5 +1,5 @@
-/**
- * Copyright 2010 JBoss Inc
+/*
+ * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,24 +15,10 @@
  */
 
 package org.drools.guvnor.server.builder;
-/*
- * Copyright 2005 JBoss Inc
- * 
- * 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.
- */
 
-
-
+import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.repository.AssetItem;
+import org.drools.repository.PackageItem;
 import org.drools.repository.VersionableItem;
 
 /**
@@ -43,18 +29,62 @@
  */
 public class ContentAssemblyError {
 
-    public ContentAssemblyError(VersionableItem it, String message) {
-        this.itemInError = it;
-        this.errorReport = message;
+    private final String  errorReport;
+
+    private final String  format;
+    private final String  name;
+    private final String  uuid;
+    private final boolean isPackageItem;
+    private final boolean isAssetItem;
+
+    public ContentAssemblyError(VersionableItem itemInError,
+                                String errorReport) {
+        format = itemInError.getFormat();
+        name = itemInError.getName();
+        uuid = itemInError.getUUID();
+        isPackageItem = itemInError instanceof PackageItem;
+        isAssetItem = itemInError instanceof AssetItem;
+
+        this.errorReport = errorReport;
     }
-    /**
-     * This may be null, if its not associated to any particular asset.
-     */
-    public VersionableItem itemInError;
-    public String errorReport;
-    
+
+    public ContentAssemblyError(RuleAsset itemInError,
+                                String errorReport) {
+        format = itemInError.metaData.format;
+        name = itemInError.metaData.name;
+        uuid = itemInError.uuid;
+        isPackageItem = false;
+        isAssetItem = true;
+
+        this.errorReport = errorReport;
+    }
+
     public String toString() {
-        return this.errorReport;
+        return this.getErrorReport();
     }
-    
+
+    public String getFormat() {
+        return format;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getUUID() {
+        return uuid;
+    }
+
+    public boolean isAssetItem() {
+        return isAssetItem;
+    }
+
+    public boolean isPackageItem() {
+        return isPackageItem;
+    }
+
+    public String getErrorReport() {
+        return errorReport;
+    }
+
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/builder/ContentPackageAssembler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,5 +1,5 @@
-/**
- * Copyright 2010 JBoss Inc
+/*
+ * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,22 +16,6 @@
 
 package org.drools.guvnor.server.builder;
 
-/*
- * Copyright 2005 JBoss Inc
- *
- * 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.
- */
-
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.ArrayList;
@@ -43,6 +27,7 @@
 import org.drools.compiler.DroolsError;
 import org.drools.compiler.DroolsParserException;
 import org.drools.guvnor.client.common.AssetFormats;
+import org.drools.guvnor.client.rpc.RuleAsset;
 import org.drools.guvnor.server.ServiceImplementation;
 import org.drools.guvnor.server.contenthandler.ContentHandler;
 import org.drools.guvnor.server.contenthandler.ContentManager;
@@ -68,216 +53,264 @@
  * @author Michael Neale
  */
 public class ContentPackageAssembler {
-	private static final LoggingHelper log  = LoggingHelper.getLogger( ContentPackageAssembler.class );
+    private static final LoggingHelper log    = LoggingHelper.getLogger( ContentPackageAssembler.class );
 
-	private PackageItem pkg;
+    private PackageItem                packageItem;
 
-	/**
-	 * We accumulate errors here. If they come from the builder, then we reset
-	 * the builders errors so as to not double report. It also means we can
-	 * track errors to the exact asset that caused it.
-	 */
-	private List<ContentAssemblyError> errors = new ArrayList<ContentAssemblyError>();
+    /**
+     * We accumulate errors here. If they come from the builder, then we reset
+     * the builders errors so as to not double report. It also means we can
+     * track errors to the exact asset that caused it.
+     */
+    private List<ContentAssemblyError> errors = new ArrayList<ContentAssemblyError>();
 
-	BRMSPackageBuilder builder;
+    BRMSPackageBuilder                 builder;
 
-	private String customSelectorName;
-	private String buildMode;
-	private String statusOperator;
-	private String statusDescriptionValue;
-	private boolean enableStatusSelector;
-	private String categoryOperator;
-	private String categoryValue;
-	private boolean enableCategorySelector;	
+    private String                     customSelectorName;
+    private String                     buildMode;
+    private String                     statusOperator;
+    private String                     statusDescriptionValue;
+    private boolean                    enableStatusSelector;
+    private String                     categoryOperator;
+    private String                     categoryValue;
+    private boolean                    enableCategorySelector;
 
-	/**
-	 * Use this if you want to build the whole package.
-	 * 
-	 * @param pkg
-	 *            The package.
-	 */
-	public ContentPackageAssembler(PackageItem pkg) {
-		this(pkg, true);
-	}
+    /**
+     * Use this if you want to build the whole package.
+     * 
+     * @param pkg
+     *            The package.
+     */
+    public ContentPackageAssembler(PackageItem pkg) {
+        this( pkg,
+              true );
+    }
 
-	/**
-	 * @param pkg
-	 *            The package.
-	 * @param compile
-	 *            true if we want to build it. False and its just for looking at
-	 *            source.
-	 */
-	public ContentPackageAssembler(PackageItem pkg, boolean compile) {
-		this(pkg, compile, null, null, null, false, null, null, false, null);
-	}
+    /**
+     * @param pkg
+     *            The package.
+     * @param compile
+     *            true if we want to build it. False and its just for looking at
+     *            source.
+     */
+    public ContentPackageAssembler(PackageItem pkg,
+                                   boolean compile) {
+        this( pkg,
+              compile,
+              null,
+              null,
+              null,
+              false,
+              null,
+              null,
+              false,
+              null );
+    }
 
-	/**
-	 * @param assetPackage
-	 *            The package.
-	 * @param compile
-	 *            true if we want to build it. False and its just for looking at
-	 *            source.
-	 * @param selectorConfigName
-	 */
-	public ContentPackageAssembler(PackageItem assetPackage, boolean compile, String buildMode,
-			String statusOperator, String statusDescriptionValue, boolean enableStatusSelector,
-			String categoryOperator, String categoryValue, boolean enableCategorySelector,
-			String selectorConfigName) {
+    /**
+     * @param assetPackage
+     *            The package.
+     * @param compile
+     *            true if we want to build it. False and its just for looking at
+     *            source.
+     * @param selectorConfigName
+     */
+    public ContentPackageAssembler(PackageItem assetPackage,
+                                   boolean compile,
+                                   String buildMode,
+                                   String statusOperator,
+                                   String statusDescriptionValue,
+                                   boolean enableStatusSelector,
+                                   String categoryOperator,
+                                   String categoryValue,
+                                   boolean enableCategorySelector,
+                                   String selectorConfigName) {
 
-		this.pkg = assetPackage;
-		this.customSelectorName = selectorConfigName;
-		this.buildMode = buildMode;
-		this.statusOperator = statusOperator;
-		this.statusDescriptionValue = statusDescriptionValue;
-		this.enableStatusSelector = enableStatusSelector;
-		this.categoryOperator = categoryOperator;
-		this.categoryValue = categoryValue;
-		this.enableCategorySelector = enableCategorySelector;
-		
-		createBuilder();
+        this.packageItem = assetPackage;
+        this.customSelectorName = selectorConfigName;
+        this.buildMode = buildMode;
+        this.statusOperator = statusOperator;
+        this.statusDescriptionValue = statusDescriptionValue;
+        this.enableStatusSelector = enableStatusSelector;
+        this.categoryOperator = categoryOperator;
+        this.categoryValue = categoryValue;
+        this.enableCategorySelector = enableCategorySelector;
 
-		if (compile && preparePackage()) {
-			buildPackage();
-		}
-	}
+        createBuilder();
 
-	/**
-	 * Use this if you want to build and compile just the one asset.
-	 */
-	public ContentPackageAssembler(AssetItem assetToBuild) {
-		this.pkg = assetToBuild.getPackage();
-		createBuilder();
+        if ( compile && preparePackage() ) {
+            buildPackage();
+        }
+    }
 
-		if (preparePackage()) {
-			buildAsset(assetToBuild);
-		}
-	}
+    /**
+     * Use this if you want to build and compile just the one asset.
+     */
+    public ContentPackageAssembler(AssetItem assetToBuild) {
+        this.packageItem = assetToBuild.getPackage();
+        createBuilder();
 
-	public void createBuilder() {
+        if ( preparePackage() ) {
+            buildAsset( assetToBuild );
+        }
+    }
+
+    public ContentPackageAssembler(RuleAsset asset,
+                                   PackageItem packageItem) {
+        this.packageItem = packageItem;
+        createBuilder();
+
+        if ( preparePackage() ) {
+            buildAsset( asset );
+        }
+    }
+
+    public void createBuilder() {
         try {
-            Properties ps = loadConfProperties(pkg);
-            ps.setProperty( DefaultPackageNameOption.PROPERTY_NAME, this.pkg.getName() );
-            builder = BRMSPackageBuilder.getInstance(BRMSPackageBuilder.getJars(pkg), ps);
-        } catch (IOException e) {
-            throw new RulesRepositoryException("Unable to load configuration properties for package.", e);            
+            Properties ps = loadConfProperties( packageItem );
+            ps.setProperty( DefaultPackageNameOption.PROPERTY_NAME,
+                            this.packageItem.getName() );
+            builder = BRMSPackageBuilder.getInstance( BRMSPackageBuilder.getJars( packageItem ),
+                                                      ps );
+        } catch ( IOException e ) {
+            throw new RulesRepositoryException( "Unable to load configuration properties for package.",
+                                                e );
         }
-	}
+    }
 
-
     /**
      * Load all the .properties and .conf files into one big happy Properties instance.
      */
     Properties loadConfProperties(PackageItem pkg) throws IOException {
         Properties ps = new Properties();
-        AssetItemIterator iter = pkg.listAssetsByFormat(new String[] {"properties", "conf"});
-        while(iter.hasNext()) {
+        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);
+            p.load( conf.getBinaryContentAttachment() );
+            ps.putAll( p );
         }
         return ps;
     }
 
     /**
-	 * This will build the package - preparePackage would have been called first.
+     * This will build the package - preparePackage would have been called first.
      * This will always prioritise DRL before other assets.
-	 */
-	private void buildPackage() {
-		AssetSelector selector = null;
-		if("customSelector".equals(buildMode)) {
-			selector = SelectorManager.getInstance().getSelector(customSelectorName);			
-		} else if ("builtInSelector".equals(buildMode)) {
-			selector = (BuiltInSelector)SelectorManager.getInstance().getSelector(
-			"BuiltInSelector");
-	        ((BuiltInSelector)selector).setStatusOperator(statusOperator);
-	        ((BuiltInSelector)selector).setStatus(statusDescriptionValue);	
-	        ((BuiltInSelector)selector).setEnableStatusSelector(enableStatusSelector);
-	        ((BuiltInSelector)selector).setCategory(categoryValue);
-	        ((BuiltInSelector)selector).setCategoryOperator(categoryOperator);
-	        ((BuiltInSelector)selector).setEnableCategorySelector(enableCategorySelector);
-		} else {
-			//return the NilSelector, i.e., allows everything
-			selector = SelectorManager.getInstance().getSelector(null);				
-		}
-		
-		if (selector == null) {
-			this.errors.add(new ContentAssemblyError(this.pkg,
-					"The selector named " + customSelectorName
-							+ " is not available."));
-			return;
-		}
-        
-		StringBuffer includedAssets = new StringBuffer("Following assets have been included in package build: ");
-        Iterator<AssetItem> drls = pkg.listAssetsByFormat(new String[]{AssetFormats.DRL});
-        while (drls.hasNext()) {
+     */
+    private void buildPackage() {
+        AssetSelector selector = null;
+        if ( "customSelector".equals( buildMode ) ) {
+            selector = SelectorManager.getInstance().getSelector( customSelectorName );
+        } else if ( "builtInSelector".equals( buildMode ) ) {
+            selector = (BuiltInSelector) SelectorManager.getInstance().getSelector( "BuiltInSelector" );
+            ((BuiltInSelector) selector).setStatusOperator( statusOperator );
+            ((BuiltInSelector) selector).setStatus( statusDescriptionValue );
+            ((BuiltInSelector) selector).setEnableStatusSelector( enableStatusSelector );
+            ((BuiltInSelector) selector).setCategory( categoryValue );
+            ((BuiltInSelector) selector).setCategoryOperator( categoryOperator );
+            ((BuiltInSelector) selector).setEnableCategorySelector( enableCategorySelector );
+        } else {
+            //return the NilSelector, i.e., allows everything
+            selector = SelectorManager.getInstance().getSelector( null );
+        }
+
+        if ( selector == null ) {
+            this.errors.add( new ContentAssemblyError( this.packageItem,
+                                                       "The selector named " + customSelectorName + " is not available." ) );
+            return;
+        }
+
+        StringBuffer includedAssets = new StringBuffer( "Following assets have been included in package build: " );
+        Iterator<AssetItem> drls = packageItem.listAssetsByFormat( new String[]{AssetFormats.DRL} );
+        while ( drls.hasNext() ) {
             AssetItem asset = (AssetItem) drls.next();
-            if (!asset.isArchived() && (selector.isAssetAllowed(asset))) {
-                buildAsset(asset);
-                includedAssets.append(asset.getName() + ", ");
+            if ( !asset.isArchived() && (selector.isAssetAllowed( asset )) ) {
+                buildAsset( asset );
+                includedAssets.append( asset.getName() + ", " );
             }
         }
-		Iterator<AssetItem> it = pkg.getAssets();
-		while (it.hasNext()) {
-			AssetItem asset = (AssetItem) it.next();
-			if (!asset.getFormat().equals(AssetFormats.DRL) && !asset.isArchived() && (selector.isAssetAllowed(asset))) {
-				buildAsset(asset);
-	            includedAssets.append(asset.getName() + ", ");
-			}
-		}
-		log.info(includedAssets.toString());
-	}
+        Iterator<AssetItem> it = packageItem.getAssets();
+        while ( it.hasNext() ) {
+            AssetItem asset = (AssetItem) it.next();
+            if ( !asset.getFormat().equals( AssetFormats.DRL ) && !asset.isArchived() && (selector.isAssetAllowed( asset )) ) {
+                buildAsset( asset );
+                includedAssets.append( asset.getName() + ", " );
+            }
+        }
+        log.info( includedAssets.toString() );
+    }
 
-	/**
-	 * Builds assets that are "rule" assets (ie things that are not functions
-	 * etc).
-	 */
-	private void buildAsset(AssetItem asset) {
-		ContentHandler h = ContentManager.getHandler(asset.getFormat());
-		if (h instanceof ICompilable && !asset.getDisabled()) {
-			try {
-				((ICompilable) h).compile(builder, asset, new ErrorLogger());
-				if (builder.hasErrors()) {
-					this.recordBuilderErrors(asset);
-					// clear the errors, so we don't double report.
-					builder.clearErrors();
-				}
-			} catch (DroolsParserException e) {
-				throw new RulesRepositoryException(e);
-			} catch (IOException e) {
-				throw new RulesRepositoryException(e);
-			}
-		}
-	}
+    /**
+     * Builds assets that are "rule" assets (ie things that are not functions
+     * etc).
+     */
+    private void buildAsset(AssetItem asset) {
+        ContentHandler h = ContentManager.getHandler( asset.getFormat() );
+        if ( h instanceof ICompilable && !asset.getDisabled() ) {
+            try {
+                ((ICompilable) h).compile( builder,
+                                           asset,
+                                           new ErrorLogger() );
+                if ( builder.hasErrors() ) {
+                    this.recordBuilderErrors( asset );
+                    // clear the errors, so we don't double report.
+                    builder.clearErrors();
+                }
+            } catch ( DroolsParserException e ) {
+                throw new RulesRepositoryException( e );
+            } catch ( IOException e ) {
+                throw new RulesRepositoryException( e );
+            }
+        }
+    }
 
-	/**
-	 * This prepares the package builder, loads the jars/classpath.
-	 * 
-	 * @return true if everything is good to go, false if its all gone horribly
-	 *         wrong, and we can't even get the package header up.
-	 */
-	private boolean preparePackage() {
+    private void buildAsset(RuleAsset asset) {
+        ContentHandler h = ContentManager.getHandler( asset.metaData.format );
+        if ( h instanceof ICompilable && !asset.metaData.disabled ) {
+            try {
+                ((ICompilable) h).compile( builder,
+                                           asset,
+                                           new ErrorLogger() );
+                if ( builder.hasErrors() ) {
+                    this.recordBuilderErrors( asset );
+                    // clear the errors, so we don't double report.
+                    builder.clearErrors();
+                }
+            } catch ( DroolsParserException e ) {
+                throw new RulesRepositoryException( e );
+            } catch ( IOException e ) {
+                throw new RulesRepositoryException( e );
+            }
+        }
+    }
 
-		// firstly we loadup the classpath
-		builder.addPackage(new PackageDescr(pkg.getName()));
+    /**
+     * This prepares the package builder, loads the jars/classpath.
+     * 
+     * @return true if everything is good to go, false if its all gone horribly
+     *         wrong, and we can't even get the package header up.
+     */
+    private boolean preparePackage() {
 
-		loadDeclaredTypes();
-		// now we deal with the header (imports, templates, globals).
-		addDrl(ServiceImplementation.getDroolsHeader(pkg));
-		if (builder.hasErrors()) {
-			recordBuilderErrors(pkg);
-			// if we have any failures, lets drop out now, no point in going
-			// any further
-			return false;
-		}
+        // firstly we loadup the classpath
+        builder.addPackage( new PackageDescr( packageItem.getName() ) );
 
-		loadDSLFiles();
+        loadDeclaredTypes();
+        // now we deal with the header (imports, templates, globals).
+        addDrl( ServiceImplementation.getDroolsHeader( packageItem ) );
+        if ( builder.hasErrors() ) {
+            recordBuilderErrors( packageItem );
+            // if we have any failures, lets drop out now, no point in going
+            // any further
+            return false;
+        }
 
-		// finally, any functions we will load at this point.
-		AssetItemIterator it = this.pkg
-				.listAssetsByFormat(new String[] { AssetFormats.FUNCTION });
-		
+        loadDSLFiles();
+
+        // finally, any functions we will load at this point.
+        AssetItemIterator it = this.packageItem.listAssetsByFormat( new String[]{AssetFormats.FUNCTION} );
+
         // Adds the function DRLs as one string because they might be calling each others.
         StringBuilder stringBuilder = new StringBuilder();
         while ( it.hasNext() ) {
@@ -290,7 +323,7 @@
         // If the function part had errors we need to add them one by one to find out which one is bad.
         if ( builder.hasErrors() ) {
             builder.clearErrors();
-            it = this.pkg.listAssetsByFormat( new String[]{AssetFormats.FUNCTION} );
+            it = this.packageItem.listAssetsByFormat( new String[]{AssetFormats.FUNCTION} );
             while ( it.hasNext() ) {
                 AssetItem func = it.next();
                 if ( !func.getDisabled() ) {
@@ -304,159 +337,171 @@
         }
 
         return errors.size() == 0;
-	}
+    }
 
-	private void loadDeclaredTypes() {
-		AssetItemIterator it = this.pkg
-				.listAssetsByFormat(new String[] { AssetFormats.DRL_MODEL });
-		while (it.hasNext()) {
-			AssetItem as = it.next();
-            if (!as.getDisabled()) {
+    private void loadDeclaredTypes() {
+        AssetItemIterator it = this.packageItem.listAssetsByFormat( new String[]{AssetFormats.DRL_MODEL} );
+        while ( it.hasNext() ) {
+            AssetItem as = it.next();
+            if ( !as.getDisabled() ) {
                 try {
                     String content = as.getContent();
-                    if (nonEmpty(content)) {
-                        builder.addPackageFromDrl(new StringReader(as.getContent()));
+                    if ( nonEmpty( content ) ) {
+                        builder.addPackageFromDrl( new StringReader( as.getContent() ) );
                     }
-                } catch (DroolsParserException e) {
-                    this.errors.add(new ContentAssemblyError(as,
-                            "Parser exception: " + e.getMessage()));
-                } catch (IOException e) {
-                    this.errors.add(new ContentAssemblyError(as, "IOException: "
-                            + e.getMessage()));
+                } catch ( DroolsParserException e ) {
+                    this.errors.add( new ContentAssemblyError( as,
+                                                               "Parser exception: " + e.getMessage() ) );
+                } catch ( IOException e ) {
+                    this.errors.add( new ContentAssemblyError( as,
+                                                               "IOException: " + e.getMessage() ) );
                 }
             }
-		}
+        }
 
-	}
+    }
 
     private boolean nonEmpty(String content) {
         return content != null && content.trim().length() > 0;
     }
 
     private void loadDSLFiles() {
-		// now we load up the DSL files
-		builder.setDSLFiles(BRMSPackageBuilder.getDSLMappingFiles(pkg,
-				new BRMSPackageBuilder.DSLErrorEvent() {
-					public void recordError(AssetItem asset, String message) {
-						errors.add(new ContentAssemblyError(asset, message));
-					}
-				}));
-	}
+        // now we load up the DSL files
+        builder.setDSLFiles( BRMSPackageBuilder.getDSLMappingFiles( packageItem,
+                                                                    new BRMSPackageBuilder.DSLErrorEvent() {
+                                                                        public void recordError(AssetItem asset,
+                                                                                                String message) {
+                                                                            errors.add( new ContentAssemblyError( asset,
+                                                                                                                  message ) );
+                                                                        }
+                                                                    } ) );
+    }
 
-	/**
-	 * This will return true if there is an error in the package configuration
-	 * or functions.
-	 * 
-	 * @return
-	 */
-	public boolean isPackageConfigurationInError() {
-		if (this.errors.size() > 0) {
-			return this.errors.get(0).itemInError instanceof PackageItem;
-		} else {
-			return false;
-		}
-	}
+    /**
+     * This will return true if there is an error in the package configuration
+     * or functions.
+     * 
+     * @return
+     */
+    public boolean isPackageConfigurationInError() {
+        if ( this.errors.size() > 0 ) {
+            return this.errors.get( 0 ).isPackageItem();
+        } else {
+            return false;
+        }
+    }
 
-	private void addDrl(String drl) {
-		if ( "".equals( drl.trim() ) ) {
-			return;
-		}
-		try {
-			builder.addPackageFromDrl(new StringReader(drl));
-		} catch (DroolsParserException e) {
-			throw new RulesRepositoryException(
-					"Unexpected error when parsing package.", e);
-		} catch (IOException e) {
-			throw new RulesRepositoryException(
-					"IO Exception occurred when parsing package.", e);
-		}
-	}
+    private void addDrl(String drl) {
+        if ( "".equals( drl.trim() ) ) {
+            return;
+        }
+        try {
+            builder.addPackageFromDrl( new StringReader( drl ) );
+        } catch ( DroolsParserException e ) {
+            throw new RulesRepositoryException( "Unexpected error when parsing package.",
+                                                e );
+        } catch ( IOException e ) {
+            throw new RulesRepositoryException( "IO Exception occurred when parsing package.",
+                                                e );
+        }
+    }
 
-	/**
-	 * This will accumulate the errors.
-	 */
-	private void recordBuilderErrors(VersionableItem asset) {
-		DroolsError[] errs = builder.getErrors().getErrors();
-		for (int i = 0; i < errs.length; i++) {
-			this.errors.add(new ContentAssemblyError(asset, errs[i]
-					.getMessage()));
-		}
+    /**
+     * This will accumulate the errors.
+     */
+    private void recordBuilderErrors(VersionableItem asset) {
+        DroolsError[] errs = builder.getErrors().getErrors();
+        for ( int i = 0; i < errs.length; i++ ) {
+            this.errors.add( new ContentAssemblyError( asset,
+                                                       errs[i].getMessage() ) );
+        }
 
-	}
+    }
 
-	/**
-	 * I've got a package people !
-	 */
-	public Package getBinaryPackage() {
-		if (this.hasErrors()) {
-			throw new IllegalStateException(
-					"There is no package available, as there were errors.");
-		}
-		return builder.getPackage();
-	}
+    private void recordBuilderErrors(RuleAsset asset) {
+        DroolsError[] errs = builder.getErrors().getErrors();
+        for ( int i = 0; i < errs.length; i++ ) {
+            this.errors.add( new ContentAssemblyError( asset,
+                                                       errs[i].getMessage() ) );
+        }
 
-	public boolean hasErrors() {
-		return errors.size() > 0;
-	}
+    }
 
-	public List<ContentAssemblyError> getErrors() {
-		return this.errors;
-	}
+    /**
+     * I've got a package people !
+     */
+    public Package getBinaryPackage() {
+        if ( this.hasErrors() ) {
+            throw new IllegalStateException( "There is no package available, as there were errors." );
+        }
+        return builder.getPackage();
+    }
 
-	public BRMSPackageBuilder getBuilder() {
-		return builder;
-	}
+    public boolean hasErrors() {
+        return errors.size() > 0;
+    }
 
-	/**
-	 * This is passed in to the compilers so extra errors can be added.
-	 * 
-	 * @author Michael Neale
-	 */
-	public class ErrorLogger {
-		public void logError(ContentAssemblyError err) {
-			errors.add(err);
-		}
-	}
+    public List<ContentAssemblyError> getErrors() {
+        return this.errors;
+    }
 
-	public String getDRL() {
-		StringBuffer src = new StringBuffer();
-		src.append("package " + this.pkg.getName() + "\n");
-		src.append(ServiceImplementation.getDroolsHeader(this.pkg) + "\n\n");
+    public BRMSPackageBuilder getBuilder() {
+        return builder;
+    }
 
-		// now we load up the DSL files
-		builder.setDSLFiles(BRMSPackageBuilder.getDSLMappingFiles(pkg,
-				new BRMSPackageBuilder.DSLErrorEvent() {
-					public void recordError(AssetItem asset, String message) {
-						errors.add(new ContentAssemblyError(asset, message));
-					}
-				}));
+    /**
+     * This is passed in to the compilers so extra errors can be added.
+     * 
+     * @author Michael Neale
+     */
+    public class ErrorLogger {
+        public void logError(ContentAssemblyError err) {
+            errors.add( err );
+        }
+    }
 
-		// do the functions and declared types.
-		AssetItemIterator it = this.pkg.listAssetsByFormat(new String[] {
-				AssetFormats.FUNCTION, AssetFormats.DRL_MODEL });
-		while (it.hasNext()) {
-			AssetItem func = it.next();
-			if (!func.isArchived() && !func.getDisabled()) {
-                src.append(func.getContent()).append("\n\n");
-			}
-		}
+    public String getDRL() {
+        StringBuffer src = new StringBuffer();
+        src.append( "package " + this.packageItem.getName() + "\n" );
+        src.append( ServiceImplementation.getDroolsHeader( this.packageItem ) + "\n\n" );
 
-		// now the rules
-		Iterator<AssetItem> iter = pkg.getAssets();
-		while (iter.hasNext()) {
-			AssetItem asset = (AssetItem) iter.next();
-			if (!asset.isArchived() && !asset.getDisabled()) {
+        // now we load up the DSL files
+        builder.setDSLFiles( BRMSPackageBuilder.getDSLMappingFiles( packageItem,
+                                                                    new BRMSPackageBuilder.DSLErrorEvent() {
+                                                                        public void recordError(AssetItem asset,
+                                                                                                String message) {
+                                                                            errors.add( new ContentAssemblyError( asset,
+                                                                                                                  message ) );
+                                                                        }
+                                                                    } ) );
 
-				ContentHandler handler = ContentManager.getHandler(asset.getFormat());
-				if (handler.isRuleAsset()) {
-					IRuleAsset ruleAsset = (IRuleAsset) handler;
-					ruleAsset.assembleDRL(builder, asset, src);
-				}
-				src.append("\n\n");
-			}
-		}
+        // do the functions and declared types.
+        AssetItemIterator it = this.packageItem.listAssetsByFormat( new String[]{AssetFormats.FUNCTION, AssetFormats.DRL_MODEL} );
+        while ( it.hasNext() ) {
+            AssetItem func = it.next();
+            if ( !func.isArchived() && !func.getDisabled() ) {
+                src.append( func.getContent() ).append( "\n\n" );
+            }
+        }
 
-		return src.toString();
-	}
+        // now the rules
+        Iterator<AssetItem> iter = packageItem.getAssets();
+        while ( iter.hasNext() ) {
+            AssetItem asset = (AssetItem) iter.next();
+            if ( !asset.isArchived() && !asset.getDisabled() ) {
 
+                ContentHandler handler = ContentManager.getHandler( asset.getFormat() );
+                if ( handler.isRuleAsset() ) {
+                    IRuleAsset ruleAsset = (IRuleAsset) handler;
+                    ruleAsset.assembleDRL( builder,
+                                           asset,
+                                           src );
+                }
+                src.append( "\n\n" );
+            }
+        }
+
+        return src.toString();
+    }
+
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BPMN2ProcessHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BPMN2ProcessHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BPMN2ProcessHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,5 +1,5 @@
-/**
- * Copyright 2010 JBoss Inc
+/*
+ * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,22 +16,6 @@
 
 package org.drools.guvnor.server.contenthandler;
 
-/*
- * Copyright 2005 JBoss Inc
- * 
- * 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.
- */
-
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -61,13 +45,12 @@
 
 import com.google.gwt.user.client.rpc.SerializationException;
 
-
 public class BPMN2ProcessHandler extends ContentHandler
     implements
     ICompilable {
 
-    private static final LoggingHelper     log  = LoggingHelper.getLogger(BPMN2ProcessHandler.class);
-    
+    private static final LoggingHelper log = LoggingHelper.getLogger( BPMN2ProcessHandler.class );
+
     public void retrieveAssetContent(RuleAsset asset,
                                      PackageItem pkg,
                                      AssetItem item) throws SerializationException {
@@ -76,12 +59,12 @@
             RuleFlowContentModel content = RuleFlowContentModelBuilder.createModel( process );
             content.setXml( item.getContent() );
             asset.content = content;
-		} else {
-			// we are very fault tolerant
-			RuleFlowContentModel content = new RuleFlowContentModel();
-			content.setXml(item.getContent());
-			asset.content = content;
-		}
+        } else {
+            // we are very fault tolerant
+            RuleFlowContentModel content = new RuleFlowContentModel();
+            content.setXml( item.getContent() );
+            asset.content = content;
+        }
     }
 
     protected RuleFlowProcess readProcess(InputStream is) {
@@ -109,8 +92,8 @@
 
     public void storeAssetContent(RuleAsset asset,
                                   AssetItem repoAsset) throws SerializationException {
-    	RuleFlowContentModel content = (RuleFlowContentModel) asset.content;
-    	System.out.println(content);
+        RuleFlowContentModel content = (RuleFlowContentModel) asset.content;
+        System.out.println( content );
         // 
         // Migrate v4 ruleflows to v5
         // Added guards to check for nulls in the case where the ruleflows
@@ -136,62 +119,67 @@
                     repoAsset.updateContent( content.getXml() );
                 }
             }
-            if ( content.getJson() != null) {
-            	try {
-            		String xml = serialize( "http://localhost:8080/designer/bpmn2_0serialization", content.getJson());
-            		System.out.println("xml = " + xml);
-            		repoAsset.updateContent(xml);
-            	} catch (Exception e) {
-            		log.error(e.getMessage(), e);
-            	}
+            if ( content.getJson() != null ) {
+                try {
+                    String xml = serialize( "http://localhost:8080/designer/bpmn2_0serialization",
+                                            content.getJson() );
+                    System.out.println( "xml = " + xml );
+                    repoAsset.updateContent( xml );
+                } catch ( Exception e ) {
+                    log.error( e.getMessage(),
+                               e );
+                }
             }
         }
     }
 
-    public static String serialize(String serializeUrl, String modelJson) throws IOException {
-    	OutputStream out = null;
-		InputStream content = null;
-		ByteArrayOutputStream bos = null;
+    public static String serialize(String serializeUrl,
+                                   String modelJson) throws IOException {
+        OutputStream out = null;
+        InputStream content = null;
+        ByteArrayOutputStream bos = null;
 
-		try {
-			modelJson = "data=" + URLEncoder.encode(modelJson, "UTF-8")	+ "&xml=true";
-			byte[] bytes = modelJson.getBytes("UTF-8");
+        try {
+            modelJson = "data=" + URLEncoder.encode( modelJson,
+                                                     "UTF-8" ) + "&xml=true";
+            byte[] bytes = modelJson.getBytes( "UTF-8" );
 
-			HttpURLConnection connection = (HttpURLConnection) new URL(serializeUrl).openConnection();
-			connection.setRequestMethod("POST");
-			connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
-			connection.setFixedLengthStreamingMode(bytes.length);
-			connection.setDoOutput(true);
-			out = connection.getOutputStream();
-			out.write(bytes);
-			out.close();
+            HttpURLConnection connection = (HttpURLConnection) new URL( serializeUrl ).openConnection();
+            connection.setRequestMethod( "POST" );
+            connection.setRequestProperty( "Content-Type",
+                                           "application/x-www-form-urlencoded" );
+            connection.setFixedLengthStreamingMode( bytes.length );
+            connection.setDoOutput( true );
+            out = connection.getOutputStream();
+            out.write( bytes );
+            out.close();
 
-			content = connection.getInputStream();
+            content = connection.getInputStream();
 
-			bos = new ByteArrayOutputStream();
-			int b = 0;
-			while ((b = content.read()) > -1) {
-				bos.write(b);
-			}
-			bytes = bos.toByteArray();
-			content.close();
-			bos.close();
-			return new String(bytes);
-		} finally {
-			try {
-				if (out != null) {
-					out.close();
-				}
-				if (content != null) {
-					content.close();
-				}
-				if (bos != null) {
-					bos.close();
-				}
-			} catch (IOException e) {
-			}
-		}
-	}
+            bos = new ByteArrayOutputStream();
+            int b = 0;
+            while ( (b = content.read()) > -1 ) {
+                bos.write( b );
+            }
+            bytes = bos.toByteArray();
+            content.close();
+            bos.close();
+            return new String( bytes );
+        } finally {
+            try {
+                if ( out != null ) {
+                    out.close();
+                }
+                if ( content != null ) {
+                    content.close();
+                }
+                if ( bos != null ) {
+                    bos.close();
+                }
+            } catch ( IOException e ) {
+            }
+        }
+    }
 
     /**
      * The rule flow can not be built if the package name is not the same as the
@@ -227,4 +215,10 @@
             builder.addProcessFromXml( new InputStreamReader( asset.getBinaryContentAttachment() ) );
         }
     }
+
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ErrorLogger logger) {
+        // This can not work, no binary data in RuleAsset
+    }
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BRLContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BRLContentHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/BRLContentHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -39,6 +39,7 @@
 import org.drools.guvnor.client.rpc.RuleAsset;
 import org.drools.guvnor.server.builder.BRMSPackageBuilder;
 import org.drools.guvnor.server.builder.ContentPackageAssembler;
+import org.drools.guvnor.server.builder.ContentPackageAssembler.ErrorLogger;
 import org.drools.ide.common.client.modeldriven.brl.RuleModel;
 import org.drools.ide.common.server.util.BRDRLPersistence;
 import org.drools.ide.common.server.util.BRLPersistence;
@@ -79,6 +80,15 @@
                                                                    builder ) ) );
     }
 
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ErrorLogger logger) throws DroolsParserException,
+                                           IOException {
+        builder.addPackageFromDrl( new StringReader( getSourceDRL( (RuleModel) asset.content,
+                                                                   builder ) ) );
+
+    }
+
     public void assembleDRL(BRMSPackageBuilder builder,
                             RuleAsset asset,
                             StringBuffer buf) {
@@ -126,4 +136,5 @@
     protected BRLPersistence getBrlXmlPersistence() {
         return BRXMLPersistence.getInstance();
     }
+
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DRLFileContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DRLFileContentHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DRLFileContentHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,21 +1,3 @@
-/**
- * Copyright 2010 JBoss Inc
- *
- * 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 org.drools.guvnor.server.contenthandler;
-
 /*
  * Copyright 2005 JBoss Inc
  *
@@ -32,6 +14,8 @@
  * limitations under the License.
  */
 
+package org.drools.guvnor.server.contenthandler;
+
 import java.io.IOException;
 import java.io.StringReader;
 import java.util.StringTokenizer;
@@ -57,6 +41,16 @@
         }
     }
 
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ContentPackageAssembler.ErrorLogger logger) throws DroolsParserException,
+                                                                   IOException {
+        String content = ((RuleContentText) asset.content).content;
+        if ( content != null && !content.trim().equals( "" ) ) {
+            builder.addPackageFromDrl( new StringReader( content ) );
+        }
+    }
+
     String wrapRuleDeclaration(String name,
                                String parentName,
                                String content) {

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DSLRuleContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DSLRuleContentHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DSLRuleContentHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -34,7 +34,6 @@
 
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.Iterator;
 import java.util.List;
 
 import org.drools.compiler.DroolsParserException;
@@ -43,6 +42,7 @@
 import org.drools.guvnor.server.builder.BRMSPackageBuilder;
 import org.drools.guvnor.server.builder.ContentAssemblyError;
 import org.drools.guvnor.server.builder.ContentPackageAssembler;
+import org.drools.guvnor.server.builder.ContentPackageAssembler.ErrorLogger;
 import org.drools.lang.ExpanderException;
 import org.drools.lang.dsl.DefaultExpander;
 import org.drools.repository.AssetItem;
@@ -80,22 +80,42 @@
                                                 asset,
                                                 logger );
 
-        //add the rule keyword if its 'stand alone'
-        String source = asset.getContent();
-        if ( DRLFileContentHandler.isStandAloneRule( source ) ) {
-            String parentName = this.parentNameFromCategory( asset,
-                                                             "" );
-            source = wrapRule( asset.getName(),
-                               parentName,
-                               source );
+        String source = getRawDRL( asset );
+
+        //expand and check for errors
+        String drl = expander.expand( source );
+
+        if ( expander.hasErrors() ) {
+            List<ExpanderException> exErrs = expander.getErrors();
+            for ( ExpanderException ex : exErrs ) {
+                logger.logError( new ContentAssemblyError( asset,
+                                                           ex.getMessage() ) );
+            }
+            return;
         }
 
+        builder.addPackageFromDrl( new StringReader( drl ) );
+    }
+
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ErrorLogger logger) throws DroolsParserException,
+                                           IOException {
+        DefaultExpander expander = getExpander( builder,
+                                                asset,
+                                                logger );
+
+        RuleContentText text = (RuleContentText) asset.content;
+        String source = getDRL( text.content,
+                                asset.metaData.name,
+                                null );
+
         //expand and check for errors
         String drl = expander.expand( source );
+
         if ( expander.hasErrors() ) {
-            List exErrs = expander.getErrors();
-            for ( Iterator iter = exErrs.iterator(); iter.hasNext(); ) {
-                ExpanderException ex = (ExpanderException) iter.next();
+            List<ExpanderException> exErrs = expander.getErrors();
+            for ( ExpanderException ex : exErrs ) {
                 logger.logError( new ContentAssemblyError( asset,
                                                            ex.getMessage() ) );
             }
@@ -117,6 +137,18 @@
         return builder.getDSLExpander();
     }
 
+    private DefaultExpander getExpander(BRMSPackageBuilder builder,
+                                        RuleAsset asset,
+                                        ContentPackageAssembler.ErrorLogger logger) {
+
+        if ( !builder.hasDSL() ) {
+            logger.logError( new ContentAssemblyError( asset,
+                                                       "This rule asset requires a DSL, yet none were configured in the package." ) );
+        }
+
+        return builder.getDSLExpander();
+    }
+
     public void assembleDRL(BRMSPackageBuilder builder,
                             RuleAsset asset,
                             StringBuffer buf) {

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DecisionTableXLSHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DecisionTableXLSHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/DecisionTableXLSHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -93,6 +93,18 @@
 
     }
 
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ErrorLogger logger) throws DroolsParserException,
+                                           IOException {
+        StringBuffer buf = new StringBuffer();
+
+        assembleDRL( builder,
+                     asset,
+                     buf );
+        builder.addPackageFromDrl( new StringReader( buf.toString() ) );
+    }
+
     public String getRawDRL(AssetItem asset) {
         return getDRL( asset.getBinaryContentAttachment() );
     }

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/EnumerationContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/EnumerationContentHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/EnumerationContentHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -33,43 +33,68 @@
  */
 
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 import org.drools.guvnor.client.rpc.BuilderResult;
 import org.drools.guvnor.client.rpc.BuilderResultLine;
+import org.drools.guvnor.client.rpc.RuleAsset;
+import org.drools.guvnor.client.rpc.RuleContentText;
 import org.drools.ide.common.server.util.DataEnumLoader;
 import org.drools.repository.AssetItem;
 
+public class EnumerationContentHandler extends PlainTextContentHandler
+    implements
+    IValidating {
 
-
-public class EnumerationContentHandler extends PlainTextContentHandler implements IValidating {
-
     public BuilderResult validateAsset(AssetItem asset) {
 
         String content = asset.getContent();
-        DataEnumLoader loader = new DataEnumLoader(content);
-        if (!loader.hasErrors()) {
+        DataEnumLoader loader = new DataEnumLoader( content );
+        if ( !loader.hasErrors() ) {
             return new BuilderResult();
         } else {
             List<BuilderResultLine> errors = new ArrayList<BuilderResultLine>();
-            List errs = loader.getErrors();
+            List<String> errs = loader.getErrors();
 
+            for ( String message : errs ) {
 
-            for ( Iterator iter = errs.iterator(); iter.hasNext(); ) {
-
                 BuilderResultLine result = new BuilderResultLine();
                 result.assetName = asset.getName();
                 result.assetFormat = asset.getFormat();
                 result.uuid = asset.getUUID();
-                result.message = (String) iter.next();
+                result.message = message;
                 errors.add( result );
             }
 
+            BuilderResult result = new BuilderResult();
+            result.lines = errors.toArray( new BuilderResultLine[errors.size()] );
 
+            return result;
+        }
+    }
+
+    public BuilderResult validateAsset(RuleAsset asset) {
+        String content = ((RuleContentText) asset.content).content;
+        DataEnumLoader loader = new DataEnumLoader( content );
+        if ( !loader.hasErrors() ) {
+            return new BuilderResult();
+        } else {
+            List<BuilderResultLine> errors = new ArrayList<BuilderResultLine>();
+            List<String> errs = loader.getErrors();
+
+            for ( String message : errs ) {
+
+                BuilderResultLine result = new BuilderResultLine();
+                result.assetName = asset.metaData.name;
+                result.assetFormat = asset.metaData.format;
+                result.uuid = asset.uuid;
+                result.message = message;
+                errors.add( result );
+            }
+
             BuilderResult result = new BuilderResult();
             result.lines = errors.toArray( new BuilderResultLine[errors.size()] );
-            
+
             return result;
         }
     }

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/GuidedDTContentHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -39,6 +39,7 @@
 import org.drools.guvnor.client.rpc.RuleAsset;
 import org.drools.guvnor.server.builder.BRMSPackageBuilder;
 import org.drools.guvnor.server.builder.ContentPackageAssembler;
+import org.drools.guvnor.server.builder.ContentPackageAssembler.ErrorLogger;
 import org.drools.ide.common.client.modeldriven.dt.GuidedDecisionTable;
 import org.drools.ide.common.server.util.GuidedDTDRLPersistence;
 import org.drools.ide.common.server.util.GuidedDTXMLPersistence;
@@ -89,6 +90,19 @@
         builder.addPackageFromDrl( new StringReader( drl ) );
     }
 
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ErrorLogger logger) throws DroolsParserException,
+                                           IOException {
+        GuidedDecisionTable model = (GuidedDecisionTable) asset.content;
+
+        String drl = GuidedDTDRLPersistence.getInstance().marshal( model );
+
+        if ( drl.equals( "" ) ) return;
+        builder.addPackageFromDrl( new StringReader( drl ) );
+
+    }
+
     public void assembleDRL(BRMSPackageBuilder builder,
                             RuleAsset asset,
                             StringBuffer buf) {

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ICompilable.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ICompilable.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/ICompilable.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,5 +1,5 @@
-/**
- * Copyright 2010 JBoss Inc
+/*
+ * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,25 +16,10 @@
 
 package org.drools.guvnor.server.contenthandler;
 
-/*
- * Copyright 2005 JBoss Inc
- * 
- * 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.
- */
-
 import java.io.IOException;
 
 import org.drools.compiler.DroolsParserException;
+import org.drools.guvnor.client.rpc.RuleAsset;
 import org.drools.guvnor.server.builder.BRMSPackageBuilder;
 import org.drools.guvnor.server.builder.ContentPackageAssembler;
 import org.drools.repository.AssetItem;
@@ -56,4 +41,9 @@
                         ContentPackageAssembler.ErrorLogger logger) throws DroolsParserException,
                                                                    IOException;
 
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ContentPackageAssembler.ErrorLogger logger) throws DroolsParserException,
+                                                                   IOException;
+
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/IValidating.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/IValidating.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/IValidating.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright 2010 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -17,6 +17,7 @@
 package org.drools.guvnor.server.contenthandler;
 
 import org.drools.guvnor.client.rpc.BuilderResult;
+import org.drools.guvnor.client.rpc.RuleAsset;
 import org.drools.repository.AssetItem;
 
 /**
@@ -28,5 +29,7 @@
 
     BuilderResult validateAsset(AssetItem asset);
 
+    BuilderResult validateAsset(RuleAsset asset);
 
+
 }

Modified: labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/RuleFlowHandler.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/RuleFlowHandler.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/main/java/org/drools/guvnor/server/contenthandler/RuleFlowHandler.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -53,7 +53,6 @@
 
 import com.google.gwt.user.client.rpc.SerializationException;
 
-
 public class RuleFlowHandler extends ContentHandler
     implements
     ICompilable,
@@ -184,4 +183,10 @@
         }
     }
 
+    public void compile(BRMSPackageBuilder builder,
+                        RuleAsset asset,
+                        ErrorLogger logger) throws DroolsParserException,
+                                           IOException {
+        // Nothing to do here, binary content
+    }
 }
\ No newline at end of file

Modified: labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/builder/ContentPackageAssemblerTest.java
===================================================================
--- labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/builder/ContentPackageAssemblerTest.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-guvnor/src/test/java/org/drools/guvnor/server/builder/ContentPackageAssemblerTest.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,5 +1,5 @@
-/**
- * Copyright 2010 JBoss Inc
+/*
+ * Copyright 2005 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,22 +16,6 @@
 
 package org.drools.guvnor.server.builder;
 
-/*
- * Copyright 2005 JBoss Inc
- *
- * 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.
- */
-
 import java.io.InputStream;
 import java.io.StringReader;
 import java.io.ByteArrayInputStream;
@@ -128,10 +112,10 @@
                                                   pkg );
         assembler = new ContentPackageAssembler( pkg );
         assertTrue( assembler.hasErrors() );
-        assertTrue( assembler.getErrors().get( 0 ).itemInError instanceof AssetItem );
+        assertTrue( assembler.getErrors().get( 0 ).isAssetItem() );
 
         assertEquals( "func1",
-                      assembler.getErrors().get( 0 ).itemInError.getName() );
+                      assembler.getErrors().get( 0 ).getName() );
         try {
             assembler.getBinaryPackage();
             fail( "should not work as is in error." );
@@ -162,11 +146,11 @@
         assembler = new ContentPackageAssembler( pkg );
         assertTrue( assembler.hasErrors() );
         assertFalse( assembler.isPackageConfigurationInError() );
-        assertTrue( assembler.getErrors().get( 0 ).itemInError.getName().equals( func.getName() ) );
-        assertNotEmpty( assembler.getErrors().get( 0 ).errorReport );
+        assertTrue( assembler.getErrors().get( 0 ).getName().equals( func.getName() ) );
+        assertNotEmpty( assembler.getErrors().get( 0 ).getErrorReport() );
     }
 
-    public void testLoadConfProperties () throws Exception {
+    public void testLoadConfProperties() throws Exception {
         RulesRepository repo = getRepo();
 
         PackageItem pkg = repo.createPackage( "testLoadConfProperties",
@@ -187,24 +171,26 @@
         rule1.updateContent( "rule 'rule1' \n when Board() \n then customer.setAge(42); \n end" );
         rule1.checkin( "" );
 
-        AssetItem props1 = pkg.addAsset("conf1", "");
-        props1.updateFormat("properties");
-        props1.updateContent("drools.accumulate.function.groupCount = org.drools.base.accumulators.MaxAccumulateFunction");
-        props1.checkin("");
+        AssetItem props1 = pkg.addAsset( "conf1",
+                                         "" );
+        props1.updateFormat( "properties" );
+        props1.updateContent( "drools.accumulate.function.groupCount = org.drools.base.accumulators.MaxAccumulateFunction" );
+        props1.checkin( "" );
 
+        AssetItem props2 = pkg.addAsset( "conf2",
+                                         "" );
+        props2.updateFormat( "conf" );
+        props2.updateBinaryContentAttachment( new ByteArrayInputStream( "drools.accumulate.function.groupFun = org.drools.base.accumulators.MinAccumulateFunction".getBytes() ) );
+        props2.checkin( "" );
 
-        AssetItem props2 = pkg.addAsset("conf2", "");
-        props2.updateFormat("conf");
-        props2.updateBinaryContentAttachment(new ByteArrayInputStream("drools.accumulate.function.groupFun = org.drools.base.accumulators.MinAccumulateFunction".getBytes()));
-        props2.checkin("");
+        ContentPackageAssembler asm = new ContentPackageAssembler( pkg );
+        assertEquals( "org.drools.base.accumulators.MaxAccumulateFunction",
+                      asm.builder.getPackageBuilderConfiguration().getAccumulateFunction( "groupCount" ).getClass().getName() );
+        assertEquals( "org.drools.base.accumulators.MinAccumulateFunction",
+                      asm.builder.getPackageBuilderConfiguration().getAccumulateFunction( "groupFun" ).getClass().getName() );
 
-        ContentPackageAssembler asm = new ContentPackageAssembler(pkg);
-        assertEquals("org.drools.base.accumulators.MaxAccumulateFunction", asm.builder.getPackageBuilderConfiguration().getAccumulateFunction( "groupCount" ).getClass().getName());
-        assertEquals("org.drools.base.accumulators.MinAccumulateFunction", asm.builder.getPackageBuilderConfiguration().getAccumulateFunction("groupFun").getClass().getName());
-
     }
 
-
     public void testPackageWithRuleflow() throws Exception {
         RulesRepository repo = getRepo();
 
@@ -246,7 +232,8 @@
 
         //now check we can do some MVEL stuff from the classloader...
         List<JarInputStream> jars = BRMSPackageBuilder.getJars( pkg );
-        PackageBuilder builder = BRMSPackageBuilder.getInstance( jars, new Properties() );
+        PackageBuilder builder = BRMSPackageBuilder.getInstance( jars,
+                                                                 new Properties() );
         ClassLoader newCL = builder.getPackageBuilderConfiguration().getClassLoader();
         ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
 
@@ -278,8 +265,8 @@
         rule1.checkin( "" );
 
         ContentPackageAssembler asm = new ContentPackageAssembler( pkg );
-        assertFalse(asm.getErrors().toString(),  asm.hasErrors() );
-        
+        assertFalse( asm.getErrors().toString(),
+                     asm.hasErrors() );
 
     }
 
@@ -289,7 +276,8 @@
         PackageItem pkg = repo.createPackage( "testSimplePackageWithDeclaredTypes2",
                                               "" );
 
-        ServiceImplementation.updateDroolsHeader("import java.util.HashMap", pkg);
+        ServiceImplementation.updateDroolsHeader( "import java.util.HashMap",
+                                                  pkg );
 
         AssetItem rule1 = pkg.addAsset( "rule_1",
                                         "" );
@@ -307,7 +295,8 @@
         repo.save();
 
         ContentPackageAssembler asm = new ContentPackageAssembler( pkg );
-        assertFalse(asm.getErrors().toString(),  asm.hasErrors() );
+        assertFalse( asm.getErrors().toString(),
+                     asm.hasErrors() );
 
         assertNotNull( asm.getBinaryPackage() );
         Package bin = asm.getBinaryPackage();
@@ -465,8 +454,8 @@
         assertFalse( asm.isPackageConfigurationInError() );
 
         for ( ContentAssemblyError err : asm.getErrors() ) {
-            assertTrue( err.itemInError.getName().equals( badRule.getName() ) );
-            assertNotEmpty( err.errorReport );
+            assertTrue( err.getName().equals( badRule.getName() ) );
+            assertNotEmpty( err.getErrorReport() );
         }
 
     }
@@ -486,15 +475,16 @@
 
         ServiceImplementation.updateDroolsHeader( "import org.drools.examples.eventing.EventRequest\n",
                                                   pkg );
-        AssetItem asset = pkg.addAsset("whee", "");
-        asset.updateFormat(AssetFormats.DRL);
-        asset.updateContent("rule 'zaa'\n  when \n  request: EventRequest( status == EventRequest.Status.ACTIVE )\n   then \n request.setStatus(EventRequest.Status.ACTIVE); \n  end");
-        asset.checkin("");
+        AssetItem asset = pkg.addAsset( "whee",
+                                        "" );
+        asset.updateFormat( AssetFormats.DRL );
+        asset.updateContent( "rule 'zaa'\n  when \n  request: EventRequest( status == EventRequest.Status.ACTIVE )\n   then \n request.setStatus(EventRequest.Status.ACTIVE); \n  end" );
+        asset.checkin( "" );
 
         ContentPackageAssembler asm = new ContentPackageAssembler( pkg );
-        if (asm.hasErrors()) {
+        if ( asm.hasErrors() ) {
             for ( ContentAssemblyError err : asm.getErrors() ) {
-                System.err.println(err.errorReport);
+                System.err.println( err.getErrorReport() );
             }
             fail();
         }
@@ -608,13 +598,11 @@
                                         "" );
         rule3.updateFormat( AssetFormats.DRL_MODEL );
         rule3.updateContent( "garbage" );
-        rule3.updateDisabled(true);
+        rule3.updateDisabled( true );
         rule3.checkin( "" );
 
-
-
         ContentPackageAssembler asm = new ContentPackageAssembler( pkg,
-                                                                   false);
+                                                                   false );
         String drl = asm.getDRL();
 
         assertNotNull( drl );
@@ -632,10 +620,11 @@
         assertContains( "rule 'foo' when Goo() then end",
                         drl );
 
-        assertEquals(-1, drl.indexOf("garbage"));
+        assertEquals( -1,
+                      drl.indexOf( "garbage" ) );
 
     }
-    
+
     public void testBuildPackageWithEmptyHeader() throws Exception {
         RulesRepository repo = getRepo();
 
@@ -662,7 +651,6 @@
 
     }
 
-
     public void testSkipDisabledPackageStuff() throws Exception {
         RulesRepository repo = getRepo();
 
@@ -678,21 +666,16 @@
         assertRule1.updateDisabled( true );
         assertRule1.checkin( "" );
 
-
         assertRule1 = pkg.addAsset( "function1",
-                                              "" );
+                                    "" );
         assertRule1.updateFormat( AssetFormats.FUNCTION );
         assertRule1.updateContent( "garbage" );
         assertRule1.updateDisabled( true );
         assertRule1.checkin( "" );
 
-        ContentPackageAssembler asm = new ContentPackageAssembler(pkg);
-        assertFalse(asm.hasErrors());
+        ContentPackageAssembler asm = new ContentPackageAssembler( pkg );
+        assertFalse( asm.hasErrors() );
 
-
-
-
-
     }
 
     public void testSkipDisabledAssets() throws Exception {
@@ -724,7 +707,7 @@
         assertRule3.checkin( "" );
 
         ContentPackageAssembler asm = new ContentPackageAssembler( pkg,
-                                                                   true);
+                                                                   true );
         assertFalse( asm.hasErrors() );
         Package p = asm.builder.getPackage();
 
@@ -774,7 +757,7 @@
 
         ContentPackageAssembler asm = new ContentPackageAssembler( pkg );
         if ( asm.hasErrors() ) {
-            System.err.println( asm.getErrors().get( 0 ).errorReport );
+            System.err.println( asm.getErrors().get( 0 ).getErrorReport() );
             System.err.println( asm.getDRL() );
         }
         assertFalse( asm.hasErrors() );
@@ -809,7 +792,7 @@
         asm = new ContentPackageAssembler( pkg );
         assertTrue( asm.hasErrors() );
         assertEquals( asset.getName(),
-                      asm.getErrors().get( 0 ).itemInError.getName() );
+                      asm.getErrors().get( 0 ).getName() );
         asm = new ContentPackageAssembler( pkg,
                                            false );
         assertFalse( asm.hasErrors() );
@@ -952,8 +935,16 @@
                               }
                           } );
 
-        ContentPackageAssembler asm = new ContentPackageAssembler( pkg, true, 
-                                                                   "customSelector", null, null, false, null, null, false, "testSelect");
+        ContentPackageAssembler asm = new ContentPackageAssembler( pkg,
+                                                                   true,
+                                                                   "customSelector",
+                                                                   null,
+                                                                   null,
+                                                                   false,
+                                                                   null,
+                                                                   null,
+                                                                   false,
+                                                                   "testSelect" );
 
         Package pk = asm.getBinaryPackage();
         assertEquals( 1,
@@ -967,15 +958,34 @@
         assertEquals( 2,
                       pk.getRules().length );
 
-        asm = new ContentPackageAssembler( pkg, true, "customSelector", null, null, false, null, null, false,
+        asm = new ContentPackageAssembler( pkg,
+                                           true,
+                                           "customSelector",
+                                           null,
+                                           null,
+                                           false,
+                                           null,
+                                           null,
+                                           false,
                                            "nothing valid" );
         assertTrue( asm.hasErrors() );
         assertEquals( 1,
                       asm.getErrors().size() );
-        assertEquals( pkg,
-                      asm.getErrors().get( 0 ).itemInError );
+        assertEquals( pkg.getName(),
+                      asm.getErrors().get( 0 ).getName() );
+        assertTrue( asm.getErrors().get( 0 ).isPackageItem() );
+        assertEquals( pkg.getUUID(),
+                      asm.getErrors().get( 0 ).getUUID() );
 
-        asm = new ContentPackageAssembler( pkg, true, "customSelector", null, null, false, null, null, false,
+        asm = new ContentPackageAssembler( pkg,
+                                           true,
+                                           "customSelector",
+                                           null,
+                                           null,
+                                           false,
+                                           null,
+                                           null,
+                                           false,
                                            "" );
         pk = asm.getBinaryPackage();
         assertEquals( 2,

Modified: labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java
===================================================================
--- labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java	2010-11-12 17:38:04 UTC (rev 35962)
+++ labs/jbossrules/trunk/drools-repository/src/main/java/org/drools/repository/AssetItem.java	2010-11-13 18:15:29 UTC (rev 35963)
@@ -1,4 +1,4 @@
-/**
+/*
  * Copyright 2010 JBoss Inc
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
@@ -39,560 +39,568 @@
  * @author btruitt
  */
 public class AssetItem extends CategorisableItem {
-	private Logger log = LoggerFactory.getLogger(AssetItem.class);
-	/**
-	 * The name of the rule node type
-	 */
-	public static final String RULE_NODE_TYPE_NAME = "drools:assetNodeType";
+    private Logger             log                                  = LoggerFactory.getLogger( AssetItem.class );
+    /**
+     * The name of the rule node type
+     */
+    public static final String RULE_NODE_TYPE_NAME                  = "drools:assetNodeType";
 
-	public static final String CONTENT_PROPERTY_NAME = "drools:content";
-	public static final String CONTENT_PROPERTY_BINARY_NAME = "drools:binaryContent";
-	public static final String CONTENT_PROPERTY_ATTACHMENT_FILENAME = "drools:attachmentFileName";
+    public static final String CONTENT_PROPERTY_NAME                = "drools:content";
+    public static final String CONTENT_PROPERTY_BINARY_NAME         = "drools:binaryContent";
+    public static final String CONTENT_PROPERTY_ATTACHMENT_FILENAME = "drools:attachmentFileName";
 
-	/**
-	 * The name of the date effective property on the rule node type
-	 */
-	public static final String DATE_EFFECTIVE_PROPERTY_NAME = "drools:dateEffective";
+    /**
+     * The name of the date effective property on the rule node type
+     */
+    public static final String DATE_EFFECTIVE_PROPERTY_NAME         = "drools:dateEffective";
 
-	public static final String DISABLED_PROPERTY_NAME = "drools:disabled";
+    public static final String DISABLED_PROPERTY_NAME               = "drools:disabled";
 
-	/**
-	 * The name of the date expired property on the rule node type
-	 */
-	public static final String DATE_EXPIRED_PROPERTY_NAME = "drools:dateExpired";
+    /**
+     * The name of the date expired property on the rule node type
+     */
+    public static final String DATE_EXPIRED_PROPERTY_NAME           = "drools:dateExpired";
 
-	public static final String PACKAGE_NAME_PROPERTY = "drools:packageName";
+    public static final String PACKAGE_NAME_PROPERTY                = "drools:packageName";
 
-	/**
-	 * Constructs a RuleItem object, setting its node attribute to the specified
-	 * node.
-	 * 
-	 * @param rulesRepository
-	 *            the rulesRepository that instantiated this object
-	 * @param node
-	 *            the node in the repository that this RuleItem corresponds to
-	 * @throws RulesRepositoryException
-	 */
-	public AssetItem(RulesRepository rulesRepository, Node node)
-			throws RulesRepositoryException {
-		super(rulesRepository, node);
-		try {
-			// make sure this node is a rule node
-			if (!(this.node.getPrimaryNodeType().getName().equals(
-					RULE_NODE_TYPE_NAME) || isHistoricalVersion())) {
-				String message = this.node.getName()
-						+ " is not a node of type " + RULE_NODE_TYPE_NAME
-						+ " nor nt:version. It is a node of type: "
-						+ this.node.getPrimaryNodeType().getName();
-				log.error(message);
-				throw new RulesRepositoryException(message);
-			}
-		} catch (Exception e) {
-			log.error("Caught exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * Constructs a RuleItem object, setting its node attribute to the specified
+     * node.
+     * 
+     * @param rulesRepository
+     *            the rulesRepository that instantiated this object
+     * @param node
+     *            the node in the repository that this RuleItem corresponds to
+     * @throws RulesRepositoryException
+     */
+    public AssetItem(RulesRepository rulesRepository,
+                     Node node) throws RulesRepositoryException {
+        super( rulesRepository,
+               node );
+        try {
+            // make sure this node is a rule node
+            if ( !(this.node.getPrimaryNodeType().getName().equals( RULE_NODE_TYPE_NAME ) || isHistoricalVersion()) ) {
+                String message = this.node.getName() + " is not a node of type " + RULE_NODE_TYPE_NAME + " nor nt:version. It is a node of type: " + this.node.getPrimaryNodeType().getName();
+                log.error( message );
+                throw new RulesRepositoryException( message );
+            }
+        } catch ( Exception e ) {
+            log.error( "Caught exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	public AssetItem() {
-		super(null, null);
-	}
+    public AssetItem() {
+        super( null,
+               null );
+    }
 
-	/**
-	 * returns the string contents of the rule node. If this is a binary asset,
-	 * this will return null (use getBinaryContent instead).
-	 */
-	public String getContent() throws RulesRepositoryException {
-		return getContent(false);
-	}
+    /**
+     * returns the string contents of the rule node. If this is a binary asset,
+     * this will return null (use getBinaryContent instead).
+     */
+    public String getContent() throws RulesRepositoryException {
+        return getContent( false );
+    }
 
-	/**
-	 * Only for use in the StorageEventManager, for passing the fromRepo
-	 * parameter
-	 * 
-	 * returns the string contents of the rule node. If this is a binary asset,
-	 * this will return null (use getBinaryContent instead).
-	 */
-	public String getContent(Boolean fromRepo) throws RulesRepositoryException {
-		try {
+    /**
+     * Only for use in the StorageEventManager, for passing the fromRepo
+     * parameter
+     * 
+     * returns the string contents of the rule node. If this is a binary asset,
+     * this will return null (use getBinaryContent instead).
+     */
+    public String getContent(Boolean fromRepo) throws RulesRepositoryException {
+        try {
 
-			if (StorageEventManager.hasLoadEvent() && !fromRepo) {
-				return IOUtils.toString(StorageEventManager.getLoadEvent()
-						.loadContent(this));
-			}
+            if ( StorageEventManager.hasLoadEvent() && !fromRepo ) {
+                return IOUtils.toString( StorageEventManager.getLoadEvent().loadContent( this ) );
+            }
 
-			if (isBinary()) {
-				return new String(this.getBinaryContentAsBytes());
-			}
-			Node ruleNode = getVersionContentNode();
-			if (ruleNode.hasProperty(CONTENT_PROPERTY_NAME)) {
-				Property data = ruleNode.getProperty(CONTENT_PROPERTY_NAME);
-				return data.getValue().getString();
+            if ( isBinary() ) {
+                return new String( this.getBinaryContentAsBytes() );
+            }
+            Node ruleNode = getVersionContentNode();
+            if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
+                Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
+                return data.getValue().getString();
 
-			} else {
-				return "";
-			}
-		} catch (Exception e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+            } else {
+                return "";
+            }
+        } catch ( Exception e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * returns the number of bytes of the content.
-	 */
-	public long getContentLength() {
-		try {
-			Node ruleNode = getVersionContentNode();
-			if (ruleNode.hasProperty(CONTENT_PROPERTY_BINARY_NAME)) {
-				Property data = ruleNode
-						.getProperty(CONTENT_PROPERTY_BINARY_NAME);
-				return data.getLength();
-			} else {
-				if (ruleNode.hasProperty(CONTENT_PROPERTY_NAME)) {
-					Property data = ruleNode.getProperty(CONTENT_PROPERTY_NAME);
-					return data.getLength();
-				} else {
-					return 0;
-				}
-			}
-		} catch (RepositoryException e) {
-			log.error(e.getMessage(), e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * returns the number of bytes of the content.
+     */
+    public long getContentLength() {
+        try {
+            Node ruleNode = getVersionContentNode();
+            if ( ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME ) ) {
+                Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
+                return data.getLength();
+            } else {
+                if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
+                    Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
+                    return data.getLength();
+                } else {
+                    return 0;
+                }
+            }
+        } catch ( RepositoryException e ) {
+            log.error( e.getMessage(),
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * True if this is a binary asset (or has binary content).
-	 */
-	public boolean isBinary() {
-		try {
-			Node ruleNode = getVersionContentNode();
-			return ruleNode.hasProperty(CONTENT_PROPERTY_BINARY_NAME);
-		} catch (RepositoryException e) {
-			log.error(e.getMessage(), e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * True if this is a binary asset (or has binary content).
+     */
+    public boolean isBinary() {
+        try {
+            Node ruleNode = getVersionContentNode();
+            return ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME );
+        } catch ( RepositoryException e ) {
+            log.error( e.getMessage(),
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * If this asset contains binary data, this is how you return it. Otherwise
-	 * it will return null.
-	 */
-	public InputStream getBinaryContentAttachment() {
-		try {
-			if (StorageEventManager.hasLoadEvent()) {
-				return StorageEventManager.getLoadEvent().loadContent(this);
-			}
-			Node ruleNode = getVersionContentNode();
-			if (ruleNode.hasProperty(CONTENT_PROPERTY_BINARY_NAME)) {
-				Property data = ruleNode
-						.getProperty(CONTENT_PROPERTY_BINARY_NAME);
-				return data.getBinary().getStream();
-			} else {
-				if (ruleNode.hasProperty(CONTENT_PROPERTY_NAME)) {
-					Property data = ruleNode.getProperty(CONTENT_PROPERTY_NAME);
-					return data.getBinary().getStream();
-				}
-				return null;
-			}
-		} catch (Exception e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * If this asset contains binary data, this is how you return it. Otherwise
+     * it will return null.
+     */
+    public InputStream getBinaryContentAttachment() {
+        try {
+            if ( StorageEventManager.hasLoadEvent() ) {
+                return StorageEventManager.getLoadEvent().loadContent( this );
+            }
+            Node ruleNode = getVersionContentNode();
+            if ( ruleNode.hasProperty( CONTENT_PROPERTY_BINARY_NAME ) ) {
+                Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
+                return data.getBinary().getStream();
+            } else {
+                if ( ruleNode.hasProperty( CONTENT_PROPERTY_NAME ) ) {
+                    Property data = ruleNode.getProperty( CONTENT_PROPERTY_NAME );
+                    return data.getBinary().getStream();
+                }
+                return null;
+            }
+        } catch ( Exception e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/** Get the name of the "file" attachment, if one is set. Null otherwise */
-	public String getBinaryContentAttachmentFileName() {
-		return getStringProperty(CONTENT_PROPERTY_ATTACHMENT_FILENAME);
-	}
+    /** Get the name of the "file" attachment, if one is set. Null otherwise */
+    public String getBinaryContentAttachmentFileName() {
+        return getStringProperty( CONTENT_PROPERTY_ATTACHMENT_FILENAME );
+    }
 
-	/**
-	 * This is a convenience method for returning the binary data as a byte
-	 * array.
-	 */
-	public byte[] getBinaryContentAsBytes() {
-		try {
-			Node ruleNode = getVersionContentNode();
-			if (StorageEventManager.hasLoadEvent()) {
-				return IOUtils.toByteArray(StorageEventManager.getLoadEvent()
-						.loadContent(this));
-			}
-			if (isBinary()) {
-				Property data = ruleNode
-						.getProperty(CONTENT_PROPERTY_BINARY_NAME);
-				InputStream in = data.getBinary().getStream();
+    /**
+     * This is a convenience method for returning the binary data as a byte
+     * array.
+     */
+    public byte[] getBinaryContentAsBytes() {
+        try {
+            Node ruleNode = getVersionContentNode();
+            if ( StorageEventManager.hasLoadEvent() ) {
+                return IOUtils.toByteArray( StorageEventManager.getLoadEvent().loadContent( this ) );
+            }
+            if ( isBinary() ) {
+                Property data = ruleNode.getProperty( CONTENT_PROPERTY_BINARY_NAME );
+                InputStream in = data.getBinary().getStream();
 
-				// Create the byte array to hold the data
-				byte[] bytes = new byte[(int) data.getLength()];
+                // Create the byte array to hold the data
+                byte[] bytes = new byte[(int) data.getLength()];
 
-				// Read in the bytes
-				int offset = 0;
-				int numRead = 0;
-				while (offset < bytes.length
-						&& (numRead = in.read(bytes, offset, bytes.length
-								- offset)) >= 0) {
-					offset += numRead;
-				}
+                // Read in the bytes
+                int offset = 0;
+                int numRead = 0;
+                while ( offset < bytes.length && (numRead = in.read( bytes,
+                                                                     offset,
+                                                                     bytes.length - offset )) >= 0 ) {
+                    offset += numRead;
+                }
 
-				// Ensure all the bytes have been read in
-				if (offset < bytes.length) {
-					throw new RulesRepositoryException(
-							"Could not completely read asset " + getName());
-				}
+                // Ensure all the bytes have been read in
+                if ( offset < bytes.length ) {
+                    throw new RulesRepositoryException( "Could not completely read asset " + getName() );
+                }
 
-				// Close the input stream and return bytes
-				in.close();
-				return bytes;
-			} else {
-				return getContent().getBytes();
-			}
-		} catch (Exception e) {
-			log.error(e.getMessage(), e);
-			if (e instanceof RuntimeException)
-				throw (RuntimeException) e;
-			throw new RulesRepositoryException(e);
-		}
-	}
+                // Close the input stream and return bytes
+                in.close();
+                return bytes;
+            } else {
+                return getContent().getBytes();
+            }
+        } catch ( Exception e ) {
+            log.error( e.getMessage(),
+                       e );
+            if ( e instanceof RuntimeException ) throw (RuntimeException) e;
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * @return the date the rule becomes effective
-	 * @throws RulesRepositoryException
-	 */
-	public Calendar getDateEffective() throws RulesRepositoryException {
-		try {
-			Node ruleNode = getVersionContentNode();
+    /**
+     * @return the date the rule becomes effective
+     * @throws RulesRepositoryException
+     */
+    public Calendar getDateEffective() throws RulesRepositoryException {
+        try {
+            Node ruleNode = getVersionContentNode();
 
-			Property dateEffectiveProperty = ruleNode
-					.getProperty(DATE_EFFECTIVE_PROPERTY_NAME);
-			return dateEffectiveProperty.getDate();
-		} catch (PathNotFoundException e) {
-			// doesn't have this property
-			return null;
-		} catch (Exception e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+            Property dateEffectiveProperty = ruleNode.getProperty( DATE_EFFECTIVE_PROPERTY_NAME );
+            return dateEffectiveProperty.getDate();
+        } catch ( PathNotFoundException e ) {
+            // doesn't have this property
+            return null;
+        } catch ( Exception e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * @return if this rule is disabled
-	 * @throws RulesRepositoryException
-	 */
-	public boolean getDisabled() throws RulesRepositoryException {
-		try {
-			Node ruleNode = getVersionContentNode();
+    /**
+     * @return if this rule is disabled
+     * @throws RulesRepositoryException
+     */
+    public boolean getDisabled() throws RulesRepositoryException {
+        try {
+            Node ruleNode = getVersionContentNode();
 
-			Property disabled = ruleNode.getProperty(DISABLED_PROPERTY_NAME);
-			return disabled.getBoolean();
-		} catch (PathNotFoundException e) {
-			// doesn't have this property
-			return false;
-		} catch (Exception e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+            Property disabled = ruleNode.getProperty( DISABLED_PROPERTY_NAME );
+            return disabled.getBoolean();
+        } catch ( PathNotFoundException e ) {
+            // doesn't have this property
+            return false;
+        } catch ( Exception e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * Creates a new version of this object's rule node, updating the effective
-	 * date for the rule node.
-	 * 
-	 * @param newDateEffective
-	 *            the new effective date for the rule
-	 * @throws RulesRepositoryException
-	 */
-	public void updateDateEffective(Calendar newDateEffective)
-			throws RulesRepositoryException {
-		checkIsUpdateable();
-		checkout();
-		try {
-			this.node.setProperty(DATE_EFFECTIVE_PROPERTY_NAME,
-					newDateEffective);
-		} catch (RepositoryException e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * Creates a new version of this object's rule node, updating the effective
+     * date for the rule node.
+     * 
+     * @param newDateEffective
+     *            the new effective date for the rule
+     * @throws RulesRepositoryException
+     */
+    public void updateDateEffective(Calendar newDateEffective) throws RulesRepositoryException {
+        checkIsUpdateable();
+        checkout();
+        try {
+            this.node.setProperty( DATE_EFFECTIVE_PROPERTY_NAME,
+                                   newDateEffective );
+        } catch ( RepositoryException e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * Creates a new version of this object's rule node, updating the disable
-	 * value for the rule node.
-	 * 
-	 * @param disabled
-	 *            is this rule disabled
-	 * @throws RulesRepositoryException
-	 */
-	public void updateDisabled(boolean disabled)
-			throws RulesRepositoryException {
-		checkIsUpdateable();
-		checkout();
-		try {
-			this.node.setProperty(DISABLED_PROPERTY_NAME, disabled);
-		} catch (RepositoryException e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * Creates a new version of this object's rule node, updating the disable
+     * value for the rule node.
+     * 
+     * @param disabled
+     *            is this rule disabled
+     * @throws RulesRepositoryException
+     */
+    public void updateDisabled(boolean disabled) throws RulesRepositoryException {
+        checkIsUpdateable();
+        checkout();
+        try {
+            this.node.setProperty( DISABLED_PROPERTY_NAME,
+                                   disabled );
+        } catch ( RepositoryException e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * @return the date the rule becomes expired
-	 * @throws RulesRepositoryException
-	 */
-	public Calendar getDateExpired() throws RulesRepositoryException {
-		try {
-			Node ruleNode = getVersionContentNode();
+    /**
+     * @return the date the rule becomes expired
+     * @throws RulesRepositoryException
+     */
+    public Calendar getDateExpired() throws RulesRepositoryException {
+        try {
+            Node ruleNode = getVersionContentNode();
 
-			Property dateExpiredProperty = ruleNode
-					.getProperty(DATE_EXPIRED_PROPERTY_NAME);
-			return dateExpiredProperty.getDate();
-		} catch (PathNotFoundException e) {
-			// doesn't have this property
-			return null;
-		} catch (Exception e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+            Property dateExpiredProperty = ruleNode.getProperty( DATE_EXPIRED_PROPERTY_NAME );
+            return dateExpiredProperty.getDate();
+        } catch ( PathNotFoundException e ) {
+            // doesn't have this property
+            return null;
+        } catch ( Exception e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * Creates a new version of this object's rule node, updating the expired
-	 * date for the rule node.
-	 * 
-	 * @param newDateExpired
-	 *            the new expired date for the rule
-	 * @throws RulesRepositoryException
-	 */
-	public void updateDateExpired(Calendar newDateExpired)
-			throws RulesRepositoryException {
-		checkout();
+    /**
+     * Creates a new version of this object's rule node, updating the expired
+     * date for the rule node.
+     * 
+     * @param newDateExpired
+     *            the new expired date for the rule
+     * @throws RulesRepositoryException
+     */
+    public void updateDateExpired(Calendar newDateExpired) throws RulesRepositoryException {
+        checkout();
 
-		try {
-			this.node.setProperty(DATE_EXPIRED_PROPERTY_NAME, newDateExpired);
-		} catch (Exception e) {
-			log.error("Caught Exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+        try {
+            this.node.setProperty( DATE_EXPIRED_PROPERTY_NAME,
+                                   newDateExpired );
+        } catch ( Exception e ) {
+            log.error( "Caught Exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * This will update the asset's content (checking it out if it is not
-	 * already). This will not save the session or create a new version of the
-	 * node (this has to be done seperately, as several properties may change as
-	 * part of one edit). This is only used if the asset is a textual asset. For
-	 * binary, use the updateBinaryContent method instead.
-	 */
-	public AssetItem updateContent(String newRuleContent)
-			throws RulesRepositoryException {
-		checkout();
-		try {
-			if (this.isBinary()) {
-				this.updateBinaryContentAttachment(new ByteArrayInputStream(
-						newRuleContent.getBytes()));
-			}
-			this.node.setProperty(CONTENT_PROPERTY_NAME, newRuleContent);
-			return this;
-		} catch (RepositoryException e) {
-			log.error("Unable to update the asset content", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * This will update the asset's content (checking it out if it is not
+     * already). This will not save the session or create a new version of the
+     * node (this has to be done seperately, as several properties may change as
+     * part of one edit). This is only used if the asset is a textual asset. For
+     * binary, use the updateBinaryContent method instead.
+     */
+    public AssetItem updateContent(String newRuleContent) throws RulesRepositoryException {
+        checkout();
+        try {
+            if ( this.isBinary() ) {
+                this.updateBinaryContentAttachment( new ByteArrayInputStream( newRuleContent.getBytes() ) );
+            }
+            this.node.setProperty( CONTENT_PROPERTY_NAME,
+                                   newRuleContent );
+            return this;
+        } catch ( RepositoryException e ) {
+            log.error( "Unable to update the asset content",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * If the asset is a binary asset, then use this to update the content (do
-	 * NOT use text).
-	 */
-	public AssetItem updateBinaryContentAttachment(InputStream data) {
-		checkout();
-		try {
-			Binary is = this.node.getSession().getValueFactory().createBinary(data);
-			this.node.setProperty(CONTENT_PROPERTY_BINARY_NAME, is);
-			return this;
-		} catch (RepositoryException e) {
-			log.error("Unable to update the assets binary content", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    /**
+     * If the asset is a binary asset, then use this to update the content (do
+     * NOT use text).
+     */
+    public AssetItem updateBinaryContentAttachment(InputStream data) {
+        checkout();
+        try {
+            Binary is = this.node.getSession().getValueFactory().createBinary( data );
+            this.node.setProperty( CONTENT_PROPERTY_BINARY_NAME,
+                                   is );
+            return this;
+        } catch ( RepositoryException e ) {
+            log.error( "Unable to update the assets binary content",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * Optionally set the filename to be associated with the binary content.
-	 */
-	public void updateBinaryContentAttachmentFileName(String name) {
-		updateStringProperty(name, CONTENT_PROPERTY_ATTACHMENT_FILENAME);
-	}
+    /**
+     * Optionally set the filename to be associated with the binary content.
+     */
+    public void updateBinaryContentAttachmentFileName(String name) {
+        updateStringProperty( name,
+                              CONTENT_PROPERTY_ATTACHMENT_FILENAME );
+    }
 
-	/**
-	 * This updates a user defined property (not one of the intrinsic ones).
-	 */
-	public void updateUserProperty(String propertyName, String value) {
-		if (propertyName.startsWith("drools:")) {
-			throw new IllegalArgumentException(
-					"Can only set the pre defined fields using the appropriate methods.");
-		}
-		updateStringProperty(value, propertyName);
+    /**
+     * This updates a user defined property (not one of the intrinsic ones).
+     */
+    public void updateUserProperty(String propertyName,
+                                   String value) {
+        if ( propertyName.startsWith( "drools:" ) ) {
+            throw new IllegalArgumentException( "Can only set the pre defined fields using the appropriate methods." );
+        }
+        updateStringProperty( value,
+                              propertyName );
 
-	}
+    }
 
-	/**
-	 * Nicely formats the information contained by the node that this object
-	 * encapsulates
-	 */
-	public String toString() {
-		try {
-			StringBuilder returnString = new StringBuilder();
-            returnString.append("Content of rule item named '").append(this.getName()).append("':\n");
-            returnString.append("Content: ").append(this.getContent()).append("\n");
-			returnString.append("------\n");
+    /**
+     * Nicely formats the information contained by the node that this object
+     * encapsulates
+     */
+    public String toString() {
+        try {
+            StringBuilder returnString = new StringBuilder();
+            returnString.append( "Content of rule item named '" ).append( this.getName() ).append( "':\n" );
+            returnString.append( "Content: " ).append( this.getContent() ).append( "\n" );
+            returnString.append( "------\n" );
 
-            returnString.append("Archived: ").append(this.isArchived()).append("\n");
-			returnString.append("------\n");
+            returnString.append( "Archived: " ).append( this.isArchived() ).append( "\n" );
+            returnString.append( "------\n" );
 
-            returnString.append("Date Effective: ").append(this.getDateEffective()).append("\n");
-            returnString.append("Date Expired: ").append(this.getDateExpired()).append("\n");
-			returnString.append("------\n");
+            returnString.append( "Date Effective: " ).append( this.getDateEffective() ).append( "\n" );
+            returnString.append( "Date Expired: " ).append( this.getDateExpired() ).append( "\n" );
+            returnString.append( "------\n" );
 
-			returnString.append("Rule state: ");
-			StateItem stateItem = this.getState();
-			if (stateItem != null) {
-                returnString.append(this.getState().getName()).append("\n");
-			} else {
-				returnString.append("NO STATE SET FOR THIS NODE\n");
-			}
-			returnString.append("------\n");
+            returnString.append( "Rule state: " );
+            StateItem stateItem = this.getState();
+            if ( stateItem != null ) {
+                returnString.append( this.getState().getName() ).append( "\n" );
+            } else {
+                returnString.append( "NO STATE SET FOR THIS NODE\n" );
+            }
+            returnString.append( "------\n" );
 
-			returnString.append("Rule tags:\n");
-			for (Iterator it = this.getCategories().iterator(); it.hasNext();) {
-				CategoryItem currentTag = (CategoryItem) it.next();
-                returnString.append(currentTag.getName()).append("\n");
-			}
-			returnString.append("--------------\n");
-			return returnString.toString();
-		} catch (Exception e) {
-			throw new RulesRepositoryException(e);
-		}
-	}
+            returnString.append( "Rule tags:\n" );
+            for ( Iterator it = this.getCategories().iterator(); it.hasNext(); ) {
+                CategoryItem currentTag = (CategoryItem) it.next();
+                returnString.append( currentTag.getName() ).append( "\n" );
+            }
+            returnString.append( "--------------\n" );
+            return returnString.toString();
+        } catch ( Exception e ) {
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	public VersionableItem getPrecedingVersion()
-			throws RulesRepositoryException {
-		try {
-			Node precedingVersionNode = this.getPrecedingVersionNode();
-			if (precedingVersionNode != null) {
-				return new AssetItem(this.rulesRepository, precedingVersionNode);
-			} else {
-				return null;
-			}
-		} catch (Exception e) {
-			log.error("Caught exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    public VersionableItem getPrecedingVersion() throws RulesRepositoryException {
+        try {
+            Node precedingVersionNode = this.getPrecedingVersionNode();
+            if ( precedingVersionNode != null ) {
+                return new AssetItem( this.rulesRepository,
+                                      precedingVersionNode );
+            } else {
+                return null;
+            }
+        } catch ( Exception e ) {
+            log.error( "Caught exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	public VersionableItem getSucceedingVersion()
-			throws RulesRepositoryException {
-		try {
-			Node succeedingVersionNode = this.getSucceedingVersionNode();
-			if (succeedingVersionNode != null) {
-				return new AssetItem(this.rulesRepository,
-						succeedingVersionNode);
-			} else {
-				return null;
-			}
-		} catch (Exception e) {
-			log.error("Caught exception", e);
-			throw new RulesRepositoryException(e);
-		}
-	}
+    public VersionableItem getSucceedingVersion() throws RulesRepositoryException {
+        try {
+            Node succeedingVersionNode = this.getSucceedingVersionNode();
+            if ( succeedingVersionNode != null ) {
+                return new AssetItem( this.rulesRepository,
+                                      succeedingVersionNode );
+            } else {
+                return null;
+            }
+        } catch ( Exception e ) {
+            log.error( "Caught exception",
+                       e );
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * Get the name of the enclosing package. As assets are stored in
-	 * versionable subfolders, this means walking up 2 levels in the hierarchy
-	 * to get to the enclosing "package" node.
-	 */
-	public String getPackageName() {
-		return super.getStringProperty(PACKAGE_NAME_PROPERTY);
-	}
+    /**
+     * Get the name of the enclosing package. As assets are stored in
+     * versionable subfolders, this means walking up 2 levels in the hierarchy
+     * to get to the enclosing "package" node.
+     */
+    public String getPackageName() {
+        return super.getStringProperty( PACKAGE_NAME_PROPERTY );
+    }
 
-	/**
-	 * @return A property value (for a user defined property).
-	 */
-	public String getUserProperty(String property) {
-		return getStringProperty(property);
-	}
+    /**
+     * @return A property value (for a user defined property).
+     */
+    public String getUserProperty(String property) {
+        return getStringProperty( property );
+    }
 
-	/**
-	 * This will remove the item. The repository will need to be saved for this
-	 * to take effect. Typically the package that contains this should be
-	 * versioned before removing this, to make it easy to roll back.
-	 */
-	public void remove() {
+    /**
+     * This will remove the item. The repository will need to be saved for this
+     * to take effect. Typically the package that contains this should be
+     * versioned before removing this, to make it easy to roll back.
+     */
+    public void remove() {
 
-		if (StorageEventManager.hasSaveEvent()) {
-			StorageEventManager.getSaveEvent().onAssetDelete(this);
-		}
+        if ( StorageEventManager.hasSaveEvent() ) {
+            StorageEventManager.getSaveEvent().onAssetDelete( this );
+        }
 
-		checkIsUpdateable();
-		if (this.getDateExpired() != null) {
-			if (Calendar.getInstance().before(this.getDateExpired())) {
-				throw new RulesRepositoryException(
-						"Can't delete an item before its expiry date.");
-			}
-		}
-		try {
-			this.node.remove();
-		} catch (RepositoryException e) {
-			throw new RulesRepositoryException(e);
-		}
-	}
+        checkIsUpdateable();
+        if ( this.getDateExpired() != null ) {
+            if ( Calendar.getInstance().before( this.getDateExpired() ) ) {
+                throw new RulesRepositoryException( "Can't delete an item before its expiry date." );
+            }
+        }
+        try {
+            this.node.remove();
+        } catch ( RepositoryException e ) {
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * 
-	 * @return An iterator over the nodes history.
-	 */
-	public AssetHistoryIterator getHistory() {
-		return new AssetHistoryIterator(this.rulesRepository, this.node);
-	}
+    /**
+     * 
+     * @return An iterator over the nodes history.
+     */
+    public AssetHistoryIterator getHistory() {
+        return new AssetHistoryIterator( this.rulesRepository,
+                                         this.node );
+    }
 
-	/**
-	 * This will get the package an asset item belongs to.
-	 */
-	public PackageItem getPackage() {
+    /**
+     * This will get the package an asset item belongs to.
+     */
+    public PackageItem getPackage() {
 
-		try {
-			if (this.isHistoricalVersion()) {
-				return this.rulesRepository.loadPackage(this.getPackageName());
-			}
-			return new PackageItem(this.rulesRepository, this.node.getParent()
-					.getParent());
-		} catch (RepositoryException e) {
-			throw new RulesRepositoryException(e);
-		}
-	}
+        try {
+            if ( this.isHistoricalVersion() ) {
+                return this.rulesRepository.loadPackage( this.getPackageName() );
+            }
+            return new PackageItem( this.rulesRepository,
+                                    this.node.getParent().getParent() );
+        } catch ( RepositoryException e ) {
+            throw new RulesRepositoryException( e );
+        }
+    }
 
-	/**
-	 * This converts a "filename" to an asset name.
-	 * 
-	 * File name is foo.drl -> ["foo", "drl"]
-	 * 
-	 * @param fileName
-	 * @return
-	 */
-	public static String[] getAssetNameFromFileName(String fileName) {
+    /**
+     * This converts a "filename" to an asset name.
+     * 
+     * File name is foo.drl -> ["foo", "drl"]
+     * 
+     * @param fileName
+     * @return
+     */
+    public static String[] getAssetNameFromFileName(String fileName) {
 
-		String[] r = new String[] { "", "" };
-		if (!fileName.contains(".")) {
-			r[0] = fileName;
-		} else if (fileName.endsWith(".bpel.jar")) {
-			r[0] = fileName.substring(0, fileName.lastIndexOf(".bpel.jar"));
-			r[1] = "bpel.jar";
-		} else if (fileName.endsWith(".model.drl")) {
-			r[0] = fileName.substring(0, fileName.lastIndexOf(".model.drl"));
-			r[1] = "model.drl";
-		} else {
-			r[0] = fileName.substring(0, fileName.lastIndexOf("."));
-			r[1] = fileName.substring(fileName.lastIndexOf(".") + 1);
+        String[] r = new String[]{"", ""};
+        if ( !fileName.contains( "." ) ) {
+            r[0] = fileName;
+        } else if ( fileName.endsWith( ".bpel.jar" ) ) {
+            r[0] = fileName.substring( 0,
+                                       fileName.lastIndexOf( ".bpel.jar" ) );
+            r[1] = "bpel.jar";
+        } else if ( fileName.endsWith( ".model.drl" ) ) {
+            r[0] = fileName.substring( 0,
+                                       fileName.lastIndexOf( ".model.drl" ) );
+            r[1] = "model.drl";
+        } else {
+            r[0] = fileName.substring( 0,
+                                       fileName.lastIndexOf( "." ) );
+            r[1] = fileName.substring( fileName.lastIndexOf( "." ) + 1 );
 
-		}
-		return r;
+        }
+        return r;
 
-	}
+    }
 
 }



More information about the jboss-svn-commits mailing list