public class DefaultRubyComponentService implements RubyComponentService {
private final ResourceDao resourceDao;
- private final DefaultComponentFinder finder;
private final ComponentService componentService;
private final PermissionService permissionService;
- public DefaultRubyComponentService(ResourceDao resourceDao, DefaultComponentFinder finder, ComponentService componentService, PermissionService permissionService) {
+ public DefaultRubyComponentService(ResourceDao resourceDao, ComponentService componentService, PermissionService permissionService) {
this.resourceDao = resourceDao;
- this.finder = finder;
this.componentService = componentService;
this.permissionService = permissionService;
}
return componentInDb.getId();
}
- public DefaultComponentQueryResult find(Map<String, Object> params) {
- ComponentQuery query = toQuery(params);
- List<Component> components = resourceDao.selectProjectsByQualifiers(query.qualifiers());
- return finder.find(query, components);
- }
-
- public DefaultComponentQueryResult findWithUncompleteProjects(Map<String, Object> params) {
- ComponentQuery query = toQuery(params);
- List<Component> components = resourceDao.selectProjectsIncludingNotCompletedOnesByQualifiers(query.qualifiers());
- return finder.find(query, components);
- }
-
- public DefaultComponentQueryResult findGhostsProjects(Map<String, Object> params) {
- ComponentQuery query = toQuery(params);
- List<Component> components = resourceDao.selectGhostsProjects(query.qualifiers());
- return finder.find(query, components);
- }
-
public List<ResourceDto> findProvisionedProjects(Map<String, Object> params) {
ComponentQuery query = toQuery(params);
return resourceDao.selectProvisionedProjects(query.qualifiers());
import org.sonar.server.platform.ServerSettings;
import org.sonar.server.platform.SettingsChangeNotifier;
import org.sonar.server.platform.ws.UpgradesAction;
-import org.sonar.server.plugins.InstalledPluginReferentialFactory;
-import org.sonar.server.plugins.PluginDownloader;
-import org.sonar.server.plugins.ServerPluginRepository;
-import org.sonar.server.plugins.UpdateCenterMatrixFactory;
import org.sonar.server.rule.RuleRepositories;
import org.sonar.server.user.NewUserNotifier;
-import org.sonar.updatecenter.common.PluginReferential;
-import org.sonar.updatecenter.common.UpdateCenter;
-import org.sonar.updatecenter.common.Version;
import static com.google.common.collect.Lists.newArrayList;
return get(ResourceTypes.class).get(qualifier);
}
- public String getResourceTypeStringProperty(String resourceTypeQualifier, String resourceTypeProperty) {
- ResourceType resourceType = getResourceType(resourceTypeQualifier);
- if (resourceType != null) {
- return resourceType.getStringProperty(resourceTypeProperty);
- }
- return null;
- }
-
public List<String> getQualifiersWithProperty(final String propertyKey) {
List<String> qualifiers = newArrayList();
for (ResourceType type : getResourceTypes()) {
}
// UPDATE CENTER ------------------------------------------------------------
- public void downloadPlugin(String pluginKey, String pluginVersion) {
- get(PluginDownloader.class).download(pluginKey, Version.create(pluginVersion));
- }
-
- public void cancelPluginDownloads() {
- get(PluginDownloader.class).cancelDownloads();
- }
-
- public List<String> getPluginDownloads() {
- return get(PluginDownloader.class).getDownloadedPluginFilenames();
- }
-
- public void uninstallPlugin(String pluginKey) {
- get(ServerPluginRepository.class).uninstall(pluginKey);
- }
-
- public void cancelPluginUninstalls() {
- get(ServerPluginRepository.class).cancelUninstalls();
- }
-
- public List<String> getPluginUninstalls() {
- return get(ServerPluginRepository.class).getUninstalledPluginFilenames();
- }
-
- public UpdateCenter getUpdatePluginCenter(boolean forceReload) {
- return get(UpdateCenterMatrixFactory.class).getUpdateCenter(forceReload).orNull();
- }
-
- public PluginReferential getInstalledPluginReferential() {
- return get(InstalledPluginReferentialFactory.class).getInstalledPluginReferential();
- }
// PLUGINS ------------------------------------------------------------------
public PropertyDefinitions getPropertyDefinitions() {
public class DefaultRubyComponentServiceTest {
ResourceDao resourceDao = mock(ResourceDao.class);
- DefaultComponentFinder finder = mock(DefaultComponentFinder.class);
ComponentService componentService = mock(ComponentService.class);
PermissionService permissionService = mock(PermissionService.class);
@Before
public void before() {
- service = new DefaultRubyComponentService(resourceDao, finder, componentService, permissionService);
+ service = new DefaultRubyComponentService(resourceDao, componentService, permissionService);
}
@Test
service.createComponent("1234", "New Project", Qualifiers.PROJECT);
}
- @Test
- public void should_find() {
- List<String> qualifiers = newArrayList("TRK");
-
- Map<String, Object> map = newHashMap();
- map.put("keys", newArrayList("org.codehaus.sonar"));
- map.put("names", newArrayList("Sonar"));
- map.put("qualifiers", qualifiers);
- map.put("pageSize", 10l);
- map.put("pageIndex", 50);
- map.put("sort", "NAME");
- map.put("asc", true);
-
- service.find(map);
- verify(resourceDao).selectProjectsByQualifiers(anyListOf(String.class));
- verify(finder).find(any(ComponentQuery.class), anyListOf(Component.class));
- }
-
- @Test
- public void should_find_with_uncomplete_projects() {
- List<String> qualifiers = newArrayList("TRK");
-
- Map<String, Object> map = newHashMap();
- map.put("keys", newArrayList("org.codehaus.sonar"));
- map.put("names", newArrayList("Sonar"));
- map.put("qualifiers", qualifiers);
- map.put("pageSize", 10l);
- map.put("pageIndex", 50);
- map.put("sort", "NAME");
- map.put("asc", true);
-
- service.findWithUncompleteProjects(map);
- verify(resourceDao).selectProjectsIncludingNotCompletedOnesByQualifiers(anyListOf(String.class));
- verify(finder).find(any(ComponentQuery.class), anyListOf(Component.class));
- }
-
- @Test
- public void should_find_ghosts_projects() {
- List<String> qualifiers = newArrayList("TRK");
-
- Map<String, Object> map = newHashMap();
- map.put("keys", newArrayList("org.codehaus.sonar"));
- map.put("names", newArrayList("Sonar"));
- map.put("qualifiers", qualifiers);
- map.put("pageSize", 10l);
- map.put("pageIndex", 50);
- map.put("sort", "NAME");
- map.put("asc", true);
-
- service.findGhostsProjects(map);
- verify(resourceDao).selectGhostsProjects(anyListOf(String.class));
- verify(finder).find(any(ComponentQuery.class), anyListOf(Component.class));
- }
-
@Test
public void should_find_provisioned_projects() {
List<String> qualifiers = newArrayList("TRK");
/**
* @since 3.6
+ * @deprecated in 6.0
*/
@ServerSide
+@Deprecated
public interface RubyComponentService {
@CheckForNull