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