Commit 1fa86252 authored by Greg Messner's avatar Greg Messner
Browse files

Mods for new Jackson version.

parent 7ec6815c
......@@ -10,6 +10,40 @@ import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.Version;
import com.fasterxml.jackson.databind.DeserializationConfig;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.PropertyNamingStrategy;
import com.fasterxml.jackson.databind.SerializationConfig;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.annotation.JsonSerialize.Inclusion;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonGenerationException;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.databind.SerializerProvider;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
/*
import org.codehaus.jackson.JsonGenerationException;
import org.codehaus.jackson.JsonGenerator;
import org.codehaus.jackson.JsonParseException;
......@@ -26,6 +60,7 @@ import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.SerializerProvider;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import org.codehaus.jackson.map.module.SimpleModule;
*/
/**
* Jackson JSON Configuration and utility class.
......@@ -39,14 +74,16 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol
public JacksonJson() {
objectMapper = new ObjectMapper();
objectMapper.setSerializationInclusion(Inclusion.NON_NULL);
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES);
objectMapper.configure(SerializationConfig.Feature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.configure(SerializationConfig.Feature.WRITE_ENUMS_USING_TO_STRING, Boolean.TRUE);
objectMapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationConfig.Feature.READ_ENUMS_USING_TO_STRING, Boolean.TRUE);
SimpleModule module = new SimpleModule("GitLabApiJsonModule", new Version(1, 0, 0, null));
objectMapper.setSerializationInclusion(Include.NON_NULL);
objectMapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE);
objectMapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
objectMapper.configure(SerializationFeature.WRITE_ENUMS_USING_TO_STRING, true);
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
objectMapper.configure(DeserializationFeature.READ_ENUMS_USING_TO_STRING, true);
SimpleModule module = new SimpleModule("GitLabApiJsonModule");
module.addSerializer(Date.class, new JsonDateSerializer());
objectMapper.registerModule(module);
}
......@@ -132,7 +169,7 @@ public class JacksonJson extends JacksonJaxbJsonProvider implements ContextResol
public static class JsonDateSerializer extends JsonSerializer<Date> {
@Override
public void serialize(java.util.Date date, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException {
public void serialize(Date date, JsonGenerator gen, SerializerProvider provider) throws IOException, JsonProcessingException {
String iso8601String = ISO8601.toString(date);
gen.writeString(iso8601String);
}
......
......@@ -5,92 +5,93 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonProperty;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Diff {
@JsonSerialize(include=Inclusion.ALWAYS)
@JsonProperty("a_mode")
private String a_mode;
@JsonSerialize(include=Inclusion.ALWAYS)
@JsonProperty("b_mode")
private String b_mode;
private Boolean deletedFile;
private String diff;
private Boolean newFile;
private String newPath;
private String oldPath;
private Boolean renamedFile;
@JsonProperty("a_mode")
public String getAMode () {
return this.a_mode;
}
public void setAMode (String aMode) {
this.a_mode = aMode;
}
@JsonProperty("b_mode")
public String getBMode () {
return this.b_mode;
}
public void setBMode (String bMode) {
this.b_mode = bMode;
}
public Boolean getDeletedFile () {
return this.deletedFile;
}
public void setDeletedFile (Boolean deletedFile) {
this.deletedFile = deletedFile;
}
public String getDiff () {
return this.diff;
}
public void setDiff (String diff) {
this.diff = diff;
}
public Boolean getNewFile () {
return this.newFile;
}
public void setNewFile (Boolean newFile) {
this.newFile = newFile;
}
public String getNewPath () {
return this.newPath;
}
public void setNewPath (String newPath) {
this.newPath = newPath;
}
public String getOldPath () {
return this.oldPath;
}
public void setOldPath (String oldPath) {
this.oldPath = oldPath;
}
public Boolean getRenamedFile () {
return this.renamedFile;
}
public void setRenamedFile (Boolean renamedFile) {
this.renamedFile = renamedFile;
}
@JsonInclude(JsonInclude.Include.ALWAYS)
@JsonProperty("a_mode")
private String a_mode;
@JsonInclude(JsonInclude.Include.ALWAYS)
@JsonProperty("b_mode")
private String b_mode;
private Boolean deletedFile;
private String diff;
private Boolean newFile;
private String newPath;
private String oldPath;
private Boolean renamedFile;
@JsonInclude(JsonInclude.Include.ALWAYS)
@JsonProperty("a_mode")
public String getAMode() {
return this.a_mode;
}
public void setAMode(String aMode) {
this.a_mode = aMode;
}
@JsonInclude(JsonInclude.Include.ALWAYS)
@JsonProperty("b_mode")
public String getBMode() {
return this.b_mode;
}
public void setBMode(String bMode) {
this.b_mode = bMode;
}
public Boolean getDeletedFile() {
return this.deletedFile;
}
public void setDeletedFile(Boolean deletedFile) {
this.deletedFile = deletedFile;
}
public String getDiff() {
return this.diff;
}
public void setDiff(String diff) {
this.diff = diff;
}
public Boolean getNewFile() {
return this.newFile;
}
public void setNewFile(Boolean newFile) {
this.newFile = newFile;
}
public String getNewPath() {
return this.newPath;
}
public void setNewPath(String newPath) {
this.newPath = newPath;
}
public String getOldPath() {
return this.oldPath;
}
public void setOldPath(String oldPath) {
this.oldPath = oldPath;
}
public Boolean getRenamedFile() {
return this.renamedFile;
}
public void setRenamedFile(Boolean renamedFile) {
this.renamedFile = renamedFile;
}
}
......@@ -7,7 +7,7 @@ import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.messners.gitlab.api.models.Commit;
import com.messners.gitlab.api.models.Repository;
......@@ -15,110 +15,110 @@ import com.messners.gitlab.api.models.Repository;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class PushEvent {
private String after;
private String before;
private List<Commit> commits;
private Integer projectId;
private String ref;
private Repository repository;
private Integer totalCommitsCount;
private Integer userId;
private String userName;
public String getAfter () {
return this.after;
}
public void setAfter (String after) {
this.after = after;
}
public String getBefore () {
return this.before;
}
public void setBefore (String before) {
this.before = before;
}
public List<Commit> getCommits () {
return this.commits;
}
public void setCommits (List<Commit> commits) {
this.commits = commits;
}
public Integer getProjectId () {
return this.projectId;
}
public void setProjectId (Integer projectId) {
this.projectId = projectId;
}
public String getRef () {
return this.ref;
}
public void setRef (String ref) {
this.ref = ref;
}
public Repository getRepository () {
return this.repository;
}
public void setRepository (Repository repository) {
this.repository = repository;
}
public Integer getTotalCommitsCount () {
return this.totalCommitsCount;
}
public void setTotalCommitsCount (Integer totalCommitsCount) {
this.totalCommitsCount = totalCommitsCount;
}
public Integer getUserId () {
return this.userId;
}
public void setUserId (Integer userId) {
this.userId = userId;
}
public String getUserName () {
return this.userName;
}
public void setUserName (String userName) {
this.userName = userName;
}
/**
* Gets the branch name from the ref. Will return null if the ref does not start with "refs/heads/".
*
* @return the branch name from the ref
*/
@JsonIgnore
public String getBranch () {
String ref = getRef();
if (ref == null || ref.trim().length() == 0) {
return (null);
}
ref = ref.trim();
int refsHeadsIndex = ref.indexOf(REFS_HEADS);
if (refsHeadsIndex != 0) {
return (null);
}
return (ref.substring(REFS_HEADS.length()));
}
private static final String REFS_HEADS = "refs/heads/";
private String after;
private String before;
private List<Commit> commits;
private Integer projectId;
private String ref;
private Repository repository;
private Integer totalCommitsCount;
private Integer userId;
private String userName;
public String getAfter() {
return this.after;
}
public void setAfter(String after) {
this.after = after;
}
public String getBefore() {
return this.before;
}
public void setBefore(String before) {
this.before = before;
}
public List<Commit> getCommits() {
return this.commits;
}
public void setCommits(List<Commit> commits) {
this.commits = commits;
}
public Integer getProjectId() {
return this.projectId;
}
public void setProjectId(Integer projectId) {
this.projectId = projectId;
}
public String getRef() {
return this.ref;
}
public void setRef(String ref) {
this.ref = ref;
}
public Repository getRepository() {
return this.repository;
}
public void setRepository(Repository repository) {
this.repository = repository;
}
public Integer getTotalCommitsCount() {
return this.totalCommitsCount;
}
public void setTotalCommitsCount(Integer totalCommitsCount) {
this.totalCommitsCount = totalCommitsCount;
}
public Integer getUserId() {
return this.userId;
}
public void setUserId(Integer userId) {
this.userId = userId;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
/**
* Gets the branch name from the ref. Will return null if the ref does not start with "refs/heads/".
*
* @return the branch name from the ref
*/
@JsonIgnore
public String getBranch() {
String ref = getRef();
if (ref == null || ref.trim().length() == 0) {
return (null);
}
ref = ref.trim();
int refsHeadsIndex = ref.indexOf(REFS_HEADS);
if (refsHeadsIndex != 0) {
return (null);
}
return (ref.substring(REFS_HEADS.length()));
}
private static final String REFS_HEADS = "refs/heads/";
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment