Index: trunk/grails-app/controllers/AssetSubItemDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/AssetSubItemDetailedController.groovy	(revision 276)
+++ trunk/grails-app/controllers/AssetSubItemDetailedController.groovy	(revision 285)
@@ -2,5 +2,7 @@
 
 class AssetSubItemDetailedController extends BaseController {
-    
+
+    def assetSubItemService
+
     def index = { redirect(controller: "assetDetailed", params:params) }
 
@@ -27,5 +29,5 @@
             }
             catch(org.springframework.dao.DataIntegrityViolationException e) {
-                flash.message = "AssetSubItem ${params.id} could not be deleted"
+                flash.errorMessage = "AssetSubItem ${params.id} could not be deleted"
                 redirect(action:show,id:params.id)
             }
@@ -110,32 +112,26 @@
 
     def create = {
-        def assetSubItemInstance = new AssetSubItem()
-        assetSubItemInstance.properties = params
-        return ['assetSubItemInstance':assetSubItemInstance]
+        def result = assetSubItemService.create(params)
+
+        if(!result.error)
+            return [assetSubItemInstance: result.assetSubItemInstance, assetInstance: result.assetInstance]
+
+        flash.message = g.message(code: result.error.code, args: result.error.args)
+        redirect(controller: 'assetDetailed', action: 'search')
     }
 
     def save = {
-        def assetSubItemInstance = new AssetSubItem(params)
+        def result = assetSubItemService.save(params)
 
-//         if(!assetSubItemInstance.asset && !assetSubItemInstance.parentItem) {
-//             flash.message = "Either an asset or parentItem is required."
-//             render(view:'create',model:[assetSubItemInstance:assetSubItemInstance])
-//             return
-//         }
-// 
-//         if(assetSubItemInstance.asset && assetSubItemInstance.parentItem) {
-//             flash.message = "Both an asset and parentItem may not be specified at the same time."
-//             render(view:'create',model:[assetSubItemInstance:assetSubItemInstance])
-//             return
-//         }
+        if(!result.error) {
+            // Success.
+            flash.message = g.message(code: "default.create.success", args: ["AssetSubItem", result.assetSubItemInstance.name])
 
-        if(!assetSubItemInstance.hasErrors() && assetSubItemInstance.save(flush: true)) {
-            flash.message = "AssetSubItem ${assetSubItemInstance.id} created"
-
-            if(assetSubItemInstance.assets)
-                redirect(controller: "assetDetailed", action:"show", id: assetSubItemInstance.assets.toArray()[0].id)
+            /// @todo: This just grabs the first parent in an unsorted list and needs improving.
+            if(result.assetSubItemInstance.assets)
+                redirect(controller: "assetDetailed", action:"show", id: result.assetSubItemInstance.assets.toArray()[0].id)
             else {
                 //Get the top parentItem.
-                def parentItem = assetSubItemInstance.parentItem
+                def parentItem = result.assetSubItemInstance.parentItem
                 def i = 0
                 while(parentItem?.parentItem) {
@@ -150,12 +146,14 @@
                     redirect(controller: "assetDetailed", action:"show", id: parentItem.assets.toArray()[0].id)
                 else
-                    redirect(action:"show", id: assetSubItemInstance.id) // End stop if all else fails.
+                    redirect(action:"show", id: result.assetSubItemInstance.id) // End stop if all else fails.
             }
+            return
+        }
 
-        }
-        else {
-            render(view:'create',model:[assetSubItemInstance:assetSubItemInstance])
-        }
-    } // end save()
+        if(result.error.code == "assetSubItem.asset.not.found")
+            flash.errorMessage = g.message(code: "default.create.success")
+
+        render(view:'create', model:[assetSubItemInstance: result.assetSubItemInstance, assetInstance: result.assetInstance])
+    }
 
 } // end class
