Aman Aggarwal

AWS, Big Data

Amazon Awards IntelliGrape For Customer Obsession

Intelligrape (Now TO THE NEW Digital ) is an Advanced Consulting Partner with Amazon and specialises in large-scale implementations and managed services for web based applications. We have been working with Amazon team in India and outside on multiple initiatives since more than 2 years now. Amazon conducted its series of APN (AWS...


AWS, DevOps

Top 10 Benefits of Using AWS

Very often people ask for compelling reasons on why they should consider AWS for their infrastructure needs. Though there are hundreds and thousands of customers leverage AWS in more than 190 countries, with hundreds of case-studies including companies like Netflix, Pinterest, Dow Jones, SAP,  Coursera, NASA/JPL, Reddit, Vodafone,...


DevOps, Grails

Server-to-server POST request

Server to server POST request can be made using Apache Commons HttpClient library. You need to include http-client jar file in project/lib folder and execute following lines of code: HttpClient client = new HttpClient() String url = "http://localhost:8080/test/person/delete/1" PostMethod method = new PostMethod(url) int...



Grails annotation – Validateable

We can easily validate domain classes and command objects using static constraints. But how about validating DTOs or any groovy class in src/groovy folder. The answer is YES, they can be validated too. Follow two simple steps: 1. Add annotation '@Validateable' above the class. 2. Declare the package to be validated in...



Searchable plugin – Lucene search on numeric values

While using searchable plugin for the first time, I wasn't aware that lucene implements only lexicographic comparisons for searching on indexed values (even on numeric fields). Before I learned this, I kept on wondering why a Person of age 6 always appeared in search results when I look for People more than 20 years of age. The solution...



Grails criteria query example for unidirectional one-to-many relationships

Following is an example of unidirectional one-to-many relationship: class Employee { String name static hasMany = [roles: Role] } class Role { String name } How can we find all the employees with a particular role - "Grails Developer"? Role role = Role.findByName("Grails Developer") One way of doing...



Injecting Method to trim string length on gsp pages

Restricting the length of a string on gsps is a common scenario in most of our projects. Groovy's metaprogramming magic made it too simple for me. I added the following lines of code to Bootstrap.groovy: Object.metaClass.trimLength = {Integer stringLength -> String trimString = delegate?.toString() String...



Groovy Maps: Reverse Sort

I want to quickly share how you can sort a Map by its key/value/field of valueObject; in either ascending or descending order using Groovy I created a Map<String, Person> as follows: class Person { String name Date dateOfBirth static constraints = { } } Map people = [:] [*(11..20), *(1..10)].each { ...



Groovy Finding Past/Future Dates

Often I found it painful working on dates when I had to find a past/future date based on weeks, months or years. Groovy class org.codehaus.groovy.runtime.TimeCategory has very helpful & intutive syntax for working on dates. I am sure I need not to explain what each of the following statements will do: Date date = new Date() ...



Groovy Collection method: groupBy()

public Map groupBy(Closure closure) Going through Groovy Collection, I found this powerful method which takes a Closure as parameter & based on the closure, it returns a map in which all unique values returned by closure act as keys. Lets take an example: If you want to group integers between 1 to 100 based on the integer...



Restricting all URLs to end with .html in a Grails Application

While going through the grails-users mailing list, I found a question about restricting all URLs to end with '.html' & returning Error 404 for the default mappings. After spending some time, I was able to build a sample CRUD application restricting URLs to end with .html. I did the following steps for the same: 1. Create a new...