aboutsummaryrefslogtreecommitdiffstats
path: root/sonar-plugin-api
diff options
context:
space:
mode:
authorJulien HENRY <julien.henry@sonarsource.com>2015-03-12 10:16:10 +0100
committerJulien Lancelot <julien.lancelot@sonarsource.com>2015-03-12 16:06:21 +0100
commitc7eba90212ed8130d8f9d8d915c30d9d7574d145 (patch)
treec4cb68455e3e2745608e3cc7a18905caacdd7e78 /sonar-plugin-api
parentc613bf937e87f7c97b5a04690d8045bac1259af8 (diff)
downloadsonarqube-c7eba90212ed8130d8f9d8d915c30d9d7574d145.tar.gz
sonarqube-c7eba90212ed8130d8f9d8d915c30d9d7574d145.zip
SONAR-6273 SONAR-6274 Feed links in compute report and remove links sensor API
Diffstat (limited to 'sonar-plugin-api')
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java14
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java5
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java33
-rw-r--r--sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectLink.java130
-rw-r--r--sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectLinkTest.java63
5 files changed, 0 insertions, 245 deletions
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
index a9eb2562878..25a7521cdd7 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SensorContext.java
@@ -25,7 +25,6 @@ import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.measures.Metric;
-import org.sonar.api.resources.ProjectLink;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
@@ -227,19 +226,6 @@ public interface SensorContext extends org.sonar.api.batch.sensor.SensorContext
@Deprecated
void saveSource(Resource reference, String source);
- // ----------- LINKS --------------
-
- /**
- * add a link to an external page like project homepage, sources (subversion, ...), continuous integration server... Example :
- * context.addLink(new ProjectLink("maven_site, "Maven site", "http://my.maven.com)
- */
- void saveLink(ProjectLink link);
-
- /**
- * remove a link. It does not fail if key is unknown.
- */
- void deleteLink(String key);
-
// ----------- EVENTS --------------
/**
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
index 6714ed9c1bb..a9d32eb7595 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/batch/SonarIndex.java
@@ -24,7 +24,6 @@ import org.sonar.api.design.Dependency;
import org.sonar.api.measures.Measure;
import org.sonar.api.measures.MeasuresFilter;
import org.sonar.api.resources.Project;
-import org.sonar.api.resources.ProjectLink;
import org.sonar.api.resources.Resource;
import org.sonar.api.rules.Violation;
import org.sonar.graph.DirectedGraphAccessor;
@@ -148,10 +147,6 @@ public abstract class SonarIndex implements DirectedGraphAccessor<Resource, Depe
public abstract Set<Dependency> getDependencies();
- public abstract void addLink(ProjectLink link);
-
- public abstract void deleteLink(String key);
-
public abstract List<Event> getEvents(Resource resource);
public abstract void deleteEvent(Event event);
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
index 3f0f2469cbb..d8b080cdab4 100644
--- a/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
+++ b/sonar-plugin-api/src/main/java/org/sonar/api/database/model/ResourceModel.java
@@ -23,18 +23,14 @@ import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
-import org.hibernate.annotations.BatchSize;
import org.sonar.api.database.BaseIdentifiable;
import org.sonar.api.resources.Language;
-import org.sonar.api.resources.ProjectLink;
import org.sonar.api.resources.Resource;
import javax.annotation.Nullable;
import javax.persistence.*;
-import java.util.ArrayList;
import java.util.Date;
-import java.util.List;
/**
* Class to map resource with hibernate model
@@ -94,11 +90,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
@Column(name = "created_at", updatable = true, nullable = true)
private Date createdAt;
- @OneToMany(mappedBy = "resource", fetch = FetchType.LAZY, cascade = {CascadeType.MERGE, CascadeType.PERSIST, CascadeType.REMOVE})
- @JoinColumn(name = "component_uuid")
- @BatchSize(size = 8)
- private List<ProjectLink> projectLinks = new ArrayList<ProjectLink>();
-
@Column(name = "uuid", updatable = false, nullable = true, length = 50)
private String uuid;
@@ -146,29 +137,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
/**
* Only available at project level.
*/
- public List<ProjectLink> getProjectLinks() {
- return projectLinks;
- }
-
- public void setProjectLinks(List<ProjectLink> projectLinks) {
- this.projectLinks = projectLinks;
- }
-
- /**
- * @return a project link given its key if exists, null otherwise
- */
- public ProjectLink getProjectLink(String key) {
- for (ProjectLink projectLink : projectLinks) {
- if (key.equals(projectLink.getKey())) {
- return projectLink;
- }
- }
- return null;
- }
-
- /**
- * Only available at project level.
- */
public String getDescription() {
return description;
}
@@ -405,7 +373,6 @@ public class ResourceModel extends BaseIdentifiable implements Cloneable {
clone.setDescription(getDescription());
clone.setDeprecatedKey(getDeprecatedKey());
clone.setEnabled(getEnabled());
- clone.setProjectLinks(getProjectLinks());
clone.setLanguageKey(getLanguageKey());
clone.setCopyResourceId(getCopyResourceId());
clone.setLongName(getLongName());
diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectLink.java b/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectLink.java
deleted file mode 100644
index 3e4f276571d..00000000000
--- a/sonar-plugin-api/src/main/java/org/sonar/api/resources/ProjectLink.java
+++ /dev/null
@@ -1,130 +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.api.resources;
-
-import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang.builder.ReflectionToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-import org.sonar.api.database.BaseIdentifiable;
-import org.sonar.api.database.model.ResourceModel;
-
-import javax.persistence.*;
-
-/**
- * @since 1.10
- */
-@Entity(name = "ProjectLink")
-@Table(name = "project_links")
-public class ProjectLink extends BaseIdentifiable {
-
- public static final int NAME_COLUMN_SIZE = 128;
- public static final int HREF_COLUMN_SIZE = 2048;
-
- @ManyToOne(fetch = FetchType.LAZY)
- @JoinColumn(name = "component_uuid", referencedColumnName = "uuid", updatable = false, nullable = false)
- private ResourceModel resource;
-
- @Column(name = "link_type", updatable = true, nullable = true, length = 20)
- private String key;
-
- @Column(name = "name", updatable = true, nullable = true, length = NAME_COLUMN_SIZE)
- private String name;
-
- @Column(name = "href", updatable = true, nullable = false, length = HREF_COLUMN_SIZE)
- private String href;
-
- public ProjectLink() {
- }
-
- public ProjectLink(String key, String name, String href) {
- this.key = key;
- setName(name);
- setHref(href);
- }
-
- public ResourceModel getResource() {
- return resource;
- }
-
- public void setResource(ResourceModel resource) {
- this.resource = resource;
- }
-
- public String getName() {
- return name;
- }
-
- public final void setName(String name) {
- this.name = StringUtils.abbreviate(name, NAME_COLUMN_SIZE);
- }
-
- public String getHref() {
- return href;
- }
-
- public final void setHref(String href) {
- if (href == null) {
- throw new IllegalArgumentException("ProjectLink.href can not be null");
- }
- this.href = StringUtils.abbreviate(href, HREF_COLUMN_SIZE);
- }
-
- public String getKey() {
- return key;
- }
-
- public void setKey(String key) {
- this.key = key;
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
-
- ProjectLink that = (ProjectLink) o;
- if (!key.equals(that.key)) {
- return false;
- }
- return resource.equals(that.resource);
-
- }
-
- @Override
- public int hashCode() {
- int result = resource != null ? resource.hashCode() : 0;
- result = 31 * result + key.hashCode();
- return result;
- }
-
- @Override
- public String toString() {
- return new ReflectionToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE).toString();
- }
-
- public void copyFieldsFrom(ProjectLink link) {
- this.name = link.getName();
- this.href = link.getHref();
- }
-}
diff --git a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectLinkTest.java b/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectLinkTest.java
deleted file mode 100644
index b193513f8ea..00000000000
--- a/sonar-plugin-api/src/test/java/org/sonar/api/resources/ProjectLinkTest.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.api.resources;
-
-import org.junit.Test;
-
-import static org.junit.Assert.assertEquals;
-
-public class ProjectLinkTest {
-
- ProjectLink link = new ProjectLink();
-
- @Test
- public void testSetName() {
- link.setName(overFillString(ProjectLink.NAME_COLUMN_SIZE));
- assertAbbreviated(ProjectLink.NAME_COLUMN_SIZE, link.getName());
- }
-
- @Test
- public void testSetHref() {
- link.setHref(overFillString(ProjectLink.HREF_COLUMN_SIZE));
- assertAbbreviated(ProjectLink.HREF_COLUMN_SIZE, link.getHref());
- }
-
- @Test
- public void testConstructor() {
- link = new ProjectLink("home",
- overFillString(ProjectLink.NAME_COLUMN_SIZE),
- overFillString(ProjectLink.HREF_COLUMN_SIZE));
- assertAbbreviated(ProjectLink.NAME_COLUMN_SIZE, link.getName());
- assertAbbreviated(ProjectLink.HREF_COLUMN_SIZE, link.getHref());
- }
-
- private String overFillString(int maxSize) {
- StringBuilder overFilled = new StringBuilder();
- for (int i = 0; i < 50 + maxSize; i++) {
- overFilled.append("x");
- }
- return overFilled.toString();
- }
-
- private void assertAbbreviated(int maxSize, String value) {
- assertEquals(maxSize, value.length());
- assertEquals('.', value.charAt(maxSize - 1));
- }
-}