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
@ApplicationPath("api") | |
public class ApplicationConfig extends ResourceConfig { | |
public ApplicationConfig() { | |
packages("com.bpd.rest"); | |
property(ServerProperties.RESPONSE_SET_STATUS_OVER_SEND_ERROR, "true"); | |
register(InvalidDepartmentExceptionMapper.class); | |
} | |
} |
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 InvalidDepartmentExceptionMapper | |
implements ExceptionMapper<ConstraintViolationException> { | |
@SuppressWarnings("rawtypes") | |
@Override | |
public Response toResponse(ConstraintViolationException exception) { | |
JsonObjectBuilder json = Json.createBuilderFactory(null).createObjectBuilder(); | |
json.add("status", Response.Status.BAD_REQUEST.getStatusCode()); | |
int counter = 1; | |
for (ConstraintViolation violation : exception.getConstraintViolations()) { |
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
// Copyright (C) Daniel Tian 2010 | |
// https://github.com/danieltian | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace StringGeneration | |
{ | |
class Program |
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
jar { | |
from (configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }) { | |
exclude "META-INF/*.SF" | |
exclude "META-INF/*.DSA" | |
exclude "META-INF/*.RSA" | |
} | |
} |
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
# Apache Tomcat 8 | |
sudo apt-get install tomcat8 | |
# Oracle Java JRE 8 | |
echo "deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main" >> /etc/apt/sources.list | |
echo "deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu precise main" >> /etc/apt/sources.list | |
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys EEA14886 |
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 project(':library') |
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
include ':library' | |
project(':library').projectDir = new File("path/to/library") |
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
@POST | |
@Consumes(MediaType.APPLICATION_JSON) | |
public void createDepartment(@ValidDepartment Department dept) { | |
EntityTransaction trans = entityManager.getTransaction(); | |
trans.begin(); | |
entityManager.persist(dept); | |
trans.commit(); | |
} |
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
package com.bpd.rest; | |
import javax.ws.rs.ApplicationPath; | |
import org.glassfish.jersey.server.ResourceConfig; | |
@ApplicationPath("api") | |
public class ApplicationConfig extends ResourceConfig { | |
public ApplicationConfig() { | |
packages("com.bpd.rest"); |
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 'javax.ws.rs:javax.ws.rs-api:2.0.1' | |
compile 'org.glassfish.jersey.core:jersey-server:2.22.1' | |
compile 'org.glassfish.jersey.core:jersey-common:2.22.1' | |
compile 'org.glassfish.jersey.containers:jersey-container-servlet:2.22.1' | |
compile 'org.glassfish.jersey.media:jersey-media-moxy:2.22.1' | |
compile 'org.glassfish.jersey.ext:jersey-bean-validation:2.22.1' | |
compile 'javax.validation:validation-api:1.1.0.Final' |