diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-10 14:35:50 +0200 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2014-07-10 14:35:50 +0200 |
commit | 90ab387cdeda985e987d1eac3764896049e94011 (patch) | |
tree | 857a137415ab91603c37cf82a6d74645f4bc6e76 /sonar-ws-client/src/main | |
parent | c4ddca5b55f3cbe21235cb7ee6f3ea3e2bbae128 (diff) | |
download | sonarqube-90ab387cdeda985e987d1eac3764896049e94011.tar.gz sonarqube-90ab387cdeda985e987d1eac3764896049e94011.zip |
Move sonar-ws-client to sub-dir server/
Diffstat (limited to 'sonar-ws-client/src/main')
169 files changed, 0 insertions, 12239 deletions
diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/Host.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/Host.java deleted file mode 100644 index f88861eb9d7..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/Host.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient; - -public class Host { - - private String host; - private String username; - private String password; - - public Host(String host) { - this.host = host; - } - - public Host(String host, String username, String password) { - this.host = host; - this.username = username; - this.password = password; - } - - public String getHost() { - return host; - } - - public Host setHost(String host) { - this.host = host; - return this; - } - - public String getUsername() { - return username; - } - - public Host setUsername(String username) { - this.username = username; - return this; - } - - public String getPassword() { - return password; - } - - public Host setPassword(String password) { - this.password = password; - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java deleted file mode 100644 index dc424d78bf9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/JdkUtils.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient; - -import org.json.simple.JSONObject; -import org.json.simple.JSONValue; -import org.sonar.wsclient.services.WSUtils; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.Set; - -public final class JdkUtils extends WSUtils { - - @Override - public String format(Date date, String format) { - SimpleDateFormat dateFormat = new SimpleDateFormat(format); - return dateFormat.format(date); - } - - @Override - public String encodeUrl(String url) { - try { - return URLEncoder.encode(url, "UTF-8"); - - } catch (UnsupportedEncodingException e) { - throw new IllegalStateException("Encoding not supported", e); - } - } - - @Override - public Object getField(Object json, String field) { - return ((JSONObject) json).get(field); - } - - @Override - @CheckForNull - public String getString(Object json, String field) { - return JsonUtils.getString((JSONObject) json, field); - } - - @Override - @CheckForNull - public Boolean getBoolean(Object json, String field) { - return JsonUtils.getBoolean((JSONObject) json, field); - } - - @Override - @CheckForNull - public Integer getInteger(Object json, String field) { - return JsonUtils.getInteger((JSONObject) json, field); - } - - @Override - @CheckForNull - public Double getDouble(Object json, String field) { - return JsonUtils.getDouble((JSONObject) json, field); - } - - @Override - @CheckForNull - public Long getLong(Object json, String field) { - return JsonUtils.getLong((JSONObject) json, field); - } - - @Override - @CheckForNull - public Date getDateTime(Object json, String field) { - return JsonUtils.getDateTime((JSONObject) json, field); - } - - @Override - public int getArraySize(Object array) { - return ((ArrayList) array).size(); - } - - @Override - public Object getArrayElement(Object array, int i) { - return ((ArrayList) array).get(i); - } - - @Override - public Object parse(String jsonStr) { - return JSONValue.parse(jsonStr); - } - - @Override - public Set<String> getFields(Object json) { - return ((JSONObject) json).keySet(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java deleted file mode 100644 index a6f52c71c97..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/Sonar.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient; - -import org.sonar.wsclient.connectors.Connector; -import org.sonar.wsclient.connectors.ConnectorFactory; -import org.sonar.wsclient.services.*; -import org.sonar.wsclient.unmarshallers.UnmarshalException; -import org.sonar.wsclient.unmarshallers.Unmarshaller; -import org.sonar.wsclient.unmarshallers.Unmarshallers; - -import java.util.Collections; -import java.util.List; - -public class Sonar { - - static { - WSUtils.setInstance(new JdkUtils()); - } - - private Connector connector; - - public Sonar(Connector connector) { - this.connector = connector; - } - - public Connector getConnector() { - return connector; - } - - public <M extends Model> M find(Query<M> query) { - String json = connector.execute(query); - M result = null; - if (json != null) { - try { - Unmarshaller<M> unmarshaller = Unmarshallers.forModel(query.getModelClass()); - result = unmarshaller.toModel(json); - } catch (Exception e) { - throw new UnmarshalException(query, json, e); - } - } - return result; - } - - public <M extends Model> List<M> findAll(Query<M> query) { - String json = connector.execute(query); - List<M> result; - if (json == null) { - result = Collections.emptyList(); - } else { - try { - Unmarshaller<M> unmarshaller = Unmarshallers.forModel(query.getModelClass()); - result = unmarshaller.toModels(json); - } catch (Exception e) { - throw new UnmarshalException(query, json, e); - } - } - return result; - } - - public <M extends Model> M create(CreateQuery<M> query) { - String json = connector.execute(query); - M result = null; - if (json != null) { - try { - Unmarshaller<M> unmarshaller = Unmarshallers.forModel(query.getModelClass()); - result = unmarshaller.toModel(json); - } catch (Exception e) { - throw new UnmarshalException(query, json, e); - } - } - return result; - } - - public void update(UpdateQuery<?> query) { - connector.execute(query); - } - - public void delete(DeleteQuery query) { - connector.execute(query); - } - - public static Sonar create(String host) { - return new Sonar(ConnectorFactory.create(new Host(host))); - } - - public static Sonar create(String host, String username, String password) { - return new Sonar(ConnectorFactory.create(new Host(host, username, password))); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java deleted file mode 100644 index 0a7275151b2..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java +++ /dev/null @@ -1,222 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient; - -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.issue.ActionPlanClient; -import org.sonar.wsclient.issue.IssueClient; -import org.sonar.wsclient.issue.internal.DefaultActionPlanClient; -import org.sonar.wsclient.issue.internal.DefaultIssueClient; -import org.sonar.wsclient.permissions.PermissionClient; -import org.sonar.wsclient.permissions.internal.DefaultPermissionClient; -import org.sonar.wsclient.project.ProjectClient; -import org.sonar.wsclient.project.internal.DefaultProjectClient; -import org.sonar.wsclient.qprofile.QProfileClient; -import org.sonar.wsclient.qprofile.internal.DefaultQProfileClient; -import org.sonar.wsclient.qualitygate.QualityGateClient; -import org.sonar.wsclient.qualitygate.internal.DefaultQualityGateClient; -import org.sonar.wsclient.system.SystemClient; -import org.sonar.wsclient.system.internal.DefaultSystemClient; -import org.sonar.wsclient.user.UserClient; -import org.sonar.wsclient.user.internal.DefaultUserClient; - -import javax.annotation.Nullable; - -/** - * Entry point of the Java Client for Sonar Web Services. It does not support all web services yet. - * <p/> - * Example: - * <pre> - * SonarClient client = SonarClient.create("http://localhost:9000"); - * IssueClient issueClient = client.issueClient(); - * </pre> - * - * @since 3.6 - */ -public class SonarClient { - - public static final int DEFAULT_CONNECT_TIMEOUT_MILLISECONDS = 30000; - public static final int DEFAULT_READ_TIMEOUT_MILLISECONDS = 60000; - - /** - * Visibility relaxed for unit tests - */ - final HttpRequestFactory requestFactory; - - private SonarClient(Builder builder) { - requestFactory = new HttpRequestFactory(builder.url) - .setLogin(builder.login) - .setPassword(builder.password) - .setProxyHost(builder.proxyHost) - .setProxyPort(builder.proxyPort) - .setProxyLogin(builder.proxyLogin) - .setProxyPassword(builder.proxyPassword) - .setConnectTimeoutInMilliseconds(builder.connectTimeoutMs) - .setReadTimeoutInMilliseconds(builder.readTimeoutMs); - } - - /** - * New client to interact with web services related to issues - */ - public IssueClient issueClient() { - return new DefaultIssueClient(requestFactory); - } - - /** - * New client to interact with web services related to issue action plans - */ - public ActionPlanClient actionPlanClient() { - return new DefaultActionPlanClient(requestFactory); - } - - /** - * New client to interact with web services related to users - */ - public UserClient userClient() { - return new DefaultUserClient(requestFactory); - } - - /** - * New client to interact with web services related to users and groups permissions - */ - public PermissionClient permissionClient() { - return new DefaultPermissionClient(requestFactory); - } - - /** - * New client to interact with web services related to projects - */ - public ProjectClient projectClient() { - return new DefaultProjectClient(requestFactory); - } - - /** - * New client to interact with web services related to quality gates - */ - public QualityGateClient qualityGateClient() { - return new DefaultQualityGateClient(requestFactory); - } - - /** - * New client to interact with web services related to quality profilesgates - */ - public QProfileClient qProfileClient() { - return new DefaultQProfileClient(requestFactory); - } - - public SystemClient systemClient() { - return new DefaultSystemClient(requestFactory); - } - - /** - * Create a builder of {@link SonarClient}s. - */ - public static Builder builder() { - return new Builder(); - } - - /** - * Create a client with default configuration. Use {@link #builder()} to define - * a custom configuration (credentials, HTTP proxy, HTTP timeouts). - */ - public static SonarClient create(String serverUrl) { - return builder().url(serverUrl).build(); - } - - public static class Builder { - private String login, password, url, proxyHost, proxyLogin, proxyPassword; - private int proxyPort = 0; - private int connectTimeoutMs = DEFAULT_CONNECT_TIMEOUT_MILLISECONDS, readTimeoutMs = DEFAULT_READ_TIMEOUT_MILLISECONDS; - - private Builder() { - } - - /** - * Mandatory HTTP server URL, eg "http://localhost:9000" - */ - public Builder url(String url) { - this.url = url; - return this; - } - - /** - * Optional login, for example "admin" - */ - public Builder login(@Nullable String login) { - this.login = login; - return this; - } - - /** - * Optional password related to {@link #login(String)}, for example "admin" - */ - public Builder password(@Nullable String password) { - this.password = password; - return this; - } - - /** - * Host and port of the optional HTTP proxy - */ - public Builder proxy(@Nullable String proxyHost, int proxyPort) { - this.proxyHost = proxyHost; - this.proxyPort = proxyPort; - return this; - } - - public Builder proxyLogin(@Nullable String proxyLogin) { - this.proxyLogin = proxyLogin; - return this; - } - - public Builder proxyPassword(@Nullable String proxyPassword) { - this.proxyPassword = proxyPassword; - return this; - } - - /** - * Sets a specified timeout value, in milliseconds, to be used when opening HTTP connection. - * A timeout of zero is interpreted as an infinite timeout. Default value is {@link SonarClient#DEFAULT_CONNECT_TIMEOUT_MILLISECONDS} - */ - public Builder connectTimeoutMilliseconds(int i) { - this.connectTimeoutMs = i; - return this; - } - - /** - * Sets the read timeout to a specified timeout, in milliseconds. - * A timeout of zero is interpreted as an infinite timeout. Default value is {@link SonarClient#DEFAULT_READ_TIMEOUT_MILLISECONDS} - */ - public Builder readTimeoutMilliseconds(int i) { - this.readTimeoutMs = i; - return this; - } - - /** - * Build a new client - */ - public SonarClient build() { - if (url == null || "".equals(url)) { - throw new IllegalStateException("Server URL must be set"); - } - return new SonarClient(this); - } - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/base/HttpException.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/base/HttpException.java deleted file mode 100644 index 756f8f22727..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/base/HttpException.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.base; - -/** - * @since 3.6 - */ -public class HttpException extends RuntimeException { - - private final String url; - private final int status; - - public HttpException(String url, int status) { - super(String.format("Error %d on %s", status, url)); - this.url = url; - this.status = status; - } - - public String url() { - return url; - } - - public int status() { - return status; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/base/Paging.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/base/Paging.java deleted file mode 100644 index 654b5938188..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/base/Paging.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.base; - -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.Map; - -/** - * @since 3.6 - */ -public class Paging { - - private final Map json; - - /** - * For internal use - */ - public Paging(Map json) { - this.json = json; - } - - public Integer pageSize() { - return JsonUtils.getInteger(json, "pageSize"); - } - - public Integer pageIndex() { - return JsonUtils.getInteger(json, "pageIndex"); - } - - public Integer total() { - return JsonUtils.getInteger(json, "total"); - } - - public Integer pages() { - return JsonUtils.getInteger(json, "pages"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/base/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/base/package-info.java deleted file mode 100644 index 201a7d382ce..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/base/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.base; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/component/Component.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/component/Component.java deleted file mode 100644 index 686799a68ac..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/component/Component.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.component; - -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; - -import java.util.Map; - -public class Component { - private final Map json; - - public Component(Map json) { - this.json = json; - } - - public String qualifier() { - return JsonUtils.getString(json, "qualifier"); - } - - public String key() { - return JsonUtils.getString(json, "key"); - } - - /** - * @since 4.2 - */ - public Long id() { - return JsonUtils.getLong(json, "id"); - } - - public String name() { - return JsonUtils.getString(json, "name"); - } - - @CheckForNull - public String longName() { - return JsonUtils.getString(json, "longName"); - } - - /** - * @since 4.2 - */ - @CheckForNull - public Long subProjectId() { - return JsonUtils.getLong(json, "subProjectId"); - } - - /** - * @since 4.2 - */ - @CheckForNull - public Long projectId() { - return JsonUtils.getLong(json, "projectId"); - } - - /** - * @since 4.2 - */ - @CheckForNull - public String path() { - return JsonUtils.getString(json, "path"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/component/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/component/package-info.java deleted file mode 100644 index 5634254c057..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/component/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.component; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/ConnectionException.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/ConnectionException.java deleted file mode 100644 index 6b4a5c590cf..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/ConnectionException.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.connectors; - -public class ConnectionException extends RuntimeException { - public ConnectionException() { - } - - public ConnectionException(String s) { - super(s); - } - - public ConnectionException(String s, Throwable throwable) { - super(s, throwable); - } - - public ConnectionException(Throwable throwable) { - super(throwable); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java deleted file mode 100644 index d19bfa17a4c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/Connector.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.connectors; - -import org.sonar.wsclient.services.CreateQuery; -import org.sonar.wsclient.services.DeleteQuery; -import org.sonar.wsclient.services.Query; -import org.sonar.wsclient.services.UpdateQuery; - -/** - * @since 2.1 - */ -public abstract class Connector { - - /** - * @return JSON response or null if 404 NOT FOUND error - * @throws ConnectionException if connection error or HTTP status not in (200, 404) - */ - public abstract String execute(Query<?> query); - - /** - * @return JSON response or null if 404 NOT FOUND error - * @since 2.2 - */ - public abstract String execute(CreateQuery<?> query); - - /** - * @return JSON response or null if 404 NOT FOUND error - * @since 2.2 - */ - public abstract String execute(DeleteQuery query); - - /** - * @return JSON response or null if 404 NOT FOUND error - * @since 2.6 - */ - public abstract String execute(UpdateQuery<?> query); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/ConnectorFactory.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/ConnectorFactory.java deleted file mode 100644 index e0e0f76a8ad..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/ConnectorFactory.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.connectors; - -import org.sonar.wsclient.Host; - -public final class ConnectorFactory { - - private ConnectorFactory() { - } - - public static Connector create(Host server) { - return new HttpClient3Connector(server); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java deleted file mode 100644 index 0cec3ab0251..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient3Connector.java +++ /dev/null @@ -1,195 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.connectors; - -import org.apache.commons.httpclient.*; -import org.apache.commons.httpclient.auth.AuthScope; -import org.apache.commons.httpclient.methods.*; -import org.apache.commons.httpclient.params.HttpConnectionManagerParams; -import org.sonar.wsclient.Host; -import org.sonar.wsclient.services.*; - -import java.io.*; - -/** - * @since 2.1 - */ -public class HttpClient3Connector extends Connector { - - private static final int MAX_TOTAL_CONNECTIONS = 40; - private static final int MAX_HOST_CONNECTIONS = 4; - - private final Host server; - private HttpClient httpClient; - - public HttpClient3Connector(final Host server) { - this.server = server; - createClient(); - } - - public HttpClient3Connector(Host server, HttpClient httpClient) { - this.httpClient = httpClient; - this.server = server; - } - - private void createClient() { - final HttpConnectionManagerParams params = new HttpConnectionManagerParams(); - params.setConnectionTimeout(AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); - params.setSoTimeout(AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); - params.setDefaultMaxConnectionsPerHost(MAX_HOST_CONNECTIONS); - params.setMaxTotalConnections(MAX_TOTAL_CONNECTIONS); - final MultiThreadedHttpConnectionManager connectionManager = new MultiThreadedHttpConnectionManager(); - connectionManager.setParams(params); - this.httpClient = new HttpClient(connectionManager); - configureCredentials(); - } - - private void configureCredentials() { - if (server.getUsername() != null) { - httpClient.getParams().setAuthenticationPreemptive(true); - Credentials defaultcreds = new UsernamePasswordCredentials(server.getUsername(), server.getPassword()); - httpClient.getState().setCredentials(AuthScope.ANY, defaultcreds); - } - } - - /** - * @since 3.4 - */ - public HttpClient getHttpClient() { - return httpClient; - } - - @Override - public String execute(Query<?> query) { - return executeRequest(newGetRequest(query)); - } - - @Override - public String execute(CreateQuery<?> query) { - return executeRequest(newPostRequest(query)); - } - - @Override - public String execute(UpdateQuery<?> query) { - return executeRequest(newPutRequest(query)); - } - - @Override - public String execute(DeleteQuery query) { - return executeRequest(newDeleteRequest(query)); - } - - private String executeRequest(HttpMethodBase method) { - String json = null; - try { - httpClient.executeMethod(method); - - if (method.getStatusCode() == HttpStatus.SC_OK) { - json = getResponseBodyAsString(method); - - } else if (method.getStatusCode() != HttpStatus.SC_NOT_FOUND) { - throw new ConnectionException("HTTP error: " + method.getStatusCode() + ", msg: " + method.getStatusText() + ", query: " + method); - } - - } catch (HttpException e) { - throw new ConnectionException("Query: " + method, e); - - } catch (IOException e) { - throw new ConnectionException("Query: " + method, e); - - } finally { - if (method != null) { - method.releaseConnection(); - } - } - return json; - } - - private HttpMethodBase newGetRequest(Query<?> query) { - HttpMethodBase method = new GetMethod(server.getHost() + query.getUrl()); - initRequest(method, query); - return method; - } - - private HttpMethodBase newDeleteRequest(DeleteQuery query) { - HttpMethodBase method = new DeleteMethod(server.getHost() + query.getUrl()); - initRequest(method, query); - return method; - } - - private HttpMethodBase newPostRequest(CreateQuery<?> query) { - PostMethod method = new PostMethod(server.getHost() + query.getUrl()); - initRequest(method, query); - setRequestEntity(method, query); - return method; - } - - private HttpMethodBase newPutRequest(UpdateQuery<?> query) { - PutMethod method = new PutMethod(server.getHost() + query.getUrl()); - initRequest(method, query); - setRequestEntity(method, query); - return method; - } - - private void setRequestEntity(EntityEnclosingMethod request, AbstractQuery<?> query) { - if (query.getBody() != null) { - try { - request.setRequestEntity(new StringRequestEntity(query.getBody(), "text/plain; charset=UTF-8", "UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new ConnectionException("Unsupported encoding", e); - } - } - } - - private void initRequest(HttpMethodBase request, AbstractQuery query) { - request.setRequestHeader("Accept", "application/json"); - if (query.getLocale() != null) { - request.setRequestHeader("Accept-Language", query.getLocale()); - } - request.getParams().setSoTimeout(query.getTimeoutMilliseconds()); - } - - private String getResponseBodyAsString(HttpMethod method) { - BufferedReader reader = null; - try { - final InputStream inputStream = method.getResponseBodyAsStream(); - reader = new BufferedReader(new InputStreamReader(inputStream)); - final StringBuilder sb = new StringBuilder(); - String line; - - while ((line = reader.readLine()) != null) { - sb.append(line).append("\n"); - } - return sb.toString(); - - } catch (IOException e) { - throw new ConnectionException("Can not read response", e); - - } finally { - if (reader != null) { - try { - reader.close(); - } catch (Exception e) { - // wsclient does not have logging ability -> silently ignore - } - } - } - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java deleted file mode 100644 index 8fa546978d9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/HttpClient4Connector.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.connectors; - -import org.apache.http.HttpEntity; -import org.apache.http.HttpException; -import org.apache.http.HttpHost; -import org.apache.http.HttpRequest; -import org.apache.http.HttpRequestInterceptor; -import org.apache.http.HttpResponse; -import org.apache.http.HttpStatus; -import org.apache.http.auth.AuthScheme; -import org.apache.http.auth.AuthScope; -import org.apache.http.auth.AuthState; -import org.apache.http.auth.Credentials; -import org.apache.http.auth.UsernamePasswordCredentials; -import org.apache.http.client.CredentialsProvider; -import org.apache.http.client.methods.HttpDelete; -import org.apache.http.client.methods.HttpEntityEnclosingRequestBase; -import org.apache.http.client.methods.HttpGet; -import org.apache.http.client.methods.HttpPost; -import org.apache.http.client.methods.HttpPut; -import org.apache.http.client.methods.HttpRequestBase; -import org.apache.http.client.protocol.ClientContext; -import org.apache.http.entity.StringEntity; -import org.apache.http.impl.auth.BasicScheme; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.params.HttpConnectionParams; -import org.apache.http.params.HttpParams; -import org.apache.http.protocol.BasicHttpContext; -import org.apache.http.protocol.ExecutionContext; -import org.apache.http.protocol.HttpContext; -import org.apache.http.util.EntityUtils; -import org.sonar.wsclient.Host; -import org.sonar.wsclient.services.AbstractQuery; -import org.sonar.wsclient.services.CreateQuery; -import org.sonar.wsclient.services.DeleteQuery; -import org.sonar.wsclient.services.Query; -import org.sonar.wsclient.services.UpdateQuery; - -import java.io.IOException; -import java.io.UnsupportedEncodingException; - -/** - * @since 2.1 - */ -public class HttpClient4Connector extends Connector { - - private Host server; - private DefaultHttpClient client; - - public HttpClient4Connector(Host server) { - this.server = server; - initClient(); - } - - public DefaultHttpClient getHttpClient() { - return client; - } - - @Override - public String execute(Query<?> query) { - return executeRequest(newGetMethod(query)); - } - - @Override - public String execute(CreateQuery<?> query) { - return executeRequest(newPostMethod(query)); - } - - @Override - public String execute(UpdateQuery<?> query) { - return executeRequest(newPutMethod(query)); - } - - @Override - public String execute(DeleteQuery query) { - return executeRequest(newDeleteMethod(query)); - } - - private String executeRequest(HttpRequestBase request) { - String json = null; - try { - BasicHttpContext context = createLocalContext(client); - HttpResponse response = client.execute(request, context); - HttpEntity entity = response.getEntity(); - if (entity != null) { - if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) { - json = EntityUtils.toString(entity); - - } else if (response.getStatusLine().getStatusCode() != HttpStatus.SC_NOT_FOUND) { - throw new ConnectionException("HTTP error: " + response.getStatusLine().getStatusCode() - + ", msg: " + response.getStatusLine().getReasonPhrase() - + ", query: " + request.toString()); - } - } - - } catch (IOException e) { - throw new ConnectionException("Query: " + request.getURI(), e); - - } finally { - request.releaseConnection(); - } - return json; - } - - public void close() { - if (client != null) { - client.getConnectionManager().shutdown(); - } - } - - private void initClient() { - client = new DefaultHttpClient(); - HttpParams params = client.getParams(); - HttpConnectionParams.setConnectionTimeout(params, AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); - HttpConnectionParams.setSoTimeout(params, AbstractQuery.DEFAULT_TIMEOUT_MILLISECONDS); - if (server.getUsername() != null) { - client.getCredentialsProvider() - .setCredentials(AuthScope.ANY, new UsernamePasswordCredentials(server.getUsername(), server.getPassword())); - } - } - - private BasicHttpContext createLocalContext(DefaultHttpClient client) { - BasicHttpContext localcontext = new BasicHttpContext(); - - if (server.getUsername() != null) { - // Generate BASIC scheme object and stick it to the local - // execution context - BasicScheme basicAuth = new BasicScheme(); - localcontext.setAttribute(PreemptiveAuth.ATTRIBUTE, basicAuth); - - // Add as the first request interceptor - client.addRequestInterceptor(new PreemptiveAuth(), 0); - } - return localcontext; - } - - private HttpGet newGetMethod(Query<?> query) { - HttpGet get = new HttpGet(server.getHost() + query.getUrl()); - initRequest(get, query); - return get; - } - - private HttpDelete newDeleteMethod(DeleteQuery query) { - HttpDelete delete = new HttpDelete(server.getHost() + query.getUrl()); - initRequest(delete, query); - return delete; - } - - private HttpPost newPostMethod(CreateQuery<?> query) { - HttpPost post = new HttpPost(server.getHost() + query.getUrl()); - initRequest(post, query); - setRequestEntity(post, query); - return post; - } - - private HttpPut newPutMethod(UpdateQuery<?> query) { - HttpPut put = new HttpPut(server.getHost() + query.getUrl()); - initRequest(put, query); - setRequestEntity(put, query); - return put; - } - - private void setRequestEntity(HttpEntityEnclosingRequestBase request, AbstractQuery<?> query) { - if (query.getBody() != null) { - try { - request.setEntity(new StringEntity(query.getBody(), "UTF-8")); - } catch (UnsupportedEncodingException e) { - throw new ConnectionException("Encoding is not supported", e); - } - } - } - - private void initRequest(HttpRequestBase request, AbstractQuery query) { - request.setHeader("Accept", "application/json"); - if (query.getLocale() != null) { - request.setHeader("Accept-Language", query.getLocale()); - } - request.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, query.getTimeoutMilliseconds()); - request.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, query.getTimeoutMilliseconds()); - } - - static final class PreemptiveAuth implements HttpRequestInterceptor { - - static final String ATTRIBUTE = "preemptive-auth"; - - public void process( - final HttpRequest request, - final HttpContext context) throws HttpException { - - AuthState authState = (AuthState) context.getAttribute(ClientContext.TARGET_AUTH_STATE); - - // If no auth scheme available yet, try to initialize it preemptively - if (authState.getAuthScheme() == null) { - AuthScheme authScheme = (AuthScheme) context.getAttribute(ATTRIBUTE); - CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute(ClientContext.CREDS_PROVIDER); - HttpHost targetHost = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST); - if (authScheme != null) { - Credentials creds = credsProvider.getCredentials( - new AuthScope( - targetHost.getHostName(), - targetHost.getPort())); - if (creds == null) { - throw new HttpException("No credentials for preemptive authentication"); - } - authState.setAuthScheme(authScheme); - authState.setCredentials(creds); - } - } - } - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/package-info.java deleted file mode 100644 index 06f909fc7d6..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/connectors/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.connectors; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java deleted file mode 100644 index 8516b293634..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/EncodingUtils.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.internal; - -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.LinkedHashMap; -import java.util.Map; - -/** - * Not an API. Please do not use this class, except maybe for unit tests. - */ -public class EncodingUtils { - - private static final String DATETIME_FORMAT = "yyyy-MM-dd'T'HH:mm:ssZ"; - private static final String DATE_FORMAT = "yyyy-MM-dd"; - - private EncodingUtils() { - // only static methods - } - - public static Map<String, Object> toMap(String... array) { - if (array.length%2==1) { - throw new IllegalArgumentException("Not an even number of arguments"); - } - Map<String, Object> map = new LinkedHashMap<String, Object>(); - for (int i = 0; i < array.length; i += 2) { - Object value = array[i + 1]; - if (value != null) { - map.put(array[i], array[i + 1]); - } - } - return map; - } - - public static String toQueryParam(String[] strings) { - StringBuilder sb = new StringBuilder(); - boolean first = true; - for (String string : strings) { - if (!first) { - sb.append(','); - } - sb.append(string); - first = false; - } - return sb.toString(); - } - - public static String toQueryParam(Date d, boolean includeTime) { - String format = includeTime ? DATETIME_FORMAT : DATE_FORMAT; - SimpleDateFormat dateFormat = new SimpleDateFormat(format); - return dateFormat.format(d); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java deleted file mode 100644 index a6f43be762e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/HttpRequestFactory.java +++ /dev/null @@ -1,172 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.internal; - -import com.github.kevinsawicki.http.HttpRequest; -import org.sonar.wsclient.base.HttpException; - -import javax.annotation.Nullable; -import java.util.Arrays; -import java.util.Map; - -import static java.net.HttpURLConnection.*; - -/** - * Not an API. Please do not use this class, except maybe for unit tests. - */ -public class HttpRequestFactory { - - private static final int[] RESPONSE_SUCCESS = {HTTP_OK, HTTP_CREATED, HTTP_NO_CONTENT}; - - private final String baseUrl; - private String login, password, proxyHost, proxyLogin, proxyPassword; - private int proxyPort; - private int connectTimeoutInMilliseconds; - private int readTimeoutInMilliseconds; - - public HttpRequestFactory(String baseUrl) { - this.baseUrl = baseUrl; - } - - public HttpRequestFactory setLogin(@Nullable String login) { - this.login = login; - return this; - } - - public HttpRequestFactory setPassword(@Nullable String password) { - this.password = password; - return this; - } - - public HttpRequestFactory setProxyHost(@Nullable String proxyHost) { - this.proxyHost = proxyHost; - return this; - } - - public HttpRequestFactory setProxyLogin(@Nullable String proxyLogin) { - this.proxyLogin = proxyLogin; - return this; - } - - public HttpRequestFactory setProxyPassword(@Nullable String proxyPassword) { - this.proxyPassword = proxyPassword; - return this; - } - - public HttpRequestFactory setProxyPort(int proxyPort) { - this.proxyPort = proxyPort; - return this; - } - - public HttpRequestFactory setConnectTimeoutInMilliseconds(int connectTimeoutInMilliseconds) { - this.connectTimeoutInMilliseconds = connectTimeoutInMilliseconds; - return this; - } - - public HttpRequestFactory setReadTimeoutInMilliseconds(int readTimeoutInMilliseconds) { - this.readTimeoutInMilliseconds = readTimeoutInMilliseconds; - return this; - } - - public String getBaseUrl() { - return baseUrl; - } - - public String getLogin() { - return login; - } - - public String getPassword() { - return password; - } - - public String getProxyHost() { - return proxyHost; - } - - public String getProxyLogin() { - return proxyLogin; - } - - public String getProxyPassword() { - return proxyPassword; - } - - public int getProxyPort() { - return proxyPort; - } - - public int getConnectTimeoutInMilliseconds() { - return connectTimeoutInMilliseconds; - } - - public int getReadTimeoutInMilliseconds() { - return readTimeoutInMilliseconds; - } - - public String get(String wsUrl, Map<String, Object> queryParams) { - HttpRequest request = prepare(HttpRequest.get(baseUrl + wsUrl, queryParams, true)); - return execute(request); - } - - public String post(String wsUrl, Map<String, Object> queryParams) { - HttpRequest request = prepare(HttpRequest.post(baseUrl + wsUrl, true)).form(queryParams, HttpRequest.CHARSET_UTF8); - return execute(request); - } - - private String execute(HttpRequest request) { - try { - if (isSuccess(request)) { - return request.body(HttpRequest.CHARSET_UTF8); - } - // TODO handle error messages - throw new HttpException(request.url().toString(), request.code()); - - } catch (HttpRequest.HttpRequestException e) { - throw new IllegalStateException("Fail to request " + request.url(), e.getCause()); - } - } - - private boolean isSuccess(HttpRequest request) { - return Arrays.binarySearch(RESPONSE_SUCCESS, request.code()) >= 0; - } - - private HttpRequest prepare(HttpRequest request) { - if (proxyHost != null) { - request.useProxy(proxyHost, proxyPort); - if (proxyLogin != null) { - request.proxyBasic(proxyLogin, proxyPassword); - } - } - request - .acceptGzipEncoding() - .uncompress(true) - .acceptJson() - .acceptCharset(HttpRequest.CHARSET_UTF8) - .connectTimeout(connectTimeoutInMilliseconds) - .readTimeout(readTimeoutInMilliseconds) - .trustAllCerts() - .trustAllHosts(); - if (login != null) { - request.basic(login, password); - } - return request; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/package-info.java deleted file mode 100644 index 2bdcdd22053..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/internal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.internal; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlan.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlan.java deleted file mode 100644 index 9f00a0359c6..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlan.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import javax.annotation.CheckForNull; - -import java.util.Date; - -/** - * @since 3.6 - */ -public interface ActionPlan { - - /** - * Unique key - */ - String key(); - - String project(); - - String name(); - - @CheckForNull - String description(); - - String status(); - - /** - * Login of the user who created the action plan. - */ - String userLogin(); - - @CheckForNull - Date deadLine(); - - Date createdAt(); - - Date updatedAt(); - - @CheckForNull - Integer totalIssues(); - - @CheckForNull - Integer unresolvedIssues(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanClient.java deleted file mode 100644 index a41aa40fcd1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanClient.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import java.util.List; - -/** - * @since 3.6 - */ -public interface ActionPlanClient { - - List<ActionPlan> find(String projectKey); - - ActionPlan create(NewActionPlan newActionPlan); - - ActionPlan update(UpdateActionPlan updateActionPlan); - - void delete(String actionPlanKey); - - ActionPlan open(String actionPlanKey); - - ActionPlan close(String actionPlanKey); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java deleted file mode 100644 index 8a2db776250..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/ActionPlanQuery.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.6 - */ -public class ActionPlanQuery { - - public static final String BASE_URL = "/api/action_plans/search"; - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private ActionPlanQuery() { - } - - public static ActionPlanQuery create() { - return new ActionPlanQuery(); - } - - Map<String, Object> urlParams() { - return params; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChange.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChange.java deleted file mode 100644 index 268eae3c7e1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChange.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import java.util.List; - -/** - * @since 3.7 - */ -public interface BulkChange { - - List<String> issuesNotChangedKeys(); - - Integer totalIssuesChanged(); - - Integer totalIssuesNotChanged(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java deleted file mode 100644 index db43ec72c54..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/BulkChangeQuery.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import org.sonar.wsclient.internal.EncodingUtils; - -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.7 - */ -public class BulkChangeQuery { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private BulkChangeQuery() { - } - - public static BulkChangeQuery create() { - return new BulkChangeQuery(); - } - - /** - * URL query string, for internal use - */ - public Map<String, Object> urlParams() { - return params; - } - - public BulkChangeQuery issues(String... keys) { - return addParam("issues", keys); - } - - public BulkChangeQuery actions(String... actions) { - return addParam("actions", actions); - } - - public BulkChangeQuery actionParameter(String action, String parameter, Object value) { - params.put(action + "." + parameter, value); - return this; - } - - public BulkChangeQuery comment(String comment) { - params.put("comment", comment); - return this; - } - - public BulkChangeQuery sendNotifications(boolean sendNotifications) { - params.put("sendNotifications", String.valueOf(sendNotifications)); - return this; - } - - private BulkChangeQuery addParam(String key, String[] values) { - if (values != null) { - params.put(key, EncodingUtils.toQueryParam(values)); - } - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java deleted file mode 100644 index 3727840e4d9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issue.java +++ /dev/null @@ -1,103 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import javax.annotation.CheckForNull; - -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * @since 3.6 - */ -public interface Issue { - - /** - * Unique key - */ - String key(); - - String componentKey(); - - /** - * @deprecated since 4.4. Use {@link #componentKey()} instead - */ - @Deprecated - Long componentId(); - - String projectKey(); - - String ruleKey(); - - String severity(); - - @CheckForNull - String message(); - - @CheckForNull - Integer line(); - - @CheckForNull - String debt(); - - String status(); - - /** - * The resolution type. Null if the issue is not resolved. - */ - @CheckForNull - String resolution(); - - @CheckForNull - String reporter(); - - /** - * Login of assignee. Null if issue is not assigned. - */ - @CheckForNull - String assignee(); - - /** - * SCM account - */ - @CheckForNull - String author(); - - @CheckForNull - String actionPlan(); - - Date creationDate(); - - Date updateDate(); - - @CheckForNull - Date closeDate(); - - @CheckForNull - String attribute(String key); - - Map<String, String> attributes(); - - /** - * Non-null list of comments - */ - List<IssueComment> comments(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueChange.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueChange.java deleted file mode 100644 index b36faeb6f3c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueChange.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import java.util.Date; -import java.util.List; - -/** - * @since 4.1 - */ -public interface IssueChange { - - String user(); - - Date creationDate(); - - List<IssueChangeDiff> diffs(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueChangeDiff.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueChangeDiff.java deleted file mode 100644 index 5bb5abda431..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueChangeDiff.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import javax.annotation.CheckForNull; - -/** - * @since 4.1 - */ -public interface IssueChangeDiff { - - String key(); - - @CheckForNull - Object newValue(); - - @CheckForNull - Object oldValue(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java deleted file mode 100644 index 5168a6fd11c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueClient.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import javax.annotation.Nullable; - -import java.util.List; - -/** - * This client is a wrapper over the web services related to issues - * - * @since 3.6 - */ -public interface IssueClient { - - /** - * Wrap the web service /api/issues/search in order to search for issues. - */ - Issues find(IssueQuery query); - - /** - * Assign an existing issue to a user. A null assignee removes the assignee. - * - * @return the updated issue - */ - Issue assign(String issueKey, @Nullable String assignee); - - /** - * Assign an existing issue to current user. - * - * @return the updated issue - */ - Issue assignToMe(String issueKey); - - - /** - * Change the severity of an existing issue. Supported values are "INFO", "MINOR", - * "MAJOR", "CRITICAL" and "BLOCKER". - * - * @return the updated issue - */ - Issue setSeverity(String issueKey, String severity); - - /** - * Link an existing issue to an action plan. A null action plan unlinks the issue. - */ - Issue plan(String issueKey, @Nullable String actionPlan); - - IssueComment addComment(String issueKey, String markdownText); - - Issue create(NewIssue issue); - - List<String> transitions(String issueKey); - - Issue doTransition(String issueKey, String transition); - - List<String> actions(String issueKey); - - Issue doAction(String issueKey, String action); - - /** - * Execute bulk change on a list of issues - */ - BulkChange bulkChange(BulkChangeQuery query); - - /** - * @since 4.1 - * - * @return the list of changes of an issue - */ - List<IssueChange> changes(String issueKey); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueComment.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueComment.java deleted file mode 100644 index b541ded3835..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueComment.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import java.util.Date; - -/** - * @since 3.6 - */ -public interface IssueComment { - String key(); - - String htmlText(); - - String login(); - - Date createdAt(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java deleted file mode 100644 index 304fee715b9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/IssueQuery.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import org.sonar.wsclient.internal.EncodingUtils; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.6 - */ -public class IssueQuery { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private IssueQuery() { - } - - public static IssueQuery create() { - return new IssueQuery(); - } - - /** - * URL query string, for internal use - */ - public Map<String, Object> urlParams() { - return params; - } - - public IssueQuery issues(String... keys) { - return addParam("issues", keys); - } - - public IssueQuery severities(String... severities) { - return addParam("severities", severities); - } - - public IssueQuery statuses(String... statuses) { - return addParam("statuses", statuses); - } - - public IssueQuery resolutions(String... resolutions) { - return addParam("resolutions", resolutions); - } - - public IssueQuery components(String... components) { - return addParam("components", components); - } - - public IssueQuery componentRoots(String... componentRoots) { - return addParam("componentRoots", componentRoots); - } - - public IssueQuery rules(String... s) { - return addParam("rules", s); - } - - public IssueQuery actionPlans(String... s) { - return addParam("actionPlans", s); - } - - public IssueQuery reporters(String... s) { - return addParam("reporters", s); - } - - public IssueQuery assignees(String... s) { - return addParam("assignees", s); - } - public IssueQuery languages(String... s) { - return addParam("languages", s); - } - - public IssueQuery assigned(Boolean assigned) { - params.put("assigned", assigned); - return this; - } - - public IssueQuery planned(Boolean planned) { - params.put("planned", planned); - return this; - } - - public IssueQuery resolved(Boolean resolved) { - params.put("resolved", resolved); - return this; - } - - /** - * @since 4.2 - */ - public IssueQuery hideRules(Boolean hideRules) { - params.put("hideRules", hideRules); - return this; - } - - /** - * Require second precision. - * @since 3.7 - */ - public IssueQuery createdAt(Date d) { - params.put("createdAt", EncodingUtils.toQueryParam(d, true)); - return this; - } - - public IssueQuery createdAfter(Date d) { - params.put("createdAfter", EncodingUtils.toQueryParam(d, true)); - return this; - } - - public IssueQuery createdBefore(Date d) { - params.put("createdBefore", EncodingUtils.toQueryParam(d, true)); - return this; - } - - public IssueQuery sort(String sort) { - params.put("sort", sort); - return this; - } - - public IssueQuery asc(boolean asc) { - params.put("asc", asc); - return this; - } - - public IssueQuery pageSize(int pageSize) { - params.put("pageSize", pageSize); - return this; - } - - public IssueQuery pageIndex(int pageIndex) { - params.put("pageIndex", pageIndex); - return this; - } - - private IssueQuery addParam(String key, String[] values) { - if (values != null) { - params.put(key, EncodingUtils.toQueryParam(values)); - } - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java deleted file mode 100644 index 702b83760ae..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/Issues.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import org.sonar.wsclient.base.Paging; -import org.sonar.wsclient.component.Component; -import org.sonar.wsclient.rule.Rule; -import org.sonar.wsclient.user.User; - -import javax.annotation.CheckForNull; - -import java.util.Collection; -import java.util.List; - -/** - * @since 3.6 - */ -public interface Issues { - List<Issue> list(); - - int size(); - - Collection<Rule> rules(); - - Rule rule(Issue issue); - - Collection<User> users(); - - @CheckForNull - User user(String login); - - Collection<Component> components(); - - @CheckForNull - Component component(Issue issue); - - @CheckForNull - Component componentById(long id); - - @CheckForNull - Component componentByKey(String key); - - Collection<Component> projects(); - - @CheckForNull - Component project(Issue issue); - - Collection<ActionPlan> actionPlans(); - - @CheckForNull - ActionPlan actionPlans(Issue issue); - - Paging paging(); - - Boolean maxResultsReached(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java deleted file mode 100644 index 015efe48e53..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewActionPlan.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import org.sonar.wsclient.internal.EncodingUtils; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.6 - */ -public class NewActionPlan { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private NewActionPlan() { - } - - public static NewActionPlan create() { - return new NewActionPlan(); - } - - public Map<String, Object> urlParams() { - return params; - } - - public NewActionPlan name(String s) { - params.put("name", s); - return this; - } - - public NewActionPlan project(String s) { - params.put("project", s); - return this; - } - - public NewActionPlan description(String s) { - params.put("description", s); - return this; - } - - public NewActionPlan deadLine(Date deadLine) { - params.put("deadLine", EncodingUtils.toQueryParam(deadLine, false)); - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java deleted file mode 100644 index 6e8dcb441ec..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/NewIssue.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.6 - */ -public class NewIssue { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private NewIssue() { - } - - public static NewIssue create() { - return new NewIssue(); - } - - public Map<String, Object> urlParams() { - return params; - } - - /** - * Optionally set the severity, in INFO, MINOR, MAJOR, CRITICAL or BLOCKER. Default value is MAJOR. - */ - public NewIssue severity(@Nullable String s) { - params.put("severity", s); - return this; - } - - public NewIssue component(String s) { - params.put("component", s); - return this; - } - - /** - * Rule key prefixed by the repository, for example "checkstyle:AvoidCycle". - */ - public NewIssue rule(String s) { - params.put("rule", s); - return this; - } - - /** - * Optional line, starting from 1. - */ - public NewIssue line(@Nullable Integer i) { - params.put("line", i); - return this; - } - - public NewIssue message(@Nullable String s) { - params.put("message", s); - return this; - } - - public NewIssue effortToFix(@Nullable Double d) { - params.put("effortToFix", d); - return this; - } - - public NewIssue attribute(String key, String value) { - params.put("attr[" + key + "]", value); - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java deleted file mode 100644 index 506132892de..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/UpdateActionPlan.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue; - -import org.sonar.wsclient.internal.EncodingUtils; - -import java.util.Date; -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.6 - */ -public class UpdateActionPlan { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private UpdateActionPlan() { - } - - public static UpdateActionPlan create() { - return new UpdateActionPlan(); - } - - public Map<String, Object> urlParams() { - return params; - } - - public UpdateActionPlan key(String s) { - params.put("key", s); - return this; - } - - public UpdateActionPlan name(String s) { - params.put("name", s); - return this; - } - - public UpdateActionPlan description(String s) { - params.put("description", s); - return this; - } - - public UpdateActionPlan deadLine(Date deadLine) { - params.put("deadLine", EncodingUtils.toQueryParam(deadLine, false)); - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlan.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlan.java deleted file mode 100644 index 8e12f27479a..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlan.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.issue.ActionPlan; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; -import java.util.Date; -import java.util.Map; - -/** - * @since 3.6 - */ -public class DefaultActionPlan implements ActionPlan { - - private final Map json; - - DefaultActionPlan(Map json) { - this.json = json; - } - - /** - * Unique key - */ - public String key() { - return JsonUtils.getString(json, "key"); - } - - public String project() { - return JsonUtils.getString(json, "project"); - } - - public String name() { - return JsonUtils.getString(json, "name"); - } - - @CheckForNull - public String description() { - return JsonUtils.getString(json, "desc"); - } - - public String status() { - return JsonUtils.getString(json, "status"); - } - - /** - * Login of the user who created the action plan. - */ - public String userLogin() { - return JsonUtils.getString(json, "userLogin"); - } - - @CheckForNull - public Date deadLine() { - return JsonUtils.getDateTime(json, "deadLine"); - } - - public Date createdAt() { - return JsonUtils.getDateTime(json, "createdAt"); - } - - public Date updatedAt() { - return JsonUtils.getDateTime(json, "updatedAt"); - } - - @CheckForNull - public Integer totalIssues() { - return JsonUtils.getInteger(json, "totalIssues"); - } - - @CheckForNull - public Integer unresolvedIssues() { - return JsonUtils.getInteger(json, "unresolvedIssues"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java deleted file mode 100644 index a9bbd61d3f3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultActionPlanClient.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.EncodingUtils; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.issue.*; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#actionPlanClient()}. - */ -public class DefaultActionPlanClient implements ActionPlanClient { - - private final HttpRequestFactory requestFactory; - - /** - * For internal use. Use {@link org.sonar.wsclient.SonarClient} to get an instance. - */ - public DefaultActionPlanClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public List<ActionPlan> find(String projectKey) { - String json = requestFactory.get(ActionPlanQuery.BASE_URL, EncodingUtils.toMap("project", projectKey)); - List<ActionPlan> result = new ArrayList<ActionPlan>(); - Map jsonRoot = (Map) JSONValue.parse(json); - List<Map> jsonActionPlans = (List<Map>) jsonRoot.get("actionPlans"); - if (jsonActionPlans != null) { - for (Map jsonActionPlan : jsonActionPlans) { - result.add(new DefaultActionPlan(jsonActionPlan)); - } - } - return result; - } - - @Override - public ActionPlan create(NewActionPlan newActionPlan) { - String json = requestFactory.post("/api/action_plans/create", newActionPlan.urlParams()); - return createActionPlanResult(json); - } - - @Override - public ActionPlan update(UpdateActionPlan updateActionPlan) { - String json = requestFactory.post("/api/action_plans/update", updateActionPlan.urlParams()); - return createActionPlanResult(json); - } - - @Override - public void delete(String actionPlanKey) { - executeSimpleAction(actionPlanKey, "delete"); - } - - @Override - public ActionPlan open(String actionPlanKey) { - String json = executeSimpleAction(actionPlanKey, "open"); - return createActionPlanResult(json); - } - - @Override - public ActionPlan close(String actionPlanKey) { - String json = executeSimpleAction(actionPlanKey, "close"); - return createActionPlanResult(json); - } - - private String executeSimpleAction(String actionPlanKey, String action) { - return requestFactory.post("/api/action_plans/" + action, EncodingUtils.toMap("key", actionPlanKey)); - } - - private ActionPlan createActionPlanResult(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultActionPlan((Map) jsonRoot.get("actionPlan")); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java deleted file mode 100644 index 9ce9b5e3c08..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultBulkChange.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.issue.BulkChange; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.ArrayList; -import java.util.List; - -/** - * @since 3.7 - */ -public class DefaultBulkChange implements BulkChange { - - private Integer totalIssuesChanged; - private Integer totalIssuesNotChanged; - private final List<String> issuesNotChangedKeys = new ArrayList<String>(); - - public List<String> issuesNotChangedKeys() { - return issuesNotChangedKeys; - } - - @CheckForNull - public Integer totalIssuesChanged() { - return totalIssuesChanged; - } - - @CheckForNull - public Integer totalIssuesNotChanged() { - return totalIssuesNotChanged; - } - - DefaultBulkChange setTotalIssuesChanged(@Nullable Integer totalIssuesChanged) { - this.totalIssuesChanged = totalIssuesChanged; - return this; - } - - DefaultBulkChange setTotalIssuesNotChanged(@Nullable Integer totalIssuesNotChanged) { - this.totalIssuesNotChanged = totalIssuesNotChanged; - return this; - } - - DefaultBulkChange setIssuesNotChanged(List<String> issueKeys) { - issuesNotChangedKeys.addAll(issueKeys); - return this; - } - - DefaultBulkChange addIssueNotchanged(String issueKey) { - issuesNotChangedKeys.add(issueKey); - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java deleted file mode 100644 index a86f9e35cbd..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssue.java +++ /dev/null @@ -1,160 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.issue.Issue; -import org.sonar.wsclient.issue.IssueComment; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; - -import java.util.*; - -/** - * @since 3.6 - */ -public class DefaultIssue implements Issue { - - private final Map json; - - DefaultIssue(Map json) { - this.json = json; - } - - /** - * Unique key - */ - public String key() { - return JsonUtils.getString(json, "key"); - } - - public Long componentId() { - return JsonUtils.getLong(json, "componentId"); - } - - public String componentKey() { - return JsonUtils.getString(json, "component"); - } - - public String projectKey() { - return JsonUtils.getString(json, "project"); - } - - public String ruleKey() { - return JsonUtils.getString(json, "rule"); - } - - public String severity() { - return JsonUtils.getString(json, "severity"); - } - - @CheckForNull - public String message() { - return JsonUtils.getString(json, "message"); - } - - @CheckForNull - public Integer line() { - return JsonUtils.getInteger(json, "line"); - } - - @CheckForNull - public String debt() { - return JsonUtils.getString(json, "debt"); - } - - public String status() { - return JsonUtils.getString(json, "status"); - } - - /** - * The resolution type. Null if the issue is not resolved. - */ - @CheckForNull - public String resolution() { - return JsonUtils.getString(json, "resolution"); - } - - @CheckForNull - public String reporter() { - return JsonUtils.getString(json, "reporter"); - } - - /** - * Login of assignee. Null if issue is not assigned. - */ - @CheckForNull - public String assignee() { - return JsonUtils.getString(json, "assignee"); - } - - /** - * SCM account - */ - @CheckForNull - public String author() { - return JsonUtils.getString(json, "author"); - } - - @CheckForNull - public String actionPlan() { - return JsonUtils.getString(json, "actionPlan"); - } - - public Date creationDate() { - return JsonUtils.getDateTime(json, "creationDate"); - } - - public Date updateDate() { - return JsonUtils.getDateTime(json, "updateDate"); - } - - @CheckForNull - public Date closeDate() { - return JsonUtils.getDateTime(json, "closeDate"); - } - - @CheckForNull - public String attribute(String key) { - return attributes().get(key); - } - - public Map<String, String> attributes() { - Map<String, String> attr = (Map<String, String>) json.get("attr"); - if (attr == null) { - return Collections.emptyMap(); - } - return attr; - } - - /** - * Non-null list of comments - */ - public List<IssueComment> comments() { - List<IssueComment> comments = new ArrayList<IssueComment>(); - List<Map> jsonComments = (List<Map>) json.get("comments"); - if (jsonComments != null) { - for (Map jsonComment : jsonComments) { - comments.add(new DefaultIssueComment(jsonComment)); - } - } - return comments; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java deleted file mode 100644 index 42b5285645c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChange.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.issue.IssueChange; -import org.sonar.wsclient.issue.IssueChangeDiff; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.ArrayList; -import java.util.Date; -import java.util.List; -import java.util.Map; - -/** - * @since 4.1 - */ -public class DefaultIssueChange implements IssueChange { - - private final Map json; - - DefaultIssueChange(Map json) { - this.json = json; - } - - public String user() { - return JsonUtils.getString(json, "user"); - } - - public Date creationDate() { - return JsonUtils.getDateTime(json, "creationDate"); - } - - public List<IssueChangeDiff> diffs() { - List<IssueChangeDiff> diffs = new ArrayList<IssueChangeDiff>(); - List<Map> jsonDiffs = (List<Map>) json.get("diffs"); - for (Map jsonDiff : jsonDiffs) { - diffs.add(new DefaultIssueChangeDiff(jsonDiff)); - } - return diffs; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChangeDiff.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChangeDiff.java deleted file mode 100644 index c2273701b43..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueChangeDiff.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.issue.IssueChangeDiff; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; - -import java.util.Map; - -/** - * @since 4.1 - */ -public class DefaultIssueChangeDiff implements IssueChangeDiff { - - private final Map json; - - DefaultIssueChangeDiff(Map json) { - this.json = json; - } - - public String key() { - return JsonUtils.getString(json, "key"); - } - - @CheckForNull - public Object newValue() { - return parseValue("newValue"); - - } - - @CheckForNull - public Object oldValue() { - return parseValue("oldValue"); - } - - private Object parseValue(String attribute) { - return JsonUtils.getString(json, attribute); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueClient.java deleted file mode 100644 index e37a111fffd..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueClient.java +++ /dev/null @@ -1,141 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.EncodingUtils; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.issue.*; - -import javax.annotation.Nullable; - -import java.util.List; -import java.util.Map; - -/** - * Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#issueClient()}. - */ -public class DefaultIssueClient implements IssueClient { - - private static final String SEARCH_URL = "/api/issues/search"; - private static final String ASSIGN_URL = "/api/issues/assign"; - - private final HttpRequestFactory requestFactory; - private final IssueJsonParser parser; - - public DefaultIssueClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - this.parser = new IssueJsonParser(); - } - - public Issues find(IssueQuery query) { - String json = requestFactory.get(SEARCH_URL, query.urlParams()); - return parser.parseIssues(json); - } - - @Override - public Issue create(NewIssue newIssue) { - String json = requestFactory.post("/api/issues/create", newIssue.urlParams()); - return jsonToIssue(json); - } - - @Override - public Issue setSeverity(String issueKey, String severity) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "severity", severity); - String json = requestFactory.post("/api/issues/set_severity", params); - return jsonToIssue(json); - } - - @Override - public Issue assign(String issueKey, @Nullable String assignee) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "assignee", assignee); - String json = requestFactory.post(ASSIGN_URL, params); - return jsonToIssue(json); - } - - @Override - public Issue assignToMe(String issueKey) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "me", "true"); - String json = requestFactory.post(ASSIGN_URL, params); - return jsonToIssue(json); - } - - @Override - public Issue plan(String issueKey, @Nullable String actionPlanKey) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "plan", actionPlanKey); - String json = requestFactory.post("/api/issues/plan", params); - return jsonToIssue(json); - } - - @Override - public IssueComment addComment(String issueKey, String markdownText) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "text", markdownText); - String json = requestFactory.post("/api/issues/add_comment", params); - Map rootJson = (Map) JSONValue.parse(json); - return new DefaultIssueComment((Map) rootJson.get("comment")); - } - - @Override - public List<String> transitions(String issueKey) { - Map<String, Object> queryParams = EncodingUtils.toMap("issue", issueKey); - String json = requestFactory.get("/api/issues/transitions", queryParams); - return parser.parseTransitions(json); - } - - @Override - public Issue doTransition(String issueKey, String transition) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "transition", transition); - String json = requestFactory.post("/api/issues/do_transition", params); - return jsonToIssue(json); - } - - @Override - public List<String> actions(String issueKey) { - Map<String, Object> queryParams = EncodingUtils.toMap("issue", issueKey); - String json = requestFactory.get("/api/issues/actions", queryParams); - return parser.parseActions(json); - } - - @Override - public Issue doAction(String issueKey, String action) { - Map<String, Object> params = EncodingUtils.toMap("issue", issueKey, "actionKey", action); - String json = requestFactory.post("/api/issues/do_action", params); - return jsonToIssue(json); - } - - @Override - public BulkChange bulkChange(BulkChangeQuery query) { - String json = requestFactory.post("/api/issues/bulk_change", query.urlParams()); - return parser.parseBulkChange(json); - } - - @Override - public List<IssueChange> changes(String issueKey) { - Map<String, Object> queryParams = EncodingUtils.toMap("issue", issueKey); - String json = requestFactory.post("/api/issues/changelog", queryParams); - return parser.parseChangelog(json); - } - - private Issue jsonToIssue(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultIssue((Map) jsonRoot.get("issue")); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueComment.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueComment.java deleted file mode 100644 index 7b89aef9ab1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssueComment.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.issue.IssueComment; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.Date; -import java.util.Map; - -/** - * @since 3.6 - */ -public class DefaultIssueComment implements IssueComment { - private final Map json; - - DefaultIssueComment(Map json) { - this.json = json; - } - - public String key() { - return JsonUtils.getString(json, "key"); - } - - public String htmlText() { - return JsonUtils.getString(json, "htmlText"); - } - - public String login() { - return JsonUtils.getString(json, "login"); - } - - public Date createdAt() { - return JsonUtils.getDateTime(json, "createdAt"); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java deleted file mode 100644 index 39e5ecbfffb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/DefaultIssues.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.sonar.wsclient.base.Paging; -import org.sonar.wsclient.component.Component; -import org.sonar.wsclient.issue.ActionPlan; -import org.sonar.wsclient.issue.Issue; -import org.sonar.wsclient.issue.Issues; -import org.sonar.wsclient.rule.Rule; -import org.sonar.wsclient.user.User; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.*; - -/** - * @since 3.6 - */ -public class DefaultIssues implements Issues { - - private final List<Issue> list = new ArrayList<Issue>(); - private final Map<String, Rule> rulesByKey = new HashMap<String, Rule>(); - private final Map<String, User> usersByKey = new HashMap<String, User>(); - private final Map<Long, Component> componentsById = new HashMap<Long, Component>(); - private final Map<String, Component> componentsByKey = new HashMap<String, Component>(); - private final Map<String, Component> projectsByKey = new HashMap<String, Component>(); - private final Map<String, ActionPlan> actionPlansByKey = new HashMap<String, ActionPlan>(); - private Paging paging; - private Boolean maxResultsReached; - - public List<Issue> list() { - return list; - } - - public int size() { - return list.size(); - } - - public Collection<Rule> rules() { - return rulesByKey.values(); - } - - public Rule rule(Issue issue) { - return rulesByKey.get(issue.ruleKey()); - } - - public Collection<User> users() { - return usersByKey.values(); - } - - @CheckForNull - public User user(String login) { - return usersByKey.get(login); - } - - public Collection<Component> components() { - return componentsByKey.values(); - } - - @CheckForNull - public Component component(Issue issue) { - return componentsByKey.get(issue.componentKey()); - } - - @CheckForNull - public Component componentById(long id) { - return componentsById.get(id); - } - - @CheckForNull - public Component componentByKey(String key) { - return componentsByKey.get(key); - } - - public Collection<Component> projects() { - return projectsByKey.values(); - } - - @CheckForNull - public Component project(Issue issue) { - return projectsByKey.get(issue.projectKey()); - } - - public Collection<ActionPlan> actionPlans() { - return actionPlansByKey.values(); - } - - @CheckForNull - public ActionPlan actionPlans(Issue issue) { - return actionPlansByKey.get(issue.actionPlan()); - } - - public Paging paging() { - return paging; - } - - @Nullable - public Boolean maxResultsReached() { - return maxResultsReached; - } - - DefaultIssues add(Issue issue) { - list.add(issue); - return this; - } - - DefaultIssues add(Rule rule) { - rulesByKey.put(rule.key(), rule); - return this; - } - - DefaultIssues add(User user) { - usersByKey.put(user.login(), user); - return this; - } - - DefaultIssues add(ActionPlan actionPlan) { - actionPlansByKey.put(actionPlan.key(), actionPlan); - return this; - } - - DefaultIssues addComponent(Component c) { - componentsById.put(c.id(), c); - componentsByKey.put(c.key(), c); - return this; - } - - DefaultIssues addProject(Component c) { - projectsByKey.put(c.key(), c); - return this; - } - - DefaultIssues setPaging(Paging paging) { - this.paging = paging; - return this; - } - - DefaultIssues setMaxResultsReached(@Nullable Boolean maxResultsReached) { - this.maxResultsReached = maxResultsReached; - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java deleted file mode 100644 index 40608c48e7d..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/IssueJsonParser.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.issue.internal; - -import org.json.simple.JSONArray; -import org.json.simple.JSONValue; -import org.sonar.wsclient.base.Paging; -import org.sonar.wsclient.component.Component; -import org.sonar.wsclient.issue.BulkChange; -import org.sonar.wsclient.issue.IssueChange; -import org.sonar.wsclient.issue.Issues; -import org.sonar.wsclient.rule.Rule; -import org.sonar.wsclient.unmarshallers.JsonUtils; -import org.sonar.wsclient.user.User; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -/** - * @since 3.6 - */ -public class IssueJsonParser { - - private static final String ISSUES = "issues"; - private static final String TOTAL = "total"; - - public Issues parseIssues(String json) { - DefaultIssues result = new DefaultIssues(); - Map jsonRoot = (Map) JSONValue.parse(json); - List<Map> jsonIssues = (List<Map>) jsonRoot.get(ISSUES); - if (jsonIssues != null) { - for (Map jsonIssue : jsonIssues) { - result.add(new DefaultIssue(jsonIssue)); - } - } - parseRules(result, jsonRoot); - parseUsers(result, jsonRoot); - parseComponents(result, jsonRoot); - parseProjects(result, jsonRoot); - parseActionPlans(result, jsonRoot); - parsePaging(result, jsonRoot); - return result; - } - - private void parsePaging(DefaultIssues result, Map jsonRoot) { - Map paging = (Map) jsonRoot.get("paging"); - result.setPaging(new Paging(paging)); - result.setMaxResultsReached(JsonUtils.getBoolean(jsonRoot, "maxResultsReached")); - } - - private void parseProjects(DefaultIssues result, Map jsonRoot) { - List<Map> jsonProjects = (List<Map>) jsonRoot.get("projects"); - if (jsonProjects != null) { - for (Map jsonProject : jsonProjects) { - result.addProject(new Component(jsonProject)); - } - } - } - - private void parseComponents(DefaultIssues result, Map jsonRoot) { - List<Map> jsonComponents = (List<Map>) jsonRoot.get("components"); - if (jsonComponents != null) { - for (Map jsonComponent : jsonComponents) { - result.addComponent(new Component(jsonComponent)); - } - } - } - - private void parseUsers(DefaultIssues result, Map jsonRoot) { - List<Map> jsonUsers = (List<Map>) jsonRoot.get("users"); - if (jsonUsers != null) { - for (Map jsonUser : jsonUsers) { - result.add(new User(jsonUser)); - } - } - } - - private void parseRules(DefaultIssues result, Map jsonRoot) { - List<Map> jsonRules = (List<Map>) jsonRoot.get("rules"); - if (jsonRules != null) { - for (Map jsonRule : jsonRules) { - result.add(new Rule(jsonRule)); - } - } - } - - private void parseActionPlans(DefaultIssues result, Map jsonRoot) { - List<Map> jsonRules = (List) jsonRoot.get("actionPlans"); - if (jsonRules != null) { - for (Map jsonRule : jsonRules) { - result.add(new DefaultActionPlan(jsonRule)); - } - } - } - - List<String> parseTransitions(String json) { - List<String> transitions = new ArrayList<String>(); - Map jRoot = (Map) JSONValue.parse(json); - List<String> jTransitions = (List<String>) jRoot.get("transitions"); - for (String jTransition : jTransitions) { - transitions.add(jTransition); - } - return transitions; - } - - List<IssueChange> parseChangelog(String json) { - List<IssueChange> changes = new ArrayList<IssueChange>(); - Map jRoot = (Map) JSONValue.parse(json); - List<Map> jChanges = (List<Map>) jRoot.get("changelog"); - if (jChanges != null) { - for (Map jChange : jChanges) { - changes.add(new DefaultIssueChange(jChange)); - } - } - return changes; - } - - List<String> parseActions(String json) { - List<String> actions = new ArrayList<String>(); - Map jRoot = (Map) JSONValue.parse(json); - List<String> jActions = (List<String>) jRoot.get("actions"); - for (String jAction : jActions) { - actions.add(jAction); - } - return actions; - } - - BulkChange parseBulkChange(String json) { - DefaultBulkChange result = new DefaultBulkChange(); - - Map jsonRoot = (Map) JSONValue.parse(json); - Map issuesChanged = (Map) jsonRoot.get("issuesChanged"); - result.setTotalIssuesChanged(JsonUtils.getInteger(issuesChanged, TOTAL)); - - Map issuesNotChanged = (Map) jsonRoot.get("issuesNotChanged"); - result.setTotalIssuesNotChanged(JsonUtils.getInteger(issuesNotChanged, TOTAL)); - JSONArray issuesJson = JsonUtils.getArray(issuesNotChanged, ISSUES); - if (issuesJson != null) { - result.setIssuesNotChanged(issuesJson); - } - - return result; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/package-info.java deleted file mode 100644 index 3412b1973db..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/internal/package-info.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.issue.internal; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/package-info.java deleted file mode 100644 index 17e63ce2fdb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/issue/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.issue; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/package-info.java deleted file mode 100644 index 0373f9e2996..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionClient.java deleted file mode 100644 index e20148c51c1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionClient.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.permissions; - - -/** - * @since 3.7 - */ -public interface PermissionClient { - - /** - * @since 3.7 - */ - void addPermission(PermissionParameters permissionParameters); - - /** - * @since 3.7 - */ - void removePermission(PermissionParameters permissionParameters); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java deleted file mode 100644 index 8965152a81b..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/PermissionParameters.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.permissions; - -import java.util.HashMap; -import java.util.Map; - -public class PermissionParameters { - - private final Map<String, Object> params; - - private PermissionParameters(){ - params = new HashMap<String, Object>(); - } - - public static PermissionParameters create() { - return new PermissionParameters(); - } - - public PermissionParameters user(String user) { - params.put("user", user); - return this; - } - - public PermissionParameters group(String group) { - params.put("group", group); - return this; - } - - public PermissionParameters component(String component) { - params.put("component", component); - return this; - } - - public PermissionParameters permission(String permission) { - params.put("permission", permission); - return this; - } - - public Map<String, Object> urlParams() { - return params; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/DefaultPermissionClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/DefaultPermissionClient.java deleted file mode 100644 index cb45891da41..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/DefaultPermissionClient.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.permissions.internal; - -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.permissions.PermissionClient; -import org.sonar.wsclient.permissions.PermissionParameters; - -public class DefaultPermissionClient implements PermissionClient { - - private static final String BASE_URL = "/api/permissions/"; - private static final String ADD_URL = BASE_URL + "add"; - private static final String REMOVE_URL = BASE_URL + "remove"; - - private final HttpRequestFactory requestFactory; - - /** - * For internal use. Use {@link org.sonar.wsclient.SonarClient} to get an instance. - */ - public DefaultPermissionClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public void addPermission(PermissionParameters permissionParameters) { - requestFactory.post(ADD_URL, permissionParameters.urlParams()); - } - - @Override - public void removePermission(PermissionParameters permissionParameters) { - requestFactory.post(REMOVE_URL, permissionParameters.urlParams()); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/package-info.java deleted file mode 100644 index 2b683b438d5..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.permissions.internal; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/package-info.java deleted file mode 100644 index fe99a19dd76..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.permissions; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java deleted file mode 100644 index 740ba8219c7..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/NewProject.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.project; - -import java.util.HashMap; -import java.util.Map; - -/** - * @since 4.0 - */ -public class NewProject { - - private final Map<String, Object> params; - - private NewProject() { - params = new HashMap<String, Object>(); - } - - public static NewProject create() { - return new NewProject(); - } - - public Map<String, Object> urlParams() { - return params; - } - - public NewProject key(String key) { - params.put("key", key); - return this; - } - - public NewProject name(String name) { - params.put("name", name); - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java deleted file mode 100644 index 5ee3109eb26..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/Project.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.project; - -/** - * @since 4.0 - */ -public interface Project { - - String id(); - - String key(); - - String name(); - - String qualifier(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/ProjectClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/ProjectClient.java deleted file mode 100644 index c3f37c4f6e7..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/ProjectClient.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.project; - -/** - * @since 4.0 - */ -public interface ProjectClient { - - Project create(NewProject newProject); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java deleted file mode 100644 index 7362c6d34cb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProject.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.project.internal; - -import org.sonar.wsclient.project.Project; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.Map; - -/** - * @since 4.0 - */ -public class DefaultProject implements Project { - - private final Map<String, String> json; - - public DefaultProject(Map<String, String> json) { - this.json = json; - } - - @Override - public String id() { - return JsonUtils.getString(json, "id"); - } - - @Override - public String key() { - return JsonUtils.getString(json, "k"); - } - - @Override - public String name() { - return JsonUtils.getString(json, "nm"); - } - - @Override - public String qualifier() { - return JsonUtils.getString(json, "qu"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProjectClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProjectClient.java deleted file mode 100644 index 7419b687f17..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/DefaultProjectClient.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.project.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.project.NewProject; -import org.sonar.wsclient.project.Project; -import org.sonar.wsclient.project.ProjectClient; - -import java.util.Map; - -/** - * Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#projectClient()}. - */ -public class DefaultProjectClient implements ProjectClient { - - private static final String ROOT_URL = "/api/projects"; - private static final String CREATE_URL = ROOT_URL + "/create"; - - private final HttpRequestFactory requestFactory; - - public DefaultProjectClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public Project create(NewProject newProject) { - String json = requestFactory.post(CREATE_URL, newProject.urlParams()); - return jsonToProject(json); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private Project jsonToProject(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultProject((Map) jsonRoot); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/package-info.java deleted file mode 100644 index c05b289ac47..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/internal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.project.internal; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/project/package-info.java deleted file mode 100644 index 81ab0cb3341..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/project/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.project; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/QProfileClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/QProfileClient.java deleted file mode 100644 index e26cd1449d7..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/QProfileClient.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.qprofile; - - -/** - * @since 4.4 - */ -public interface QProfileClient { - - QProfileResult restoreDefault(String language); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/QProfileResult.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/QProfileResult.java deleted file mode 100644 index 9734e4ce16c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/QProfileResult.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.qprofile; - -import java.util.List; - -public interface QProfileResult { - - List<String> infos(); - - List<String> warnings(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileClient.java deleted file mode 100644 index 4948228eb03..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileClient.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.qprofile.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.qprofile.QProfileClient; -import org.sonar.wsclient.qprofile.QProfileResult; - -import java.util.Collections; -import java.util.Map; - -public class DefaultQProfileClient implements QProfileClient { - - private final HttpRequestFactory requestFactory; - - public DefaultQProfileClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public QProfileResult restoreDefault(String language) { - String json = requestFactory.post("/api/qualityprofiles/restore_default", Collections.singletonMap("language", (Object) language)); - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultQProfileResult(jsonRoot); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java deleted file mode 100644 index ca9e6237e06..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qprofile/internal/DefaultQProfileResult.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.qprofile.internal; - -import org.sonar.wsclient.qprofile.QProfileResult; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -public class DefaultQProfileResult implements QProfileResult { - - private Map json; - - DefaultQProfileResult(Map json) { - this.json = json; - } - - @Override - public List<String> infos() { - List<String> infos = new ArrayList<String>(); - List<String> jsonInfos = (List<String>) json.get("infos"); - if (jsonInfos != null) { - for (String info : jsonInfos) { - infos.add(info); - } - } - return infos; - } - - @Override - public List<String> warnings() { - List<String> warnings = new ArrayList<String>(); - List<String> jsonWarnings = (List<String>) json.get("warnings"); - if (jsonWarnings != null) { - for (String warning : jsonWarnings) { - warnings.add(warning); - } - } - return warnings; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java deleted file mode 100644 index 64f8ff9d7a6..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/NewCondition.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - -import javax.annotation.Nullable; - -import java.util.HashMap; -import java.util.Map; - -/** - * @since 4.3 - */ -public class NewCondition { - - private final Map<String, Object> params; - - private NewCondition() { - params = new HashMap<String, Object>(); - } - - public static NewCondition create(long qGateId) { - NewCondition newCondition = new NewCondition(); - newCondition.params.put("gateId", qGateId); - return newCondition; - } - - public Map<String, Object> urlParams() { - return params; - } - - public NewCondition metricKey(String metricKey) { - params.put("metric", metricKey); - return this; - } - - public NewCondition operator(String operator) { - params.put("op", operator); - return this; - } - - public NewCondition warningThreshold(@Nullable String warning) { - params.put("warning", warning); - return this; - } - - public NewCondition errorThreshold(@Nullable String error) { - params.put("error", error); - return this; - } - - public NewCondition period(@Nullable Integer period) { - params.put("period", period); - return this; - } -} - diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGate.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGate.java deleted file mode 100644 index 76b29d21f5a..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGate.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - -/** - * @since 4.3 - */ -public interface QualityGate { - - Long id(); - - String name(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateClient.java deleted file mode 100644 index 3744c3799db..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateClient.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - - -/** - * @since 4.3 - */ -public interface QualityGateClient { - - QualityGates list(); - - QualityGate create(String qGateName); - - QualityGate rename(long qGateId, String qGateName); - - QualityGateDetails show(long qGateId); - - QualityGateDetails show(String qGateName); - - QualityGateCondition createCondition(NewCondition condition); - - QualityGateCondition updateCondition(UpdateCondition condition); - - void deleteCondition(long conditionId); - - void destroy(long qGateId); - - void setDefault(long qGateId); - - void unsetDefault(); - - void selectProject(long qGateId, long projectId); - - void deselectProject(long qGateId, long projectId); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateCondition.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateCondition.java deleted file mode 100644 index 35f11fcfc78..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateCondition.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - -/** - * @since 4.3 - */ -public interface QualityGateCondition { - - Long id(); - - String metricKey(); - - String operator(); - - String warningThreshold(); - - String errorThreshold(); - - Integer period(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateDetails.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateDetails.java deleted file mode 100644 index de3faedeb7a..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGateDetails.java +++ /dev/null @@ -1,30 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - -import java.util.Collection; - -/** - * @since 4.3 - */ -public interface QualityGateDetails extends QualityGate { - - Collection<QualityGateCondition> conditions(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGates.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGates.java deleted file mode 100644 index d757963e074..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/QualityGates.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - -import java.util.Collection; - -/** - * @since 4.3 - */ -public interface QualityGates { - - Collection<QualityGate> qualityGates(); - - QualityGate defaultGate(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java deleted file mode 100644 index 70fb4c6d5b5..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/UpdateCondition.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate; - -import javax.annotation.Nullable; - -import java.util.HashMap; -import java.util.Map; - -/** - * @since 4.3 - */ -public class UpdateCondition { - - private final Map<String, Object> params; - - private UpdateCondition() { - params = new HashMap<String, Object>(); - } - - public static UpdateCondition create(long id) { - UpdateCondition newCondition = new UpdateCondition(); - newCondition.params.put("id", id); - return newCondition; - } - - public Map<String, Object> urlParams() { - return params; - } - - public UpdateCondition metricKey(String metricKey) { - params.put("metric", metricKey); - return this; - } - - public UpdateCondition operator(String operator) { - params.put("op", operator); - return this; - } - - public UpdateCondition warningThreshold(@Nullable String warning) { - params.put("warning", warning); - return this; - } - - public UpdateCondition errorThreshold(@Nullable String error) { - params.put("error", error); - return this; - } - - public UpdateCondition period(@Nullable Integer period) { - params.put("period", period); - return this; - } -} - diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGate.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGate.java deleted file mode 100644 index 06648eb4fce..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGate.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate.internal; - -import org.sonar.wsclient.qualitygate.QualityGate; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.Map; - -public class DefaultQualityGate implements QualityGate { - - private Map<String, String> json; - - DefaultQualityGate(Map<String, String> json) { - this.json = json; - } - - @Override - public Long id() { - return JsonUtils.getLong(json, "id"); - } - - @Override - public String name() { - return JsonUtils.getString(json, "name"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java deleted file mode 100644 index b9497d652e2..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateClient.java +++ /dev/null @@ -1,168 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.qualitygate.*; - -import java.util.*; - -public class DefaultQualityGateClient implements QualityGateClient { - - private static final String ROOT_URL = "/api/qualitygates"; - private static final String LIST_URL = ROOT_URL + "/list"; - private static final String SHOW_URL = ROOT_URL + "/show"; - private static final String CREATE_URL = ROOT_URL + "/create"; - private static final String CREATE_CONDITION_URL = ROOT_URL + "/create_condition"; - private static final String UPDATE_CONDITION_URL = ROOT_URL + "/update_condition"; - private static final String DELETE_CONDITION_URL = ROOT_URL + "/delete_condition"; - private static final String RENAME_URL = ROOT_URL + "/rename"; - private static final String DESTROY_URL = ROOT_URL + "/destroy"; - private static final String SET_DEFAULT_URL = ROOT_URL + "/set_as_default"; - private static final String UNSET_DEFAULT_URL = ROOT_URL + "/unset_default"; - private static final String SELECT_URL = ROOT_URL + "/select"; - private static final String DESELECT_URL = ROOT_URL + "/deselect"; - - private final HttpRequestFactory requestFactory; - - public DefaultQualityGateClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public QualityGates list() { - String json = requestFactory.get(LIST_URL, Collections.<String, Object> emptyMap()); - return jsonToQualityGates(json); - } - - @Override - public QualityGate create(String qGateName) { - String json = requestFactory.post(CREATE_URL, Collections.singletonMap("name", (Object) qGateName)); - return jsonToQualityGate(json); - } - - @Override - public QualityGate rename(long qGateId, String qGateName) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("id", qGateId); - params.put("name", qGateName); - String json = requestFactory.post(RENAME_URL, params); - return jsonToQualityGate(json); - } - - @Override - public QualityGateDetails show(long qGateId) { - String json = requestFactory.get(SHOW_URL, Collections.singletonMap("id", (Object) qGateId)); - return jsonToDetails(json); - } - - @Override - public QualityGateDetails show(String qGateName) { - String json = requestFactory.get(SHOW_URL, Collections.singletonMap("name", (Object) qGateName)); - return jsonToDetails(json); - } - - @Override - public QualityGateCondition createCondition(NewCondition condition) { - String json = requestFactory.post(CREATE_CONDITION_URL, condition.urlParams()); - return jsonToCondition(json); - } - - @Override - public QualityGateCondition updateCondition(UpdateCondition condition) { - String json = requestFactory.post(UPDATE_CONDITION_URL, condition.urlParams()); - return jsonToCondition(json); - } - - @Override - public void deleteCondition(long conditionId) { - requestFactory.post(DELETE_CONDITION_URL, Collections.singletonMap("id", (Object) conditionId)); - } - - @Override - public void destroy(long qGateId) { - requestFactory.post(DESTROY_URL, Collections.singletonMap("id", (Object) qGateId)); - } - - @Override - public void setDefault(long qGateId) { - requestFactory.post(SET_DEFAULT_URL, Collections.singletonMap("id", (Object) qGateId)); - } - - @Override - public void unsetDefault() { - requestFactory.post(UNSET_DEFAULT_URL, Collections.<String, Object> emptyMap()); - } - - @Override - public void selectProject(long qGateId, long projectId) { - requestFactory.post(SELECT_URL, selectionParams(qGateId, projectId)); - } - - @Override - public void deselectProject(long qGateId, long projectId) { - requestFactory.post(DESELECT_URL, selectionParams(qGateId, projectId)); - } - - private Map<String, Object> selectionParams(long qGateId, long projectId) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("gateId", Long.toString(qGateId)); - params.put("projectId", Long.toString(projectId)); - return params; - } - - - @SuppressWarnings({"rawtypes", "unchecked"}) - private QualityGate jsonToQualityGate(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultQualityGate((Map) jsonRoot); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private QualityGates jsonToQualityGates(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultQualityGates((Map) jsonRoot); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private QualityGateDetails jsonToDetails(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultQualityGateDetails((Map) jsonRoot, jsonToConditions(json)); - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private Collection<QualityGateCondition> jsonToConditions(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - Collection<Map> conditionArray = (Collection<Map>) jsonRoot.get("conditions"); - Collection<QualityGateCondition> conditions = new ArrayList<QualityGateCondition>(); - if (conditionArray != null) { - for (Map conditionJson: conditionArray) { - conditions.add(new DefaultQualityGateCondition(conditionJson)); - } - } - return conditions; - } - - @SuppressWarnings({"rawtypes", "unchecked"}) - private DefaultQualityGateCondition jsonToCondition(String json) { - return new DefaultQualityGateCondition((Map) JSONValue.parse(json)); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateCondition.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateCondition.java deleted file mode 100644 index cc8836a94aa..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateCondition.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate.internal; - -import org.sonar.wsclient.qualitygate.QualityGateCondition; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.Map; - -public class DefaultQualityGateCondition implements QualityGateCondition { - - private Map<String, String> json; - - public DefaultQualityGateCondition(Map<String, String> json) { - this.json = json; - } - - @Override - public Long id() { - return JsonUtils.getLong(json, "id"); - } - - @Override - public String metricKey() { - return JsonUtils.getString(json, "metric"); - } - - @Override - public String operator() { - return JsonUtils.getString(json, "op"); - } - - @Override - public String warningThreshold() { - return JsonUtils.getString(json, "warning"); - } - - @Override - public String errorThreshold() { - return JsonUtils.getString(json, "error"); - } - - @Override - public Integer period() { - return JsonUtils.getInteger(json, "period"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateDetails.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateDetails.java deleted file mode 100644 index 318d038e566..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGateDetails.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate.internal; - -import org.sonar.wsclient.qualitygate.QualityGateCondition; -import org.sonar.wsclient.qualitygate.QualityGateDetails; - -import java.util.Collection; -import java.util.Map; - -public class DefaultQualityGateDetails extends DefaultQualityGate implements QualityGateDetails { - - private final Collection<QualityGateCondition> conditions; - - DefaultQualityGateDetails(Map<String, String> json, Collection<QualityGateCondition> conditions) { - super(json); - this.conditions = conditions; - } - - @Override - public Collection<QualityGateCondition> conditions() { - return conditions; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java deleted file mode 100644 index e29c5123a37..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/qualitygate/internal/DefaultQualityGates.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.qualitygate.internal; - -import org.json.simple.JSONArray; - -import org.sonar.wsclient.unmarshallers.JsonUtils; -import org.sonar.wsclient.qualitygate.QualityGate; - -import java.util.Collection; -import java.util.LinkedHashMap; -import java.util.Map; - -import org.sonar.wsclient.qualitygate.QualityGates; - -public class DefaultQualityGates implements QualityGates { - - private Map<Long, QualityGate> qualityGates; - - private Long defaultId; - - @SuppressWarnings("unchecked") - public DefaultQualityGates(Map<String, Object> json) { - qualityGates = new LinkedHashMap<Long, QualityGate>(); - JSONArray gatesJson = JsonUtils.getArray(json, "qualitygates"); - if (gatesJson != null) { - for (Object entry: gatesJson) { - QualityGate qGate = new DefaultQualityGate((Map<String, String>) entry); - qualityGates.put(qGate.id(), qGate); - } - } - defaultId = JsonUtils.getLong(json, "default"); - } - - @Override - public Collection<QualityGate> qualityGates() { - return qualityGates.values(); - } - - @Override - public QualityGate defaultGate() { - return qualityGates.get(defaultId); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/Rule.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/Rule.java deleted file mode 100644 index 7b668e06364..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/Rule.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.rule; - -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import java.util.Map; - -/** - * @since 3.6 - */ -public class Rule { - private final Map json; - - public Rule(Map json) { - this.json = json; - } - - /** - * Unique key - */ - public String key() { - return JsonUtils.getString(json, "key"); - } - - public String name() { - return JsonUtils.getString(json, "name"); - } - - public String description() { - return JsonUtils.getString(json, "desc"); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/package-info.java deleted file mode 100644 index 9a070fae071..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/rule/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.rule; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java deleted file mode 100644 index 2de84f70c50..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AbstractQuery.java +++ /dev/null @@ -1,148 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.Nullable; - -import java.util.Date; - -/** - * @since 2.2 - */ -public abstract class AbstractQuery<M extends Model> { - - /** - * Default timeout for waiting data, in milliseconds. - * - * @since 2.10 - */ - public static final int DEFAULT_TIMEOUT_MILLISECONDS = 30 * 1000; - - private int timeoutMilliseconds = DEFAULT_TIMEOUT_MILLISECONDS; - - // accepted-language as defined in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - private String locale; - - /** - * Must start with a slash, for example: /api/metrics - * <p> - * IMPORTANT: In implementations of this method we must use helper methods to construct URL. - * </p> - * - * @see #encode(String) - * @see #appendUrlParameter(StringBuilder, String, Object) - * @see #appendUrlParameter(StringBuilder, String, Object[]) - * @see #appendUrlParameter(StringBuilder, String, Date, boolean) - */ - public abstract String getUrl(); - - /** - * Request body. By default it is empty but it can be overridden. - */ - public String getBody() { - return null; - } - - /** - * Get the timeout for waiting data, in milliseconds. A value of zero is interpreted as an infinite timeout. - * - * @since 2.10 - */ - public final int getTimeoutMilliseconds() { - return timeoutMilliseconds; - } - - /** - * Set the timeout for waiting data, in milliseconds. Avalue of zero is interpreted as an infinite timeout. - * - * @since 2.10 - */ - public final AbstractQuery<M> setTimeoutMilliseconds(int i) { - this.timeoutMilliseconds = i<0 ? 0 : i; - return this; - } - - /** - * Accepted-language, as defined in http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html - * - * @since 2.10 - */ - public final String getLocale() { - return locale; - } - - /** - * Set the Accepted-language HTTP parameter - * - * @since 2.10 - */ - public final AbstractQuery<M> setLocale(String locale) { - this.locale = locale; - return this; - } - - /** - * Encodes single parameter value. - */ - protected static String encode(String value) { - return WSUtils.getINSTANCE().encodeUrl(value); - } - - protected static void appendUrlParameter(StringBuilder url, String paramKey, int paramValue) { - url.append(paramKey) - .append('=') - .append(paramValue) - .append("&"); - } - - protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Object paramValue) { - if (paramValue != null) { - url.append(paramKey) - .append('=') - .append(encode(paramValue.toString())) - .append('&'); - } - } - - protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Object[] paramValues) { - if (paramValues != null) { - url.append(paramKey).append('='); - for (int index = 0; index < paramValues.length; index++) { - if (index > 0) { - url.append(','); - } - if (paramValues[index] != null) { - url.append(encode(paramValues[index].toString())); - } - } - url.append('&'); - } - } - - protected static void appendUrlParameter(StringBuilder url, String paramKey, @Nullable Date paramValue, boolean includeTime) { - if (paramValue != null) { - String format = includeTime ? "yyyy-MM-dd'T'HH:mm:ssZ" : "yyyy-MM-dd"; - url.append(paramKey) - .append('=') - .append(encode(WSUtils.getINSTANCE().format(paramValue, format))) - .append('&'); - } - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Authentication.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Authentication.java deleted file mode 100644 index a47bd353c40..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Authentication.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class Authentication extends Model { - - private boolean valid; - - public boolean isValid() { - return valid; - } - - public Authentication setValid(boolean valid) { - this.valid = valid; - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AuthenticationQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AuthenticationQuery.java deleted file mode 100644 index f0191d3f0de..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/AuthenticationQuery.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class AuthenticationQuery extends Query<Authentication> { - public static final String BASE_URL = "/api/authentication/validate"; - - @Override - public String getUrl() { - return BASE_URL; - } - - @Override - public Class<Authentication> getModelClass() { - return Authentication.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/CreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/CreateQuery.java deleted file mode 100644 index 9878ff520de..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/CreateQuery.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * POST HTTP request - * - * @since 2.2 - */ -public abstract class CreateQuery<M extends Model> extends AbstractQuery<M> { - - public abstract Class<M> getModelClass(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DeleteQuery.java deleted file mode 100644 index 5921e95be81..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DeleteQuery.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * DELETE HTTP request - * - * @since 2.2 - */ -public abstract class DeleteQuery extends AbstractQuery { - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java deleted file mode 100644 index 085e52f7bfb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Dependency.java +++ /dev/null @@ -1,175 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class Dependency extends Model { - - private String id; - private Long fromId; - private Long toId; - private String usage; - private Integer weight; - private String fromKey; - private String fromName; - private String fromQualifier; - private String toKey; - private String toName; - private String toQualifier; - - @CheckForNull - public String getId() { - return id; - } - - public Dependency setId(@Nullable String id) { - this.id = id; - return this; - } - - @CheckForNull - public Long getFromId() { - return fromId; - } - - public Dependency setFromId(@Nullable Long fromId) { - this.fromId = fromId; - return this; - } - - @CheckForNull - public Long getToId() { - return toId; - } - - public Dependency setToId(@Nullable Long toId) { - this.toId = toId; - return this; - } - - @CheckForNull - public String getFromKey() { - return fromKey; - } - - public Dependency setFromKey(@Nullable String fromKey) { - this.fromKey = fromKey; - return this; - } - - @CheckForNull - public String getToKey() { - return toKey; - } - - public Dependency setToKey(@Nullable String toKey) { - this.toKey = toKey; - return this; - } - - @CheckForNull - public String getUsage() { - return usage; - } - - public Dependency setUsage(@Nullable String usage) { - this.usage = usage; - return this; - } - - @CheckForNull - public Integer getWeight() { - return weight; - } - - public Dependency setWeight(@Nullable Integer weight) { - this.weight = weight; - return this; - } - - @CheckForNull - public String getFromName() { - return fromName; - } - - public Dependency setFromName(@Nullable String fromName) { - this.fromName = fromName; - return this; - } - - @CheckForNull - public String getFromQualifier() { - return fromQualifier; - } - - public Dependency setFromQualifier(@Nullable String fromQualifier) { - this.fromQualifier = fromQualifier; - return this; - } - - @CheckForNull - public String getToName() { - return toName; - } - - public Dependency setToName(@Nullable String toName) { - this.toName = toName; - return this; - } - - @CheckForNull - public String getToQualifier() { - return toQualifier; - } - - public Dependency setToQualifier(@Nullable String toQualifier) { - this.toQualifier = toQualifier; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Dependency that = (Dependency) o; - return id.equals(that.id); - } - - @Override - public int hashCode() { - return id.hashCode(); - } - - @Override - public String toString() { - return new StringBuilder() - .append(fromKey) - .append(" -> ") - .append(toKey) - .toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java deleted file mode 100644 index e5acd48ef8e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyQuery.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * The web service "dependency" is since Sonar 2.0 - */ -public class DependencyQuery extends Query<Dependency> { - public static final String BASE_URL = "/api/dependencies"; - - private String resourceIdOrKey = null; - private String direction = null; - private String parentId = null; - private String id = null; - public static final String INCOMING_DIRECTION = "in"; - public static final String OUTGOING_DIRECTION = "out"; - - public String getResourceIdOrKey() { - return resourceIdOrKey; - } - - public DependencyQuery setResourceIdOrKey(String resourceIdOrKey) { - this.resourceIdOrKey = resourceIdOrKey; - return this; - } - - public DependencyQuery setResourceId(long resourceId) { - this.resourceIdOrKey = String.valueOf(resourceId); - return this; - } - - public String getDirection() { - return direction; - } - - public DependencyQuery setDirection(String direction) { - this.direction = direction; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", resourceIdOrKey); - appendUrlParameter(url, "dir", direction); - appendUrlParameter(url, "parent", parentId); - appendUrlParameter(url, "id", id); - return url.toString(); - } - - public String getParentId() { - return parentId; - } - - public String getId() { - return id; - } - - public DependencyQuery setId(String id) { - this.id = id; - return this; - } - - public DependencyQuery setParentId(String parentId) { - this.parentId = parentId; - return this; - } - - @Override - public Class<Dependency> getModelClass() { - return Dependency.class; - } - - /** - * Resources that depend upon a resource - * - * @param resourceIdOrKey the target resource. Can be the primary key (a number) or the logical key (String) - */ - public static DependencyQuery createForIncomingDependencies(String resourceIdOrKey) { - DependencyQuery query = new DependencyQuery(); - query.setResourceIdOrKey(resourceIdOrKey); - query.setDirection(INCOMING_DIRECTION); - return query; - } - - /** - * Resources that are depended upon a resource = all the resources that a resource depends upon - * - * @param resourceIdOrKey the target resource. Can be the primary key (an integer) or the logical key (String) - */ - public static DependencyQuery createForOutgoingDependencies(String resourceIdOrKey) { - DependencyQuery query = new DependencyQuery(); - query.setResourceIdOrKey(resourceIdOrKey); - query.setDirection(OUTGOING_DIRECTION); - return query; - } - - /** - * Resources that depend upon or are depended upon a resource. It equals the merge of createForIncomingDependencies(resourceIdOrKey) - * and createForOutgoingDependencies(resourceIdOrKey) - * - * @param resourceIdOrKey the target resource. Can be the primary key (an integer) or the logical key (String) - */ - public static DependencyQuery createForResource(String resourceIdOrKey) { - DependencyQuery query = new DependencyQuery(); - query.setResourceIdOrKey(resourceIdOrKey); - return query; - } - - public static DependencyQuery createForResource(long resourceId) { - DependencyQuery query = new DependencyQuery(); - query.setResourceId(resourceId); - return query; - } - - public static DependencyQuery createForSubDependencies(String dependencyId) { - DependencyQuery query = new DependencyQuery(); - query.setParentId(dependencyId); - return query; - } - - public static DependencyQuery createForId(String id) { - DependencyQuery query = new DependencyQuery(); - query.setId(id); - return query; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java deleted file mode 100644 index c2118fbb0bb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTree.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.List; - -/** - * Experimental - */ -public class DependencyTree extends Model { - private String depId; - private String resourceId; - private String resourceKey; - private String resourceName; - private String usage; - private String resourceScope; - private String resourceQualifier; - private String resourceVersion; - private Integer weight; - private List<DependencyTree> to; - - @CheckForNull - public String getDepId() { - return depId; - } - - public DependencyTree setDepId(@Nullable String depId) { - this.depId = depId; - return this; - } - @CheckForNull - public String getResourceId() { - return resourceId; - } - - public DependencyTree setResourceId(@Nullable String resourceId) { - this.resourceId = resourceId; - return this; - } - @CheckForNull - public String getResourceKey() { - return resourceKey; - } - - public DependencyTree setResourceKey(@Nullable String resourceKey) { - this.resourceKey = resourceKey; - return this; - } - @CheckForNull - public String getResourceName() { - return resourceName; - } - - public DependencyTree setResourceName(@Nullable String resourceName) { - this.resourceName = resourceName; - return this; - } - @CheckForNull - public String getUsage() { - return usage; - } - - public DependencyTree setUsage(@Nullable String usage) { - this.usage = usage; - return this; - } - @CheckForNull - public String getResourceScope() { - return resourceScope; - } - - public DependencyTree setResourceScope(@Nullable String resourceScope) { - this.resourceScope = resourceScope; - return this; - } - @CheckForNull - public String getResourceQualifier() { - return resourceQualifier; - } - - public DependencyTree setResourceQualifier(@Nullable String resourceQualifier) { - this.resourceQualifier = resourceQualifier; - return this; - } - @CheckForNull - public String getResourceVersion() { - return resourceVersion; - } - - public DependencyTree setResourceVersion(@Nullable String resourceVersion) { - this.resourceVersion = resourceVersion; - return this; - } - - @CheckForNull - public Integer getWeight() { - return weight; - } - - public DependencyTree setWeight(@Nullable Integer weight) { - this.weight = weight; - return this; - } - - public List<DependencyTree> getTo() { - return to; - } - - public DependencyTree setTo(List<DependencyTree> to) { - this.to = to; - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java deleted file mode 100644 index 2521a24ae7b..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/DependencyTreeQuery.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.1 - */ -public class DependencyTreeQuery extends Query<DependencyTree> { - private static final String BASE_URL = "/api/dependency_tree"; - - private String resourceId; - private String[] scopes; - - public DependencyTreeQuery(String resourceId) { - this.resourceId = resourceId; - } - - public String getResourceId() { - return resourceId; - } - - public String[] getScopes() { - return scopes; - } - - public DependencyTreeQuery setResourceId(String resourceId) { - this.resourceId = resourceId; - return this; - } - - public DependencyTreeQuery setScopes(String... scopes) { - this.scopes = scopes; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", resourceId); - appendUrlParameter(url, "scopes", scopes); - return url.toString(); - } - - @Override - public Class<DependencyTree> getModelClass() { - return DependencyTree.class; - } - - public static DependencyTreeQuery createForResource(String resourceIdOrKey) { - return new DependencyTreeQuery(resourceIdOrKey); - } - - public static DependencyTreeQuery createForProject(String projectIdOrKey) { - return new DependencyTreeQuery(projectIdOrKey).setScopes(Resource.SCOPE_SET); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java deleted file mode 100644 index b7a5d90d537..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Event.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Date; - -public class Event extends Model { - - private String id; - private String name; - private String category; - private String description; - private String resourceKey; - private Date date; - - @CheckForNull - public String getId() { - return id; - } - - public Event setId(@Nullable String id) { - this.id = id; - return this; - } - - @CheckForNull - public String getName() { - return name; - } - - public Event setName(@Nullable String name) { - this.name = name; - return this; - } - - @CheckForNull - public String getCategory() { - return category; - } - - public Event setCategory(@Nullable String category) { - this.category = category; - return this; - } - - @CheckForNull - public String getDescription() { - return description; - } - - public Event setDescription(@Nullable String description) { - this.description = description; - return this; - } - - @CheckForNull - public Date getDate() { - return date; - } - - public Event setDate(@Nullable Date date) { - this.date = date; - return this; - } - - @CheckForNull - public String getResourceKey() { - return resourceKey; - } - - public Event setResourceKey(@Nullable String resourceKey) { - this.resourceKey = resourceKey; - return this; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - - Event event = (Event) o; - return !(id != null ? !id.equals(event.id) : event.id != null); - } - - @Override - public int hashCode() { - return id != null ? id.hashCode() : 0; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/EventCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/EventCreateQuery.java deleted file mode 100644 index bced338a48e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/EventCreateQuery.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @author Evgeny Mandrikov - * @since 2.2 - */ -public class EventCreateQuery extends CreateQuery<Event> { - private Event event; - - public EventCreateQuery(Event event) { - this.event = event; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(EventQuery.BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", event.getResourceKey()); - appendUrlParameter(url, "category", event.getCategory()); - appendUrlParameter(url, "name", event.getName()); - appendUrlParameter(url, "description", event.getDescription()); - return url.toString(); - } - - @Override - public Class<Event> getModelClass() { - return Event.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/EventQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/EventQuery.java deleted file mode 100644 index 28bff177471..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/EventQuery.java +++ /dev/null @@ -1,114 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import java.util.Date; - -public class EventQuery extends Query<Event> { - public static final String BASE_URL = "/api/events"; - - private String resourceKey; - private String[] categories; - private Date fromDate; - private boolean includeFromTime; - private Date toDate; - private boolean includeToTime; - - public EventQuery() { - } - - public EventQuery(String resourceKey) { - this.resourceKey = resourceKey; - } - - public Date getFrom() { - return fromDate; - } - - public EventQuery setFrom(Date fromDate, boolean includeTime) { - this.fromDate = fromDate; - this.includeFromTime = includeTime; - return this; - } - - public boolean isIncludeFromTime() { - return includeFromTime; - } - - public Date getTo() { - return toDate; - } - - public EventQuery setTo(Date toDate, boolean includeTime) { - this.toDate = toDate; - this.includeToTime = includeTime; - return this; - } - - public boolean isIncludeToTime() { - return includeToTime; - } - - public String getResourceKey() { - return resourceKey; - } - - public EventQuery setResourceKey(String resourceKey) { - this.resourceKey = resourceKey; - return this; - } - - public String[] getCategories() { - return categories; - } - - public EventQuery setCategories(String[] categories) { - this.categories = categories; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", resourceKey); - appendUrlParameter(url, "categories", categories); - if (fromDate != null) { - if (includeFromTime) { - appendUrlParameter(url, "fromDateTime", fromDate, true); - } else { - appendUrlParameter(url, "fromDate", fromDate, false); - } - } - if (toDate != null) { - if (includeToTime) { - appendUrlParameter(url, "toDateTime", toDate, true); - } else { - appendUrlParameter(url, "toDate", toDate, false); - } - } - return url.toString(); - } - - @Override - public Class<Event> getModelClass() { - return Event.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Favourite.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Favourite.java deleted file mode 100644 index 9b9d1494620..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Favourite.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class Favourite extends Model { - - private Integer id; - private String key; - private String name; - private String scope; - private String qualifier; - private String language; - - @CheckForNull - public Integer getId() { - return id; - } - - public Favourite setId(@Nullable Integer id) { - this.id = id; - return this; - } - - @CheckForNull - public String getKey() { - return key; - } - - public Favourite setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getName() { - return name; - } - - - public Favourite setName(@Nullable String name) { - this.name = name; - return this; - } - - @CheckForNull - public String getScope() { - return scope; - } - - public Favourite setScope(@Nullable String scope) { - this.scope = scope; - return this; - } - - @CheckForNull - public String getQualifier() { - return qualifier; - } - - public Favourite setQualifier(@Nullable String qualifier) { - this.qualifier = qualifier; - return this; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - public Favourite setLanguage(@Nullable String language) { - this.language = language; - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java deleted file mode 100644 index e28bbd8eb41..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteCreateQuery.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class FavouriteCreateQuery extends CreateQuery<Favourite> { - - private String idOrKey; - - public FavouriteCreateQuery(String idOrKey) { - this.idOrKey = idOrKey; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(FavouriteQuery.BASE_URL).append('?'); - appendUrlParameter(url, "key", idOrKey); - return url.toString(); - } - - @Override - public Class<Favourite> getModelClass() { - return Favourite.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java deleted file mode 100644 index e8e8a6d883c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteDeleteQuery.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class FavouriteDeleteQuery extends DeleteQuery { - - private String idOrKey; - - public FavouriteDeleteQuery(String idOrKey) { - this.idOrKey = idOrKey; - } - - public String getIdOrKey() { - return idOrKey; - } - - @Override - public String getUrl() { - return new StringBuilder().append(FavouriteQuery.BASE_URL).append('/').append(encode(idOrKey)).toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteQuery.java deleted file mode 100644 index b3c2d5d194b..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/FavouriteQuery.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class FavouriteQuery extends Query<Favourite> { - - public static final String BASE_URL = "/api/favourites"; - - @Override - public Class<Favourite> getModelClass() { - return Favourite.class; - } - - @Override - public String getUrl() { - return BASE_URL; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java deleted file mode 100644 index 714f6606c6c..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasure.java +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Date; - -/** - * @since 2.10 - */ -public class ManualMeasure extends Model { - - private Long id; - private String metricKey; - private String resourceKey; - private Double value; - private String textValue; - private Date createdAt; - private Date updatedAt; - private String userLogin; - private String username; - - public ManualMeasure() { - } - - @CheckForNull - public Long getId() { - return id; - } - - public ManualMeasure setId(@Nullable Long id) { - this.id = id; - return this; - } - - @CheckForNull - public String getMetricKey() { - return metricKey; - } - - public ManualMeasure setMetricKey(@Nullable String metricKey) { - this.metricKey = metricKey; - return this; - } - - @CheckForNull - public Double getValue() { - return value; - } - - public ManualMeasure setValue(@Nullable Double value) { - this.value = value; - return this; - } - - @CheckForNull - public String getTextValue() { - return textValue; - } - - public ManualMeasure setTextValue(@Nullable String textValue) { - this.textValue = textValue; - return this; - } - - @CheckForNull - public Date getCreatedAt() { - return createdAt; - } - - public ManualMeasure setCreatedAt(@Nullable Date createdAt) { - this.createdAt = createdAt; - return this; - } - - @CheckForNull - public Date getUpdatedAt() { - return updatedAt; - } - - public ManualMeasure setUpdatedAt(@Nullable Date updatedAt) { - this.updatedAt = updatedAt; - return this; - } - - @CheckForNull - public String getUserLogin() { - return userLogin; - } - - public ManualMeasure setUserLogin(@Nullable String userLogin) { - this.userLogin = userLogin; - return this; - } - - @CheckForNull - public String getUsername() { - return username; - } - - public ManualMeasure setUsername(@Nullable String username) { - this.username = username; - return this; - } - - @CheckForNull - public String getResourceKey() { - return resourceKey; - } - - public ManualMeasure setResourceKey(@Nullable String resourceKey) { - this.resourceKey = resourceKey; - return this; - } - - @Override - public String toString() { - return new StringBuilder().append("Measure{") - .append("id='").append(id).append('\'') - .append("resourceKey='").append(resourceKey).append('\'') - .append("metricKey='").append(metricKey).append('\'') - .append(", value=").append(value) - .append(", textValue='").append(textValue).append('\'') - .append('}').toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java deleted file mode 100644 index ca3f456975a..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureCreateQuery.java +++ /dev/null @@ -1,109 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.10 - */ -public final class ManualMeasureCreateQuery extends CreateQuery<ManualMeasure> { - - private String resourceKey; - private String metricKey; - private Integer intValue; - private Double value; - private String textValue; - private String description; - - private ManualMeasureCreateQuery(String resourceKey, String metricKey) { - this.resourceKey = resourceKey; - this.metricKey = metricKey; - } - - public String getResourceKey() { - return resourceKey; - } - - public String getMetricKey() { - return metricKey; - } - - public Double getValue() { - return value; - } - - public ManualMeasureCreateQuery setValue(Double value) { - this.value = value; - return this; - } - - public Integer getIntValue() { - return intValue; - } - - public ManualMeasureCreateQuery setIntValue(Integer intValue) { - this.intValue = intValue; - return this; - } - - public String getTextValue() { - return textValue; - } - - public ManualMeasureCreateQuery setTextValue(String textValue) { - this.textValue = textValue; - return this; - } - - public String getDescription() { - return description; - } - - public ManualMeasureCreateQuery setDescription(String description) { - this.description = description; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(ManualMeasureQuery.BASE_URL); - appendUrlParameter(url, "resource", resourceKey); - appendUrlParameter(url, "metric", metricKey); - if (value != null) { - appendUrlParameter(url, "val", value); - } else if (intValue != null) { - appendUrlParameter(url, "val", intValue); - } - - // limitations : POST body is not used, so the complete URL size is limited - appendUrlParameter(url, "text", textValue); - appendUrlParameter(url, "desc", description); - return url.toString(); - } - - @Override - public Class<ManualMeasure> getModelClass() { - return ManualMeasure.class; - } - - public static ManualMeasureCreateQuery create(String resourceKey, String metricKey) { - return new ManualMeasureCreateQuery(resourceKey, metricKey); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java deleted file mode 100644 index 6e30c0d0d2b..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureDeleteQuery.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.10 - */ -public final class ManualMeasureDeleteQuery extends DeleteQuery { - - private String resourceKey; - private String metricKey; - - private ManualMeasureDeleteQuery(String resourceKey, String metricKey) { - this.resourceKey = resourceKey; - this.metricKey = metricKey; - } - - public static ManualMeasureDeleteQuery create(String resourceKey, String metricKey) { - return new ManualMeasureDeleteQuery(resourceKey, metricKey); - } - - public String getResourceKey() { - return resourceKey; - } - - public String getMetricKey() { - return metricKey; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(ManualMeasureQuery.BASE_URL); - appendUrlParameter(url, "resource", resourceKey); - appendUrlParameter(url, "metric", metricKey); - return url.toString(); - } - - @Override - public String toString() { - return getUrl(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureQuery.java deleted file mode 100644 index 709b891c04b..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ManualMeasureQuery.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.10 - */ -public final class ManualMeasureQuery extends Query<ManualMeasure> { - public static final String BASE_URL = "/api/manual_measures?"; - - private String resourceKey; - private String metricKey; - - private ManualMeasureQuery(String resourceKey) { - this.resourceKey = resourceKey; - } - - public String getResourceKey() { - return resourceKey; - } - - public String getMetricKey() { - return metricKey; - } - - public ManualMeasureQuery setMetricKey(String s) { - this.metricKey = s; - return this; - } - - @Override - public String getUrl() { - StringBuilder sb = new StringBuilder(BASE_URL); - appendUrlParameter(sb, "resource", resourceKey); - appendUrlParameter(sb, "metric", metricKey); - return sb.toString(); - } - - @Override - public Class<ManualMeasure> getModelClass() { - return ManualMeasure.class; - } - - public static ManualMeasureQuery create(String resourceKey) { - return new ManualMeasureQuery(resourceKey); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java deleted file mode 100644 index 3d40a55e9a5..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Measure.java +++ /dev/null @@ -1,381 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; -import java.util.LinkedHashMap; -import java.util.Map; - -public class Measure extends Model { - - private String metricKey; - private String metricName; - private Double value; - private String formattedValue; - private String alertStatus; - private String alertText; - private String data; - private String characteristicKey; - private String characteristicName; - - private Integer trend; - private Integer var; - - private String ruleKey; - private String ruleName; - private String ruleSeverity; - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - private String ruleCategory; - - private Double variation1, variation2, variation3, variation4, variation5; - - @CheckForNull - public String getMetricKey() { - return metricKey; - } - - public Measure setMetricKey(@Nullable String metricKey) { - this.metricKey = metricKey; - return this; - } - - @CheckForNull - public String getMetricName() { - return metricName; - } - - public Measure setMetricName(@Nullable String metricName) { - this.metricName = metricName; - return this; - } - - @CheckForNull - public Double getValue() { - return value; - } - - @CheckForNull - public Integer getIntValue() { - if (value == null) { - return null; - } - return value.intValue(); - } - - @CheckForNull - public Long getLongValue() { - if (value == null) { - return null; - } - return value.longValue(); - } - - public Measure setValue(@Nullable Double value) { - this.value = value; - return this; - } - - @CheckForNull - public String getFormattedValue() { - return formattedValue; - } - - @CheckForNull - public String getFormattedValue(@Nullable String defaultValue) { - if (formattedValue == null) { - return defaultValue; - } - return formattedValue; - } - - public Measure setFormattedValue(@Nullable String formattedValue) { - this.formattedValue = formattedValue; - return this; - } - - @CheckForNull - public String getAlertStatus() { - return alertStatus; - } - - public Measure setAlertStatus(@Nullable String alertStatus) { - this.alertStatus = alertStatus; - return this; - } - - @CheckForNull - public String getAlertText() { - return alertText; - } - - public Measure setAlertText(@Nullable String alertText) { - this.alertText = alertText; - return this; - } - - @CheckForNull - public String getData() { - return data; - } - - @CheckForNull - public Map<String, String> getDataAsMap() { - return getDataAsMap(","); - } - - @CheckForNull - public Map<String, String> getDataAsMap(String separator) { - if (data == null) { - return null; - } - Map<String, String> map = new LinkedHashMap<String, String>(); - String[] parts = data.split(separator); - for (String part : parts) { - String[] kv = part.split("="); - map.put(kv[0], kv[1]); - } - return map; - } - - public Measure setData(@Nullable String data) { - this.data = data; - return this; - } - - @CheckForNull - public Integer getTrend() { - return trend; - } - - public Measure setTrend(@Nullable Integer trend) { - this.trend = trend; - return this; - } - - @CheckForNull - public Integer getVar() { - return var; - } - - public Measure setVar(@Nullable Integer var) { - this.var = var; - return this; - } - - @CheckForNull - public String getRuleKey() { - return ruleKey; - } - - public Measure setRuleKey(@Nullable String ruleKey) { - this.ruleKey = ruleKey; - return this; - } - - @CheckForNull - public String getRuleName() { - return ruleName; - } - - public Measure setRuleName(@Nullable String ruleName) { - this.ruleName = ruleName; - return this; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - @CheckForNull - public String getRuleCategory() { - return ruleCategory; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public Measure setRuleCategory(@Nullable String ruleCategory) { - this.ruleCategory = ruleCategory; - return this; - } - - /** - * @since 2.5 - */ - public Measure setRuleSeverity(@Nullable String ruleSeverity) { - this.ruleSeverity = ruleSeverity; - return this; - } - - /** - * @since 2.5 - */ - @CheckForNull - public String getRuleSeverity() { - return ruleSeverity; - } - - /** - * @deprecated since 2.5 use {@link #getRuleSeverity()} instead. See http://jira.codehaus.org/browse/SONAR-1829 - */ - @Deprecated - @CheckForNull - public String getRulePriority() { - return ruleSeverity; - } - - /** - * @deprecated since 2.5 use {@link #setRuleSeverity(String)} instead. See http://jira.codehaus.org/browse/SONAR-1829 - */ - @Deprecated - public Measure setRulePriority(@Nullable String rulePriority) { - this.ruleSeverity = rulePriority; - return this; - } - - @CheckForNull - public String getCharacteristicKey() { - return characteristicKey; - } - - @CheckForNull - public String getCharacteristicName() { - return characteristicName; - } - - public Measure setCharacteristicKey(@Nullable String s) { - this.characteristicKey = s; - return this; - } - - public Measure setCharacteristicName(@Nullable String s) { - this.characteristicName = s; - return this; - } - - /** - * Variation value on period 1. The value is loaded if ResourceQuery#setIncludeTrends() is set to true. - * @since 2.5 - */ - @CheckForNull - public Double getVariation1() { - return variation1; - } - - /** - * @since 2.5 - */ - public Measure setVariation1(@Nullable Double variation1) { - this.variation1 = variation1; - return this; - } - - /** - * Variation value on period 2. The value is loaded if ResourceQuery#setIncludeTrends() is set to true. - * @since 2.5 - */ - @CheckForNull - public Double getVariation2() { - return variation2; - } - - /** - * @since 2.5 - */ - public Measure setVariation2(@Nullable Double variation2) { - this.variation2 = variation2; - return this; - } - - /** - * Variation value on period 3. The value is loaded if ResourceQuery#setIncludeTrends() is set to true. - * @since 2.5 - */ - @CheckForNull - public Double getVariation3() { - return variation3; - } - - /** - * @since 2.5 - */ - public Measure setVariation3(@Nullable Double variation3) { - this.variation3 = variation3; - return this; - } - - /** - * Variation value on period 4. The value is loaded if ResourceQuery#setIncludeTrends() is set to true. - * @since 2.5 - */ - @CheckForNull - public Double getVariation4() { - return variation4; - } - - /** - * @since 2.5 - */ - public Measure setVariation4(@Nullable Double variation4) { - this.variation4 = variation4; - return this; - } - - /** - * Variation value on period 5. The value is loaded if ResourceQuery#setIncludeTrends() is set to true. - * @since 2.5 - */ - @CheckForNull - public Double getVariation5() { - return variation5; - } - - /** - * @since 2.5 - */ - public Measure setVariation5(@Nullable Double variation5) { - this.variation5 = variation5; - return this; - } - - @Override - public String toString() { - return new StringBuilder().append("Measure{") - .append("metricKey='").append(metricKey).append('\'') - .append(", metricName='").append(metricName).append('\'') - .append(", value=").append(value) - .append(", formattedValue='").append(formattedValue).append('\'') - .append(", data='").append(data).append('\'') - .append(", characteristicKey='").append(characteristicKey).append('\'') - .append(", characteristicName='").append(characteristicName).append('\'') - .append(", trend=").append(trend).append(", var=").append(var) - .append(", ruleKey='").append(ruleKey).append('\'') - .append(", ruleName='").append(ruleName).append('\'') - .append(", ruleCategory='").append(ruleCategory).append('\'') - .append(", rulePriority='").append(ruleSeverity).append('\'') - .append('}').toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java deleted file mode 100644 index 90ba55ecb99..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Metric.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class Metric extends Model { - - private String key; - private String name; - private Integer direction; - private String domain; - private String description; - private String type; - private Boolean userManaged; - private Boolean hidden; - - @CheckForNull - public String getKey() { - return key; - } - - public Metric setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getName() { - return name; - } - - public Metric setName(@Nullable String name) { - this.name = name; - return this; - } - - @CheckForNull - public Integer getDirection() { - return direction; - } - - public Metric setDirection(@Nullable Integer direction) { - this.direction = direction; - return this; - } - - @CheckForNull - public String getDomain() { - return domain; - } - - public Metric setDomain(@Nullable String domain) { - this.domain = domain; - return this; - } - - @CheckForNull - public String getDescription() { - return description; - } - - public Metric setDescription(@Nullable String description) { - this.description = description; - return this; - } - - @CheckForNull - public String getType() { - return type; - } - - public Metric setType(@Nullable String type) { - this.type = type; - return this; - } - - @CheckForNull - public Boolean getHidden() { - return hidden; - } - - public Metric setHidden(@Nullable Boolean hidden) { - this.hidden = hidden; - return this; - } - - @CheckForNull - public Boolean getUserManaged() { - return userManaged; - } - - public Metric setUserManaged(@Nullable Boolean userManaged) { - this.userManaged = userManaged; - return this; - } - - @Override - public String toString() { - return new StringBuilder() - .append(name) - .append("(") - .append(key) - .append(")") - .toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricCreateQuery.java deleted file mode 100644 index 6cee3692439..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricCreateQuery.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 3.6 - */ -public class MetricCreateQuery extends CreateQuery<Metric> { - - private String key; - private String name; - private String description; - private String domain; - private String type; - - public static MetricCreateQuery create(String metricKey) { - return new MetricCreateQuery(metricKey); - } - - private MetricCreateQuery(String key) { - this.key = key; - } - - public MetricCreateQuery setName(String name) { - this.name = name; - return this; - } - - public MetricCreateQuery setDescription(String description) { - this.description = description; - return this; - } - - public MetricCreateQuery setDomain(String domain) { - this.domain = domain; - return this; - } - - public MetricCreateQuery setType(String type) { - this.type = type; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(MetricQuery.BASE_URL); - url.append("/").append(encode(key)); - url.append('?'); - appendUrlParameter(url, "name", name); - appendUrlParameter(url, "description", description); - appendUrlParameter(url, "domain", domain); - appendUrlParameter(url, "val_type", type); - return url.toString(); - } - - @Override - public Class<Metric> getModelClass() { - return Metric.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricDeleteQuery.java deleted file mode 100644 index 6a0de9db9a3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricDeleteQuery.java +++ /dev/null @@ -1,53 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 3.6 - */ -public class MetricDeleteQuery extends DeleteQuery { - - private String key; - - public static MetricDeleteQuery delete(String key){ - return new MetricDeleteQuery(key); - } - - private MetricDeleteQuery(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public MetricDeleteQuery setKey(String key) { - this.key = key; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(MetricQuery.BASE_URL); - url.append("/").append(encode(key)); - return url.toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java deleted file mode 100644 index c55749dfa2e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricQuery.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public final class MetricQuery extends Query<Metric> { - public static final String BASE_URL = "/api/metrics"; - - private String key; - - private MetricQuery() { - } - - private MetricQuery(String key) { - this.key = key; - } - - @Override - public String getUrl() { - StringBuilder sb = new StringBuilder(BASE_URL); - if (key != null && !"".equals(key)) { - sb.append("/"); - sb.append(encode(key)); - } - sb.append("?"); - return sb.toString(); - } - - @Override - public Class<Metric> getModelClass() { - return Metric.class; - } - - public static MetricQuery all() { - return new MetricQuery(); - } - - public static MetricQuery byKey(String metricKey) { - return new MetricQuery(metricKey); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricUpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricUpdateQuery.java deleted file mode 100644 index f66f200262d..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/MetricUpdateQuery.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 3.6 - */ -public class MetricUpdateQuery extends UpdateQuery<Metric> { - - private String key; - private String name; - private String description; - private String domain; - private String type; - - public static MetricUpdateQuery update(String key){ - return new MetricUpdateQuery(key); - } - - private MetricUpdateQuery(String key) { - this.key = key; - } - - public MetricUpdateQuery setName(String name) { - this.name = name; - return this; - } - - public MetricUpdateQuery setDescription(String description) { - this.description = description; - return this; - } - - public MetricUpdateQuery setDomain(String domain) { - this.domain = domain; - return this; - } - - public MetricUpdateQuery setType(String type) { - this.type = type; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(MetricQuery.BASE_URL); - url.append("/").append(encode(key)); - url.append('?'); - appendUrlParameter(url, "name", name); - appendUrlParameter(url, "description", description); - appendUrlParameter(url, "domain", domain); - appendUrlParameter(url, "val_type", type); - return url.toString(); - } - - /** - * Property {@link #description} transmitted through request body as content may exceed URL size allowed by the server. - */ - @Override - public String getBody() { - return description; - } - - @Override - public Class<Metric> getModelClass() { - return Metric.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Model.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Model.java deleted file mode 100644 index 706bc6e7951..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Model.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public abstract class Model { -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java deleted file mode 100644 index e38ec4d910e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Plugin.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -/** - * @since 2.4 - */ -public class Plugin extends Model { - - private String key; - private String name; - private String version; - - @CheckForNull - public String getKey() { - return key; - } - - public Plugin setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getName() { - return name; - } - - public Plugin setName(@Nullable String name) { - this.name = name; - return this; - } - - @CheckForNull - public String getVersion() { - return version; - } - - public Plugin setVersion(@Nullable String version) { - this.version = version; - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java deleted file mode 100644 index 22077d37721..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Profile.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.*; - -/** - * @since 2.7 - */ -public class Profile extends Model { - - private String language; - private String name; - private boolean defaultProfile; - private String parentName; - private List<Rule> rules = new ArrayList<Rule>(); - - @CheckForNull - public String getLanguage() { - return language; - } - - public Profile setLanguage(@Nullable String s) { - this.language = s; - return this; - } - - @CheckForNull - public String getName() { - return name; - } - - public Profile setName(@Nullable String name) { - this.name = name; - return this; - } - - public boolean isDefaultProfile() { - return defaultProfile; - } - - public Profile setDefaultProfile(boolean b) { - this.defaultProfile = b; - return this; - } - - public String getParentName() { - return parentName; - } - - @CheckForNull - public Profile setParentName(@Nullable String s) { - this.parentName = s; - return this; - } - - public List<Rule> getRules() { - return rules; - } - - public Rule getRule(String repositoryKey, String ruleKey) { - for (Rule rule : rules) { - if (repositoryKey.equals(rule.getRepository()) && ruleKey.equals(rule.getKey())) { - return rule; - } - } - return null; - } - - public Profile addRule(Rule rule) { - rules.add(rule); - return this; - } - - public static final class Rule { - private String key; - private String repository; - private String severity; - private String inheritance; - private Map<String,String> parameters; - - @CheckForNull - public String getKey() { - return key; - } - - public Rule setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getRepository() { - return repository; - } - - public Rule setRepository(@Nullable String repository) { - this.repository = repository; - return this; - } - - @CheckForNull - public String getSeverity() { - return severity; - } - - public Rule setSeverity(@Nullable String severity) { - this.severity = severity; - return this; - } - - @CheckForNull - public String getInheritance() { - return inheritance; - } - - public Rule setInheritance(@Nullable String inheritance) { - this.inheritance = inheritance; - return this; - } - - public Map<String, String> getParameters() { - if (parameters==null) { - return Collections.emptyMap(); - } - return parameters; - } - - public String getParameter(String key) { - return getParameters().get(key); - } - - public Rule addParameter(@Nullable String key, @Nullable String value) { - if (parameters==null) { - parameters = new HashMap<String,String>(); - } - parameters.put(key, value); - return this; - } - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProfileQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProfileQuery.java deleted file mode 100644 index dab318b69c3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProfileQuery.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.7 - */ -public final class ProfileQuery extends Query<Profile> { - public static final String BASE_URL = "/api/profiles"; - - private String language; - private String name;//optional - private String[] ruleRepositories;//optional - private String[] ruleSeverities;//optional - - private ProfileQuery(String language) { - this.language = language; - } - - public String getLanguage() { - return language; - } - - public String getName() { - return name; - } - - public String[] getRuleRepositories() { - return ruleRepositories; - } - - public String[] getRuleSeverities() { - return ruleSeverities; - } - - public ProfileQuery setName(String name) { - this.name = name; - return this; - } - - public ProfileQuery setRuleRepositories(String[] ruleRepositories) { - this.ruleRepositories = ruleRepositories; - return this; - } - - public ProfileQuery setRuleSeverities(String[] ruleSeverities) { - this.ruleSeverities = ruleSeverities; - return this; - } - - @Override - public Class<Profile> getModelClass() { - return Profile.class; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "language", language); - appendUrlParameter(url, "name", name); - appendUrlParameter(url, "rule_repositories", ruleRepositories); - appendUrlParameter(url, "rule_severities", ruleSeverities); - return url.toString(); - } - - public static ProfileQuery createWithLanguage(String language) { - return new ProfileQuery(language); - } - - public static ProfileQuery create(String language, String name) { - return new ProfileQuery(language).setName(name); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProjectDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProjectDeleteQuery.java deleted file mode 100644 index 287fec55535..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ProjectDeleteQuery.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.11 - */ -public final class ProjectDeleteQuery extends DeleteQuery { - - private String key; - private static final String BASE_URL = "/api/projects/"; - - private ProjectDeleteQuery(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(BASE_URL); - url.append(encode(key)); - return url.toString(); - } - - public static ProjectDeleteQuery create(String projectKeyOrId) { - return new ProjectDeleteQuery(projectKeyOrId); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Property.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Property.java deleted file mode 100644 index 83d90d22cb0..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Property.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -public class Property extends Model { - - private String key; - private String value; - - public Property(String key, String value) { - this.key = key; - this.value = value; - } - - public Property() { - } - - @CheckForNull - public String getKey() { - return key; - } - - public Property setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getValue() { - return value; - } - - public Property setValue(@Nullable String value) { - this.value = value; - return this; - } - - @Override - public String toString() { - return new StringBuilder() - .append('[') - .append(key) - .append(':') - .append(value) - .append(']') - .toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java deleted file mode 100644 index 0a4a98d1ad1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyCreateQuery.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.6 - */ -public class PropertyCreateQuery extends CreateQuery<Property> { - - private String key; - private String value; - private String resourceKeyOrId; - - public PropertyCreateQuery() { - } - - public PropertyCreateQuery(String key, String value) { - this.key = key; - this.value = value; - } - - public PropertyCreateQuery(String key, String value, String resourceKeyOrId) { - this.key = key; - this.value = value; - this.resourceKeyOrId = resourceKeyOrId; - } - - public PropertyCreateQuery(Property property) { - this.key = property.getKey(); - this.value = property.getValue(); - } - - public String getKey() { - return key; - } - - public PropertyCreateQuery setKey(String key) { - this.key = key; - return this; - } - - public String getValue() { - return value; - } - - public PropertyCreateQuery setValue(String value) { - this.value = value; - return this; - } - - public String getResourceKeyOrId() { - return resourceKeyOrId; - } - - public PropertyCreateQuery setResourceKeyOrId(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(PropertyQuery.BASE_URL); - url.append("?id=").append(encode(key)).append("&"); - appendUrlParameter(url, "value", value); - appendUrlParameter(url, "resource", resourceKeyOrId); - return url.toString(); - } - - /** - * Property value is transmitted through request body as content may - * exceed URL size allowed by the server. - */ - @Override - public String getBody() { - return value; - } - - @Override - public Class<Property> getModelClass() { - return Property.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java deleted file mode 100644 index ce58cd72921..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyDeleteQuery.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.6 - */ -public class PropertyDeleteQuery extends DeleteQuery { - - private String key; - private String resourceKeyOrId; - - public PropertyDeleteQuery(String key) { - this.key = key; - } - - public PropertyDeleteQuery(String key, String resourceKeyOrId) { - this.key = key; - this.resourceKeyOrId = resourceKeyOrId; - } - - public PropertyDeleteQuery(Property property) { - this.key = property.getKey(); - } - - public String getKey() { - return key; - } - - public PropertyDeleteQuery setKey(String key) { - this.key = key; - return this; - } - - public String getResourceKeyOrId() { - return resourceKeyOrId; - } - - public PropertyDeleteQuery setResourceKeyOrId(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(PropertyQuery.BASE_URL); - url.append("/").append(encode(key)); - url.append('?'); - appendUrlParameter(url, "resource", resourceKeyOrId); - return url.toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java deleted file mode 100644 index 3d8976bacf9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyQuery.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class PropertyQuery extends Query<Property> { - public static final String BASE_URL = "/api/properties"; - - private String key = null; - private String resourceKeyOrId = null; - - public String getKey() { - return key; - } - - public PropertyQuery setKey(String key) { - this.key = key; - return this; - } - - public String getResourceKeyOrId() { - return resourceKeyOrId; - } - - public PropertyQuery setResourceKeyOrId(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - if (key != null) { - url.append("/").append(encode(key)); - } - url.append('?'); - appendUrlParameter(url, "resource", resourceKeyOrId); - return url.toString(); - } - - @Override - public Class<Property> getModelClass() { - return Property.class; - } - - public static PropertyQuery createForAll() { - return new PropertyQuery(); - } - - public static PropertyQuery createForKey(String key) { - return new PropertyQuery().setKey(key); - } - - public static PropertyQuery createForResource(String key, String resourceKeyOrId) { - return new PropertyQuery().setKey(key).setResourceKeyOrId(resourceKeyOrId); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java deleted file mode 100644 index 104e20ed5ca..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/PropertyUpdateQuery.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.6 - */ -public class PropertyUpdateQuery extends UpdateQuery<Property> { - - private String key; - private String value; - private String resourceKeyOrId; - - public PropertyUpdateQuery() { - } - - public PropertyUpdateQuery(String key, String value) { - this.key = key; - this.value = value; - } - - public PropertyUpdateQuery(String key, String value, String resourceKeyOrId) { - this.key = key; - this.value = value; - this.resourceKeyOrId = resourceKeyOrId; - } - - public PropertyUpdateQuery(Property property) { - this.key = property.getKey(); - this.value = property.getValue(); - } - - public String getKey() { - return key; - } - - public PropertyUpdateQuery setKey(String key) { - this.key = key; - return this; - } - - public String getValue() { - return value; - } - - public PropertyUpdateQuery setValue(String value) { - this.value = value; - return this; - } - - public String getResourceKeyOrId() { - return resourceKeyOrId; - } - - public PropertyUpdateQuery setResourceKeyOrId(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append(PropertyQuery.BASE_URL); - url.append("/").append(encode(key)); - url.append('?'); - appendUrlParameter(url, "resource", resourceKeyOrId); - return url.toString(); - } - - /** - * Property value is transmitted through request body as content may - * exceed URL size allowed by the server. - */ - @Override - public String getBody() { - return value; - } - - @Override - public Class<Property> getModelClass() { - return Property.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Query.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Query.java deleted file mode 100644 index 0af65a7cf57..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Query.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.1 - */ -public abstract class Query<M extends Model> extends AbstractQuery<M> { - - public abstract Class<M> getModelClass(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Resource.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Resource.java deleted file mode 100644 index 19d2c3f2fdb..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Resource.java +++ /dev/null @@ -1,500 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Collections; -import java.util.Date; -import java.util.List; - -public class Resource extends Model { - - /* SCOPES */ - public static final String SCOPE_SET = "PRJ"; - public static final String SCOPE_SPACE = "DIR"; - public static final String SCOPE_ENTITY = "FIL"; - - /* QUALIFIERS */ - public static final String QUALIFIER_VIEW = "VW"; - public static final String QUALIFIER_SUBVIEW = "SVW"; - public static final String QUALIFIER_LIB = "LIB"; - public static final String QUALIFIER_PROJECT = "TRK"; - public static final String QUALIFIER_MODULE = "BRC"; - /** - * @deprecated since 4.2 - */ - @Deprecated - public static final String QUALIFIER_PACKAGE = "PAC"; - public static final String QUALIFIER_DIRECTORY = "DIR"; - public static final String QUALIFIER_FILE = "FIL"; - /** - * @deprecated since 4.2 - */ - @Deprecated - public static final String QUALIFIER_CLASS = "CLA"; - public static final String QUALIFIER_UNIT_TEST_CLASS = "UTS"; - - /* LANGUAGES */ - public static final String LANGUAGE_JAVA = "java"; - - private Integer id; - private String key; - private String name; - private String longName; - private String scope; - private String qualifier; - private String language; - private String version; - private Integer copy; - private String description; - private Date date; - private List<Measure> measures; - private Date creationDate; - - // periods used for variations and tracking of violations - private String period1Mode, period2Mode, period3Mode, period4Mode, period5Mode; - private String period1Param, period2Param, period3Param, period4Param, period5Param; - private Date period1Date, period2Date, period3Date, period4Date, period5Date; - - @CheckForNull - public Integer getId() { - return id; - } - - public Resource setId(@Nullable Integer id) { - this.id = id; - return this; - } - - @CheckForNull - public String getKey() { - return key; - } - - public Resource setKey(@Nullable String key) { - this.key = key; - return this; - } - - @CheckForNull - public String getDescription() { - return description; - } - - public Resource setDescription(@Nullable String description) { - this.description = description; - return this; - } - - @CheckForNull - public String getName() { - return name; - } - - @CheckForNull - public String getName(boolean longFormatIfDefined) { - if (longFormatIfDefined && longName != null && !"".equals(longName)) { - return longName; - } - return name; - } - - @CheckForNull - public String getLongName() { - return longName; - } - - public Resource setLongName(@Nullable String longName) { - this.longName = longName; - return this; - } - - public Resource setName(@Nullable String s) { - this.name = s; - return this; - } - - @CheckForNull - public String getScope() { - return scope; - } - - public Resource setScope(@Nullable String scope) { - this.scope = scope; - return this; - } - - @CheckForNull - public String getQualifier() { - return qualifier; - } - - public Resource setQualifier(@Nullable String qualifier) { - this.qualifier = qualifier; - return this; - } - - @CheckForNull - public String getLanguage() { - return language; - } - - public Resource setLanguage(@Nullable String language) { - this.language = language; - return this; - } - - @CheckForNull - public String getVersion() { - return version; - } - - public Resource setVersion(@Nullable String version) { - this.version = version; - return this; - } - - @CheckForNull - public Integer getCopy() { - return copy; - } - - public Resource setCopy(@Nullable Integer copy) { - this.copy = copy; - return this; - } - - @CheckForNull - public Date getDate() { - return date; - } - - public Resource setDate(@Nullable Date d) { - this.date = d; - return this; - } - - @CheckForNull - public Date getCreationDate() { - return creationDate; - } - - public Resource setCreationDate(@Nullable Date d) { - this.creationDate = d; - return this; - } - - public List<Measure> getMeasures() { - if (measures == null) { - return Collections.emptyList(); - } - return measures; - } - - public Measure getMeasure(String metricKey) { - for (Measure measure : getMeasures()) { - if (metricKey.equals(measure.getMetricKey())) { - return measure; - } - } - return null; - } - - public Double getMeasureValue(String metricKey) { - Measure measure = getMeasure(metricKey); - if (measure != null) { - return measure.getValue(); - } - return null; - } - - public Integer getMeasureIntValue(String metricKey) { - Double d = getMeasureValue(metricKey); - if (d != null) { - return d.intValue(); - } - return null; - } - - public String getMeasureFormattedValue(String metricKey, String defaultValue) { - Measure measure = getMeasure(metricKey); - if (measure != null) { - return measure.getFormattedValue(defaultValue); - } - return defaultValue; - } - - public void setMeasures(List<Measure> measures) { - this.measures = measures; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod1Mode() { - return period1Mode; - } - - /** - * @since 2.5 - */ - public Resource setPeriod1Mode(@Nullable String period1Mode) { - this.period1Mode = period1Mode; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod2Mode() { - return period2Mode; - } - - /** - * @since 2.5 - */ - public Resource setPeriod2Mode(@Nullable String period2Mode) { - this.period2Mode = period2Mode; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod3Mode() { - return period3Mode; - } - - /** - * @since 2.5 - */ - public Resource setPeriod3Mode(@Nullable String period3Mode) { - this.period3Mode = period3Mode; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod4Mode() { - return period4Mode; - } - - /** - * @since 2.5 - */ - public Resource setPeriod4Mode(@Nullable String period4Mode) { - this.period4Mode = period4Mode; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod5Mode() { - return period5Mode; - } - - /** - * @since 2.5 - */ - public Resource setPeriod5Mode(@Nullable String period5Mode) { - this.period5Mode = period5Mode; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod1Param() { - return period1Param; - } - - /** - * @since 2.5 - */ - public Resource setPeriod1Param(@Nullable String period1Param) { - this.period1Param = period1Param; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod2Param() { - return period2Param; - } - - /** - * @since 2.5 - */ - public Resource setPeriod2Param(@Nullable String period2Param) { - this.period2Param = period2Param; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod3Param() { - return period3Param; - } - - /** - * @since 2.5 - */ - public Resource setPeriod3Param(@Nullable String period3Param) { - this.period3Param = period3Param; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod4Param() { - return period4Param; - } - - /** - * @since 2.5 - */ - public Resource setPeriod4Param(@Nullable String period4Param) { - this.period4Param = period4Param; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public String getPeriod5Param() { - return period5Param; - } - - /** - * @since 2.5 - */ - public Resource setPeriod5Param(@Nullable String period5Param) { - this.period5Param = period5Param; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public Date getPeriod1Date() { - return period1Date; - } - - /** - * @since 2.5 - */ - public Resource setPeriod1Date(@Nullable Date period1Date) { - this.period1Date = period1Date; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public Date getPeriod2Date() { - return period2Date; - } - - /** - * @since 2.5 - */ - public Resource setPeriod2Date(@Nullable Date period2Date) { - this.period2Date = period2Date; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public Date getPeriod3Date() { - return period3Date; - } - - /** - * @since 2.5 - */ - public Resource setPeriod3Date(@Nullable Date period3Date) { - this.period3Date = period3Date; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public Date getPeriod4Date() { - return period4Date; - } - - /** - * @since 2.5 - */ - public Resource setPeriod4Date(@Nullable Date period4Date) { - this.period4Date = period4Date; - return this; - } - - /** - * @since 2.5 only on projects, else null - */ - @CheckForNull - public Date getPeriod5Date() { - return period5Date; - } - - /** - * @since 2.5 - */ - public Resource setPeriod5Date(@Nullable Date period5Date) { - this.period5Date = period5Date; - return this; - } - - @Override - public String toString() { - return new StringBuilder() - .append("[id=") - .append(id) - .append(",key=") - .append(key) - .append("]") - .toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java deleted file mode 100644 index 2d06ec99efc..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceQuery.java +++ /dev/null @@ -1,317 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class ResourceQuery extends Query<Resource> { - - public static final String BASE_URL = "/api/resources"; - - public static final int DEPTH_UNLIMITED = -1; - - private Integer depth; - private String resourceKeyOrId; - private Integer limit; - private String[] scopes; - private String[] qualifiers; - private String[] metrics; - private String[] rules; - private String[] ruleSeverities; - private String[] characteristicKeys; - private boolean excludeRules = true; - private boolean excludeRuleSeverities = true; - private Boolean includeTrends = null; - private Boolean includeAlerts = null; - private Boolean verbose = Boolean.FALSE; - - public ResourceQuery() { - } - - public ResourceQuery(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - } - - public ResourceQuery(long resourceId) { - this.resourceKeyOrId = String.valueOf(resourceId); - } - - public Integer getDepth() { - return depth; - } - - public ResourceQuery setDepth(Integer depth) { - this.depth = depth; - return this; - } - - public ResourceQuery setAllDepths() { - return setDepth(DEPTH_UNLIMITED); - } - - public String getResourceKeyOrId() { - return resourceKeyOrId; - } - - public ResourceQuery setResourceKeyOrId(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - return this; - } - - public ResourceQuery setResourceId(int resourceId) { - this.resourceKeyOrId = Integer.toString(resourceId); - return this; - } - - public ResourceQuery setCharacteristics(String... keys) { - this.characteristicKeys = keys; - return this; - } - - public Integer getLimit() { - return limit; - } - - public ResourceQuery setLimit(Integer limit) { - this.limit = limit; - return this; - } - - public String[] getScopes() { - return scopes; - } - - public ResourceQuery setScopes(String... scopes) { - this.scopes = scopes; - return this; - } - - public String[] getQualifiers() { - return qualifiers; - } - - public ResourceQuery setQualifiers(String... qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - public String[] getMetrics() { - return metrics; - } - - public ResourceQuery setMetrics(String... metrics) { - this.metrics = metrics; - return this; - } - - public String[] getRules() { - return rules; - } - - public ResourceQuery setRules(String... rules) { - this.rules = rules; - this.excludeRules = false; - return this; - } - - /** - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public String[] getRuleCategories() { - return null; - } - - /** - * @param ruleCategories values: Maintainability, Usability, Reliability, Efficiency, Portability - * @deprecated since 2.5 See http://jira.codehaus.org/browse/SONAR-2007 - */ - @Deprecated - public ResourceQuery setRuleCategories(String... ruleCategories) { - return this; - } - - /** - * @since 2.5 - */ - public String[] getRuleSeverities() { - return ruleSeverities; - } - - /** - * @since 2.5 - * @param ruleSeverities values: BLOCKER, CRITICAL, MAJOR, MINOR, INFO - */ - public ResourceQuery setRuleSeverities(String... ruleSeverities) { - this.ruleSeverities = ruleSeverities; - this.excludeRuleSeverities = false; - return this; - } - - /** - * @deprecated since 2.5 use {@link #getRuleSeverities()} instead. See http://jira.codehaus.org/browse/SONAR-1829 - */ - @Deprecated - public String[] getRulePriorities() { - return ruleSeverities; - } - - /** - * @deprecated since 2.5 use {@link #setRuleSeverities(String...)} instead. See http://jira.codehaus.org/browse/SONAR-1829 - */ - @Deprecated - public ResourceQuery setRulePriorities(String... rulePriorities) { - return setRuleSeverities(rulePriorities); - } - - public boolean isExcludeRules() { - return excludeRules; - } - - public ResourceQuery setExcludeRules(boolean excludeRules) { - this.excludeRules = excludeRules; - return this; - } - - /** - * @deprecated since 2.5 not used anymore - */ - @Deprecated - public boolean isExcludeRuleCategories() { - return false; - } - - /** - * @deprecated since 2.5 not used anymore - */ - @Deprecated - public ResourceQuery setExcludeRuleCategories(boolean b) { - return this; - } - - /** - * @since 2.5 - */ - public boolean isExcludeRuleSeverities() { - return excludeRuleSeverities; - } - - public ResourceQuery setExcludeRuleSeverities(boolean excludeRuleSeverities) { - this.excludeRuleSeverities = excludeRuleSeverities; - return this; - } - - /** - * @deprecated since 2.5 use {@link #isExcludeRuleSeverities()} instead. See http://jira.codehaus.org/browse/SONAR-1829 - */ - @Deprecated - public boolean isExcludeRulePriorities() { - return excludeRuleSeverities; - } - - /** - * @deprecated since 2.5 use {@link #setExcludeRuleSeverities(boolean)} instead. See http://jira.codehaus.org/browse/SONAR-1829 - */ - @Deprecated - public ResourceQuery setExcludeRulePriorities(boolean b) { - this.excludeRuleSeverities = b; - return this; - } - - public Boolean isVerbose() { - return verbose; - } - - public ResourceQuery setVerbose(Boolean verbose) { - this.verbose = verbose; - return this; - } - - public Boolean isIncludeTrends() { - return includeTrends; - } - - public ResourceQuery setIncludeTrends(Boolean includeTrends) { - this.includeTrends = includeTrends; - return this; - } - - public Boolean isIncludeAlerts() { - return includeAlerts; - } - - public ResourceQuery setIncludeAlerts(Boolean includeAlerts) { - this.includeAlerts = includeAlerts; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", resourceKeyOrId); - appendUrlParameter(url, "metrics", metrics); - appendUrlParameter(url, "scopes", scopes); - appendUrlParameter(url, "qualifiers", qualifiers); - appendUrlParameter(url, "depth", depth); - appendUrlParameter(url, "limit", limit); - appendRuleField(url, "rules", excludeRules, rules); - appendRuleField(url, "rule_priorities", excludeRuleSeverities, ruleSeverities); - appendUrlParameter(url, "includetrends", includeTrends); - appendUrlParameter(url, "characteristics", characteristicKeys); - appendUrlParameter(url, "includealerts", includeAlerts); - appendUrlParameter(url, "verbose", verbose); - return url.toString(); - } - - private void appendRuleField(StringBuilder url, String field, boolean excludeField, String[] list) { - if (!excludeField) { - if (list == null || list.length == 0) { - appendUrlParameter(url, field, true); - } else { - appendUrlParameter(url, field, list); - } - } - } - - @Override - public final Class<Resource> getModelClass() { - return Resource.class; - } - - public static ResourceQuery createForMetrics(String resourceKeyOrId, String... metricKeys) { - return new ResourceQuery(resourceKeyOrId) - .setMetrics(metricKeys); - } - - public static ResourceQuery createForResource(Resource resource, String... metricKeys) { - Integer id = resource.getId(); - if (id == null) { - throw new IllegalArgumentException("id must be set"); - } - return new ResourceQuery(id.toString()) - .setMetrics(metricKeys); - } - - /** - * @since 2.10 - */ - public static ResourceQuery create(String resourceKey) { - return new ResourceQuery(resourceKey); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java deleted file mode 100644 index 64d5d395e76..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchQuery.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 3.4 - */ -public class ResourceSearchQuery extends Query<ResourceSearchResult> { - - private int page = -1; - private int pageSize = -1; - private String[] qualifiers = null; - private String text; - - private ResourceSearchQuery() { - } - - public static ResourceSearchQuery create(String text) { - return new ResourceSearchQuery().setText(text); - } - - public int getPage() { - return page; - } - - public ResourceSearchQuery setPage(int page) { - this.page = page; - return this; - } - - public int getPageSize() { - return pageSize; - } - - public ResourceSearchQuery setPageSize(int pageSize) { - this.pageSize = pageSize; - return this; - } - - public String[] getQualifiers() { - return qualifiers; - } - - public ResourceSearchQuery setQualifiers(String... qualifiers) { - this.qualifiers = qualifiers; - return this; - } - - public String getText() { - return text; - } - - public ResourceSearchQuery setText(String text) { - this.text = text; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(); - url.append("/api/resources/search?"); - appendUrlParameter(url, "s", text); - if (page > 0) { - appendUrlParameter(url, "p", page); - } - if (pageSize > 0) { - appendUrlParameter(url, "ps", pageSize); - } - appendUrlParameter(url, "q", qualifiers); - return url.toString(); - } - - @Override - public Class<ResourceSearchResult> getModelClass() { - return ResourceSearchResult.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchResult.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchResult.java deleted file mode 100644 index e4bbce52301..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ResourceSearchResult.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.List; - -public class ResourceSearchResult extends Model { - - public static class Resource { - private String key, name, qualifier; - - @CheckForNull - public String key() { - return key; - } - - @CheckForNull - public String name() { - return name; - } - - @CheckForNull - public String qualifier() { - return qualifier; - } - - public void setKey(@Nullable String key) { - this.key = key; - } - - public void setName(@Nullable String s) { - this.name = s; - } - - public void setQualifier(@Nullable String qualifier) { - this.qualifier = qualifier; - } - } - - - private Integer page, pageSize, total; - private List<ResourceSearchResult.Resource> resources; - - @CheckForNull - public Integer getPage() { - return page; - } - - @CheckForNull - public Integer getTotal() { - return total; - } - - public List<ResourceSearchResult.Resource> getResources() { - return resources; - } - - public void setPage(@Nullable Integer page) { - this.page = page; - } - - public void setTotal(@Nullable Integer total) { - this.total = total; - } - - @CheckForNull - public Integer getPageSize() { - return pageSize; - } - - public void setPageSize(@Nullable Integer pageSize) { - this.pageSize = pageSize; - } - - public void setResources(List<Resource> resources) { - this.resources = resources; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Server.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Server.java deleted file mode 100644 index ac3304fc69d..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Server.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -/** - * @author Evgeny Mandrikov - */ -public class Server extends Model { - - public static enum Status { - SETUP, - UP, - DOWN, - - /** - * @since 3.3 - */ - MIGRATION_RUNNING - } - - private String id; - private String version; - private Status status; - private String statusMessage; - - @CheckForNull - public String getVersion() { - return version; - } - - @CheckForNull - public String getId() { - return id; - } - - public Server setVersion(@Nullable String s) { - this.version = s; - return this; - } - - public Server setId(@Nullable String id) { - this.id = id; - return this; - } - - @CheckForNull - public Status getStatus() { - return status; - } - - @CheckForNull - public String getStatusMessage() { - return statusMessage; - } - - public Server setStatus(Status status) { - this.status = status; - return this; - } - - public Server setStatusMessage(@Nullable String statusMessage) { - this.statusMessage = statusMessage; - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerQuery.java deleted file mode 100644 index b3a3f8d7535..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerQuery.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @author Evgeny Mandrikov - */ -public class ServerQuery extends Query<Server> { - public static final String BASE_URL = "/api/server/index"; - - @Override - public String getUrl() { - return BASE_URL; - } - - @Override - public Class<Server> getModelClass() { - return Server.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerSetup.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerSetup.java deleted file mode 100644 index dfddf400c23..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerSetup.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -/** - * @since 2.9 - */ -public class ServerSetup extends Model { - private String status; - private String message; - - @CheckForNull - public String getStatus() { - return status; - } - - public ServerSetup setStatus(@Nullable String status) { - this.status = status; - return this; - } - - @CheckForNull - public String getMessage() { - return message; - } - - public ServerSetup setMessage(@Nullable String message) { - this.message = message; - return this; - } - - public boolean isSuccessful() { - return "ok".equals(status); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerSetupQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerSetupQuery.java deleted file mode 100644 index db641786b97..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/ServerSetupQuery.java +++ /dev/null @@ -1,37 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.9 - */ -public class ServerSetupQuery extends CreateQuery<ServerSetup> { - public static final String BASE_URL = "/api/server/setup"; - - @Override - public String getUrl() { - return BASE_URL; - } - - @Override - public Class<ServerSetup> getModelClass() { - return ServerSetup.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java deleted file mode 100644 index a8393c5dbbc..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/Source.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Collection; -import java.util.SortedMap; -import java.util.TreeMap; - -public class Source extends Model { - - private SortedMap<Integer, String> lines = new TreeMap<Integer, String>(); - - public Collection<String> getLines() { - return lines.values(); - } - - public SortedMap<Integer, String> getLinesById() { - return lines; - } - - @CheckForNull - public String getLine(int index) { - return lines.get(index); - } - - public int size() { - return lines.size(); - } - - public Source addLine(int index, @Nullable String line) { - lines.put(index, line); - return this; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java deleted file mode 100644 index 8cdab7c8f92..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/SourceQuery.java +++ /dev/null @@ -1,87 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -public class SourceQuery extends Query<Source> { - public static final String BASE_URL = "/api/sources"; - - private String resourceKeyOrId; - private int from = 0; - private int to = 0; - - public SourceQuery(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - } - - public String getResourceKeyOrId() { - return resourceKeyOrId; - } - - public SourceQuery setResourceKeyOrId(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - return this; - } - - public int getFrom() { - return from; - } - - /** - * Get only a few lines - * - * @param from Index of the first line, starts to 1 - * @param excludedTo Index of the last line (excluded). - */ - public SourceQuery setFromLineToLine(int from, int excludedTo) { - this.from = from; - this.to = excludedTo; - return this; - } - - public SourceQuery setLinesFromLine(int from, int length) { - this.from = from; - this.to = from + length; - return this; - } - - public int getTo() { - return to; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", resourceKeyOrId); - if (from > 0 && to > 0) { - url.append("from=").append(from).append("&to=").append(to).append("&"); - } - return url.toString(); - } - - @Override - public Class<Source> getModelClass() { - return Source.class; - } - - public static SourceQuery create(String resourceKeyOrId) { - return new SourceQuery(resourceKeyOrId); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachine.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachine.java deleted file mode 100644 index ab90b1da6be..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachine.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * Past values of a given resource - * - * @since 2.5 - */ -public class TimeMachine extends Model { - - private TimeMachineColumn[] columns; - private TimeMachineCell[] cells; - - public TimeMachine(TimeMachineColumn[] columns, TimeMachineCell[] cells) { - this.columns = columns; - this.cells = cells; - } - - public TimeMachineColumn[] getColumns() { - return columns; - } - - public TimeMachineCell[] getCells() { - return cells; - } - - public TimeMachineColumn getColumn(String metricKey) { - for (TimeMachineColumn column : columns) { - if (metricKey.equals(column.getMetricKey()) && column.getCharacteristicKey()==null) { - return column; - } - } - return null; - } - - public int getColumnIndex(String metricKey) { - TimeMachineColumn col = getColumn(metricKey); - return col!=null ? col.getIndex() : -1; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineCell.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineCell.java deleted file mode 100644 index 04a21930efc..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineCell.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.util.Date; - -/** - * @since 2.5 - */ -public class TimeMachineCell { - - private Date date; - public Object[] values; - - public TimeMachineCell(@Nullable Date date, Object[] values) { - this.date = date; - this.values = values; - } - - @CheckForNull - public Date getDate() { - return date; - } - - public Object[] getValues() { - return values; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java deleted file mode 100644 index 9a7ce4e1fb1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineColumn.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -/** - * @since 2.5 - */ -public class TimeMachineColumn { - - private int index; - private String metricKey; - private String modelName; - private String characteristicKey; - - public TimeMachineColumn(int index, @Nullable String metricKey, @Nullable String modelName, @Nullable String characteristicKey) { - this.index = index; - this.metricKey = metricKey; - this.modelName = modelName; - this.characteristicKey = characteristicKey; - } - - @CheckForNull - public String getMetricKey() { - return metricKey; - } - - @CheckForNull - public String getModelName() { - return modelName; - } - - @CheckForNull - public String getCharacteristicKey() { - return characteristicKey; - } - - public int getIndex() { - return index; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java deleted file mode 100644 index c0bfe1d3c9e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/TimeMachineQuery.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import java.util.Date; - -/** - * @since 2.5 - */ -public class TimeMachineQuery extends Query<TimeMachine> { - - public static final String BASE_URL = "/api/timemachine"; - - private String resourceKeyOrId; - private String[] metrics; - private Date from; - private Date to; - - private String model; - private String[] characteristicKeys; - - public TimeMachineQuery(String resourceKeyOrId) { - this.resourceKeyOrId = resourceKeyOrId; - } - - public String[] getMetrics() { - return metrics; - } - - public TimeMachineQuery setMetrics(String... metrics) { - this.metrics = metrics; - return this; - } - - public Date getFrom() { - return from; - } - - public TimeMachineQuery setFrom(Date from) { - this.from = from; - return this; - } - - public Date getTo() { - return to; - } - - public TimeMachineQuery setTo(Date to) { - this.to = to; - return this; - } - - public TimeMachineQuery setCharacteristicKeys(String model, String... keys) { - this.model = model; - this.characteristicKeys = keys; - return this; - } - - @Override - public String getUrl() { - StringBuilder url = new StringBuilder(BASE_URL); - url.append('?'); - appendUrlParameter(url, "resource", resourceKeyOrId); - appendUrlParameter(url, "metrics", metrics); - appendUrlParameter(url, "fromDateTime", from, true); - appendUrlParameter(url, "toDateTime", to, true); - appendUrlParameter(url, "model", model); - appendUrlParameter(url, "characteristics", characteristicKeys); - return url.toString(); - } - - @Override - public Class<TimeMachine> getModelClass() { - return TimeMachine.class; - } - - public static TimeMachineQuery createForMetrics(String resourceKeyOrId, String... metricKeys) { - return new TimeMachineQuery(resourceKeyOrId).setMetrics(metricKeys); - } - - public static TimeMachineQuery createForMetrics(Resource resource, String... metricKeys) { - Integer id = resource.getId(); - if (id == null) { - throw new IllegalArgumentException("id must be set"); - } - return new TimeMachineQuery(id.toString()).setMetrics(metricKeys); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java deleted file mode 100644 index b4ec3023db1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateCenterQuery.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.4 - */ -public final class UpdateCenterQuery extends Query<Plugin> { - - public static final String BASE_URL = "/api/updatecenter/"; - private String action; - - private UpdateCenterQuery(String action) { - this.action = action; - } - - @Override - public Class<Plugin> getModelClass() { - return Plugin.class; - } - - @Override - public String getUrl() { - return BASE_URL + action; - } - - public static UpdateCenterQuery createForInstalledPlugins() { - return new UpdateCenterQuery("installed_plugins"); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateQuery.java deleted file mode 100644 index 49aa3726f5d..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UpdateQuery.java +++ /dev/null @@ -1,31 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * PUT HTTP request - * - * @since 2.6 - */ -public abstract class UpdateQuery<M extends Model> extends AbstractQuery<M> { - - public abstract Class<M> getModelClass(); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyCreateQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyCreateQuery.java deleted file mode 100644 index c5310d77417..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyCreateQuery.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.2 - */ -public class UserPropertyCreateQuery extends CreateQuery<Property> { - - private String key; - private String value; - - public UserPropertyCreateQuery() { - } - - public UserPropertyCreateQuery(String key, String value) { - this.key = key; - this.value = value; - } - - public UserPropertyCreateQuery(Property property) { - this.key = property.getKey(); - this.value = property.getValue(); - } - - public String getKey() { - return key; - } - - public UserPropertyCreateQuery setKey(String key) { - this.key = key; - return this; - } - - public String getValue() { - return value; - } - - public UserPropertyCreateQuery setValue(String value) { - this.value = value; - return this; - } - - @Override - public String getUrl() { - StringBuilder sb = new StringBuilder(); - sb.append(UserPropertyQuery.BASE_URL); - sb.append('?'); - appendUrlParameter(sb, "key", key); - appendUrlParameter(sb, "value", value); - return sb.toString(); - } - - @Override - public Class<Property> getModelClass() { - return Property.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java deleted file mode 100644 index b37b4684f7a..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyDeleteQuery.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * @since 2.2 - */ -public class UserPropertyDeleteQuery extends DeleteQuery { - - private String key; - - public UserPropertyDeleteQuery(String key) { - this.key = key; - } - - public UserPropertyDeleteQuery(Property property) { - this.key = property.getKey(); - } - - public String getKey() { - return key; - } - - public UserPropertyDeleteQuery setKey(String key) { - this.key = key; - return this; - } - - @Override - public String getUrl() { - return new StringBuilder().append(UserPropertyQuery.BASE_URL).append('/').append(encode(key)).toString(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java deleted file mode 100644 index 67d1fd3fcf3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/UserPropertyQuery.java +++ /dev/null @@ -1,67 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -/** - * Get properties of the authenticated user. - * - * @since 2.2 - */ -public class UserPropertyQuery extends Query<Property> { - public static final String BASE_URL = "/api/user_properties"; - - private String key = null; - - /** - * Get all user properties - */ - public UserPropertyQuery() { - } - - /** - * Get only one specific user property - */ - public UserPropertyQuery(String key) { - this.key = key; - } - - public String getKey() { - return key; - } - - public UserPropertyQuery setKey(String key) { - this.key = key; - return this; - } - - @Override - public String getUrl() { - String url = BASE_URL; - if (key != null) { - url += "/" + encode(key); - } - return url + "?"; - } - - @Override - public Class<Property> getModelClass() { - return Property.class; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java deleted file mode 100644 index 188204771b3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/WSUtils.java +++ /dev/null @@ -1,118 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.services; - -import javax.annotation.CheckForNull; - -import java.util.Date; -import java.util.Set; - -/** - * Compatibility layer between GWT and plain Java. - * Well, this is bad, because code is not type-safe, so all unmarshallers also, - * but this allows to remove duplications between sonar-gwt-api and sonar-ws-client. - */ -public abstract class WSUtils { - - private static WSUtils instance = null; - - public static void setInstance(WSUtils utils) { - instance = utils; - } - - public static WSUtils getINSTANCE() { - return instance; - } - - public abstract String format(Date date, String format); - - public abstract String encodeUrl(String url); - - /** - * @return value of specified field from specified JSON object, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract Object getField(Object json, String field); - - /** - * @return value of a string field from specified JSON object, - * or string representation of a numeric field, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract String getString(Object json, String field); - - /** - * @return Boolean value of specified field from specified JSON object, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract Boolean getBoolean(Object json, String field); - - /** - * @return Integer value of specified field from specified JSON object, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract Integer getInteger(Object json, String field); - - /** - * @return Double value of specified field from specified JSON object, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract Double getDouble(Object json, String field); - - /** - * @return Long value of specified field from specified JSON object, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract Long getLong(Object json, String field); - - /** - * @return Date value of specified field from specified JSON object, - * or <code>null</code> if field does not exist - */ - @CheckForNull - public abstract Date getDateTime(Object json, String field); - - /** - * @return size of specified JSON array - */ - public abstract int getArraySize(Object array); - - /** - * @return element from specified JSON array - */ - public abstract Object getArrayElement(Object array, int i); - - /** - * @return JSON object - */ - public abstract Object parse(String jsonStr); - - /** - * @return field names in specified JSON object - */ - public abstract Set<String> getFields(Object json); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/services/package-info.java deleted file mode 100644 index d17eb9015ab..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/services/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.services; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/Migration.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/system/Migration.java deleted file mode 100644 index 7c9ee2b664e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/Migration.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.system; - -import javax.annotation.Nullable; -import java.util.Date; - -/** - * @since 4.0 - */ -public interface Migration { - enum Status { - MIGRATION_NEEDED, MIGRATION_RUNNING, MIGRATION_FAILED, - MIGRATION_SUCCEEDED, NO_MIGRATION - } - - boolean operationalWebapp(); - - Status status(); - - @Nullable - String message(); - - @Nullable - Date startedAt(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/SystemClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/system/SystemClient.java deleted file mode 100644 index 297925efaa2..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/SystemClient.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.system; - -/** - * @since 4.0 - */ -public interface SystemClient { - /** - * Asynchronously start a database migration. No effect if executed - * several times. - */ - Migration migrate(); - - /** - * Synchronously start a database migration. - */ - Migration migrate(long timeoutInSeconds, long rateInSeconds); - - /** - * Restart server. Available only in development mode. - * @since 4.3 - */ - void restart(); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/DefaultMigration.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/DefaultMigration.java deleted file mode 100644 index 2aa30be3346..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/DefaultMigration.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.system.internal; - -import org.sonar.wsclient.system.Migration; -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.Nullable; -import java.util.Date; -import java.util.Map; - -public class DefaultMigration implements Migration { - - private final Map json; - - public DefaultMigration(Map json) { - this.json = json; - } - - @Override - public boolean operationalWebapp() { - return JsonUtils.getBoolean(json, "operational")==Boolean.TRUE; - } - - @Override - public Status status() { - String state = JsonUtils.getString(json, "state"); - if (state == null) { - throw new IllegalStateException("State is not set"); - } - return Status.valueOf(state); - } - - @Override - public String message() { - return JsonUtils.getString(json, "message"); - } - - @Override - @Nullable - public Date startedAt() { - return JsonUtils.getDateTime(json, "startedAt"); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/DefaultSystemClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/DefaultSystemClient.java deleted file mode 100644 index 7eacea238b4..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/DefaultSystemClient.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.system.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.system.Migration; -import org.sonar.wsclient.system.SystemClient; - -import java.util.Collections; -import java.util.Map; - -public class DefaultSystemClient implements SystemClient { - - private final HttpRequestFactory requestFactory; - - public DefaultSystemClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public Migration migrate() { - String json = requestFactory.post("/api/server/setup", Collections.<String, Object>emptyMap()); - return jsonToMigration(json); - } - - @Override - public Migration migrate(long timeoutInMs, long rateInMs) { - if (rateInMs >= timeoutInMs) { - throw new IllegalArgumentException("Timeout must be greater than rate"); - } - Migration migration = null; - boolean running = true; - long endAt = System.currentTimeMillis() + timeoutInMs; - while (running && System.currentTimeMillis() < endAt) { - migration = migrate(); - if (migration.status() == Migration.Status.MIGRATION_NEEDED || - migration.status() == Migration.Status.MIGRATION_RUNNING) { - sleepQuietly(rateInMs); - } else { - running = false; - } - } - return migration; - } - - @Override - public void restart() { - requestFactory.post("/api/system/restart", Collections.<String, Object>emptyMap()); - } - - private void sleepQuietly(long rateInMs) { - try { - Thread.sleep(rateInMs); - } catch (InterruptedException e) { - throw new IllegalStateException("Fail to sleep!", e); - } - } - - private Migration jsonToMigration(String json) { - Map jsonRoot = (Map) JSONValue.parse(json); - return new DefaultMigration(jsonRoot); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/package-info.java deleted file mode 100644 index 637c20b1ab8..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/internal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.system.internal; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/system/package-info.java deleted file mode 100644 index 5acdc1aa2f5..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/system/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.system; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java deleted file mode 100644 index 1a4c2abe4c2..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AbstractUnmarshaller.java +++ /dev/null @@ -1,62 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Model; -import org.sonar.wsclient.services.WSUtils; - -import java.util.ArrayList; -import java.util.List; - -public abstract class AbstractUnmarshaller<M extends Model> implements Unmarshaller<M> { - - public final M toModel(String json) { - WSUtils utils = WSUtils.getINSTANCE(); - M result = null; - Object array = utils.parse(json); - if (array instanceof List) { - if (utils.getArraySize(array) >= 1) { - Object elt = utils.getArrayElement(array, 0); - if (elt != null) { - result = parse(elt); - } - } - } else { - result = parse(array); - } - return result; - - } - - public final List<M> toModels(String json) { - WSUtils utils = WSUtils.getINSTANCE(); - List<M> result = new ArrayList<M>(); - Object array = utils.parse(json); - for (int i = 0; i < utils.getArraySize(array); i++) { - Object elt = utils.getArrayElement(array, i); - if (elt != null) { - result.add(parse(elt)); - } - } - return result; - } - - protected abstract M parse(Object elt); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AuthenticationUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AuthenticationUnmarshaller.java deleted file mode 100644 index 6be57d09231..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/AuthenticationUnmarshaller.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Authentication; -import org.sonar.wsclient.services.WSUtils; - -import java.util.List; - -public class AuthenticationUnmarshaller implements Unmarshaller<Authentication> { - - public Authentication toModel(String json) { - WSUtils utils = WSUtils.getINSTANCE(); - Object map = utils.parse(json); - - Boolean validJson = utils.getBoolean(map, "valid"); - return new Authentication().setValid(validJson != null ? validJson : false); - } - - public List<Authentication> toModels(String json) { - throw new UnsupportedOperationException(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshaller.java deleted file mode 100644 index 044a9d0db3e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/DependencyTreeUnmarshaller.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.DependencyTree; -import org.sonar.wsclient.services.WSUtils; - -import java.util.ArrayList; -import java.util.List; - -public class DependencyTreeUnmarshaller extends AbstractUnmarshaller<DependencyTree> { - @Override - protected DependencyTree parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - DependencyTree tree = new DependencyTree() - .setDepId(utils.getString(json, "did")) - .setResourceId(utils.getString(json, "rid")) - .setResourceKey(utils.getString(json, "k")) - .setResourceName(utils.getString(json, "n")) - .setResourceScope(utils.getString(json, "s")) - .setResourceQualifier(utils.getString(json, "q")) - .setResourceVersion(utils.getString(json, "v")) - .setUsage(utils.getString(json, "u")) - .setWeight(utils.getInteger(json, "w")); - - List<DependencyTree> to = new ArrayList<DependencyTree>(); - tree.setTo(to); - - Object toJson = utils.getField(json, "to"); - if (toJson != null) { - for (int i = 0; i < utils.getArraySize(toJson); i++) { - to.add(parse(utils.getArrayElement(toJson, i))); - } - } - return tree; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshaller.java deleted file mode 100644 index 3f50088d449..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/DependencyUnmarshaller.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Dependency; -import org.sonar.wsclient.services.WSUtils; - -public class DependencyUnmarshaller extends AbstractUnmarshaller<Dependency> { - - @Override - protected Dependency parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new Dependency() - .setId(utils.getString(json, "id")) - .setFromId(utils.getLong(json, "fi")) - .setToId(utils.getLong(json, "ti")) - .setFromKey(utils.getString(json, "fk")) - .setToKey(utils.getString(json, "tk")) - .setUsage(utils.getString(json, "u")) - .setWeight(utils.getInteger(json, "w")) - .setFromName(utils.getString(json, "fn")) - .setFromQualifier(utils.getString(json, "fq")) - .setToName(utils.getString(json, "tn")) - .setToQualifier(utils.getString(json, "tq")); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/EventUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/EventUnmarshaller.java deleted file mode 100644 index 44c329832a1..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/EventUnmarshaller.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Event; -import org.sonar.wsclient.services.WSUtils; - -public class EventUnmarshaller extends AbstractUnmarshaller<Event> { - - @Override - protected Event parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new Event() - .setId(utils.getString(json, "id")) - .setResourceKey(utils.getString(json, "rk")) - .setName(utils.getString(json, "n")) - .setCategory(utils.getString(json, "c")) - .setDate(utils.getDateTime(json, "dt")) - .setDescription(utils.getString(json, "ds")); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/FavouriteUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/FavouriteUnmarshaller.java deleted file mode 100644 index 7be9b036e0e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/FavouriteUnmarshaller.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Favourite; -import org.sonar.wsclient.services.WSUtils; - -public class FavouriteUnmarshaller extends AbstractUnmarshaller<Favourite> { - - @Override - protected Favourite parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new Favourite() - .setId(utils.getInteger(json, "id")) - .setKey(utils.getString(json, "key")) - .setName(utils.getString(json, "name")) - .setScope(utils.getString(json, "scope")) - .setQualifier(utils.getString(json, "qualifier")) - .setLanguage(utils.getString(json, "lang")); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java deleted file mode 100644 index 6843ec8c9b3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/JsonUtils.java +++ /dev/null @@ -1,125 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.json.simple.JSONArray; - -import javax.annotation.CheckForNull; -import javax.annotation.Nullable; - -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Map; - -// Godin: we will use raw types here, because typically JSONObject passed as an argument -@SuppressWarnings("rawtypes") -public final class JsonUtils { - - private JsonUtils() { - // only static methods - } - - @CheckForNull - public static String getString(Map obj, String field) { - Object value = obj.get(field); - if (value instanceof String || value instanceof Number) { - return value.toString(); - } - return null; - } - - @CheckForNull - public static Integer getInteger(Map obj, String field) { - Object value = obj.get(field); - if (value != null) { - return ((Long) value).intValue(); - } - return null; - } - - @CheckForNull - public static Boolean getBoolean(Map obj, String field) { - Object value = obj.get(field); - if (value != null) { - return (Boolean) value; - } - return null; - } - - @CheckForNull - public static Long getLong(Map obj, String field) { - Object value = obj.get(field); - if (value != null) { - return (Long) value; - } - return null; - } - - @CheckForNull - public static Double getDouble(Map obj, String field) { - Object value = obj.get(field); - if (value != null) { - if (value instanceof Long) { - return ((Long) value).doubleValue(); - } - return (Double) value; - } - return null; - } - - /** - * @since 2.5 - */ - @CheckForNull - public static JSONArray getArray(Map obj, String field) { - return (JSONArray) obj.get(field); - } - - @CheckForNull - public static Date getDateTime(Map obj, String field) { - return parseDate(getString(obj, field), "yyyy-MM-dd'T'HH:mm:ssZ"); - } - - @CheckForNull - public static Date getDate(Map obj, String field) { - return parseDate(getString(obj, field)); - } - - @CheckForNull - public static Date parseDate(@Nullable String value) { - return parseDate(value, "yyyy-MM-dd"); - } - - @CheckForNull - private static Date parseDate(@Nullable String value, String format) { - if (value != null) { - try { - SimpleDateFormat dateFormat = new SimpleDateFormat(format); - return dateFormat.parse(value); - - } catch (ParseException e) { - throw new IllegalArgumentException("Fail to parse date '" + value + "': " + format, e); - } - } - return null; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java deleted file mode 100644 index d8f2de93cf3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ManualMeasureUnmarshaller.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.ManualMeasure; -import org.sonar.wsclient.services.WSUtils; - -/** - * @since 2.10 - */ -public class ManualMeasureUnmarshaller extends AbstractUnmarshaller<ManualMeasure> { - - @Override - protected ManualMeasure parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new ManualMeasure() - .setId(utils.getLong(json, "id")) - .setMetricKey(utils.getString(json, "metric")) - .setResourceKey(utils.getString(json, "resource")) - .setCreatedAt(utils.getDateTime(json, "created_at")) - .setUpdatedAt(utils.getDateTime(json, "updated_at")) - .setUserLogin(utils.getString(json, "login")) - .setUsername(utils.getString(json, "username")) - .setValue(utils.getDouble(json, "val")) - .setTextValue(utils.getString(json, "text")); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/MetricUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/MetricUnmarshaller.java deleted file mode 100644 index 3064a843818..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/MetricUnmarshaller.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Metric; -import org.sonar.wsclient.services.WSUtils; - -public class MetricUnmarshaller extends AbstractUnmarshaller<Metric> { - - @Override - protected Metric parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new Metric() - .setKey(utils.getString(json, "key")) - .setName(utils.getString(json, "name")) - .setDomain(utils.getString(json, "domain")) - .setDescription(utils.getString(json, "description")) - .setDirection(utils.getInteger(json, "direction")) - .setType(utils.getString(json, "val_type")) - .setUserManaged(utils.getBoolean(json, "user_managed")) - .setHidden(utils.getBoolean(json, "hidden")); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java deleted file mode 100644 index a871445badf..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PluginUnmarshaller.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Plugin; -import org.sonar.wsclient.services.WSUtils; - -/** - * @since 2.4 - */ -public class PluginUnmarshaller extends AbstractUnmarshaller<Plugin> { - - @Override - protected Plugin parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new Plugin() - .setKey(utils.getString(json, "key")) - .setName(utils.getString(json, "name")) - .setVersion(utils.getString(json, "version")); - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java deleted file mode 100644 index 988fcadf00d..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ProfileUnmarshaller.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Profile; -import org.sonar.wsclient.services.WSUtils; - -public class ProfileUnmarshaller extends AbstractUnmarshaller<Profile> { - - @Override - protected Profile parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - Profile profile = new Profile(); - Boolean defaultProfile = utils.getBoolean(json, "default"); - profile - .setLanguage(utils.getString(json, "language")) - .setName(utils.getString(json, "name")) - .setDefaultProfile(defaultProfile != null ? defaultProfile : false) - .setParentName(utils.getString(json, "parent")); - - parseRules(utils, profile, json); - return profile; - } - - private void parseRules(WSUtils utils, Profile profile, Object json) { - Object rulesJson = utils.getField(json, "rules"); - if (rulesJson != null) { - for (int i = 0; i < utils.getArraySize(rulesJson); i++) { - Object ruleJson = utils.getArrayElement(rulesJson, i); - if (ruleJson != null) { - Profile.Rule rule = new Profile.Rule(); - rule.setKey(utils.getString(ruleJson, "key")); - rule.setRepository(utils.getString(ruleJson, "repo")); - rule.setSeverity(utils.getString(ruleJson, "severity")); - rule.setInheritance(utils.getString(ruleJson, "inheritance")); - - parseRuleParameters(utils, rule, ruleJson); - profile.addRule(rule); - } - } - } - } - - private void parseRuleParameters(WSUtils utils, Profile.Rule rule, Object ruleJson) { - Object paramsJson = utils.getField(ruleJson, "params"); - if (paramsJson != null) { - for (int indexParam = 0; indexParam < utils.getArraySize(paramsJson); indexParam++) { - Object paramJson = utils.getArrayElement(paramsJson, indexParam); - rule.addParameter(utils.getString(paramJson, "key"), utils.getString(paramJson, "value")); - } - } - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshaller.java deleted file mode 100644 index 8c26c2f1a0e..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/PropertyUnmarshaller.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Property; -import org.sonar.wsclient.services.WSUtils; - -public class PropertyUnmarshaller extends AbstractUnmarshaller<Property> { - - @Override - protected Property parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - return new Property() - .setKey(utils.getString(json, "key")) - .setValue(utils.getString(json, "value")); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java deleted file mode 100644 index 5fa580560b8..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceSearchUnmarshaller.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.json.simple.JSONArray; -import org.json.simple.JSONObject; -import org.sonar.wsclient.services.ResourceSearchResult; -import org.sonar.wsclient.services.WSUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - * @since 3.4 - */ -public class ResourceSearchUnmarshaller extends AbstractUnmarshaller<ResourceSearchResult> { - - @Override - protected ResourceSearchResult parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - ResourceSearchResult result = new ResourceSearchResult(); - result.setPage(utils.getInteger(json, "page")); - result.setPageSize(utils.getInteger(json, "page_size")); - result.setTotal(utils.getInteger(json, "total")); - - List<ResourceSearchResult.Resource> resources = new ArrayList<ResourceSearchResult.Resource>(); - JSONArray dataJson = JsonUtils.getArray((JSONObject) json, "data"); - if (dataJson != null) { - for (Object jsonResource : dataJson) { - ResourceSearchResult.Resource resource = new ResourceSearchResult.Resource(); - resource.setKey(JsonUtils.getString((JSONObject) jsonResource, "key")); - resource.setName(JsonUtils.getString((JSONObject) jsonResource, "nm")); - resource.setQualifier(JsonUtils.getString((JSONObject) jsonResource, "q")); - resources.add(resource); - } - } - result.setResources(resources); - return result; - } - - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java deleted file mode 100644 index e216ced6137..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ResourceUnmarshaller.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Measure; -import org.sonar.wsclient.services.Resource; -import org.sonar.wsclient.services.WSUtils; - -import java.util.ArrayList; -import java.util.List; - -public class ResourceUnmarshaller extends AbstractUnmarshaller<Resource> { - - @Override - protected Resource parse(Object json) { - Resource resource = new Resource(); - parseResourceFields(json, resource); - parseMeasures(json, resource); - return resource; - } - - private void parseResourceFields(Object json, Resource resource) { - WSUtils utils = WSUtils.getINSTANCE(); - resource.setId(utils.getInteger(json, "id")) - .setKey(utils.getString(json, "key")) - .setName(utils.getString(json, "name")) - .setLongName(utils.getString(json, "lname")) - .setCopy(utils.getInteger(json, "copy")) - .setScope(utils.getString(json, "scope")) - .setQualifier(utils.getString(json, "qualifier")) - .setLanguage(utils.getString(json, "lang")) - .setDescription(utils.getString(json, "description")) - .setDate(utils.getDateTime(json, "date")) - .setCreationDate(utils.getDateTime(json, "creationDate")) - .setVersion(utils.getString(json, "version")) - .setPeriod1Mode(utils.getString(json, "p1")) - .setPeriod1Param(utils.getString(json, "p1p")) - .setPeriod1Date(utils.getDateTime(json, "p1d")) - .setPeriod2Mode(utils.getString(json, "p2")) - .setPeriod2Param(utils.getString(json, "p2p")) - .setPeriod2Date(utils.getDateTime(json, "p2d")) - .setPeriod3Mode(utils.getString(json, "p3")) - .setPeriod3Param(utils.getString(json, "p3p")) - .setPeriod3Date(utils.getDateTime(json, "p3d")) - .setPeriod4Mode(utils.getString(json, "p4")) - .setPeriod4Param(utils.getString(json, "p4p")) - .setPeriod4Date(utils.getDateTime(json, "p4d")) - .setPeriod5Mode(utils.getString(json, "p5")) - .setPeriod5Param(utils.getString(json, "p5p")) - .setPeriod5Date(utils.getDateTime(json, "p5d")); - } - - private void parseMeasures(Object json, Resource resource) { - WSUtils utils = WSUtils.getINSTANCE(); - Object measuresJson = utils.getField(json, "msr"); - if (measuresJson != null) { - resource.setMeasures(parseMeasures(measuresJson)); - } - } - - private List<Measure> parseMeasures(Object measuresJson) { - WSUtils utils = WSUtils.getINSTANCE(); - List<Measure> projectMeasures = new ArrayList<Measure>(); - int len = utils.getArraySize(measuresJson); - for (int i = 0; i < len; i++) { - Object measureJson = utils.getArrayElement(measuresJson, i); - if (measureJson != null) { - Measure measure = parseMeasure(measureJson); - projectMeasures.add(measure); - } - } - return projectMeasures; - } - - private Measure parseMeasure(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - - Measure measure = new Measure(); - measure - .setMetricKey(utils.getString(json, "key")) - .setMetricName(utils.getString(json, "name")) - .setValue(utils.getDouble(json, "val")) - .setFormattedValue(utils.getString(json, "frmt_val")) - .setAlertStatus(utils.getString(json, "alert")) - .setAlertText(utils.getString(json, "alert_text")) - .setTrend(utils.getInteger(json, "trend")) - .setVar(utils.getInteger(json, "var")) - .setData(utils.getString(json, "data")) - .setRuleKey(utils.getString(json, "rule_key")) - .setRuleName(utils.getString(json, "rule_name")) - .setRuleCategory(utils.getString(json, "rule_category")) - .setRuleSeverity(utils.getString(json, "rule_priority")) - .setCharacteristicKey(utils.getString(json, "ctic_key")) - .setCharacteristicName(utils.getString(json, "ctic_name")) - .setVariation1(utils.getDouble(json, "var1")) - .setVariation2(utils.getDouble(json, "var2")) - .setVariation3(utils.getDouble(json, "var3")) - .setVariation4(utils.getDouble(json, "var4")) - .setVariation5(utils.getDouble(json, "var5")); - return measure; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshaller.java deleted file mode 100644 index ae72b1324a9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ServerSetupUnmarshaller.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.ServerSetup; -import org.sonar.wsclient.services.WSUtils; - -import java.util.List; - -/** - * @since 2.9 - */ -public class ServerSetupUnmarshaller implements Unmarshaller<ServerSetup> { - public ServerSetup toModel(String json) { - WSUtils utils = WSUtils.getINSTANCE(); - Object map = utils.parse(json); - return new ServerSetup() - .setStatus(utils.getString(map, "status")) - .setMessage(utils.getString(map, "msg")); - } - - public List<ServerSetup> toModels(String json) { - throw new UnsupportedOperationException(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ServerUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ServerUnmarshaller.java deleted file mode 100644 index 0951e2d28d3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/ServerUnmarshaller.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Server; -import org.sonar.wsclient.services.WSUtils; - -import java.util.List; - -/** - * @author Evgeny Mandrikov - */ -public class ServerUnmarshaller implements Unmarshaller<Server> { - public Server toModel(String json) { - WSUtils utils = WSUtils.getINSTANCE(); - Object map = utils.parse(json); - Server server = new Server() - .setId(utils.getString(map, "id")) - .setVersion(utils.getString(map, "version")) - .setStatusMessage(utils.getString(map, "status_msg")); - String status = utils.getString(map, "status"); - if (status != null) { - server.setStatus(Server.Status.valueOf(status)); - } - return server; - } - - public List<Server> toModels(String json) { - throw new UnsupportedOperationException(); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/SourceUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/SourceUnmarshaller.java deleted file mode 100644 index bdf91d1d6d0..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/SourceUnmarshaller.java +++ /dev/null @@ -1,38 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Source; -import org.sonar.wsclient.services.WSUtils; - -public class SourceUnmarshaller extends AbstractUnmarshaller<Source> { - - @Override - protected Source parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - Source source = new Source(); - - for (String field : utils.getFields(json)) { - source.addLine(Integer.parseInt(field), utils.getString(json, field)); - } - - return source; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java deleted file mode 100644 index dd2248dda47..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/TimeMachineUnmarshaller.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.TimeMachine; -import org.sonar.wsclient.services.TimeMachineCell; -import org.sonar.wsclient.services.TimeMachineColumn; -import org.sonar.wsclient.services.WSUtils; - -public class TimeMachineUnmarshaller extends AbstractUnmarshaller<TimeMachine> { - - @Override - protected TimeMachine parse(Object json) { - WSUtils utils = WSUtils.getINSTANCE(); - Object cols = utils.getField(json, "cols"); - if (cols == null) { - throw new IllegalArgumentException("cols must be set"); - } - Object cells = utils.getField(json, "cells"); - if (cells == null) { - throw new IllegalArgumentException("cells must be set"); - } - return new TimeMachine(toColumns(cols), toCells(cells)); - } - - private TimeMachineColumn[] toColumns(Object cols) { - WSUtils utils = WSUtils.getINSTANCE(); - int size = utils.getArraySize(cols); - TimeMachineColumn[] result = new TimeMachineColumn[size]; - for (int index = 0; index < size; index++) { - Object colJson = utils.getArrayElement(cols, index); - result[index] = new TimeMachineColumn(index, utils.getString(colJson, "metric"), null, null); - } - return result; - } - - private TimeMachineCell[] toCells(Object cells) { - WSUtils utils = WSUtils.getINSTANCE(); - int size = utils.getArraySize(cells); - TimeMachineCell[] result = new TimeMachineCell[size]; - for (int i = 0; i < size; i++) { - Object cellJson = utils.getArrayElement(cells, i); - Object valuesJson = utils.getField(cellJson, "v"); - if (valuesJson != null) { - Object[] resultValues = new Object[utils.getArraySize(valuesJson)]; - for (int indexValue = 0; indexValue < utils.getArraySize(valuesJson); indexValue++) { - Object value = utils.getArrayElement(valuesJson, indexValue); - resultValues[indexValue] = value; - } - result[i] = new TimeMachineCell(utils.getDateTime(cellJson, "d"), resultValues); - } - } - return result; - } - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/UnmarshalException.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/UnmarshalException.java deleted file mode 100644 index 2e028275d8f..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/UnmarshalException.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.AbstractQuery; - -/** - * @since 2.10 - */ -public final class UnmarshalException extends RuntimeException { - public UnmarshalException(String s) { - super(s); - } - - public UnmarshalException(AbstractQuery query, String json, Throwable t) { - super("Can not parse the response of query " + query.getUrl() + ": " + json, t); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshaller.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshaller.java deleted file mode 100644 index 0609cfb35a9..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshaller.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.Model; - -import java.util.List; - -public interface Unmarshaller<M extends Model> { - - M toModel(String json); - - List<M> toModels(String json); - -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java deleted file mode 100644 index 094bc270cd3..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/Unmarshallers.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.unmarshallers; - -import org.sonar.wsclient.services.*; - -import java.util.HashMap; -import java.util.Map; - -public final class Unmarshallers { - private Unmarshallers() { - } - - private static Map<Class, Unmarshaller> unmarshallers; - - static { - unmarshallers = new HashMap<Class, Unmarshaller>(); - unmarshallers.put(Metric.class, new MetricUnmarshaller()); - unmarshallers.put(Dependency.class, new DependencyUnmarshaller()); - unmarshallers.put(Resource.class, new ResourceUnmarshaller()); - unmarshallers.put(Property.class, new PropertyUnmarshaller()); - unmarshallers.put(Source.class, new SourceUnmarshaller()); - unmarshallers.put(Server.class, new ServerUnmarshaller()); - unmarshallers.put(ServerSetup.class, new ServerSetupUnmarshaller()); - unmarshallers.put(DependencyTree.class, new DependencyTreeUnmarshaller()); - unmarshallers.put(Event.class, new EventUnmarshaller()); - unmarshallers.put(Favourite.class, new FavouriteUnmarshaller()); - unmarshallers.put(Plugin.class, new PluginUnmarshaller()); - unmarshallers.put(TimeMachine.class, new TimeMachineUnmarshaller()); - unmarshallers.put(Profile.class, new ProfileUnmarshaller()); - unmarshallers.put(ManualMeasure.class, new ManualMeasureUnmarshaller()); - unmarshallers.put(Authentication.class, new AuthenticationUnmarshaller()); - unmarshallers.put(ResourceSearchResult.class, new ResourceSearchUnmarshaller()); - } - - public static <M extends Model> Unmarshaller<M> forModel(Class<M> modelClass) { - return unmarshallers.get(modelClass); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/package-info.java deleted file mode 100644 index f3773ead6c0..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/unmarshallers/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.unmarshallers; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/User.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/User.java deleted file mode 100644 index c7a814f1145..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/User.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.user; - -import org.sonar.wsclient.unmarshallers.JsonUtils; - -import javax.annotation.CheckForNull; -import java.util.Map; - -/** - * @since 3.6 - */ -public class User { - private final Map json; - - public User(Map json) { - this.json = json; - } - - /** - * Unique login - */ - public String login() { - return JsonUtils.getString(json, "login"); - } - - public String name() { - return JsonUtils.getString(json, "name"); - } - - @CheckForNull - public String email() { - return JsonUtils.getString(json, "email"); - } - - public boolean active() { - return JsonUtils.getBoolean(json, "active") == Boolean.TRUE; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java deleted file mode 100644 index 261745326bf..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserClient.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.user; - -import java.util.List; - -/** - * @since 3.6 - */ -public interface UserClient { - - List<User> find(UserQuery query); - - /** - * @since 3.7 - */ - User create(UserParameters userParameters); - - /** - * @since 3.7 - */ - User update(UserParameters userParameters); - - /** - * @since 3.7 - */ - void deactivate(String login); -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java deleted file mode 100644 index 50a2411532a..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserParameters.java +++ /dev/null @@ -1,65 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -package org.sonar.wsclient.user; - -import java.util.HashMap; -import java.util.Map; - -public class UserParameters { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private UserParameters() { - } - - public static UserParameters create() { - return new UserParameters(); - } - - public Map<String, Object> urlParams() { - return params; - } - - public UserParameters login(String s) { - params.put("login", s); - return this; - } - - public UserParameters name(String s) { - params.put("name", s); - return this; - } - - public UserParameters password(String s) { - params.put("password", s); - return this; - } - - public UserParameters passwordConfirmation(String s) { - params.put("password_confirmation", s); - return this; - } - - public UserParameters email(String s) { - params.put("email", s); - return this; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java deleted file mode 100644 index a77bd2f1943..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/UserQuery.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.user; - -import org.sonar.wsclient.internal.EncodingUtils; - -import javax.annotation.Nullable; -import java.util.HashMap; -import java.util.Map; - -/** - * @since 3.6 - */ -public class UserQuery { - - private final Map<String, Object> params = new HashMap<String, Object>(); - - private UserQuery() { - } - - public static UserQuery create() { - return new UserQuery(); - } - - public UserQuery includeDeactivated() { - params.put("includeDeactivated", "true"); - return this; - } - - public UserQuery logins(String... s) { - params.put("logins", EncodingUtils.toQueryParam(s)); - return this; - } - - public UserQuery searchText(@Nullable String s) { - if (s != null) { - params.put("s", s); - } else { - params.remove("s"); - } - return this; - } - - public Map<String, Object> urlParams() { - return params; - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java deleted file mode 100644 index 2a73cd871ff..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ -package org.sonar.wsclient.user.internal; - -import org.json.simple.JSONValue; -import org.sonar.wsclient.internal.HttpRequestFactory; -import org.sonar.wsclient.user.User; -import org.sonar.wsclient.user.UserClient; -import org.sonar.wsclient.user.UserParameters; -import org.sonar.wsclient.user.UserQuery; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -/** - * Do not instantiate this class, but use {@link org.sonar.wsclient.SonarClient#userClient()}. - */ -public class DefaultUserClient implements UserClient { - - private static final String BASE_URL = "/api/users/"; - private static final String SEARCH_URL = BASE_URL + "search"; - private static final String CREATE_URL = BASE_URL + "create"; - private static final String UPDATE_URL = BASE_URL + "update"; - private static final String DEACTIVATE_URL = BASE_URL + "deactivate"; - - private final HttpRequestFactory requestFactory; - - /** - * For internal use. Use {@link org.sonar.wsclient.SonarClient} to get an instance. - */ - public DefaultUserClient(HttpRequestFactory requestFactory) { - this.requestFactory = requestFactory; - } - - @Override - public List<User> find(UserQuery query) { - String json = requestFactory.get(SEARCH_URL, query.urlParams()); - List<User> result = new ArrayList<User>(); - Map jsonRoot = (Map) JSONValue.parse(json); - List<Map> jsonUsers = (List<Map>) jsonRoot.get("users"); - if (jsonUsers != null) { - for (Map jsonUser : jsonUsers) { - result.add(new User(jsonUser)); - } - } - return result; - } - - @Override - public User create(UserParameters userParameters) { - String json = requestFactory.post(CREATE_URL, userParameters.urlParams()); - Map jsonRoot = (Map) JSONValue.parse(json); - Map jsonUser = (Map) jsonRoot.get("user"); - return new User(jsonUser); - } - - @Override - public User update(UserParameters userParameters) { - String json = requestFactory.post(UPDATE_URL, userParameters.urlParams()); - Map jsonRoot = (Map) JSONValue.parse(json); - Map jsonUser = (Map) jsonRoot.get("user"); - return new User(jsonUser); - } - - @Override - public void deactivate(String login) { - Map<String, Object> params = new HashMap<String, Object>(); - params.put("login", login); - requestFactory.post(DEACTIVATE_URL, params); - } -} diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/package-info.java deleted file mode 100644 index 20e56b94013..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.user.internal; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/package-info.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/package-info.java deleted file mode 100644 index 3825e7dffc4..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/package-info.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2014 SonarSource - * mailto:contact AT sonarsource DOT com - * - * SonarQube is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 3 of the License, or (at your option) any later version. - * - * SonarQube is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - */ - -@javax.annotation.ParametersAreNonnullByDefault -package org.sonar.wsclient.user; |