grails3

Uploading a large file (>1GB) to grails3

吃可爱长大的小学妹 提交于 2021-02-10 19:42:29
问题 Uploading a large file (>1GB) to a grails, I only need to access it via stream, no need to save the entire file to disk or RAM. However how can I access the upload stream? I tried with an Interceptor: class UploadLargeFileInterceptor { int order = HIGHEST_PRECEDENCE UploadLargeFileInterceptor() { match(controller:"apiv2", action:"uploadLarge") } boolean before() { log.error('before') log.error(request.getInputStream().text.length() as String) true } boolean after() { log.error('after') true }

Uploading a large file (>1GB) to grails3

心不动则不痛 提交于 2021-02-10 19:41:31
问题 Uploading a large file (>1GB) to a grails, I only need to access it via stream, no need to save the entire file to disk or RAM. However how can I access the upload stream? I tried with an Interceptor: class UploadLargeFileInterceptor { int order = HIGHEST_PRECEDENCE UploadLargeFileInterceptor() { match(controller:"apiv2", action:"uploadLarge") } boolean before() { log.error('before') log.error(request.getInputStream().text.length() as String) true } boolean after() { log.error('after') true }

Second level expand in gson

纵饮孤独 提交于 2020-01-15 09:23:05
问题 I'm using Grails 3.2.2 and org.grails.plugins:views-gradle:1.1.1 and in my section gson I'd like to expand all users and their carnets. I tried: import com.example.sections.Section model { Section section } json g.render(section, [excludes:['archived', 'deleted'], expand:['clients', 'clients.carnets']]){ } but it only expands clients in result json. how can I do that? btw carnets in Client domain class are transient. Is it possible to add transient variables to result gson? If so - how? 来源:

springSecurityService.principal returns Null when deployed as a WAR in tomcat 8.5

故事扮演 提交于 2019-12-23 09:19:51
问题 Preamble I'm designing an API gateway for a Grails microservice federation. This issue seems related to a bunch of issues already filed in this repository but nothing provides a solution. Versions and Configurations Grails: 3.2.2 Tomcat: 8.5 Plugin versions: compile 'org.grails.plugins:spring-security-core:3.1.2' compile "org.grails.plugins:spring-security-rest:2.0.0.M2" I'm using spring security rest plugin for only token authentication. I'm doing the authorization part myself by returning

delete is not working even in service?

做~自己de王妃 提交于 2019-12-13 03:12:47
问题 I have book domain package bookfinal class Book { String name static constraints = { } } Book Controller is as follows package bookfinal class BookController { def bookService def destroy(Long id){ bookService.destroy(id) redirect(action:'index') } def index() { [books: Book.findAll()] } def create(){ } def save(){ def book = new Book(params) book.save() redirect(action:'show', id:book.id) } def edit(Long id){ [book: Book.get(id)] } def update(Long id){ bookService.update(id, params) redirect

In JSON views, how do I flatten an object out as a single string?

放肆的年华 提交于 2019-12-12 04:31:39
问题 In my grails 3 app (I'm using grails 3.2.4), I have an object type which I want to be serialized as a string, for any Domain object that uses it: class MyDomain1 { CustomId id } class MyDomain2 { CustomId id } I want to create a view that serializes CustomId as a string, rather than an object: //instance of MyDomain1, in JSON format: { "id": "123" } How can I do this without customizing the view for every object that uses CustomId? 回答1: Json views 1.2 supports a converter API that can do what

Rendering few models in gson

吃可爱长大的小学妹 提交于 2019-12-12 03:54:01
问题 Is it possible to send few objects into gson rendering view? I tried to use in controller : respond trainings, [status: OK, view:"trainingsByClients", model: [myVariable: "test", anotherVariable: 123]] and in gson view : model { Iterable<Training> trainingList String myVariable } json { myVariable myVariable trainings tmpl.training(trainingList ?: []) } and it responds with: { "myVariable": null, "trainings": [ { "id": 3, "name": "test t", "numberOfAbsentClients": 0, "startDate": "2016-11

In Grails 3.2.4, controller that has an .async.task call in it sets request.asyncStarted() to true but doesn't render response

假装没事ソ 提交于 2019-12-12 02:18:57
问题 First off, this wasn't an issue in Grails 2.5.4. I'm making an angular AJAX call to my Grails controller and the Grails controller is never responding. The front end call looks something like this.. $http({ method: "GET", url: actionLink, params: {} }).then(function successCallback(response) { console.log("Yaaay, I got back with some sort of response"); }, function errorCallback(response) { console.log("ERROR PULLING DETAIL") }); I've confirmed that AJAX calls to other controllers that don't

Grails 3.2.8 dependency injection in domain classes

◇◆丶佛笑我妖孽 提交于 2019-12-11 07:12:16
问题 Grails 3.2.8 doesn't seem to have dependency injection working for domain classes by default. When I create a new app and add Spring Security Core 3.1.1 with the following println: protected void encodePassword() { println "springSecurityService == null? ${(springSecurityService==null).toString()}" password = springSecurityService?.passwordEncoder ? springSecurityService.encodePassword(password) : password } I get: springSecurityService == null? true If I try creating and injecting a service

gradle war vs gradle assemble (Grails 3.2.6 and Sec plugin 3.1.2)

放肆的年华 提交于 2019-12-02 11:17:18
问题 I am having really hard time figuring this one out. I have an app which works fine in intellij and as a standalone war (created with gradlew assemble ). But when I am trying to deploy this war (created with gradlew assemble but with tomcat starter set as provided in build.gradle file) in the tomcat 8.5, I am getting this exception. But if I generate a war using gradlew war then I do not see this exception and tomcat is deployed alright. But in that case my app is giving all kind of crap