Commit 78af4e54 authored by 六幻's avatar 六幻
Browse files

fix conflicts

parents c4e0b4ed 83365b1b
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<groupId>com.messners</groupId> <groupId>com.messners</groupId>
<artifactId>gitlab-api</artifactId> <artifactId>gitlab-api</artifactId>
<packaging>jar</packaging> <packaging>jar</packaging>
<version>1.0.16-SNAPSHOT</version> <version>2.0.1-SNAPSHOT</version>
<name>gitlab-api</name> <name>gitlab-api</name>
<description>GitLab API provides a full featured Java API for working with GitLab repositories via the GitLab REST API</description> <description>GitLab API provides a full featured Java API for working with GitLab repositories via the GitLab REST API</description>
<url>http://www.messners.com/#gitlab-api/gitlab-api.html</url> <url>http://www.messners.com/#gitlab-api/gitlab-api.html</url>
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<properties> <properties>
<jdk.version>1.6</jdk.version> <jdk.version>1.6</jdk.version>
<jersey.version>1.18</jersey.version> <jersey.version>2.14</jersey.version>
<jackson.version>1.9.13</jackson.version> <jackson.version>1.9.13</jackson.version>
<junit.version>4.9</junit.version> <junit.version>4.9</junit.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
...@@ -134,15 +134,10 @@ ...@@ -134,15 +134,10 @@
<version>${jackson.version}</version> <version>${jackson.version}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.sun.jersey</groupId> <groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId> <artifactId>jersey-client</artifactId>
<version>${jersey.version}</version> <version>${jersey.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>
<version>${jersey.version}</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
......
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.net.URL; import javax.ws.rs.core.Form;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import com.sun.jersey.api.client.ClientResponse; import java.net.URL;
import com.sun.jersey.api.representation.Form;
/** /**
* This class is the base class for all the sub API classes. It provides implementations of * This class is the base class for all the sub API classes. It provides implementations of
...@@ -37,23 +35,14 @@ public abstract class AbstractApi { ...@@ -37,23 +35,14 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected Response get (Response.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws GitLabApiException { throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().get(queryParams, pathArgs), expectedStatus);
try {
response = getApiClient().get(queryParams, pathArgs);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
} }
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
}
/** /**
* Perform an HTTP GET call with the specified query parameters and URL, returning * Perform an HTTP GET call with the specified query parameters and URL, returning
...@@ -65,22 +54,14 @@ public abstract class AbstractApi { ...@@ -65,22 +54,14 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse get (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) protected Response get (Response.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url)
throws GitLabApiException { throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().get(queryParams, url), expectedStatus);
try {
response = getApiClient().get(queryParams, url);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
} }
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
}
/** /**
...@@ -93,20 +74,12 @@ public abstract class AbstractApi { ...@@ -93,20 +74,12 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse post (ClientResponse.Status expectedStatus, Form formData, Object ... pathArgs) throws GitLabApiException { protected Response post (Response.Status expectedStatus, Form formData, Object ... pathArgs) throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().post(formData, pathArgs), expectedStatus);
try {
response = getApiClient().post(formData, pathArgs);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
} }
return (response);
} }
...@@ -120,20 +93,12 @@ public abstract class AbstractApi { ...@@ -120,20 +93,12 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse post (ClientResponse.Status expectedStatus, Form formData, URL url) throws GitLabApiException { protected Response post (Response.Status expectedStatus, Form formData, URL url) throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().post(formData, url), expectedStatus);
try {
response = getApiClient().post(formData, url);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
} }
return (response);
} }
...@@ -147,21 +112,13 @@ public abstract class AbstractApi { ...@@ -147,21 +112,13 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) throws GitLabApiException { protected Response put (Response.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().put(queryParams, pathArgs), expectedStatus);
try {
response = getApiClient().put(queryParams, pathArgs);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
} }
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
}
/** /**
...@@ -174,21 +131,13 @@ public abstract class AbstractApi { ...@@ -174,21 +131,13 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse put (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException { protected Response put (Response.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().put(queryParams, url), expectedStatus);
try {
response = getApiClient().put(queryParams, url);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
} }
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
}
/** /**
...@@ -201,22 +150,14 @@ public abstract class AbstractApi { ...@@ -201,22 +150,14 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected Response delete (Response.Status expectedStatus, MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws GitLabApiException { throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().delete(queryParams, pathArgs), expectedStatus);
try {
response = getApiClient().delete(queryParams, pathArgs);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
} }
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
}
return (response);
}
/** /**
...@@ -229,20 +170,12 @@ public abstract class AbstractApi { ...@@ -229,20 +170,12 @@ public abstract class AbstractApi {
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws GitLabApiException * @throws GitLabApiException
*/ */
protected ClientResponse delete (ClientResponse.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException { protected Response delete (Response.Status expectedStatus, MultivaluedMap<String, String> queryParams, URL url) throws GitLabApiException {
try {
ClientResponse response = null; return validate(getApiClient().delete(queryParams, url), expectedStatus);
try {
response = getApiClient().delete(queryParams, url);
} catch (Exception e) { } catch (Exception e) {
throw (new GitLabApiException(e)); throw handle(e);
}
if (response.getStatus() != expectedStatus.getStatusCode()) {
throw (new GitLabApiException(response));
} }
return (response);
} }
...@@ -269,7 +202,7 @@ public abstract class AbstractApi { ...@@ -269,7 +202,7 @@ public abstract class AbstractApi {
* @throws IllegalArgumentException if a required parameter is null or empty * @throws IllegalArgumentException if a required parameter is null or empty
*/ */
protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException { protected void addFormParam(Form formData, String name, Object value, boolean required) throws IllegalArgumentException {
if (value == null) { if (value == null) {
if (required) { if (required) {
...@@ -284,6 +217,31 @@ public abstract class AbstractApi { ...@@ -284,6 +217,31 @@ public abstract class AbstractApi {
throw new IllegalArgumentException(name + " cannot be empty or null"); throw new IllegalArgumentException(name + " cannot be empty or null");
} }
formData.add(name, stringValue); formData.param(name, stringValue);
}
/**
* Validates response.
* @param response response
* @param expected expected respone status
* @return original response if the response status is expected
* @throws GitLabApiException in case of unexpected response status
*/
protected Response validate(Response response, Response.Status expected) throws GitLabApiException {
if (response.getStatus() != expected.getStatusCode()) {
throw new GitLabApiException(response);
}
return response;
}
/**
* Wraps exception if needed
* @param thrown exception
* @return never returns
* @throws GitLabApiException always
*/
protected GitLabApiException handle(Exception thrown) throws GitLabApiException {
if (thrown instanceof GitLabApiException) { throw (GitLabApiException) thrown; }
throw new GitLabApiException(thrown);
} }
} }
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.util.List;
import com.messners.gitlab.api.models.Commit; import com.messners.gitlab.api.models.Commit;
import com.messners.gitlab.api.models.Diff; import com.messners.gitlab.api.models.Diff;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.util.List;
/** /**
* This class implements the client side API for the GitLab commits calls. * This class implements the client side API for the GitLab commits calls.
...@@ -29,8 +29,8 @@ public class CommitsApi extends AbstractApi { ...@@ -29,8 +29,8 @@ public class CommitsApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Commit> getCommits (int projectId) throws GitLabApiException { public List<Commit> getCommits (int projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "repository", "commits"); Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "commits");
return (response.getEntity(new GenericType<List<Commit>>() {})); return (response.readEntity(new GenericType<List<Commit>>(){}));
} }
...@@ -45,8 +45,8 @@ public class CommitsApi extends AbstractApi { ...@@ -45,8 +45,8 @@ public class CommitsApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Commit getCommits (int projectId, String sha) throws GitLabApiException { public Commit getCommits (int projectId, String sha) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "repository", "commits", sha); Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "commits", sha);
return (response.getEntity(Commit.class)); return (response.readEntity(Commit.class));
} }
...@@ -61,8 +61,8 @@ public class CommitsApi extends AbstractApi { ...@@ -61,8 +61,8 @@ public class CommitsApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Diff getDiff (int projectId, String sha) throws GitLabApiException { public Diff getDiff (int projectId, String sha) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, Response response = get(Response.Status.OK, null,
"projects", projectId, "repository", "commits", sha, "diff"); "projects", projectId, "repository", "commits", sha, "diff");
return (response.getEntity(Diff.class)); return (response.readEntity(Diff.class));
} }
} }
\ No newline at end of file
File mode changed from 100755 to 100644
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.io.IOException; import org.glassfish.jersey.client.ClientConfig;
import java.net.URL; import org.glassfish.jersey.client.ClientProperties;
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.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection; import javax.net.ssl.HttpsURLConnection;
...@@ -15,19 +10,24 @@ import javax.net.ssl.SSLSession; ...@@ -15,19 +10,24 @@ import javax.net.ssl.SSLSession;
import javax.net.ssl.SSLSocketFactory; import javax.net.ssl.SSLSocketFactory;
import javax.net.ssl.TrustManager; import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager; import javax.net.ssl.X509TrustManager;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.Entity;
import javax.ws.rs.client.Invocation;
import javax.ws.rs.client.WebTarget;
import javax.ws.rs.core.Form;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.core.MultivaluedMap;
import javax.ws.rs.core.Response;
import com.sun.jersey.api.client.Client; import java.io.IOException;
import com.sun.jersey.api.client.ClientHandlerException; import java.net.URL;
import com.sun.jersey.api.client.ClientResponse; import java.security.GeneralSecurityException;
import com.sun.jersey.api.client.UniformInterfaceException; import java.security.NoSuchAlgorithmException;
import com.sun.jersey.api.client.WebResource; import java.security.SecureRandom;
import com.sun.jersey.api.client.config.ClientConfig; import java.security.cert.CertificateException;
import com.sun.jersey.api.client.config.DefaultClientConfig; import java.security.cert.X509Certificate;
import com.sun.jersey.api.json.JSONConfiguration; import java.util.List;
import com.sun.jersey.api.representation.Form; import java.util.Map;
import com.sun.jersey.client.urlconnection.HTTPSProperties;
/** /**
* This class utilizes the Jersey client package to communicate with a GitLab API endpoint. * This class utilizes the Jersey client package to communicate with a GitLab API endpoint.
...@@ -45,7 +45,6 @@ public class GitLabApiClient { ...@@ -45,7 +45,6 @@ public class GitLabApiClient {
private String privateToken; private String privateToken;
private static boolean ignoreCertificateErrors; private static boolean ignoreCertificateErrors;
private static SSLSocketFactory defaultSocketFactory; private static SSLSocketFactory defaultSocketFactory;
private static HTTPSProperties defaultHttpsProperties;
/** /**
...@@ -60,11 +59,9 @@ public class GitLabApiClient { ...@@ -60,11 +59,9 @@ public class GitLabApiClient {
// Remove the trailing "/" from the hostUrl if present // Remove the trailing "/" from the hostUrl if present
this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl) + API_NAMESPACE; this.hostUrl = (hostUrl.endsWith("/") ? hostUrl.replaceAll("/$", "") : hostUrl) + API_NAMESPACE;
this.privateToken = privateToken; this.privateToken = privateToken;
clientConfig = new DefaultClientConfig(); clientConfig = new ClientConfig();
clientConfig.getClasses().add(JacksonJson.class); clientConfig.register(JacksonJson.class);
clientConfig.getFeatures().put(ClientConfig.PROPERTY_FOLLOW_REDIRECTS, Boolean.TRUE);
clientConfig.getFeatures().put(JSONConfiguration.FEATURE_POJO_MAPPING, Boolean.TRUE);
} }
...@@ -92,20 +89,16 @@ public class GitLabApiClient { ...@@ -92,20 +89,16 @@ public class GitLabApiClient {
} }
if (ignoreCertificateErrors == false) { if (ignoreCertificateErrors == false) {
GitLabApiClient.ignoreCertificateErrors = false; GitLabApiClient.ignoreCertificateErrors = false;
HttpsURLConnection.setDefaultSSLSocketFactory(GitLabApiClient.defaultSocketFactory); HttpsURLConnection.setDefaultSSLSocketFactory(GitLabApiClient.defaultSocketFactory);
clientConfig.getProperties().put(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES, GitLabApiClient.defaultHttpsProperties);
return; return;
} }
SSLSocketFactory defaultSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory(); SSLSocketFactory defaultSocketFactory = HttpsURLConnection.getDefaultSSLSocketFactory();
HTTPSProperties defaultHttpsProperties = (HTTPSProperties)clientConfig.getProperties().get(HTTPSProperties.PROPERTY_HTTPS_PROPERTIES);
if (ignoreCertificateErrors() == true) { if (ignoreCertificateErrors() == true) {
GitLabApiClient.ignoreCertificateErrors = true; GitLabApiClient.ignoreCertificateErrors = true;
GitLabApiClient.defaultSocketFactory = defaultSocketFactory; GitLabApiClient.defaultSocketFactory = defaultSocketFactory;
GitLabApiClient.defaultHttpsProperties = defaultHttpsProperties;
} else { } else {
throw new RuntimeException("Unable to ignore certificate errors."); throw new RuntimeException("Unable to ignore certificate errors.");
} }
...@@ -150,23 +143,6 @@ public class GitLabApiClient { ...@@ -150,23 +143,6 @@ public class GitLabApiClient {
return (false); return (false);
} }
// Set up a HostnameVerifier for Jersey to verify all hostnames as valid
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) {
HttpsURLConnection.setDefaultSSLSocketFactory(defaultSocketFactory);
return (false);
}
return (true); return (true);
} }
...@@ -198,12 +174,10 @@ public class GitLabApiClient { ...@@ -198,12 +174,10 @@ public class GitLabApiClient {
* @param queryParams * @param queryParams
* @param pathArgs * @param pathArgs
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
* @throws IOException * @throws IOException
*/ */
protected ClientResponse get (MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected Response get (MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws UniformInterfaceException, ClientHandlerException, IOException { throws IOException {
URL url = getApiUrl(pathArgs); URL url = getApiUrl(pathArgs);
return (get(queryParams, url)); return (get(queryParams, url));
} }
...@@ -216,25 +190,10 @@ public class GitLabApiClient { ...@@ -216,25 +190,10 @@ public class GitLabApiClient {
* @param queryParams * @param queryParams
* @param url * @param url
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
*/ */
protected ClientResponse get (MultivaluedMap<String, String> queryParams, URL url) protected Response get (MultivaluedMap<String, String> queryParams, URL url) {
throws UniformInterfaceException, ClientHandlerException { return invocation(url, queryParams).get();
}
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));
}
/** /**
...@@ -244,17 +203,15 @@ public class GitLabApiClient { ...@@ -244,17 +203,15 @@ public class GitLabApiClient {
* @param formData * @param formData
* @param pathArgs * @param pathArgs
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
* @throws IOException * @throws IOException
*/ */
protected ClientResponse post (Form formData, Object ... pathArgs) protected Response post (Form formData, Object ... pathArgs)
throws UniformInterfaceException, ClientHandlerException, IOException { throws IOException {
URL url = getApiUrl(pathArgs); URL url = getApiUrl(pathArgs);
return (post(formData, url)); return post(formData, url);
} }
/** /**
* Perform an HTTP POST call with the specified form data and URL, returning * Perform an HTTP POST call with the specified form data and URL, returning
* a ClientResponse instance with the data returned from the endpoint. * a ClientResponse instance with the data returned from the endpoint.
...@@ -262,20 +219,9 @@ public class GitLabApiClient { ...@@ -262,20 +219,9 @@ public class GitLabApiClient {
* @param formData * @param formData
* @param url * @param url
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
*/ */
protected ClientResponse post (Form formData, URL url) throws UniformInterfaceException, ClientHandlerException { protected Response post (Form formData, URL url) {
return invocation(url, null).post(Entity.entity(formData, MediaType.APPLICATION_FORM_URLENCODED_TYPE));
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));
} }
...@@ -286,12 +232,10 @@ public class GitLabApiClient { ...@@ -286,12 +232,10 @@ public class GitLabApiClient {
* @param queryParams * @param queryParams
* @param pathArgs * @param pathArgs
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
* @throws IOException * @throws IOException
*/ */
protected ClientResponse put (MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected Response put (MultivaluedMap<String, String> queryParams, Object ... pathArgs)
throws UniformInterfaceException, ClientHandlerException, IOException { throws IOException {
URL url = getApiUrl(pathArgs); URL url = getApiUrl(pathArgs);
return (put(queryParams, url)); return (put(queryParams, url));
} }
...@@ -304,69 +248,70 @@ public class GitLabApiClient { ...@@ -304,69 +248,70 @@ public class GitLabApiClient {
* @param queryParams * @param queryParams
* @param url * @param url
* @return a ClientResponse instance with the data returned from the endpoint * @return a ClientResponse instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
*/ */
protected ClientResponse put (MultivaluedMap<String, String> queryParams, URL url) protected Response put (MultivaluedMap<String, String> queryParams, URL url) {
throws UniformInterfaceException, ClientHandlerException { return invocation(url, queryParams).put(null);
}
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)
.put(ClientResponse.class));
}
/** /**
* Perform an HTTP DELETE call with the specified form data and path objects, returning * Perform an HTTP DELETE call with the specified form data and path objects, returning
* a ClientResponse instance with the data returned from the endpoint. * a Response instance with the data returned from the endpoint.
* *
* @param queryParams * @param queryParams
* @param pathArgs * @param pathArgs
* @return a ClientResponse instance with the data returned from the endpoint * @return a Response instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
* @throws IOException * @throws IOException
*/ */
protected ClientResponse delete (MultivaluedMap<String, String> queryParams, Object ... pathArgs) protected Response delete (MultivaluedMap<String, String> queryParams, Object ... pathArgs) throws IOException {
throws UniformInterfaceException, ClientHandlerException, IOException { return delete(queryParams, getApiUrl(pathArgs));
URL url = getApiUrl(pathArgs);
return (delete(queryParams, url));
} }
/** /**
* Perform an HTTP DELETE call with the specified form data and URL, returning * Perform an HTTP DELETE call with the specified form data and URL, returning
* a ClientResponse instance with the data returned from the endpoint. * a Response instance with the data returned from the endpoint.
* *
* @param queryParams * @param queryParams
* @param url * @param url
* @return a ClientResponse instance with the data returned from the endpoint * @return a Response instance with the data returned from the endpoint
* @throws UniformInterfaceException
* @throws ClientHandlerException
*/ */
protected ClientResponse delete (MultivaluedMap<String, String> queryParams, URL url) protected Response delete (MultivaluedMap<String, String> queryParams, URL url) {
throws UniformInterfaceException, ClientHandlerException { return invocation(url, queryParams).delete();
}
protected class AcceptAllHostnameVerifier implements HostnameVerifier {
@Override
public boolean verify(String s, SSLSession sslSession) {
return true;
}
}
protected Invocation.Builder invocation(URL url, MultivaluedMap<String, String> queryParams) {
if (apiClient == null) { if (apiClient == null) {
apiClient = Client.create(clientConfig); apiClient = ClientBuilder.newBuilder()
.withConfig(clientConfig)
.sslContext(getSslContext())
.hostnameVerifier(new AcceptAllHostnameVerifier())
.build();
} }
WebResource resource = apiClient.resource(url.toString()); WebTarget target = apiClient.target(url.toExternalForm()).property(ClientProperties.FOLLOW_REDIRECTS, true);
if (queryParams != null) { if (queryParams != null) {
resource.queryParams(queryParams); for (Map.Entry<String, List<String>> param : queryParams.entrySet()) {
target = target.queryParam(param.getKey(), param.getValue().toArray());
}
} }
return target.request().header(PRIVATE_TOKEN_HEADER, privateToken).accept(MediaType.APPLICATION_JSON);
return (resource.header(PRIVATE_TOKEN_HEADER, privateToken) }
.accept(MediaType.APPLICATION_JSON)
.delete(ClientResponse.class)); private SSLContext getSslContext() {
} try {
return SSLContext.getDefault();
} catch (NoSuchAlgorithmException e) {
throw new UnsupportedOperationException(e);
}
}
} }
package com.messners.gitlab.api; package com.messners.gitlab.api;
import javax.ws.rs.core.Response.StatusType;
import com.messners.gitlab.api.models.ErrorMessage; import com.messners.gitlab.api.models.ErrorMessage;
import com.sun.jersey.api.client.ClientResponse;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.StatusType;
/** /**
...@@ -26,7 +26,7 @@ public class GitLabApiException extends Exception { ...@@ -26,7 +26,7 @@ public class GitLabApiException extends Exception {
* *
* @param response * @param response
*/ */
public GitLabApiException (ClientResponse response) { public GitLabApiException (Response response) {
super(); super();
statusInfo = response.getStatusInfo(); statusInfo = response.getStatusInfo();
...@@ -35,7 +35,7 @@ public class GitLabApiException extends Exception { ...@@ -35,7 +35,7 @@ public class GitLabApiException extends Exception {
if (response.hasEntity()) { if (response.hasEntity()) {
try { try {
ErrorMessage errorMessage = response.getEntity(ErrorMessage.class); ErrorMessage errorMessage = response.readEntity(ErrorMessage.class);
message = errorMessage.getMessage(); message = errorMessage.getMessage();
} catch (Exception ignore) {} } catch (Exception ignore) {}
......
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.util.List;
import com.messners.gitlab.api.models.Group; import com.messners.gitlab.api.models.Group;
import com.messners.gitlab.api.models.Member; import com.messners.gitlab.api.models.Member;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType; import javax.ws.rs.core.Form;
import com.sun.jersey.api.representation.Form; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.util.List;
/** /**
* This class implements the client side API for the GitLab groups calls. * This class implements the client side API for the GitLab groups calls.
...@@ -29,8 +29,8 @@ public class GroupApi extends AbstractApi { ...@@ -29,8 +29,8 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Group> getGroups () throws GitLabApiException { public List<Group> getGroups () throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "groups"); Response response = get(Response.Status.OK, null, "groups");
return (response.getEntity(new GenericType<List<Group>>() {})); return (response.readEntity(new GenericType<List<Group>>() {}));
} }
...@@ -44,8 +44,8 @@ public class GroupApi extends AbstractApi { ...@@ -44,8 +44,8 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Group getGroup (int groupId) throws GitLabApiException { public Group getGroup (int groupId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "groups", groupId); Response response = get(Response.Status.OK, null, "groups", groupId);
return (response.getEntity(Group.class)); return (response.readEntity(Group.class));
} }
...@@ -60,9 +60,9 @@ public class GroupApi extends AbstractApi { ...@@ -60,9 +60,9 @@ public class GroupApi extends AbstractApi {
public void addGroup (String name, String path) throws GitLabApiException { public void addGroup (String name, String path) throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("name", name); formData.param("name", name);
formData.add("path", path); formData.param("path", path);
post(ClientResponse.Status.OK, formData, "groups"); post(Response.Status.OK, formData, "groups");
} }
...@@ -80,7 +80,7 @@ public class GroupApi extends AbstractApi { ...@@ -80,7 +80,7 @@ public class GroupApi extends AbstractApi {
throw new RuntimeException("groupId cannot be null"); throw new RuntimeException("groupId cannot be null");
} }
delete(ClientResponse.Status.OK, null, "groups", groupId); delete(Response.Status.OK, null, "groups", groupId);
} }
...@@ -106,8 +106,8 @@ public class GroupApi extends AbstractApi { ...@@ -106,8 +106,8 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Member> getMembers (int groupId) throws GitLabApiException { public List<Member> getMembers (int groupId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "groups", groupId, "members"); Response response = get(Response.Status.OK, null, "groups", groupId, "members");
return (response.getEntity(new GenericType<List<Member>>() {})); return (response.readEntity(new GenericType<List<Member>>() {}));
} }
/** /**
...@@ -124,10 +124,10 @@ public class GroupApi extends AbstractApi { ...@@ -124,10 +124,10 @@ public class GroupApi extends AbstractApi {
public Member addMember (Integer groupId, Integer userId, Integer accessLevel) throws GitLabApiException { public Member addMember (Integer groupId, Integer userId, Integer accessLevel) throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("user_id", userId); formData.param("user_id", userId.toString());
formData.add("access_level", accessLevel); formData.param("access_level", accessLevel.toString());
ClientResponse response = post(ClientResponse.Status.OK, formData, "groups", groupId, "members"); Response response = post(Response.Status.OK, formData, "groups", groupId, "members");
return (response.getEntity(Member.class)); return (response.readEntity(Member.class));
} }
...@@ -141,6 +141,6 @@ public class GroupApi extends AbstractApi { ...@@ -141,6 +141,6 @@ public class GroupApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public void removeMember (Integer projectId, Integer userId) throws GitLabApiException { public void removeMember (Integer projectId, Integer userId) throws GitLabApiException {
delete(ClientResponse.Status.OK, null, "groups", projectId, "members", userId); delete(Response.Status.OK, null, "groups", projectId, "members", userId);
} }
} }
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.util.List;
import com.messners.gitlab.api.models.MergeRequest; import com.messners.gitlab.api.models.MergeRequest;
import com.messners.gitlab.api.models.MergeRequestComment; import com.messners.gitlab.api.models.MergeRequestComment;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType; import javax.ws.rs.core.Form;
import com.sun.jersey.api.representation.Form; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.util.List;
/** /**
* This class implements the client side API for the GitLab merge request calls. * This class implements the client side API for the GitLab merge request calls.
* *
* @author Greg Messner <greg@messners.com> * @author Greg Messner <greg@messners.com>
*/ */
public class MergeRequestApi extends AbstractApi { public class MergeRequestApi extends AbstractApi {
...@@ -18,44 +18,44 @@ public class MergeRequestApi extends AbstractApi { ...@@ -18,44 +18,44 @@ public class MergeRequestApi extends AbstractApi {
MergeRequestApi (GitLabApi gitLabApi) { MergeRequestApi (GitLabApi gitLabApi) {
super(gitLabApi); super(gitLabApi);
} }
/** /**
* Get all merge requests for the specified project. * Get all merge requests for the specified project.
* *
* GET /projects/:id/merge_requests * GET /projects/:id/merge_requests
* *
* @param projectId the project ID to get the merge requests for * @param projectId the project ID to get the merge requests for
* @return all merge requests for the specified project * @return all merge requests for the specified project
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<MergeRequest> getMergeRequests (Integer projectId) throws GitLabApiException { public List<MergeRequest> getMergeRequests (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "merge_requests"); Response response = get(Response.Status.OK, null, "projects", projectId, "merge_requests");
return (response.getEntity(new GenericType<List<MergeRequest>>() {})); return (response.readEntity(new GenericType<List<MergeRequest>>() {}));
} }
/** /**
* Get information about a single merge request. * Get information about a single merge request.
* *
* GET /projects/:id/merge_request/:merge_request_id * GET /projects/:id/merge_request/:merge_request_id
* *
* @param projectId * @param projectId
* @param mergeRequestId * @param mergeRequestId
* @return the specified MergeRequest instance * @return the specified MergeRequest instance
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public MergeRequest getMergeRequest (Integer projectId, Integer mergeRequestId) throws GitLabApiException { public MergeRequest getMergeRequest (Integer projectId, Integer mergeRequestId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "merge_request", mergeRequestId); Response response = get(Response.Status.OK, null, "projects", projectId, "merge_request", mergeRequestId);
return (response.getEntity(MergeRequest.class)); return (response.readEntity(MergeRequest.class));
} }
/** /**
* Creates a merge request and optionally assigns a reviewer to it. * Creates a merge request and optionally assigns a reviewer to it.
* *
* POST /projects/:id/merge_requests * POST /projects/:id/merge_requests
* *
* @param projectId the ID of a project, required * @param projectId the ID of a project, required
* @param sourceBranch the source branch, required * @param sourceBranch the source branch, required
* @param targetBranch the target branch, required * @param targetBranch the target branch, required
...@@ -63,32 +63,32 @@ public class MergeRequestApi extends AbstractApi { ...@@ -63,32 +63,32 @@ public class MergeRequestApi extends AbstractApi {
* @param description the description of the merge request * @param description the description of the merge request
* @param assigneeId the Assignee user ID, optional * @param assigneeId the Assignee user ID, optional
* @return the created MergeRequest instance * @return the created MergeRequest instance
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public MergeRequest createMergeRequest (Integer projectId, String sourceBranch, String targetBranch, String title, String description, Integer assigneeId) public MergeRequest createMergeRequest (Integer projectId, String sourceBranch, String targetBranch, String title, String description, Integer assigneeId)
throws GitLabApiException { throws GitLabApiException {
if (projectId == null) { if (projectId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
Form formData = new Form(); Form formData = new Form();
addFormParam(formData, "source_branch", sourceBranch, true); addFormParam(formData, "source_branch", sourceBranch, true);
addFormParam(formData, "target_branch", targetBranch, true); addFormParam(formData, "target_branch", targetBranch, true);
addFormParam(formData, "title", title, true); addFormParam(formData, "title", title, true);
addFormParam(formData, "description", description, false); addFormParam(formData, "description", description, false);
addFormParam(formData, "assignee_id", assigneeId, false); addFormParam(formData, "assignee_id", assigneeId, false);
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "projects", projectId, "merge_requests"); Response response = post(Response.Status.CREATED, formData, "projects", projectId, "merge_requests");
return (response.getEntity(MergeRequest.class)); return (response.readEntity(MergeRequest.class));
} }
/** /**
* Updates an existing merge request. You can change branches, title, or even close the MR. * Updates an existing merge request. You can change branches, title, or even close the MR.
* *
* PUT /projects/:id/merge_request/:merge_request_id * PUT /projects/:id/merge_request/:merge_request_id
* *
* @param projectId * @param projectId
* @param mergeRequestId * @param mergeRequestId
* @param sourceBranch * @param sourceBranch
...@@ -97,47 +97,47 @@ public class MergeRequestApi extends AbstractApi { ...@@ -97,47 +97,47 @@ public class MergeRequestApi extends AbstractApi {
* @param description * @param description
* @param assigneeId * @param assigneeId
* @return the updated merge request * @return the updated merge request
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public MergeRequest updateMergeRequest (Integer projectId, Integer mergeRequestId, public MergeRequest updateMergeRequest (Integer projectId, Integer mergeRequestId,
String sourceBranch, String targetBranch, String title, String description, Integer assigneeId) throws GitLabApiException { String sourceBranch, String targetBranch, String title, String description, Integer assigneeId) throws GitLabApiException {
if (projectId == null) { if (projectId == null) {
throw new RuntimeException("mergeRequestId cannot be null"); throw new RuntimeException("mergeRequestId cannot be null");
} }
if (mergeRequestId == null) { if (mergeRequestId == null) {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
Form formData = new Form(); Form formData = new Form();
addFormParam(formData, "source_branch", sourceBranch, false); addFormParam(formData, "source_branch", sourceBranch, false);
addFormParam(formData, "target_branch", targetBranch, false); addFormParam(formData, "target_branch", targetBranch, false);
addFormParam(formData, "title", title, false); addFormParam(formData, "title", title, false);
addFormParam(formData, "description", description, false); addFormParam(formData, "description", description, false);
addFormParam(formData, "assignee_id", assigneeId, false); addFormParam(formData, "assignee_id", assigneeId, false);
ClientResponse response = put(ClientResponse.Status.OK, formData, "projects", projectId, "merge_request", mergeRequestId); Response response = put(Response.Status.OK, formData.asMap(), "projects", projectId, "merge_request", mergeRequestId);
return (response.getEntity(MergeRequest.class)); return (response.readEntity(MergeRequest.class));
} }
/** /**
* Adds a comment to a merge request. * Adds a comment to a merge request.
* *
* POST /projects/:id/merge_request/:merge_request_id/comments * POST /projects/:id/merge_request/:merge_request_id/comments
* *
* @param projectId * @param projectId
* @param mergeRequestId * @param mergeRequestId
* @param comments * @param comments
* @return the added merge request comment * @return the added merge request comment
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public MergeRequestComment addMergeRequestComment (Integer projectId, Integer mergeRequestId, String comments) throws GitLabApiException { public MergeRequestComment addMergeRequestComment (Integer projectId, Integer mergeRequestId, String comments) throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("note", comments); formData.param("note", comments);
ClientResponse response = post(ClientResponse.Status.OK, formData, "projects", projectId, "merge_request", mergeRequestId, "comments"); Response response = post(Response.Status.OK, formData, "projects", projectId, "merge_request", mergeRequestId, "comments");
return (response.getEntity(MergeRequestComment.class)); return (response.readEntity(MergeRequestComment.class));
} }
} }
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
import com.messners.gitlab.api.models.Event; import com.messners.gitlab.api.models.Event;
import com.messners.gitlab.api.models.Member; import com.messners.gitlab.api.models.Member;
import com.messners.gitlab.api.models.Project; import com.messners.gitlab.api.models.Project;
import com.messners.gitlab.api.models.ProjectHook; import com.messners.gitlab.api.models.ProjectHook;
import com.sun.jersey.api.client.ClientResponse; import org.glassfish.jersey.uri.UriComponent;
import com.sun.jersey.api.client.GenericType;
import com.sun.jersey.api.representation.Form; import javax.ws.rs.core.Form;
import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.List;
public class ProjectApi extends AbstractApi { public class ProjectApi extends AbstractApi {
ProjectApi (GitLabApi gitLabApi) { ProjectApi (GitLabApi gitLabApi) {
super(gitLabApi); super(gitLabApi);
} }
...@@ -28,8 +29,8 @@ public class ProjectApi extends AbstractApi { ...@@ -28,8 +29,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Project> getProjects () throws GitLabApiException { public List<Project> getProjects () throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects"); Response response = get(Response.Status.OK, null, "projects");
return (response.getEntity(new GenericType<List<Project>>() {})); return (response.readEntity(new GenericType<List<Project>>(){}));
} }
...@@ -42,8 +43,8 @@ public class ProjectApi extends AbstractApi { ...@@ -42,8 +43,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Project> getAllProjects () throws GitLabApiException { public List<Project> getAllProjects () throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", "all"); Response response = get(Response.Status.OK, UriComponent.decodeQuery("per_page=9999", true), "projects", "all");
return (response.getEntity(new GenericType<List<Project>>() {})); return (response.readEntity(new GenericType<List<Project>>(){}));
} }
...@@ -56,8 +57,8 @@ public class ProjectApi extends AbstractApi { ...@@ -56,8 +57,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Project> getOwnedProjects () throws GitLabApiException { public List<Project> getOwnedProjects () throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", "owned"); Response response = get(Response.Status.OK, null, "projects", "owned");
return (response.getEntity(new GenericType<List<Project>>() {})); return (response.readEntity(new GenericType<List<Project>>(){}));
} }
...@@ -71,8 +72,8 @@ public class ProjectApi extends AbstractApi { ...@@ -71,8 +72,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Project getProject (Integer projectId) throws GitLabApiException { public Project getProject (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId); Response response = get(Response.Status.OK, null, "projects", projectId);
return (response.getEntity(Project.class)); return (response.readEntity(Project.class));
} }
...@@ -95,9 +96,9 @@ public class ProjectApi extends AbstractApi { ...@@ -95,9 +96,9 @@ public class ProjectApi extends AbstractApi {
throw (new GitLabApiException(uee)); throw (new GitLabApiException(uee));
} }
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", pid); Response response = get(Response.Status.OK, null, "projects", pid);
return (response.getEntity(Project.class)); return (response.readEntity(Project.class));
} }
/** /**
...@@ -114,8 +115,8 @@ public class ProjectApi extends AbstractApi { ...@@ -114,8 +115,8 @@ public class ProjectApi extends AbstractApi {
addFormParam(formData, "namespace_id", groupId); addFormParam(formData, "namespace_id", groupId);
addFormParam(formData, "name", projectName, true); addFormParam(formData, "name", projectName, true);
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "projects"); Response response = post(Response.Status.CREATED, formData, "projects");
return (response.getEntity(Project.class)); return (response.readEntity(Project.class));
} }
...@@ -124,8 +125,7 @@ public class ProjectApi extends AbstractApi { ...@@ -124,8 +125,7 @@ public class ProjectApi extends AbstractApi {
* *
* @param project the Project instance with the configuration for the new project * @param project the Project instance with the configuration for the new project
* @return a Project instance with the newly created project info * @return a Project instance with the newly created project info
* @throws IOException * @throws GitLabApiException
* @throws GitLabApiException
*/ */
public Project createProject (Project project) throws GitLabApiException { public Project createProject (Project project) throws GitLabApiException {
return (createProject(project, null)); return (createProject(project, null));
...@@ -177,8 +177,8 @@ public class ProjectApi extends AbstractApi { ...@@ -177,8 +177,8 @@ public class ProjectApi extends AbstractApi {
addFormParam(formData, "visibility_level", project.getVisibilityLevel()); addFormParam(formData, "visibility_level", project.getVisibilityLevel());
addFormParam(formData, "import_url", importUrl); addFormParam(formData, "import_url", importUrl);
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "projects"); Response response = post(Response.Status.CREATED, formData, "projects");
return (response.getEntity(Project.class)); return (response.readEntity(Project.class));
} }
/** /**
...@@ -217,8 +217,8 @@ public class ProjectApi extends AbstractApi { ...@@ -217,8 +217,8 @@ public class ProjectApi extends AbstractApi {
addFormParam(formData, "visibility_level", visibilityLevel); addFormParam(formData, "visibility_level", visibilityLevel);
addFormParam(formData, "import_url", importUrl); addFormParam(formData, "import_url", importUrl);
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "projects"); Response response = post(Response.Status.CREATED, formData, "projects");
return (response.getEntity(Project.class)); return (response.readEntity(Project.class));
} }
/** /**
...@@ -235,7 +235,7 @@ public class ProjectApi extends AbstractApi { ...@@ -235,7 +235,7 @@ public class ProjectApi extends AbstractApi {
throw new RuntimeException("projectId cannot be null"); throw new RuntimeException("projectId cannot be null");
} }
delete(ClientResponse.Status.OK, null, "projects", projectId); delete(Response.Status.OK, null, "projects", projectId);
} }
...@@ -262,8 +262,8 @@ public class ProjectApi extends AbstractApi { ...@@ -262,8 +262,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Member> getMembers (Integer projectId) throws GitLabApiException { public List<Member> getMembers (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "members"); Response response = get(Response.Status.OK, null, "projects", projectId, "members");
return (response.getEntity(new GenericType<List<Member>>() {})); return (response.readEntity(new GenericType<List<Member>>() {}));
} }
...@@ -278,8 +278,8 @@ public class ProjectApi extends AbstractApi { ...@@ -278,8 +278,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Member getMember (Integer projectId, Integer userId) throws GitLabApiException { public Member getMember (Integer projectId, Integer userId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "members", userId); Response response = get(Response.Status.OK, null, "projects", projectId, "members", userId);
return (response.getEntity(Member.class)); return (response.readEntity(Member.class));
} }
...@@ -299,10 +299,10 @@ public class ProjectApi extends AbstractApi { ...@@ -299,10 +299,10 @@ public class ProjectApi extends AbstractApi {
public Member addMember (Integer projectId, Integer userId, Integer accessLevel) throws GitLabApiException { public Member addMember (Integer projectId, Integer userId, Integer accessLevel) throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("user_id", userId); formData.param("user_id", userId.toString());
formData.add("access_level", accessLevel); formData.param("access_level", accessLevel.toString());
ClientResponse response = post(ClientResponse.Status.OK, formData, "projects", projectId, "members"); Response response = post(Response.Status.OK, formData, "projects", projectId, "members");
return (response.getEntity(Member.class)); return (response.readEntity(Member.class));
} }
...@@ -316,7 +316,7 @@ public class ProjectApi extends AbstractApi { ...@@ -316,7 +316,7 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public void removeMember (Integer projectId, Integer userId) throws GitLabApiException { public void removeMember (Integer projectId, Integer userId) throws GitLabApiException {
delete(ClientResponse.Status.OK, null, "projects", projectId, "members", userId); delete(Response.Status.OK, null, "projects", projectId, "members", userId);
} }
...@@ -330,8 +330,8 @@ public class ProjectApi extends AbstractApi { ...@@ -330,8 +330,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Event> getProjectEvents (Integer projectId) throws GitLabApiException { public List<Event> getProjectEvents (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "events"); Response response = get(Response.Status.OK, null, "projects", projectId, "events");
return (response.getEntity(new GenericType<List<Event>>() {})); return (response.readEntity(new GenericType<List<Event>>() {}));
} }
...@@ -345,8 +345,8 @@ public class ProjectApi extends AbstractApi { ...@@ -345,8 +345,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<ProjectHook> getHooks (Integer projectId) throws GitLabApiException { public List<ProjectHook> getHooks (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "hooks"); Response response = get(Response.Status.OK, null, "projects", projectId, "hooks");
return (response.getEntity(new GenericType<List<ProjectHook>>() {} )); return (response.readEntity(new GenericType<List<ProjectHook>>() {}));
} }
...@@ -361,8 +361,8 @@ public class ProjectApi extends AbstractApi { ...@@ -361,8 +361,8 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public ProjectHook getHook (Integer projectId, Integer hookId) throws GitLabApiException { public ProjectHook getHook (Integer projectId, Integer hookId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "hooks", hookId); Response response = get(Response.Status.OK, null, "projects", projectId, "hooks", hookId);
return (response.getEntity(ProjectHook.class)); return (response.readEntity(ProjectHook.class));
} }
...@@ -409,13 +409,13 @@ public class ProjectApi extends AbstractApi { ...@@ -409,13 +409,13 @@ public class ProjectApi extends AbstractApi {
throws GitLabApiException { throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("url", url); formData.param("url", url);
formData.add("push_events", doPushEvents); formData.param("push_events", Boolean.toString(doPushEvents));
formData.add("issues_enabled", doIssuesEvents); formData.param("issues_enabled", Boolean.toString(doIssuesEvents));
formData.add("merge_requests_events", doMergeRequestsEvents); formData.param("merge_requests_events", Boolean.toString(doMergeRequestsEvents));
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "projects", projectId, "hooks"); Response response = post(Response.Status.CREATED, formData, "projects", projectId, "hooks");
return (response.getEntity(ProjectHook.class)); return (response.readEntity(ProjectHook.class));
} }
...@@ -429,7 +429,7 @@ public class ProjectApi extends AbstractApi { ...@@ -429,7 +429,7 @@ public class ProjectApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public void deleteHook (Integer projectId, Integer hookId) throws GitLabApiException { public void deleteHook (Integer projectId, Integer hookId) throws GitLabApiException {
delete(ClientResponse.Status.OK, null, "projects", projectId, "hooks", hookId); delete(Response.Status.OK, null, "projects", projectId, "hooks", hookId);
} }
...@@ -458,12 +458,12 @@ public class ProjectApi extends AbstractApi { ...@@ -458,12 +458,12 @@ public class ProjectApi extends AbstractApi {
public ProjectHook modifyHook (ProjectHook hook) throws GitLabApiException { public ProjectHook modifyHook (ProjectHook hook) throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("url", hook.getUrl()); formData.param("url", hook.getUrl());
formData.add("push_events", hook.getPushEvents()); formData.param("push_events", hook.getPushEvents().toString());
formData.add("issues_enabled", hook.getIssuesEvents()); formData.param("issues_enabled", hook.getIssuesEvents().toString());
formData.add("merge_requests_events", hook.getMergeRequestsEvents()); formData.param("merge_requests_events", hook.getMergeRequestsEvents().toString());
ClientResponse response = put(ClientResponse.Status.OK, formData, "projects", hook.getProjectId(), "hooks", hook.getId()); Response response = put(Response.Status.OK, formData.asMap(), "projects", hook.getProjectId(), "hooks", hook.getId());
return (response.getEntity(ProjectHook.class)); return (response.readEntity(ProjectHook.class));
} }
} }
package com.messners.gitlab.api; package com.messners.gitlab.api;
import java.util.List;
import com.messners.gitlab.api.models.Branch; import com.messners.gitlab.api.models.Branch;
import com.messners.gitlab.api.models.Tag; import com.messners.gitlab.api.models.Tag;
import com.messners.gitlab.api.models.TreeItem; import com.messners.gitlab.api.models.TreeItem;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType; import javax.ws.rs.core.Form;
import com.sun.jersey.api.representation.Form; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.util.List;
/** /**
...@@ -32,8 +32,8 @@ public class RepositoryApi extends AbstractApi { ...@@ -32,8 +32,8 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Branch> getBranches (Integer projectId) throws GitLabApiException { public List<Branch> getBranches (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "repository", "branches"); Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "branches");
return (response.getEntity(new GenericType<List<Branch>>() {})); return (response.readEntity(new GenericType<List<Branch>>() {}));
} }
...@@ -48,8 +48,8 @@ public class RepositoryApi extends AbstractApi { ...@@ -48,8 +48,8 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Branch getBranch (Integer projectId, String branchName) throws GitLabApiException { public Branch getBranch (Integer projectId, String branchName) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "repository", "branches", branchName); Response response = get(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName);
return (response.getEntity(Branch.class)); return (response.readEntity(Branch.class));
} }
...@@ -66,10 +66,10 @@ public class RepositoryApi extends AbstractApi { ...@@ -66,10 +66,10 @@ public class RepositoryApi extends AbstractApi {
*/ */
public Branch createBranch (Integer projectId, String branchName, String ref) throws GitLabApiException { public Branch createBranch (Integer projectId, String branchName, String ref) throws GitLabApiException {
Form formData = new Form(); Form formData = new Form();
formData.add("branch_name ", branchName); formData.param("branch_name ", branchName);
formData.add("ref ", ref); formData.param("ref ", ref);
ClientResponse response = post(ClientResponse.Status.OK, formData, "projects", projectId, "repository", "branches"); Response response = post(Response.Status.OK, formData, "projects", projectId, "repository", "branches");
return (response.getEntity(Branch.class)); return (response.readEntity(Branch.class));
} }
...@@ -85,8 +85,8 @@ public class RepositoryApi extends AbstractApi { ...@@ -85,8 +85,8 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Branch protectBranch (Integer projectId, String branchName) throws GitLabApiException { public Branch protectBranch (Integer projectId, String branchName) throws GitLabApiException {
ClientResponse response = put(ClientResponse.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "protect"); Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "protect");
return (response.getEntity(Branch.class)); return (response.readEntity(Branch.class));
} }
...@@ -102,8 +102,8 @@ public class RepositoryApi extends AbstractApi { ...@@ -102,8 +102,8 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public Branch unprotectBranch (Integer projectId, String branchName) throws GitLabApiException { public Branch unprotectBranch (Integer projectId, String branchName) throws GitLabApiException {
ClientResponse response = put(ClientResponse.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "unprotect"); Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "branches", branchName, "unprotect");
return (response.getEntity(Branch.class)); return (response.readEntity(Branch.class));
} }
...@@ -117,8 +117,8 @@ public class RepositoryApi extends AbstractApi { ...@@ -117,8 +117,8 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<Tag> getTags (Integer projectId) throws GitLabApiException { public List<Tag> getTags (Integer projectId) throws GitLabApiException {
ClientResponse response = put(ClientResponse.Status.OK, null, "projects", projectId, "repository", "tags"); Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "tags");
return (response.getEntity(new GenericType<List<Tag>>() {})); return (response.readEntity(new GenericType<List<Tag>>() {}));
} }
...@@ -132,8 +132,8 @@ public class RepositoryApi extends AbstractApi { ...@@ -132,8 +132,8 @@ public class RepositoryApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<TreeItem> getTree (Integer projectId) throws GitLabApiException { public List<TreeItem> getTree (Integer projectId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "projects", projectId, "repository", "tree"); Response response = put(Response.Status.OK, null, "projects", projectId, "repository", "tree");
return (response.getEntity(new GenericType<List<TreeItem>>() {})); return (response.readEntity(new GenericType<List<TreeItem>>() {}));
} }
...@@ -151,7 +151,7 @@ public class RepositoryApi extends AbstractApi { ...@@ -151,7 +151,7 @@ public class RepositoryApi extends AbstractApi {
Form formData = new Form(); Form formData = new Form();
addFormParam(formData, "filepath", filepath, true); addFormParam(formData, "filepath", filepath, true);
ClientResponse response = get(ClientResponse.Status.OK, formData, "projects", projectId, "repository", "blobs", commitOrBranchName); Response response = get(Response.Status.OK, formData.asMap(), "projects", projectId, "repository", "blobs", commitOrBranchName);
return (response.getEntity(String.class)); return (response.readEntity(String.class));
} }
} }
package com.messners.gitlab.api; package com.messners.gitlab.api;
import com.messners.gitlab.api.models.Session; import com.messners.gitlab.api.models.Session;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.representation.Form; import javax.ws.rs.core.Form;
import javax.ws.rs.core.Response;
/** /**
...@@ -41,7 +42,7 @@ public class SessionApi extends AbstractApi { ...@@ -41,7 +42,7 @@ public class SessionApi extends AbstractApi {
addFormParam(formData, "password", password, true); addFormParam(formData, "password", password, true);
addFormParam(formData, "login", username, false); addFormParam(formData, "login", username, false);
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "session"); Response response = post(Response.Status.CREATED, formData, "session");
return (response.getEntity(Session.class)); return (response.readEntity(Session.class));
} }
} }
...@@ -6,9 +6,11 @@ import java.net.URL; ...@@ -6,9 +6,11 @@ import java.net.URL;
import java.util.List; import java.util.List;
import com.messners.gitlab.api.models.User; import com.messners.gitlab.api.models.User;
import com.sun.jersey.api.client.ClientResponse;
import com.sun.jersey.api.client.GenericType; import javax.ws.rs.core.Form;
import com.sun.jersey.api.representation.Form; import javax.ws.rs.core.GenericType;
import javax.ws.rs.core.Response;
import java.util.List;
public class UserApi extends AbstractApi { public class UserApi extends AbstractApi {
...@@ -26,8 +28,8 @@ public class UserApi extends AbstractApi { ...@@ -26,8 +28,8 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public List<User> getUsers () throws GitLabApiException { public List<User> getUsers () throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "users"); Response response = get(Response.Status.OK, null, "users");
return (response.getEntity(new GenericType<List<User>>() {})); return (response.readEntity(new GenericType<List<User>>() {}));
} }
...@@ -46,8 +48,8 @@ public class UserApi extends AbstractApi { ...@@ -46,8 +48,8 @@ public class UserApi extends AbstractApi {
Form formData = new Form(); Form formData = new Form();
addFormParam(formData, "page", page, false); addFormParam(formData, "page", page, false);
addFormParam(formData, "per_page", perPage, false); addFormParam(formData, "per_page", perPage, false);
ClientResponse response = get(ClientResponse.Status.OK, formData, "users"); Response response = get(Response.Status.OK, formData.asMap(), "users");
return (response.getEntity(new GenericType<List<User>>() {})); return (response.readEntity(new GenericType<List<User>>() {}));
} }
...@@ -61,8 +63,8 @@ public class UserApi extends AbstractApi { ...@@ -61,8 +63,8 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public User getUser (int userId) throws GitLabApiException { public User getUser (int userId) throws GitLabApiException {
ClientResponse response = get(ClientResponse.Status.OK, null, "users", userId); Response response = get(Response.Status.OK, null, "users", userId);
return (response.getEntity(User.class)); return (response.readEntity(User.class));
} }
// Search users by Email or username // Search users by Email or username
...@@ -88,8 +90,8 @@ public class UserApi extends AbstractApi { ...@@ -88,8 +90,8 @@ public class UserApi extends AbstractApi {
e.printStackTrace(); e.printStackTrace();
return null; return null;
} }
ClientResponse response = get(ClientResponse.Status.OK, null, url); Response response = get(Response.Status.OK, null, url);
return (response.getEntity(new GenericType<List<User>>() {})); return (response.readEntity(new GenericType<List<User>>() {}));
} }
/** /**
...@@ -117,28 +119,12 @@ public class UserApi extends AbstractApi { ...@@ -117,28 +119,12 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public User createUser (User user, String password, Integer projectsLimit) throws GitLabApiException { public User createUser (User user, String password, Integer projectsLimit) throws GitLabApiException {
Form formData = user2form(user, projectsLimit, password, true);
Form formData = new Form(); Response response = post(Response.Status.CREATED, formData, "users");
addFormParam(formData, "email", user.getEmail(), true); return (response.readEntity(User.class));
addFormParam(formData, "password", password, true);
addFormParam(formData, "username", user.getUsername(), true);
addFormParam(formData, "name", user.getName(), true);
addFormParam(formData, "skype", user.getSkype(), false);
addFormParam(formData, "linkedin", user.getLinkedin(), false);
addFormParam(formData, "twitter", user.getTwitter(), false);
addFormParam(formData, "website_url", user.getWebsiteUrl(), false);
addFormParam(formData, "projects_limit", projectsLimit, false);
addFormParam(formData, "extern_uid", user.getExternUid(), false);
addFormParam(formData, "provider", user.getProvider(), false);
addFormParam(formData, "bio", user.getBio(), false);
addFormParam(formData, "admin", user.getIsAdmin(), false);
addFormParam(formData, "can_create_group", user.getCanCreateGroup(), false);
ClientResponse response = post(ClientResponse.Status.CREATED, formData, "users");
return (response.getEntity(User.class));
} }
/** /**
* Modifies an existing user. Only administrators can change attributes of a user. * Modifies an existing user. Only administrators can change attributes of a user.
* *
...@@ -164,25 +150,9 @@ public class UserApi extends AbstractApi { ...@@ -164,25 +150,9 @@ public class UserApi extends AbstractApi {
* @throws GitLabApiException * @throws GitLabApiException
*/ */
public User modifyUser (User user, String password, Integer projectsLimit) throws GitLabApiException { public User modifyUser (User user, String password, Integer projectsLimit) throws GitLabApiException {
Form form = user2form(user, projectsLimit, password, false);
Form formData = new Form(); Response response = put(Response.Status.OK, form.asMap(), "users", user.getId());
addFormParam(formData, "email", user.getEmail(), false); return (response.readEntity(User.class));
addFormParam(formData, "password", password, false);
addFormParam(formData, "username", user.getUsername(), false);
addFormParam(formData, "name", user.getName(), false);
addFormParam(formData, "skype", user.getSkype(), false);
addFormParam(formData, "linkedin", user.getLinkedin(), false);
addFormParam(formData, "twitter", user.getTwitter(), false);
addFormParam(formData, "website_url", user.getWebsiteUrl(), false);
addFormParam(formData, "projects_limit", projectsLimit, false);
addFormParam(formData, "extern_uid", user.getExternUid(), false);
addFormParam(formData, "provider", user.getProvider(), false);
addFormParam(formData, "bio", user.getBio(), false);
addFormParam(formData, "admin", user.getIsAdmin(), false);
addFormParam(formData, "can_create_group", user.getCanCreateGroup(), false);
ClientResponse response = put(ClientResponse.Status.OK, formData, "users", user.getId());
return (response.getEntity(User.class));
} }
...@@ -200,7 +170,7 @@ public class UserApi extends AbstractApi { ...@@ -200,7 +170,7 @@ public class UserApi extends AbstractApi {
throw new RuntimeException("userId cannot be null"); throw new RuntimeException("userId cannot be null");
} }
delete(ClientResponse.Status.OK, null, "users", userId); delete(Response.Status.OK, null, "users", userId);
} }
...@@ -215,4 +185,23 @@ public class UserApi extends AbstractApi { ...@@ -215,4 +185,23 @@ public class UserApi extends AbstractApi {
public void deleteUser (User user) throws GitLabApiException { public void deleteUser (User user) throws GitLabApiException {
deleteUser(user.getId()); deleteUser(user.getId());
} }
private Form user2form(User user, Integer projectsLimit, String password, boolean isCreate) {
Form form = new Form();
addFormParam(form, "email", user.getEmail(), isCreate);
addFormParam(form, "password", password, isCreate);
addFormParam(form, "username", user.getUsername(), isCreate);
addFormParam(form, "name", user.getName(), isCreate);
addFormParam(form, "skype", user.getSkype(), false);
addFormParam(form, "linkedin", user.getLinkedin(), false);
addFormParam(form, "twitter", user.getTwitter(), false);
addFormParam(form, "website_url", user.getWebsiteUrl(), false);
addFormParam(form, "projects_limit", projectsLimit, false);
addFormParam(form, "extern_uid", user.getExternUid(), false);
addFormParam(form, "provider", user.getProvider(), false);
addFormParam(form, "bio", user.getBio(), false);
addFormParam(form, "admin", user.getIsAdmin(), false);
addFormParam(form, "can_create_group", user.getCanCreateGroup(), false);
return form;
}
} }
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