From: Jean-Baptiste Vilain Date: Tue, 16 Jul 2013 15:07:03 +0000 (+0200) Subject: Moved non-exposed implementation classes to internal package X-Git-Tag: 3.7~92 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=dc080ba936f22f60ddd8de75e9deedd9899f9428;p=sonarqube.git Moved non-exposed implementation classes to internal package --- 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 index f0bf2e077bf..830dce49eae 100644 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/SonarClient.java @@ -24,10 +24,10 @@ 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.DefaultPermissionClient; import org.sonar.wsclient.permissions.PermissionClient; -import org.sonar.wsclient.user.DefaultUserClient; +import org.sonar.wsclient.permissions.internal.DefaultPermissionClient; import org.sonar.wsclient.user.UserClient; +import org.sonar.wsclient.user.internal.DefaultUserClient; import javax.annotation.Nullable; diff --git a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/DefaultPermissionClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/DefaultPermissionClient.java deleted file mode 100644 index 9bb4a6fcaa2..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/DefaultPermissionClient.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 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 org.sonar.wsclient.internal.HttpRequestFactory; - -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/DefaultPermissionClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/DefaultPermissionClient.java new file mode 100644 index 00000000000..18b568b1847 --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/permissions/internal/DefaultPermissionClient.java @@ -0,0 +1,51 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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/user/DefaultUserClient.java b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java deleted file mode 100644 index 676676d0985..00000000000 --- a/sonar-ws-client/src/main/java/org/sonar/wsclient/user/DefaultUserClient.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * SonarQube, open source software quality management tool. - * Copyright (C) 2008-2013 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.json.simple.JSONValue; -import org.sonar.wsclient.internal.HttpRequestFactory; - -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 find(UserQuery query) { - String json = requestFactory.get(SEARCH_URL, query.urlParams()); - List result = new ArrayList(); - Map jsonRoot = (Map) JSONValue.parse(json); - List jsonUsers = (List) 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 params = new HashMap(); - params.put("login", login); - requestFactory.post(DEACTIVATE_URL, params); - } -} 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 index 5060a2fee2a..2c0b2f53264 100644 --- 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 @@ -58,7 +58,7 @@ public class UserQuery { return this; } - Map urlParams() { + public Map 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 new file mode 100644 index 00000000000..5b4fd891a2d --- /dev/null +++ b/sonar-ws-client/src/main/java/org/sonar/wsclient/user/internal/DefaultUserClient.java @@ -0,0 +1,90 @@ +/* + * SonarQube, open source software quality management tool. + * Copyright (C) 2008-2013 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 find(UserQuery query) { + String json = requestFactory.get(SEARCH_URL, query.urlParams()); + List result = new ArrayList(); + Map jsonRoot = (Map) JSONValue.parse(json); + List jsonUsers = (List) 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 params = new HashMap(); + params.put("login", login); + requestFactory.post(DEACTIVATE_URL, params); + } +} diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java index 667b6b9a1db..eab25a50d34 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/SonarClientTest.java @@ -22,8 +22,8 @@ package org.sonar.wsclient; import org.junit.Test; import org.sonar.wsclient.issue.internal.DefaultActionPlanClient; import org.sonar.wsclient.issue.internal.DefaultIssueClient; -import org.sonar.wsclient.permissions.DefaultPermissionClient; -import org.sonar.wsclient.user.DefaultUserClient; +import org.sonar.wsclient.permissions.internal.DefaultPermissionClient; +import org.sonar.wsclient.user.internal.DefaultUserClient; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.Fail.fail; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java index b3a6a572f72..cfff8516dde 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/permissions/DefaultPermissionClientTest.java @@ -25,6 +25,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.wsclient.MockHttpServerInterceptor; import org.sonar.wsclient.internal.HttpRequestFactory; +import org.sonar.wsclient.permissions.internal.DefaultPermissionClient; import static org.fest.assertions.Assertions.assertThat; import static org.fest.assertions.MapAssert.entry; diff --git a/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java b/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java index 7056a2d32e7..18dbd05c55d 100644 --- a/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java +++ b/sonar-ws-client/src/test/java/org/sonar/wsclient/user/DefaultUserClientTest.java @@ -24,6 +24,7 @@ import org.junit.Rule; import org.junit.Test; import org.sonar.wsclient.MockHttpServerInterceptor; import org.sonar.wsclient.internal.HttpRequestFactory; +import org.sonar.wsclient.user.internal.DefaultUserClient; import java.util.Arrays; import java.util.List;