This commit is contained in:
Sebastian Sdorra
2012-09-30 09:48:17 +02:00
parent 24e6e7e7af
commit 910c937a30
2 changed files with 74 additions and 53 deletions

View File

@@ -128,56 +128,56 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
final PluginInformation other = (PluginInformation) obj; final PluginInformation other = (PluginInformation) obj;
if ((this.artifactId == null) if ((this.artifactId == null)
? (other.artifactId != null) ? (other.artifactId != null)
: !this.artifactId.equals(other.artifactId)) : !this.artifactId.equals(other.artifactId))
{ {
return false; return false;
} }
if ((this.author == null) if ((this.author == null)
? (other.author != null) ? (other.author != null)
: !this.author.equals(other.author)) : !this.author.equals(other.author))
{ {
return false; return false;
} }
if ((this.category == null) if ((this.category == null)
? (other.category != null) ? (other.category != null)
: !this.category.equals(other.category)) : !this.category.equals(other.category))
{ {
return false; return false;
} }
if ((this.condition != other.condition) if ((this.condition != other.condition)
&& ((this.condition == null) ||!this.condition.equals(other.condition))) && ((this.condition == null) ||!this.condition.equals(other.condition)))
{ {
return false; return false;
} }
if ((this.description == null) if ((this.description == null)
? (other.description != null) ? (other.description != null)
: !this.description.equals(other.description)) : !this.description.equals(other.description))
{ {
return false; return false;
} }
if ((this.groupId == null) if ((this.groupId == null)
? (other.groupId != null) ? (other.groupId != null)
: !this.groupId.equals(other.groupId)) : !this.groupId.equals(other.groupId))
{ {
return false; return false;
} }
if ((this.name == null) if ((this.name == null)
? (other.name != null) ? (other.name != null)
: !this.name.equals(other.name)) : !this.name.equals(other.name))
{ {
return false; return false;
} }
if ((this.screenshots != other.screenshots) if ((this.screenshots != other.screenshots)
&& ((this.screenshots == null) && ((this.screenshots == null)
||!this.screenshots.equals(other.screenshots))) ||!this.screenshots.equals(other.screenshots)))
{ {
return false; return false;
} }
@@ -188,22 +188,22 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
} }
if ((this.url == null) if ((this.url == null)
? (other.url != null) ? (other.url != null)
: !this.url.equals(other.url)) : !this.url.equals(other.url))
{ {
return false; return false;
} }
if ((this.version == null) if ((this.version == null)
? (other.version != null) ? (other.version != null)
: !this.version.equals(other.version)) : !this.version.equals(other.version))
{ {
return false; return false;
} }
if ((this.wiki == null) if ((this.wiki == null)
? (other.wiki != null) ? (other.wiki != null)
: !this.wiki.equals(other.wiki)) : !this.wiki.equals(other.wiki))
{ {
return false; return false;
} }
@@ -223,41 +223,41 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
int hash = 5; int hash = 5;
hash = 79 * hash + ((this.artifactId != null) hash = 79 * hash + ((this.artifactId != null)
? this.artifactId.hashCode() ? this.artifactId.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.author != null) hash = 79 * hash + ((this.author != null)
? this.author.hashCode() ? this.author.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.category != null) hash = 79 * hash + ((this.category != null)
? this.category.hashCode() ? this.category.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.condition != null) hash = 79 * hash + ((this.condition != null)
? this.condition.hashCode() ? this.condition.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.description != null) hash = 79 * hash + ((this.description != null)
? this.description.hashCode() ? this.description.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.groupId != null) hash = 79 * hash + ((this.groupId != null)
? this.groupId.hashCode() ? this.groupId.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.name != null) hash = 79 * hash + ((this.name != null)
? this.name.hashCode() ? this.name.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.screenshots != null) hash = 79 * hash + ((this.screenshots != null)
? this.screenshots.hashCode() ? this.screenshots.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.state != null) hash = 79 * hash + ((this.state != null)
? this.state.hashCode() ? this.state.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.url != null) hash = 79 * hash + ((this.url != null)
? this.url.hashCode() ? this.url.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.version != null) hash = 79 * hash + ((this.version != null)
? this.version.hashCode() ? this.version.hashCode()
: 0); : 0);
hash = 79 * hash + ((this.wiki != null) hash = 79 * hash + ((this.wiki != null)
? this.wiki.hashCode() ? this.wiki.hashCode()
: 0); : 0);
return hash; return hash;
} }
@@ -337,12 +337,31 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
* @return * @return
*/ */
public String getId() public String getId()
{
return getId(true);
}
/**
* Method description
*
*
* @param withVersion
*
* @return
* @since 1.21
*/
public String getId(boolean withVersion)
{ {
StringBuilder id = new StringBuilder(groupId); StringBuilder id = new StringBuilder(groupId);
id.append(":").append(artifactId).append(":"); id.append(":").append(artifactId);
return id.append(version).toString(); if (withVersion)
{
id.append(":").append(version);
}
return id.toString();
} }
/** /**
@@ -421,7 +440,7 @@ public class PluginInformation implements Validateable, Cloneable, Serializable
public boolean isValid() public boolean isValid()
{ {
return Util.isNotEmpty(groupId) && Util.isNotEmpty(artifactId) return Util.isNotEmpty(groupId) && Util.isNotEmpty(artifactId)
&& Util.isNotEmpty(name) && Util.isNotEmpty(version); && Util.isNotEmpty(name) && Util.isNotEmpty(version);
} }
//~--- set methods ---------------------------------------------------------- //~--- set methods ----------------------------------------------------------

View File

@@ -35,6 +35,7 @@ package sonia.scm.api.rest.resources;
//~--- non-JDK imports -------------------------------------------------------- //~--- non-JDK imports --------------------------------------------------------
import com.google.common.collect.Lists;
import com.google.inject.Inject; import com.google.inject.Inject;
import com.google.inject.Singleton; import com.google.inject.Singleton;
@@ -56,7 +57,6 @@ import com.sun.jersey.multipart.FormDataParam;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.Iterator; import java.util.Iterator;
@@ -295,9 +295,11 @@ public class PluginResource
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON }) @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
public Collection<PluginInformation> getOverview() public Collection<PluginInformation> getOverview()
{ {
List<PluginInformation> plugins = new ArrayList<PluginInformation>( //J-
pluginManager.get( List<PluginInformation> plugins = Lists.newArrayList(
OverviewPluginFilter.INSTANCE)); pluginManager.get(OverviewPluginFilter.INSTANCE)
);
//J+
Collections.sort(plugins, PluginInformationComparator.INSTANCE); Collections.sort(plugins, PluginInformationComparator.INSTANCE);
@@ -307,7 +309,7 @@ public class PluginResource
while (it.hasNext()) while (it.hasNext())
{ {
PluginInformation pi = it.next(); PluginInformation pi = it.next();
String id = pi.getGroupId().concat(":").concat(pi.getArtifactId()); String id = pi.getId(false);
if ((last != null) && id.equals(last)) if ((last != null) && id.equals(last))
{ {