Changeset 1357
- Timestamp:
- Jan 10, 2011, 4:44:44 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/grails-app/controllers/RestController.groovy
r1328 r1357 175 175 items[name] = value 176 176 } 177 178 // Add study version number 179 items['version'] = study.version; 180 177 181 returnStudies.push items 178 182 } … … 183 187 } 184 188 189 /** 190 * REST resource for data modules. 191 * Consumer and token should be supplied via URL parameters. 192 * Provides the version number of the specified study 193 * 194 * @param studyToken optional parameter. If no studyToken is given, a 400 error is given 195 * @param consumer consumer name of the calling module 196 * @param token token for the authenticated user (e.g. session_id) 197 * @return JSON object list containing 'studyToken', and 'version' 198 * 199 * A 404 error might occur if the study doesn't exist, and a 401 error if the user is not 200 * authorized to access this study. 201 * 202 * Example. REST call with one studyToken. 203 * 204 * Call: http://localhost:8080/gscf/rest/getStudyVersion?studyToken=PPSH 205 * 206 * Result: {"studyToken":"PPSH","version":31} 207 */ 208 def getStudyVersion = { 209 210 def versionInfo = [:]; 211 def study 212 213 if( !params.studyToken || !(params.studyToken instanceof String)) { 214 response.sendError(400) 215 return false 216 } else { 217 study = Study.findByCode( params.studyToken ) 218 if( study ) { 219 if( !study.canRead(AuthenticationService.getRemotelyLoggedInUser( params.consumer, params.token )) ) { 220 response.sendError(401) 221 return false 222 } 223 } else { 224 response.sendError(404) 225 return false 226 } 227 } 228 229 versionInfo[ 'studyToken' ] = params.studyToken; 230 versionInfo[ 'version' ] = study.version; 231 232 render versionInfo as JSON 233 } 185 234 186 235 /** -
trunk/grails-app/domain/dbnp/studycapturing/AssayModule.groovy
r1027 r1357 16 16 */ 17 17 String url 18 19 /** Determines whether this module will be notified of changes in studies. This can be used 20 * to determine when synchronization should take place in a module. The URL called is 21 * 22 * [url]/rest/notifyStudyChange?studyToken=abc 23 * 24 * @see synchronizationService 25 */ 26 boolean notify = false; 18 27 19 28 static constraints = { -
trunk/grails-app/domain/dbnp/studycapturing/Study.groovy
r1353 r1357 13 13 class Study extends TemplateEntity { 14 14 static searchable = true 15 16 def synchronizationService 15 17 16 18 SecUser owner // The owner of the study. A new study is automatically owned by its creator. … … 499 501 } 500 502 } 503 504 // Send messages to modules about changes in this study 505 def beforeInsert = { 506 synchronizationService.invalidateStudy( this ); 507 } 508 def beforeUpdate = { 509 synchronizationService.invalidateStudy( this ); 510 } 511 def beforeDelete = { 512 synchronizationService.invalidateStudy( this ); 513 } 501 514 }
Note: See TracChangeset
for help on using the changeset viewer.