Commit ba0a4ef7 authored by unknown's avatar unknown
Browse files

Initial check-in.

No related merge requests found
Showing with 1385 additions and 0 deletions
+1385 -0
LICENSE 0 → 100644
The MIT License (MIT)
Copyright (c) 2014 Greg Messner <greg@messners.com>
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
gitlab-api
==========
This project provides a full featured Java API for working with GitLab repositories via the standard GitLab REST API.
pom.xml 0 → 100644
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.messners</groupId>
<artifactId>gitlab-api</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>gitlab-api</name>
<licenses>
<license>
<name>The MIT License (MIT)</name>
<url>http://opensource.org/licenses/MIT</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>gmessner</id>
<name>Greg Messner</name>
<email>greg@messners.com</email>
</developer>
</developers>
<properties>
<jersey.version>1.18</jersey.version>
<jackson.version>1.9.13</jackson.version>
<junit.version>4.9</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.2.2</version>
<configuration>
<!-- Whether to allow timestamped SNAPSHOT dependencies. 'true' means
the release plugin will continue to operate even when a project has dependencies
on SNAPSHOTs (which is normally not the case) -->
<allowTimestampedSnapshots>true</allowTimestampedSnapshots>
<localCheckout>true</localCheckout>
<checkModificationExcludes>
<checkModificationExclude>build-number.txt</checkModificationExclude>
</checkModificationExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>2.1.2</version>
<executions>
<execution>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<version>${jackson.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-client</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.9</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
package com.messners.gitlab.api;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
@XmlAccessorType (XmlAccessType.FIELD)
public class AbstractUser {
private Date createdAt;
private String email;
private Integer id;
private String name;
private String state;
private String username;
public Date getCreatedAt () {
return this.createdAt;
}
public void setCreatedAt (Date createdAt) {
this.createdAt = createdAt;
}
public String getEmail () {
return this.email;
}
public void setEmail (String email) {
this.email = email;
}
public Integer getId () {
return this.id;
}
public void setId (Integer id) {
this.id = id;
}
public String getName () {
return this.name;
}
public void setName (String name) {
this.name = name;
}
public String getState () {
return this.state;
}
public void setState (String state) {
this.state = state;
}
public String getUsername () {
return this.username;
}
public void setUsername (String username) {
this.username = username;
}
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Assignee extends AbstractUser {
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Author extends AbstractUser {
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType (XmlAccessType.FIELD)
public class Branch {
private Commit commit;
private String name;
private boolean isProtected;
public Commit getCommit () {
return this.commit;
}
public void setCommit (Commit commit) {
this.commit = commit;
}
public String getName () {
return this.name;
}
public void setName (String name) {
this.name = name;
}
public boolean getProtected () {
return this.isProtected;
}
public void setProtected (boolean isProtected) {
this.isProtected = isProtected;
}
}
package com.messners.gitlab.api;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Commit {
private Author author;
private Date authoredDate;
private Date committedDate;
private Committer committer;
private String id;
private String message;
@XmlElement(name = "id", type = String.class)
@XmlElementWrapper(name = "parents")
private List<String> parentIds;
private String shortId;
private Date timestamp;
private String title;
private String tree;
private String url;
public Author getAuthor () {
return this.author;
}
public void setAuthor (Author author) {
this.author = author;
}
public Date getAuthored_date () {
return this.authoredDate;
}
public void setAuthored_date (Date authoredDate) {
this.authoredDate = authoredDate;
}
public Date getCommitted_date () {
return this.committedDate;
}
public void setCommitted_date (Date committedDate) {
this.committedDate = committedDate;
}
public Committer getCommitter () {
return this.committer;
}
public void setCommitter (Committer committer) {
this.committer = committer;
}
public String getId () {
return this.id;
}
public void setId (String id) {
this.id = id;
}
public String getShortId () {
return this.shortId;
}
public String getMessage () {
return this.message;
}
public void setMessage (String message) {
this.message = message;
}
public List<String> getParents () {
return this.parentIds;
}
public void setParents (List<String> parentIds) {
this.parentIds = parentIds;
}
public void setShort_id (String short_id) {
this.shortId = short_id;
}
public Date getTimestamp () {
return this.timestamp;
}
public void setTimestamp (Date timestamp) {
this.timestamp = timestamp;
}
public String getTitle () {
return this.title;
}
public void setTitle (String title) {
this.title = title;
}
public String getTree () {
return this.tree;
}
public void setTree (String tree) {
this.tree = tree;
}
public String getUrl () {
return this.url;
}
public void setUrl (String url) {
this.url = url;
}
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
public class Committer extends AbstractUser {
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
import org.codehaus.jackson.annotate.JsonProperty;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Diff {
@JsonProperty("a_mode")
private String aMode;
@JsonProperty("b_mode")
private String bMode;
private boolean deletedFile;
private String diff;
private boolean newFile;
private String newPath;
private String oldPath;
private boolean renamedFile;
public String getAMode () {
return this.aMode;
}
public void setAMode (String aMode) {
this.aMode = aMode;
}
public String getBMode () {
return this.bMode;
}
public void setBMode (String bMode) {
this.bMode = 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;
}
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class ErrorMessage {
private String message;
public String getMessage () {
return this.message;
}
public void setMessage (String message) {
this.message = message;
}
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Event {
private String actionName;
private Integer authorId;
private EventData data;
private Integer projectId;
private String targetId;
private String targetTitle;
private String targetType;
private String title;
public String getActionName () {
return this.actionName;
}
public void setActionName (String actionName) {
this.actionName = actionName;
}
public Integer getAuthorId () {
return this.authorId;
}
public void setAuthorId (Integer authorId) {
this.authorId = authorId;
}
public EventData getData () {
return this.data;
}
public void setData (EventData data) {
this.data = data;
}
public Integer getProjectId () {
return this.projectId;
}
public void setProjectId (Integer projectId) {
this.projectId = projectId;
}
public String getTargetId () {
return this.targetId;
}
public void setTargetId (String targetId) {
this.targetId = targetId;
}
public String getTargetTitle () {
return this.targetTitle;
}
public void setTargetTitle (String targetTitle) {
this.targetTitle = targetTitle;
}
public String getTargetType () {
return this.targetType;
}
public void setTargetType (String targetType) {
this.targetType = targetType;
}
public String getTitle () {
return this.title;
}
public void setTitle (String title) {
this.title = title;
}
}
package com.messners.gitlab.api;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType (XmlAccessType.FIELD)
public class EventData {
private String after;
private String before;
private List<Commit> commits;
private String ref;
private Repository repository;
private Integer total_commits_count;
private Integer user_id;
private String user_name;
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 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 getTotal_commits_count () {
return this.total_commits_count;
}
public void setTotal_commits_count (Integer total_commits_count) {
this.total_commits_count = total_commits_count;
}
public Integer getUser_id () {
return this.user_id;
}
public void setUser_id (Integer user_id) {
this.user_id = user_id;
}
public String getUser_name () {
return this.user_name;
}
public void setUser_name (String user_name) {
this.user_name = user_name;
}
}
package com.messners.gitlab.api;
import java.io.IOException;
import java.util.List;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.representation.Form;
/**
* This class specifies methods to interact with a GitLab server utilizing the standard GitLab API.
*
* @author Greg Messner <greg@messners.com>
*/
public class GitLabApi {
private GitLabApiClient apiClient;
/**
* Contructs a GitLabApi instance set up to interact with the GitLab server
* specified by hostUrl.
*
* @param hostUrl
* @param privateToken
*/
public GitLabApi (String hostUrl, String privateToken) {
apiClient = new GitLabApiClient(hostUrl, privateToken);
}
public List<Project> getProjects () throws IOException {
ClientResponse response = apiClient.get(null, "projects");
return (response.getEntity(new GenericType<List<Project>>() {}));
}
public List<Project> getAllProjects () throws IOException {
ClientResponse response = apiClient.get(null, "projects", "all");
return (response.getEntity(new GenericType<List<Project>>() {}));
}
public List<Project> getOwnedProjects () throws IOException {
ClientResponse response = apiClient.get(null, "projects", "owned");
return (response.getEntity(new GenericType<List<Project>>() {}));
}
public Project getProject (Integer projectId) throws IOException {
ClientResponse response = apiClient.get(null, "projects", projectId);
return (response.getEntity(Project.class));
}
public List<Event> getProjectEvents (Integer projectId) throws IOException {
ClientResponse response = apiClient.get(null, "project", projectId, "events");
return (response.getEntity(new GenericType<List<Event>>() {}));
}
/**
* Creates new project owned by the current user.
*
* @param project the Project instance with the configuration for the new project
* @return a Project instance with the newly created project info
* @throws IOException
*/
public Project createProject (Project project) throws IOException {
return (createProject(project, null));
}
/**
* Creates new project owned by the current user. The following properties on the Project instance
* are utilized in the creation of the project:
*
* name (required) - new project name
* description (optional) - short project description
* issuesEnabled (optional)
* wallEnabled (optional)
* mergeRequestsEnabled (optional)
* wikiEnabled (optional)
* snippetsEnabled (optional)
* isPublic (optional) - if true same as setting visibility_level = 20
* visibilityLevel (optional)
*
* @param project the Project instance with the configuration for the new project
* @param importUrl
* @return a Project instance with the newly created project info
* @throws IOException
*/
public Project createProject (Project project, String importUrl) throws IOException {
if (project == null) {
return (null);
}
String name = project.getName();
if (name == null || name.trim().length() == 0) {
return (null);
}
Form formData = new Form();
formData.add("name", name);
formData.add("description", project.getDescription());
formData.add("issues_enabled", project.getIssuesEnabled());
formData.add("wall_enabled", project.getWallEnabled());
formData.add("merge_requests_enabled", project.getMergeRequestsEnabled());
formData.add("wiki_enabled", project.getWikiEnabled());
formData.add("snippets_enabled", project.getSnippetsEnabled());
formData.add("public", project.getPublic());
formData.add("visibility_level", project.getVisibilityLevel());
formData.add("import_url", importUrl);
ClientResponse response = apiClient.post(formData, "projects");
if (response.getStatus() != ClientResponse.Status.CREATED.getStatusCode()) {
ErrorMessage errorMessage = response.getEntity(ErrorMessage.class);
throw new RuntimeException(errorMessage.getMessage());
}
return (response.getEntity(Project.class));
}
public boolean deleteProject (Project project) throws IOException {
return (deleteProject(project.getId()));
}
public boolean deleteProject (Integer projectId) throws IOException {
if (projectId == null) {
throw new RuntimeException("projectId cannot be null");
}
ClientResponse response = apiClient.delete(null, "projects", projectId);
return (response.getStatus() == ClientResponse.Status.OK.getStatusCode());
}
/**
* Creates a merge request and optionally assignes it.
*
* @param projectId the ID of a project, required
* @param sourceBranch the source branch, required
* @param targetBranch the target branch, required
* @param title the title for the merge request, required
* @param assigneeId the Assignee user ID, optional
* @return the created MergeRequest instance
* @throws IOException
*/
public MergeRequest createMergeRequest (Integer projectId, String sourceBranch, String targetBranch, String title, Integer assigneeId)
throws IOException {
/*
* Parameters:
* id (required) - The ID of a project
* source_branch (required) - The source branch
* target_branch (required) - The target branch
* assignee_id (optional) - Assignee user ID
* title (required) - Title of MR
*/
if (projectId == null) {
throw new RuntimeException("projectId cannot be null");
}
Form formData = new Form();
formData.add("id", projectId);
formData.add("source_branch", sourceBranch);
formData.add("target_branch", targetBranch);
formData.add("title", title);
if (assigneeId != null) {
formData.add("assignee_id", assigneeId);
}
ClientResponse response = apiClient.post(formData, "projects", projectId, "merge-requests");
if (response.getStatus() != ClientResponse.Status.CREATED.getStatusCode()) {
ErrorMessage errorMessage = response.getEntity(ErrorMessage.class);
throw new RuntimeException(errorMessage.getMessage());
}
return (response.getEntity(MergeRequest.class));
}
}
package com.messners.gitlab.api;
import java.io.IOException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.cert.CertificateException;
import java.security.cert.X509Certificate;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLContext;
import javax.net.ssl.SSLSession;
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap;
import com.sun.jersey.api.client.Client;
import com.sun.jersey.api.client.ClientHandlerException;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.UniformInterfaceException;
import com.sun.jersey.api.client.WebResource;
import com.sun.jersey.api.client.config.ClientConfig;
import com.sun.jersey.api.client.config.DefaultClientConfig;
import com.sun.jersey.api.json.JSONConfiguration;
import com.sun.jersey.api.representation.Form;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
/**
* This class utilizes the Jersey client package to communicate with a GitLab API endpoint.
*
* @author gmessner
*/
public class GitLabApiClient {
protected static final String PRIVATE_TOKEN_HEADER = "PRIVATE-TOKEN";
protected static final String API_NAMESPACE = "/api/v3";
private ClientConfig clientConfig;
private Client apiClient;
private String hostUrl;
private String privateToken;
public GitLabApiClient (String hostUrl, String privateToken) {
// Remove the trailing "/" from the hostUrl if present
this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl) + API_NAMESPACE;
this.privateToken = privateToken;
clientConfig = new DefaultClientConfig();
clientConfig.getClasses().add(JacksonJsonConfig.class);
clientConfig.getFeatures().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, Boolean.TRUE);
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
}
protected boolean ignoreCertificateErrors () {
// Create a TrustManager that trusts all certificates
TrustManager[ ] certs = new TrustManager[ ] {
new X509TrustManager() {
@Override
public X509Certificate[] getAcceptedIssuers() {
return null;
}
@Override
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
@Override
public void checkClientTrusted(X509Certificate[] chain, String authType)
throws CertificateException {
}
}
};
// Now set the default SSLSocketFactory to use the just created TrustManager
SSLContext sslContext = null;
try {
sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, certs, new SecureRandom());
HttpsURLConnection.setDefaultSSLSocketFactory(sslContext.getSocketFactory());
} catch (GeneralSecurityException ex) {
return (false);
}
// Set up a HostnameVerifier for Jersey to verify all hostnames
try {
clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, new HTTPSProperties(
new HostnameVerifier() {
@Override
public boolean verify(String s, SSLSession sslSession) {
return (true);
}
}
));
} catch (NoSuchAlgorithmException e) {
return (false);
}
return (true);
}
protected URL getApiUrl (Object ... pathArgs) throws IOException {
StringBuilder url = new StringBuilder();
url.append(hostUrl);
for (Object pathArg : pathArgs) {
url.append("/");
url.append(pathArg.toString());
}
return (new URL(url.toString()));
}
protected ClientResponse get (MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws UniformInterfaceException, ClientHandlerException, IOException {
URL url = getApiUrl(pathArgs);
return (get(queryParams, url));
}
protected ClientResponse get (MultivaluedMap<String, String> queryParams, URL url)
throws UniformInterfaceException, ClientHandlerException {
if (apiClient == null) {
apiClient = Client.create(clientConfig);
}
WebResource resource = apiClient.resource(url.toString());
if (queryParams != null) {
resource.queryParams(queryParams);
}
return (resource.header(PRIVATE_TOKEN_HEADER, privateToken)
.accept(MediaType.APPLICATION_JSON)
.get(ClientResponse.class));
}
protected ClientResponse post (Form formData, Object ... pathArgs)
throws UniformInterfaceException, ClientHandlerException, IOException {
URL url = getApiUrl(pathArgs);
return (post(formData, url));
}
protected ClientResponse post (Form formData, URL url) throws UniformInterfaceException, ClientHandlerException {
if (apiClient == null) {
apiClient = Client.create(clientConfig);
}
return (apiClient.resource(url.toString())
.header(PRIVATE_TOKEN_HEADER, privateToken)
.accept(MediaType.APPLICATION_JSON)
.type(MediaType.APPLICATION_FORM_URLENCODED_TYPE)
.post(ClientResponse.class, formData));
}
protected ClientResponse delete (MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws UniformInterfaceException, ClientHandlerException, IOException {
URL url = getApiUrl(pathArgs);
return (delete(queryParams, url));
}
protected ClientResponse delete (MultivaluedMap<String, String> queryParams, URL url)
throws UniformInterfaceException, ClientHandlerException {
if (apiClient == null) {
apiClient = Client.create(clientConfig);
}
WebResource resource = apiClient.resource(url.toString());
if (queryParams != null) {
resource.queryParams(queryParams);
}
return (resource.header(PRIVATE_TOKEN_HEADER, privateToken)
.accept(MediaType.APPLICATION_JSON)
.delete(ClientResponse.class));
}
}
package com.messners.gitlab.api;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Group {
private Integer id;
private String name;
private Integer ownerId;
private String path;
public Integer getId () {
return this.id;
}
public void setId (Integer id) {
this.id = id;
}
public String getName () {
return this.name;
}
public void setName (String name) {
this.name = name;
}
public Integer getOwnerId () {
return this.ownerId;
}
public void setOwnerId (Integer ownerId) {
this.ownerId = ownerId;
}
public String getPath () {
return this.path;
}
public void setPath (String path) {
this.path = path;
}
}
package com.messners.gitlab.api;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Issue {
private Assignee assignee;
private Author author;
private Date createdAt;
private String description;
private Integer id;
private Integer iid;
private List<String> labels;
private Milestone milestone;
private Integer project_id;
private String state;
private String title;
private Date updatedAt;
public Assignee getAssignee () {
return this.assignee;
}
public void setAssignee (Assignee assignee) {
this.assignee = assignee;
}
public Author getAuthor () {
return this.author;
}
public void setAuthor (Author author) {
this.author = author;
}
public Date getCreatedAt () {
return this.createdAt;
}
public void setCreatedAt (Date createdAt) {
this.createdAt = createdAt;
}
public String getDescription () {
return this.description;
}
public void setDescription (String description) {
this.description = description;
}
public Integer getId () {
return this.id;
}
public void setId (Integer id) {
this.id = id;
}
public Integer getIid () {
return this.iid;
}
public void setIid (Integer iid) {
this.iid = iid;
}
public List<String> getLabels () {
return this.labels;
}
public void setLabels (List<String> labels) {
this.labels = labels;
}
public Milestone getMilestone () {
return this.milestone;
}
public void setMilestone (Milestone milestone) {
this.milestone = milestone;
}
public Integer getProject_id () {
return this.project_id;
}
public void setProject_id (Integer project_id) {
this.project_id = project_id;
}
public String getState () {
return this.state;
}
public void setState (String state) {
this.state = state;
}
public String getTitle () {
return this.title;
}
public void setTitle (String title) {
this.title = title;
}
public Date getUpdatedAt () {
return this.updatedAt;
}
public void setUpdatedAt (Date updatedAt) {
this.updatedAt = updatedAt;
}
}
package com.messners.gitlab.api;
import javax.ws.rs.Consumes;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.ext.ContextResolver;
import javax.ws.rs.ext.Provider;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.map.PropertyNamingStrategy;
import org.codehaus.jackson.map.SerializationConfig;
import org.codehaus.jackson.map.DeserializationConfig;
import org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion;
/**
* Jackson JSON Configuration class
*
* @author Greg Messner <greg@messners.com>
*
*/
@Provider
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class JacksonJsonConfig implements ContextResolver<ObjectMapper> {
private final ObjectMapper objectMapper;
public JacksonJsonConfig () {
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);
}
@Override
public ObjectMapper getContext (Class<?> objectType) {
return (objectMapper);
}
}
\ No newline at end of file
package com.messners.gitlab.api;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType (XmlAccessType.FIELD)
public class Key {
private Date createdAt;
private Integer id;
private String key;
private String title;
public Date getCreatedAt () {
return this.createdAt;
}
public void setCreatedAt (Date createdAt) {
this.createdAt = createdAt;
}
public Integer getId () {
return this.id;
}
public void setId (Integer id) {
this.id = id;
}
public String getKey () {
return this.key;
}
public void setKey (String key) {
this.key = key;
}
public String getTitle () {
return this.title;
}
public void setTitle (String title) {
this.title = title;
}
}
package com.messners.gitlab.api;
import java.util.Date;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
@XmlRootElement
@XmlAccessorType(XmlAccessType.FIELD)
public class Member {
private Integer accessLevel;
private Date createdAt;
private String email;
private Integer id;
private String name;
private String state;
private String username;
public Integer getAccessLevel () {
return this.accessLevel;
}
public void setAccessLevel (Integer accessLevel) {
this.accessLevel = accessLevel;
}
public Date getCreatedAt () {
return this.createdAt;
}
public void setCreatedAt (Date createdAt) {
this.createdAt = createdAt;
}
public String getEmail () {
return this.email;
}
public void setEmail (String email) {
this.email = email;
}
public Integer getId () {
return this.id;
}
public void setId (Integer id) {
this.id = id;
}
public String getName () {
return this.name;
}
public void setName (String name) {
this.name = name;
}
public String getState () {
return this.state;
}
public void setState (String state) {
this.state = state;
}
public String getUsername () {
return this.username;
}
public void setUsername (String username) {
this.username = username;
}
}
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