This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum Category { | |
//IAB1 : Arts & Entertainment | |
IAB1_1("IAB1-1","Books & Literature"), | |
IAB1_2("IAB1-2","Celebrity Fan/Gossip"), | |
IAB1_3("IAB1-3","Fine Art"), | |
IAB1_4("IAB1-4","Humour"), | |
IAB1_5("IAB1-5","Movies"), | |
IAB1_6("IAB1-6","Music"), | |
IAB1_7("IAB1-7","Television"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Bean(name="testRestTemplate") | |
public RestTemplate getPubPostbackRestTemplate(){ | |
final int readTimeOut = 5000; | |
final int connectTimeout = 5000; | |
final HttpComponentsClientHttpRequestFactory clientHttpRequestFactory = | |
new HttpComponentsClientHttpRequestFactory(); | |
clientHttpRequestFactory.setConnectTimeout(connectTimeout); | |
clientHttpRequestFactory.setReadTimeout(readTimeOut); | |
return new RestTemplate(clientHttpRequestFactory); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile group: 'org.apache.commons', name: 'commons-lang3', version: '3.4' | |
compile group: 'org.spockframework', name: 'spock-core', version: '1.0-groovy-2.4' | |
compile group: 'com.google.guava', name: 'guava', version: '19.0' | |
compile group: 'org.spockframework', name: 'spock-spring', version: '1.0-groovy-2.4' | |
compile group: 'com.fasterxml.jackson.core', name: 'jackson-core', version: '2.8.1' | |
compile group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: '2.8.1' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################## Profiles ################ | |
spring.profiles.active=dev | |
################### Logging ################ | |
logging.level.org.springframework.web=debug | |
################### Security ################ | |
security.basic.enabled=false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################### Logging ################ | |
logging.level.org.springframework.web=debug | |
################### Security ################ | |
security.basic.enabled=false | |
################### DataSource ################ | |
spring.datasource.url=jdbc:h2:mem:devDb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class HttpServletRequestUtils { | |
public static String getIp(final HttpServletRequest request) { | |
PreConditions.checkNull(request, "request cannot be null"); | |
String ip = request.getHeader("X-FORWARDED-FOR"); | |
if (ip==null || ip.trim().length()==0)) { | |
ip = request.getRemoteAddr(); | |
} | |
return ip; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Directories # | |
/build/ | |
bin/ | |
repos/ | |
/repos/ | |
doc/ | |
/doc/ | |
.gradle/ | |
/bin/ | |
target/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class PreCondition { | |
public static <T> void checkNull(final T t, final String errorMsg){ | |
if(t==null){ | |
throw new IllegalArgumentException(errorMsg); | |
} | |
} | |
public static void checkEmptyString(final String str, final String errorMsg){ | |
if(!Strings.hasText(str)){ | |
throw new IllegalArgumentException(errorMsg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.IOException; | |
import com.fasterxml.jackson.core.JsonParseException; | |
import com.fasterxml.jackson.databind.JsonMappingException; | |
import com.fasterxml.jackson.databind.ObjectMapper; | |
public class JsonUtils { | |
private static final ObjectMapper objMapper = new ObjectMapper(); | |
public static <T> T toObject(final String json , final Class<T> clazz) throws Exception{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class EnumUtils { | |
public static <T extends Enum<T>> T getEnumFromString(final Class<T> enumClass,final String value) { | |
if(enumClass == null){ | |
throw new IllegalArgumentException("enumClass cannot be null"); | |
} | |
for (final Enum<?> enumValue : enumClass.getEnumConstants()) { | |
if (enumValue.toString().equalsIgnoreCase(value)) { |
NewerOlder