Ignore:
Timestamp:
Jan 26, 2011, 9:47:40 PM (10 years ago)
Author:
work@…
Message:
  • refactored the importer to use the dynamic entities of gdt, instead of the hardcoded entities in Config.groovy
  • removed the hardcoded 'importable entities' from Config.groovy
  • added xbean.jar which seems to be required for the importer to be able to import xml
  • updated gdt to 0.0.5 which is required by the refactored importer
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r1430 r1443  
    55import org.apache.poi.ss.usermodel.Workbook
    66import grails.converters.JSON
    7 import cr.co.arquetipos.crypto.Blowfish
     7//import cr.co.arquetipos.crypto.Blowfish
    88import org.codehaus.groovy.grails.plugins.web.taglib.ValidationTagLib
    99import grails.plugins.springsecurity.Secured
     
    3232        def ImporterService
    3333        def validationTagLib = new ValidationTagLib()
     34        def GdtService
    3435
    3536        /**
     
    4041                // Grom a development message
    4142                if (pluginManager.getGrailsPlugin('grom')) "redirecting into the webflow".grom()
    42 
    43                 // TODO --> move this logic to the application Bootstrapping as this
    44                 //                      does not need to run every time the importer is started
    45                 //
    46                 // encrypt the importable entities
    47                 grailsApplication.config.gscf.domain.importableEntities.each {
    48                         it.value.encrypted =
    49                                 URLEncoder.encode(Blowfish.encryptBase64(
    50                                         it.value.entity.toString().replaceAll(/^class /, ''),
    51                                         grailsApplication.config.crypto.shared.secret
    52                                 ))
    53                 }
    5443
    5544                /**
     
    120109                                flow.page = 1
    121110                                flow.studies = Study.findAllWhere(owner: authenticationService.getLoggedInUser())
    122                                 flow.importer_importableentities = grailsApplication.config.gscf.domain.importableEntities
     111                                flow.importer_importableentities = GdtService.getTemplateEntities()
    123112
    124113                                success()
     
    298287         */
    299288        def ajaxGetTemplatesByEntity = {
    300                 def entityName = Blowfish.decryptBase64(
    301                         URLDecoder.decode(params.entity),
    302                         grailsApplication.config.crypto.shared.secret
    303                 )
    304 
    305                 //def entityClass = grailsApplication.config.gscf.domain.importableEntities.get(params.entity).entity
    306                 def entityClass = entityName
    307 
    308289                // fetch all templates for a specific entity
    309                 def templates = Template.findAllByEntity(Class.forName(entityClass, true, this.getClass().getClassLoader()))
     290                def templates = Template.findAllByEntity(GdtService.getInstanceByEntity(params.entity.decodeURL()))
     291
    310292
    311293                // render as JSON
     
    330312                        def selectedentities = []
    331313
    332                         def entityName = Blowfish.decryptBase64(
    333                                 URLDecoder.decode(params.entity),
    334                                 grailsApplication.config.crypto.shared.secret
    335                         )
    336 
    337                         def entityClass = Class.forName(entityName, true, this.getClass().getClassLoader())
     314                        def entityName = GdtService.decryptEntity(params.entity.decodeURL())
     315                        def entityClass = GdtService.getInstanceByEntityName(entityName)
    338316
    339317                        // Initialize some session variables
Note: See TracChangeset for help on using the changeset viewer.