Index: trunk/grails-app/controllers/AssetDetailedController.groovy
===================================================================
--- trunk/grails-app/controllers/AssetDetailedController.groovy	(revision 271)
+++ trunk/grails-app/controllers/AssetDetailedController.groovy	(revision 278)
@@ -7,6 +7,7 @@
     def filterService
     def exportService
-
-    def index = { redirect(action:search,params:params) }
+    def assetService
+
+    def index = { redirect(action:overview,params:params) }
 
     // the delete, save and update actions only accept POST requests
@@ -14,4 +15,6 @@
 
     def importAssetTree = {
+    }
+    def overview = {
     }
 
@@ -245,5 +248,7 @@
         }
 
-        def assetInstance = new Asset(name: assetToCopy.name, section: assetToCopy.section)
+        def assetInstance = new Asset(name: assetToCopy.name,
+                                                            description: assetToCopy.description,
+                                                            section: assetToCopy.section)
         assetInstance.properties = params
         return ['assetInstance':assetInstance, assetToCopy: assetToCopy]
@@ -262,5 +267,5 @@
 
     def saveCopy = {
-        def result = saveCopySrvce(params)
+        def result = assetService.saveCopy(params)
 
         if(!result.error) {
@@ -276,91 +281,10 @@
         }
 
+        if(result.error.code != "default.create.failure") {
+            flash.warning = g.message(code: result.error.code, args: ["Asset"])
+        }
+
         render(view:'copy', model:[assetInstance: result.assetInstance, assetToCopy: result.assetToCopy])
     }
 
-    def saveCopySrvce(params) {
-        Asset.withTransaction { status ->
-            def result = [:]
-
-            def fail = { Map m ->
-                status.setRollbackOnly()
-                if(result.assetInstance && m.field)
-                    result.assetInstance.errors.rejectValue(m.field, m.code)
-                result.error = [ code: m.code, args: ["Asset", params.id] ]
-                return result
-            }
-
-            result.assetToCopy = Asset.get(params.assetToCopy?.id)
-            if(!result.assetToCopy)
-                return fail(code:"default.not.found")
-
-            result.assetInstance =  new Asset(params)
-
-            if(result.assetInstance.hasErrors() || !result.assetInstance.save())
-                return fail(code:"default.create.failure")
-
-            def assetSubItemInstance1
-
-            // Copy subItems from level 2 and bellow.
-            def copyAssetSubItem = { assetSubItemToCopy, parentItem ->
-                def assetSubItemInstance = new AssetSubItem(name: assetSubItemToCopy.name,
-                                                                                            description: assetSubItemToCopy.description,
-                                                                                            parentItem: parentItem)
-
-                if(assetSubItemInstance.hasErrors() || !assetSubItemInstance.save())
-                    return fail(field:"subItems", code:"default.create.failure")
-
-                def i = 0
-                for(assetSubItem in assetSubItemToCopy.subItems) {
-                    call(assetSubItem, assetSubItemInstance)
-                    // Protect against endless recurrsion.
-                    i++
-                    if(i > 100)
-                        fail(code:"default.create.failure")
-                    // Stop if an error is flagged.
-                    if(result.error)
-                        break
-                }
-            } //copyAssetSubItem
-
-            // Copy the 1st level of subItems.
-            def copyAssetSubItem1 = { assetSubItemToCopy ->
-                assetSubItemInstance1 = new AssetSubItem(name: assetSubItemToCopy.name,
-                                                                                        description: assetSubItemToCopy.description,
-                                                                                        asset: result.assetInstance)
-
-                if(assetSubItemInstance1.hasErrors() || !assetSubItemInstance1.save())
-                    return fail(field:"assetSubItems", code:"default.create.failure")
-
-                def i = 0
-                for(assetSubItem in assetSubItemToCopy.subItems) {
-                    copyAssetSubItem(assetSubItem, assetSubItemInstance1)
-                    // Protect against endless recurrsion.
-                    i++
-                    if(i > 100)
-                        fail(code:"default.create.failure")
-                    // Stop if an error is flagged.
-                    if(result.error)
-                        break
-                }
-            } //copyAssetSubItem1
-
-            def i = 0
-            for(assetSubItem in result.assetToCopy.assetSubItems) {
-                copyAssetSubItem1(assetSubItem)
-                // Protect against endless recurrsion.
-                i++
-                if(i > 100)
-                    fail(code:"default.create.failure")
-                // Stop if an error is flagged.
-                if(result.error)
-                    break
-            }
-
-            // Success or not.
-            return result
-
-        } //end withTransaction
-    } // end saveCopySrvce
-
 } // end class
