Ignore:
Timestamp:
Feb 28, 2011, 5:44:13 PM (11 years ago)
Author:
robert@…
Message:
  • Solved locking problems with module communication
  • Fixed a null pointer bug in assayController
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/grails-app/services/dbnp/modules/ModuleCommunicationService.groovy

    r1517 r1576  
    1616
    1717import dbnp.studycapturing.*
     18import dbnp.authentication.*
    1819import grails.converters.*
    1920import javax.servlet.http.HttpServletResponse
    2021import org.codehaus.groovy.grails.commons.ConfigurationHolder
     22import org.hibernate.*;
    2123
    2224class ModuleCommunicationService implements Serializable {
    23         boolean transactional = false
     25        static transactional = false
    2426        def authenticationService
    2527        def moduleNotificationService
    26 
     28        SessionFactory sessionFactory
     29       
    2730        /**
    2831         * Cache containing the contents of different URLs. These urls are
     
    98101
    99102                // put the session token to work
    100                 authenticationService.logInRemotely( consumer, sessionToken, authenticationService.getLoggedInUser() )
    101 
     103                // This saving is done in a separate session, since that seems to be the only way to have grails/hibernate
     104                // really save the object to the database. This is needed, since the module will start a new http request to GSCF
     105                // and in that request the database object must exist.
     106                // Using session.flush(), save(flush:true) or transaction.commit() don't do the trick. If you know
     107                // a better way to perform this trick, feel free to change it :)
     108                def hibernateSession = sessionFactory.openSession( sessionFactory.getCurrentSession().connection() );
     109                def transaction = hibernateSession.beginTransaction();
     110               
     111                if( transaction ) {
     112                        authenticationService.logInRemotely( consumer, sessionToken, authenticationService.getLoggedInUser() )
     113                        transaction.commit();
     114                }
     115                hibernateSession.flush();
     116               
    102117                // Append the sessionToken to the URL
    103118                def url = restUrl
     
    109124                        url += '?sessionToken=' + sessionToken
    110125                }
    111 
     126               
    112127                // Perform a call to the url
    113128                def restResponse
     
    122137                } finally {
    123138                        // Dispose of the ephemeral session token
    124                         authenticationService.logOffRemotely(consumer, sessionToken)
     139                        //authenticationService.logOffRemotely(consumer, sessionToken)
    125140                }
    126141
Note: See TracChangeset for help on using the changeset viewer.