Ignore:
Timestamp:
Feb 10, 2010, 3:52:30 AM (10 years ago)
Author:
gav
Message:

Move AssetSubItem delete to a service method and configure cascade deletion checks.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/AssetSubItemDetailedController.groovy

    r342 r347  
    9292
    9393    def delete = {
    94         def assetSubItemInstance = AssetSubItem.get( params.id )
    95         if(assetSubItemInstance) {
    96             try {
    97                 assetSubItemInstance.delete(flush:true)
    98                 flash.message = "AssetSubItem ${params.id} deleted"
    99                 redirect(action: "search")
    100             }
    101             catch(org.springframework.dao.DataIntegrityViolationException e) {
    102                 flash.errorMessage = "AssetSubItem ${params.id} could not be deleted"
    103                 redirect(action:show,id:params.id)
    104             }
    105         }
    106         else {
    107             flash.message = "AssetSubItem not found with id ${params.id}"
    108             redirect(action: "search")
    109         }
     94        def result = assetSubItemService.delete(params)
     95
     96        if(!result.error) {
     97            flash.message = g.message(code: "default.delete.success", args: ["AssetSubItem", params.id])
     98            redirect(action: search)
     99            return
     100        }
     101
     102        flash.errorMessage = g.message(code: result.error.code, args: result.error.args)
     103
     104        if(result.error.code == "default.not.found") {
     105            redirect(action: search)
     106            return
     107        }
     108
     109        redirect(action:show, id: params.id)
    110110    }
    111111
Note: See TracChangeset for help on using the changeset viewer.