Ignore:
Timestamp:
Mar 4, 2011, 12:30:52 PM (11 years ago)
Author:
s.h.sikkema@…
Message:

Fixed tests (except webtests); cleaned up Example{Studies,Templates}.groovy; decapitalized injected services; made 'transactional' properties static

Location:
trunk/grails-app/controllers
Files:
6 edited

Legend:

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

    r1579 r1588  
    3030     /**************************************************/
    3131
    32         def AuthenticationService       
    33         def beforeInterceptor = [action:this.&auth,except:["isUser"]]
     32        def authenticationService
     33//      def beforeInterceptor = [action:this.&auth,except:["isUser"]]
    3434        def credentials
    3535        def requestUser
     
    4545         */
    4646        private def auth() {
    47                 if( !AuthenticationService.isRemotelyLoggedIn( params.consumer, params.token ) ) {
     47                if( !authenticationService.isRemotelyLoggedIn( params.consumer, params.token ) ) {
    4848                        response.sendError(403)
    4949                        return false
     
    6363         */
    6464        def isUser = {
    65                 boolean isUser = AuthenticationService.isRemotelyLoggedIn( params.consumer, params.token )
     65                boolean isUser = authenticationService.isRemotelyLoggedIn( params.consumer, params.token )
    6666                def reply = ['authenticated':isUser]
    6767                render reply as JSON
     
    7878         */
    7979        def getUser = {
    80                 SecUser user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )
     80                SecUser user = authenticationService.getRemotelyLoggedInUser( params.consumer, params.token )
    8181                def reply = [username: user.username, id: user.id]
    8282                render reply as JSON
     
    139139                        def study = Study.findByStudyUUID( params.studyToken )
    140140                        if( study ) {
    141                                 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) {
     141                                if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) {
    142142                                        response.sendError(401)
    143143                                        return false
     
    162162                studies.each { study ->
    163163                        if(study) {
    164                                 def user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )
     164                                def user = authenticationService.getRemotelyLoggedInUser( params.consumer, params.token )
    165165                                // Check whether the person is allowed to read the data of this study
    166                                 if( study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
     166                                if( study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
    167167
    168168                    def items = [studyToken:study.giveUUID()]
     
    214214                        study = Study.findByStudyUUID( params.studyToken )
    215215                        if( study ) {
    216                                 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) {
     216                                if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) {
    217217                                        response.sendError(401)
    218218                                        return false
     
    249249                        if(study) {
    250250                                // Check whether the person is allowed to read the data of this study
    251                                 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
     251                                if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
    252252                                        response.sendError(401)
    253253                                        return false
     
    321321                        if(study) {
    322322                                // Check whether the person is allowed to read the data of this study
    323                                 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
     323                                if( !study.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
    324324                                        response.sendError(401)
    325325                                        return false
     
    443443                        if( assay )  {
    444444                                // Check whether the person is allowed to read the data of this study
    445                                 if( !assay.parent.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
     445                                if( !assay.parent.canRead(authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ))) {
    446446                                        response.sendError(401)
    447447                                        return false
     
    456456                } else {
    457457                        // Find all samples from studies the user can read
    458                         def studies = Study.list().findAll { it.canRead( AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) ) };
     458                        def studies = Study.list().findAll { it.canRead( authenticationService.getRemotelyLoggedInUser( params.consumer, params.token ) ) };
    459459                        samples = studies*.getSamples().flatten();
    460460                }
     
    537537                        }
    538538
    539                         def user = AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token );
     539                        def user = authenticationService.getRemotelyLoggedInUser( params.consumer, params.token );
    540540                        def auth = ['isOwner': study.isOwner(user), 'canRead': study.canRead(user), 'canWrite': study.canWrite(user)];
    541541                        log.trace "Authorization for study " + study.title + " and user " + user.username + ": " + auth
  • trunk/grails-app/controllers/dbnp/authentication/LoginController.groovy

    r1430 r1588  
    2828         * Dependency injection for the GSCF authentication service
    2929         */
    30         def AuthenticationService
     30        def authenticationService
    3131
    3232        /**
     
    7575            // If the user is already authenticated with this session_id, redirect
    7676            // him
    77             if( AuthenticationService.isRemotelyLoggedIn( consumer, token ) ) {
     77            if( authenticationService.isRemotelyLoggedIn( consumer, token ) ) {
    7878                if( returnUrl ) {
    7979                                        redirect url: returnUrl
     
    8585            // If the user is already logged in locally, we log him in and
    8686            // immediately redirect him
    87             if (AuthenticationService.isLoggedIn()) {
    88                                 AuthenticationService.logInRemotely( consumer, token, AuthenticationService.getLoggedInUser() )
     87            if (authenticationService.isLoggedIn()) {
     88                                authenticationService.logInRemotely( consumer, token, authenticationService.getLoggedInUser() )
    8989
    9090                                if( returnUrl ) {
  • trunk/grails-app/controllers/dbnp/authentication/LogoutController.groovy

    r1482 r1588  
    44
    55class LogoutController {
    6         def AuthenticationService
     6        def authenticationService
    77       
    88        /**
     
    2424                if( params.consumer || params.token ) {
    2525                        // Log out the remote user
    26                         AuthenticationService.logOffRemotely( params.consumer, params.token )
     26                        authenticationService.logOffRemotely( params.consumer, params.token )
    2727                }
    2828               
  • trunk/grails-app/controllers/dbnp/exporter/ExporterController.groovy

    r1456 r1588  
    11/**
    2  * ExporterController Controler
     2 * ExporterController Controller
    33 *
    44 * Description of my controller
     
    3232class ExporterController {
    3333
    34     def AuthenticationService
    35     def ImporterService
     34    def authenticationService
    3635
    3736    /*
     
    4140    def index = {
    4241
    43         def user = AuthenticationService.getLoggedInUser()
     42        def user = authenticationService.getLoggedInUser()
    4443        def max = Math.min(params.max ? params.int('max') : 10, 100)
    4544
  • trunk/grails-app/controllers/dbnp/importer/ImporterController.groovy

    r1562 r1588  
    2727        def authenticationService
    2828        def fileService
    29         def ImporterService
     29        def importerService
    3030        def validationTagLib = new ValidationTagLib()
    31         def GdtService
     31        def gdtService
    3232
    3333        /**
     
    114114
    115115                if (params.entity) {
    116                     flash.importer_datatemplates = Template.findAllByEntity(GdtService.getInstanceByEntity(params.entity.decodeURL()))
     116                    flash.importer_datatemplates = Template.findAllByEntity(gdtService.getInstanceByEntity(params.entity.decodeURL()))
    117117                }
    118118               
     
    133133
    134134                if (params.entity) {
    135                     flash.importer_datatemplates = Template.findAllByEntity(GdtService.getInstanceByEntity(params.entity.decodeURL()))
     135                    flash.importer_datatemplates = Template.findAllByEntity(gdtService.getInstanceByEntity(params.entity.decodeURL()))
    136136                }
    137137
     
    320320        def ajaxGetTemplatesByEntity = {
    321321                // fetch all templates for a specific entity
    322                 def templates = Template.findAllByEntity(GdtService.getInstanceByEntity(params.entity.decodeURL()))
     322                def templates = Template.findAllByEntity(gdtService.getInstanceByEntity(params.entity.decodeURL()))
    323323
    324324
     
    340340        if (importedfile.exists()) {
    341341            try {
    342                 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile))
     342                session.importer_workbook = importerService.getWorkbook(new FileInputStream(importedfile))
    343343            } catch (Exception e) {
    344344                log.error ".importer wizard could not load file: " + e
     
    351351                       
    352352            try {
    353                 session.importer_workbook = ImporterService.getWorkbook(new FileInputStream(importedfile))
     353                session.importer_workbook = importerService.getWorkbook(new FileInputStream(importedfile))
    354354            } catch (Exception e) {
    355355                log.error ".importer wizard could not load file: " + e
     
    360360                        def selectedentities = []
    361361
    362                         def entityName = GdtService.decryptEntity(params.entity.decodeURL())
    363                         def entityClass = GdtService.getInstanceByEntityName(entityName)
     362                        def entityName = gdtService.decryptEntity(params.entity.decodeURL())
     363                        def entityClass = gdtService.getInstanceByEntityName(entityName)
    364364
    365365                        // Initialize some session variables
     
    371371                        flow.importer_headerrow = params.headerrow.toInteger()
    372372            flow.importer_entityclass = entityClass
    373             flow.importer_entity = GdtService.cachedEntities.find{ it.entity==entityName }
     373            flow.importer_entity = gdtService.cachedEntities.find{ it.entity==entityName }
    374374         
    375375                        // Get the header from the Excel file using the arguments given in the first step of the wizard
    376                         flow.importer_header = ImporterService.getHeader(session.importer_workbook,
     376                        flow.importer_header = importerService.getHeader(session.importer_workbook,
    377377                                flow.importer_sheetindex,
    378378                                flow.importer_headerrow,
     
    380380                                entityClass)
    381381
    382                         session.importer_datamatrix = ImporterService.getDatamatrix(
     382                        session.importer_datamatrix = importerService.getDatamatrix(
    383383                                session.importer_workbook, flow.importer_header,
    384384                                flow.importer_sheetindex,
     
    437437                        // Create an actual class instance of the selected entity with the selected template
    438438                        // This should be inside the closure because in some cases in the advanced importer, the fields can have different target entities                     
    439                         //def entityClass = GdtService.getInstanceByEntityName(flow.importer_header[columnindex.toInteger()].entity.getName())           
     439                        //def entityClass = gdtService.getInstanceByEntityName(flow.importer_header[columnindex.toInteger()].entity.getName())
    440440            def entityObj = flow.importer_entityclass.newInstance(template:template)
    441441
     
    520520
    521521                // Import the workbook and store the table with entity records and store the failed cells
    522                 def (table, failedcells) = ImporterService.importData(flow.importer_template_id,
     522                def (table, failedcells) = importerService.importData(flow.importer_template_id,
    523523                        session.importer_workbook,
    524524                        flow.importer_sheetindex,
     
    661661                //def (validatedSuccesfully, updatedEntities, failedToPersist) =
    662662                //try {
    663                 ImporterService.saveDatamatrix(flow.importer_study, flow.importer_importeddata, authenticationService, log)
     663                importerService.saveDatamatrix(flow.importer_study, flow.importer_importeddata, authenticationService, log)
    664664
    665665                //}
  • trunk/grails-app/controllers/dbnp/studycapturing/StudyController.groovy

    r1494 r1588  
    1111 */
    1212class StudyController {
    13     def AuthenticationService
     13    def authenticationService
    1414   
    1515    //static allowedMethods = [save: "POST", update: "POST", delete: "POST"]
     
    2424    def list = {
    2525
    26         def user = AuthenticationService.getLoggedInUser()
     26        def user = authenticationService.getLoggedInUser()
    2727        def max = Math.min(params.max ? params.int('max') : 10, 100)
    2828                def offset = params.offset ? params.int( 'offset' ) : 0
     
    3737    @Secured(['IS_AUTHENTICATED_REMEMBERED'])
    3838    def myStudies = {
    39         def user = AuthenticationService.getLoggedInUser()
     39        def user = authenticationService.getLoggedInUser()
    4040        def max = Math.min(params.max ? params.int('max') : 10, 100)
    4141                def offset = params.offset ? params.int( 'offset' ) : 0
     
    8888        else {
    8989            // Check whether the user may see this study
    90             def loggedInUser = AuthenticationService.getLoggedInUser()
     90            def loggedInUser = authenticationService.getLoggedInUser()
    9191            if( !studyInstance.canRead(loggedInUser) ) {
    9292                flash.message = "You have no access to this study"
     
    111111                        return
    112112
    113                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     113                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    114114    }
    115115
     
    124124                        return
    125125
    126                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     126                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    127127    }
    128128
     
    137137                        return
    138138
    139                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     139                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    140140    }
    141141
     
    150150                        return
    151151
    152                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     152                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    153153    }
    154154
     
    163163                        return
    164164
    165                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     165                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    166166    }
    167167
     
    176176                        return
    177177
    178                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     178                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    179179    }
    180180
     
    189189                        return
    190190
    191                 [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: AuthenticationService.getLoggedInUser() ]
     191                [studyList: studyList, studyInstanceTotal: Study.count(), multipleStudies: ( studyList.size() > 1 ), loggedInUser: authenticationService.getLoggedInUser() ]
    192192    }
    193193
     
    236236                // Check whether the user may see these studies
    237237                def studiesAllowed = []
    238         def loggedInUser = AuthenticationService.getLoggedInUser()
     238        def loggedInUser = authenticationService.getLoggedInUser()
    239239
    240240                studyList.each { studyInstance ->
     
    262262        else {
    263263            // Check whether the user may see this study
    264             def loggedInUser = AuthenticationService.getLoggedInUser()
     264            def loggedInUser = authenticationService.getLoggedInUser()
    265265            if( !studyInstance.canRead(loggedInUser) ) {
    266266                flash.message = "You have no access to this study"
Note: See TracChangeset for help on using the changeset viewer.