001/*
002 * SonarQube, open source software quality management tool.
003 * Copyright (C) 2008-2014 SonarSource
004 * mailto:contact AT sonarsource DOT com
005 *
006 * SonarQube is free software; you can redistribute it and/or
007 * modify it under the terms of the GNU Lesser General Public
008 * License as published by the Free Software Foundation; either
009 * version 3 of the License, or (at your option) any later version.
010 *
011 * SonarQube is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
014 * Lesser General Public License for more details.
015 *
016 * You should have received a copy of the GNU Lesser General Public License
017 * along with this program; if not, write to the Free Software Foundation,
018 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
019 */
020
021package org.sonar.wsclient.permissions.internal;
022
023import org.sonar.wsclient.internal.HttpRequestFactory;
024import org.sonar.wsclient.permissions.PermissionClient;
025import org.sonar.wsclient.permissions.PermissionParameters;
026
027public class DefaultPermissionClient implements PermissionClient {
028
029  private static final String BASE_URL = "/api/permissions/";
030  private static final String ADD_URL = BASE_URL + "add";
031  private static final String REMOVE_URL = BASE_URL + "remove";
032
033  private final HttpRequestFactory requestFactory;
034
035  /**
036   * For internal use. Use {@link org.sonar.wsclient.SonarClient} to get an instance.
037   */
038  public DefaultPermissionClient(HttpRequestFactory requestFactory) {
039    this.requestFactory = requestFactory;
040  }
041
042  @Override
043  public void addPermission(PermissionParameters permissionParameters) {
044    requestFactory.post(ADD_URL, permissionParameters.urlParams());
045  }
046
047  @Override
048  public void removePermission(PermissionParameters permissionParameters) {
049    requestFactory.post(REMOVE_URL, permissionParameters.urlParams());
050  }
051}