aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml4
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java14
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml4
-rw-r--r--archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java153
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js15
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/CiManagement.java3
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Dependency.java3
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java3
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/IssueManagement.java3
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/License.java3
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MailingList.java2
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacet.java6
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Organization.java3
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java2
-rw-r--r--archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Scm.java3
15 files changed, 211 insertions, 10 deletions
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
index d28c32ed1..2dd898627 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/pom.xml
@@ -45,6 +45,10 @@
<artifactId>archiva-policies</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-model</artifactId>
+ </dependency>
<dependency>
<groupId>org.codehaus.redback</groupId>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
index 15d6b4c9c..758a52c94 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
@@ -18,6 +18,7 @@ package org.apache.archiva.rest.api.services;
* under the License.
*/
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.rest.api.model.BrowseResult;
import org.apache.archiva.rest.api.model.VersionsList;
import org.codehaus.plexus.redback.authorization.RedbackAuthorization;
@@ -26,7 +27,6 @@ import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
/**
@@ -50,10 +50,18 @@ public interface BrowseService
BrowseResult browseGroupId( @PathParam( "groupId" ) String groupId )
throws ArchivaRestServiceException;
- @Path( "browseGroupId" )
+ @Path( "versionsList/{g}/{a}" )
@GET
@Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
@RedbackAuthorization( noRestriction = true, noPermission = false )
- VersionsList getVersionsList( @QueryParam( "g" ) String groupId, @QueryParam( "a" ) String artifactId )
+ VersionsList getVersionsList( @PathParam( "g" ) String groupId, @PathParam( "a" ) String artifactId )
+ throws ArchivaRestServiceException;
+
+ @Path( "projectVersionMetadata/{g}/{a}" )
+ @GET
+ @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
+ @RedbackAuthorization( noRestriction = true, noPermission = false )
+ ProjectVersionMetadata getProjectVersionMetadata( @PathParam( "g" ) String groupId,
+ @PathParam( "a" ) String artifactId )
throws ArchivaRestServiceException;
}
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
index 8bdd8d35e..2b85bdc61 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/pom.xml
@@ -46,6 +46,10 @@
</dependency>
<dependency>
<groupId>org.apache.archiva</groupId>
+ <artifactId>metadata-model</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.archiva</groupId>
<artifactId>archiva-configuration</artifactId>
<scope>runtime</scope>
</dependency>
diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
index 360868142..c6f2d7869 100644
--- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
+++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
@@ -18,15 +18,18 @@ package org.apache.archiva.rest.services;
* under the License.
*/
+import org.apache.archiva.metadata.model.ProjectVersionMetadata;
import org.apache.archiva.metadata.repository.MetadataResolutionException;
import org.apache.archiva.metadata.repository.MetadataResolver;
import org.apache.archiva.metadata.repository.RepositorySession;
+import org.apache.archiva.metadata.repository.storage.maven2.MavenProjectFacet;
import org.apache.archiva.rest.api.model.BrowseResult;
import org.apache.archiva.rest.api.model.BrowseResultEntry;
import org.apache.archiva.rest.api.model.VersionsList;
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.BrowseService;
import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import javax.ws.rs.core.Response;
@@ -170,8 +173,23 @@ public class DefaultBrowseService
return new VersionsList();
}
- RepositorySession repositorySession = repositorySessionFactory.createSession();
+ try
+ {
+ return new VersionsList( new ArrayList<String>( getVersions( selectedRepos, groupId, artifactId ) ) );
+ }
+ catch ( MetadataResolutionException e )
+ {
+ throw new ArchivaRestServiceException( e.getMessage(),
+ Response.Status.INTERNAL_SERVER_ERROR.getStatusCode() );
+ }
+ }
+
+ private Set<String> getVersions( List<String> selectedRepos, String groupId, String artifactId )
+ throws MetadataResolutionException
+
+ {
+ RepositorySession repositorySession = repositorySessionFactory.createSession();
try
{
MetadataResolver metadataResolver = repositorySession.getResolver();
@@ -184,7 +202,132 @@ public class DefaultBrowseService
metadataResolver.resolveProjectVersions( repositorySession, repoId, groupId, artifactId ) );
}
- return new VersionsList( new ArrayList<String>( versions ) );
+ return versions;
+ }
+ finally
+ {
+ repositorySession.close();
+ }
+ }
+
+ public ProjectVersionMetadata getProjectVersionMetadata( String groupId, String artifactId )
+ throws ArchivaRestServiceException
+ {
+
+ List<String> selectedRepos = getObservableRepos();
+
+ if ( CollectionUtils.isEmpty( selectedRepos ) )
+ {
+ // FIXME 403 ???
+ return null;
+ }
+
+ RepositorySession repositorySession = null;
+ try
+ {
+
+ Set<String> projectVersions = getVersions( selectedRepos, groupId, artifactId );
+
+ repositorySession = repositorySessionFactory.createSession();
+
+ MetadataResolver metadataResolver = repositorySession.getResolver();
+
+ ProjectVersionMetadata sharedModel = new ProjectVersionMetadata();
+
+ MavenProjectFacet mavenFacet = new MavenProjectFacet();
+ mavenFacet.setGroupId( groupId );
+ mavenFacet.setArtifactId( artifactId );
+ sharedModel.addFacet( mavenFacet );
+
+ boolean isFirstVersion = true;
+
+ for ( String version : projectVersions )
+ {
+ ProjectVersionMetadata versionMetadata = null;
+ for ( String repoId : selectedRepos )
+ {
+ if ( versionMetadata == null )
+ {
+ try
+ {
+ versionMetadata =
+ metadataResolver.resolveProjectVersion( repositorySession, repoId, groupId, artifactId,
+ version );
+ }
+ catch ( MetadataResolutionException e )
+ {
+ log.error( "Skipping invalid metadata while compiling shared model for " + groupId + ":"
+ + artifactId + " in repo " + repoId + ": " + e.getMessage() );
+ }
+ }
+ }
+
+ if ( versionMetadata == null )
+ {
+ continue;
+ }
+
+ if ( isFirstVersion )
+ {
+ sharedModel = versionMetadata;
+ sharedModel.setId( null );
+ }
+ else
+ {
+ MavenProjectFacet versionMetadataMavenFacet =
+ (MavenProjectFacet) versionMetadata.getFacet( MavenProjectFacet.FACET_ID );
+ if ( versionMetadataMavenFacet != null )
+ {
+ if ( mavenFacet.getPackaging() != null && !StringUtils.equalsIgnoreCase(
+ mavenFacet.getPackaging(), versionMetadataMavenFacet.getPackaging() ) )
+ {
+ mavenFacet.setPackaging( null );
+ }
+ }
+
+ if ( sharedModel.getName() != null && !StringUtils.equalsIgnoreCase( sharedModel.getName(),
+ versionMetadata.getName() ) )
+ {
+ sharedModel.setName( "" );
+ }
+
+ if ( sharedModel.getDescription() != null && !StringUtils.equalsIgnoreCase(
+ sharedModel.getDescription(), versionMetadata.getDescription() ) )
+ {
+ sharedModel.setDescription( null );
+ }
+
+ if ( sharedModel.getIssueManagement() != null && versionMetadata.getIssueManagement() != null
+ && !StringUtils.equalsIgnoreCase( sharedModel.getIssueManagement().getUrl(),
+ versionMetadata.getIssueManagement().getUrl() ) )
+ {
+ sharedModel.setIssueManagement( null );
+ }
+
+ if ( sharedModel.getCiManagement() != null && versionMetadata.getCiManagement() != null
+ && !StringUtils.equalsIgnoreCase( sharedModel.getCiManagement().getUrl(),
+ versionMetadata.getCiManagement().getUrl() ) )
+ {
+ sharedModel.setCiManagement( null );
+ }
+
+ if ( sharedModel.getOrganization() != null && versionMetadata.getOrganization() != null
+ && !StringUtils.equalsIgnoreCase( sharedModel.getOrganization().getName(),
+ versionMetadata.getOrganization().getName() ) )
+ {
+ sharedModel.setOrganization( null );
+ }
+
+ if ( sharedModel.getUrl() != null && !StringUtils.equalsIgnoreCase( sharedModel.getUrl(),
+ versionMetadata.getUrl() ) )
+ {
+ sharedModel.setUrl( null );
+ }
+ }
+
+ isFirstVersion = false;
+ }
+ return sharedModel;
}
catch ( MetadataResolutionException e )
{
@@ -193,9 +336,11 @@ public class DefaultBrowseService
}
finally
{
- repositorySession.close();
+ if ( repositorySession != null )
+ {
+ repositorySession.close();
+ }
}
-
}
//---------------------------
diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
index 9a641848f..3a2ab5b50 100644
--- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
+++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
@@ -42,7 +42,7 @@ $(function() {
displayProjectEntry=function(id){
$.log("displayProjectEntry:"+id);
- var url = "restServices/archivaServices/browseService/browseGroupId?g=org.apache.maven&a=maven-archiver";
+ var url = "restServices/archivaServices/browseService/versionsList/org.apache.maven/maven-archiver";
$.ajax(url, {
type: "GET",
@@ -50,7 +50,18 @@ $(function() {
success: function(data) {
}
- });
+ });
+
+ url = "restServices/archivaServices/browseService/projectVersionMetadata/org.apache.maven/maven-archiver";
+
+ $.ajax(url, {
+ type: "GET",
+ dataType: 'json',
+ success: function(data) {
+
+ }
+ });
+
}
breadCrumbEntries=function(){
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/CiManagement.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/CiManagement.java
index bbee4efcf..d58936d77 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/CiManagement.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/CiManagement.java
@@ -19,11 +19,14 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
+
/**
* Information about the CI system used by the project.
*
* @todo considering moving this to a facet - avoid referring to it externally
*/
+@XmlRootElement( name = "ciManagement" )
public class CiManagement
{
/**
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Dependency.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Dependency.java
index a2658769d..772984fd9 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Dependency.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Dependency.java
@@ -19,11 +19,14 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
+
/**
* Information about a dependency that this project has on another project or artifact.
*
* @todo will be reviewing what is appropriate for the base here - rest should be in a maven dependency facet - avoid details on it externally
*/
+@XmlRootElement( name = "dependency" )
public class Dependency
{
/**
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java
index 5e7d82d3c..387813e36 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/FacetedMetadata.java
@@ -19,6 +19,7 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlElement;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
@@ -77,7 +78,7 @@ public abstract class FacetedMetadata
/**
* Get all available facets as a Map (typically used by bean rendering, such as in Archiva's JSPs).
-
+ *
* @return the map of facets
* @see #facets
*/
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/IssueManagement.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/IssueManagement.java
index 83eecda0d..12137ba43 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/IssueManagement.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/IssueManagement.java
@@ -19,11 +19,14 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
+
/**
* Information about the issue management system used by the project.
*
* @todo considering moving this to a facet - avoid referring to it externally
*/
+@XmlRootElement( name = "issueManagement" )
public class IssueManagement
{
/**
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/License.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/License.java
index b1ce93b77..5fbb28015 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/License.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/License.java
@@ -19,9 +19,12 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
+
/**
* A description of a particular license used by a project.
*/
+@XmlRootElement( name = "license" )
public class License
{
/**
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MailingList.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MailingList.java
index 129358d4a..922e2d5d8 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MailingList.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MailingList.java
@@ -1,5 +1,6 @@
package org.apache.archiva.metadata.model;
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/*
@@ -26,6 +27,7 @@ import java.util.List;
*
* @todo considering moving this to a facet - avoid referring to it externally
*/
+@XmlRootElement( name = "mailingList" )
public class MailingList
{
/**
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacet.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacet.java
index ebc3dd2ff..d146efd2d 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacet.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/MetadataFacet.java
@@ -19,14 +19,20 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.Map;
+@XmlRootElement( name = "metadataFacet" )
public interface MetadataFacet
{
+ @XmlElement(name = "facetId")
String getFacetId();
+ @XmlElement(name = "name")
String getName();
+ @XmlElement(name = "properties")
Map<String, String> toProperties();
void fromProperties( Map<String, String> properties );
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Organization.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Organization.java
index f3d841d4c..23048cbed 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Organization.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Organization.java
@@ -19,6 +19,9 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement( name = "organization" )
public class Organization
{
private String name;
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java
index b61135e78..d614bc990 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/ProjectVersionMetadata.java
@@ -19,9 +19,11 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
import java.util.ArrayList;
import java.util.List;
+@XmlRootElement( name = "projectVersionMetadata" )
public class ProjectVersionMetadata
extends FacetedMetadata
{
diff --git a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Scm.java b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Scm.java
index a3d8158fb..5e45e931f 100644
--- a/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Scm.java
+++ b/archiva-modules/metadata/metadata-model/src/main/java/org/apache/archiva/metadata/model/Scm.java
@@ -19,6 +19,9 @@ package org.apache.archiva.metadata.model;
* under the License.
*/
+import javax.xml.bind.annotation.XmlRootElement;
+
+@XmlRootElement( name = "scm" )
public class Scm
{
private String connection;