archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From och...@apache.org
Subject svn commit: r711320 - in /archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc: archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/ archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/ archiva-xmlrpc-services/sr...
Date Tue, 04 Nov 2008 17:17:20 GMT
Author: oching
Date: Tue Nov  4 09:17:19 2008
New Revision: 711320

URL: http://svn.apache.org/viewvc?rev=711320&view=rev
Log:
[MRM-206]
- added getDependencies(..) and getDependees(..) implementation
- added test cases

Added:
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Dependency.java
Modified:
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java
    archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java?rev=711320&r1=711319&r2=711320&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/SearchService.java
Tue Nov  4 09:17:19 2008
@@ -23,6 +23,8 @@
 import java.util.List;
 
 import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
+import org.apache.archiva.web.xmlrpc.api.beans.Dependency;
+
 import com.atlassian.xmlrpc.ServiceObject;
 
 @ServiceObject("Search")
@@ -48,7 +50,7 @@
     public List<Artifact> getArtifactVersionsByDate( String groupId, String artifactId,
String version, Date whenGathered )
             throws Exception;
 
-    public List<Artifact> getDirectDependencies( String repositoryId, String groupId,
String artifactId, String version ) 
+    public List<Dependency> getDependencies( String groupId, String artifactId, String
version ) 
             throws Exception;
     
     public List<Artifact> getDependencyTree( String groupId, String artifactId, String
version ) throws Exception;

Added: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Dependency.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Dependency.java?rev=711320&view=auto
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Dependency.java
(added)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-api/src/main/java/org/apache/archiva/web/xmlrpc/api/beans/Dependency.java
Tue Nov  4 09:17:19 2008
@@ -0,0 +1,111 @@
+package org.apache.archiva.web.xmlrpc.api.beans;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.Serializable;
+
+import com.atlassian.xmlrpc.ServiceBean;
+
+@ServiceBean
+public class Dependency
+    implements Serializable
+{
+    private String groupId;
+    
+    private String artifactId;
+    
+    private String version;
+    
+    private String classifier;
+    
+    private String type;
+    
+    private String scope;
+    
+    public Dependency( String groupId, String artifactId, String version, String classifier,
String type, String scope )
+    {
+        this.groupId = groupId;
+        this.artifactId = artifactId;
+        this.version = version;
+        this.classifier = classifier;
+        this.type = type;
+        this.scope = scope;
+    }
+
+    public String getGroupId()
+    {
+        return groupId;
+    }
+
+    public void setGroupId( String groupId )
+    {
+        this.groupId = groupId;
+    }
+
+    public String getArtifactId()
+    {
+        return artifactId;
+    }
+
+    public void setArtifactId( String artifactId )
+    {
+        this.artifactId = artifactId;
+    }
+
+    public String getVersion()
+    {
+        return version;
+    }
+
+    public void setVersion( String version )
+    {
+        this.version = version;
+    }
+
+    public String getClassifier()
+    {
+        return classifier;
+    }
+
+    public void setClassifier( String classifier )
+    {
+        this.classifier = classifier;
+    }
+
+    public String getType()
+    {
+        return type;
+    }
+
+    public void setType( String type )
+    {
+        this.type = type;
+    }
+
+    public String getScope()
+    {
+        return scope;
+    }
+
+    public void setScope( String scope )
+    {
+        this.scope = scope;
+    }
+}

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java?rev=711320&r1=711319&r2=711320&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/main/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImpl.java
Tue Nov  4 09:17:19 2008
@@ -26,9 +26,11 @@
 import org.apache.archiva.indexer.util.SearchUtil;
 import org.apache.archiva.web.xmlrpc.api.SearchService;
 import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
+import org.apache.archiva.web.xmlrpc.api.beans.Dependency;
 import org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories;
 import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.browsing.BrowsingResults;
 import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
 import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
@@ -37,6 +39,7 @@
 import org.apache.maven.archiva.indexer.search.SearchResultLimits;
 import org.apache.maven.archiva.indexer.search.SearchResults;
 import org.apache.maven.archiva.model.ArchivaArtifact;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
 
 /**
  * SearchServiceImpl
@@ -176,19 +179,36 @@
         return artifacts;
     }
     
-    public List<Artifact> getDirectDependencies( String repositoryId, String groupId,
String artifactId, String version ) 
+    public List<Dependency> getDependencies( String groupId, String artifactId, String
version ) 
         throws Exception
     {  
-        List<Artifact> artifacts = new ArrayList<Artifact>();
+        List<Dependency> dependencies = new ArrayList<Dependency>();        
+        List<String> observableRepos = xmlRpcUserRepositories.getObservableRepositories();
         
-        return artifacts;
+        try
+        {
+            ArchivaProjectModel model = repoBrowsing.selectVersion( "", observableRepos,
groupId, artifactId, version );
+            List<org.apache.maven.archiva.model.Dependency> modelDeps = model.getDependencies();
+            for( org.apache.maven.archiva.model.Dependency dep : modelDeps )
+            {
+                Dependency dependency = new Dependency( 
+                    dep.getGroupId(), dep.getArtifactId(), dep.getVersion(), dep.getClassifier(),
dep.getType(), dep.getScope() );
+                dependencies.add( dependency );
+            }
+        }
+        catch ( ObjectNotFoundException oe )
+        {
+            throw new Exception( "Artifact does not exist." );
+        }
+        
+        return dependencies;
     }
     
     public List<Artifact> getDependencyTree( String groupId, String artifactId, String
version ) 
         throws Exception
     {
         List<Artifact> a = new ArrayList<Artifact>();
-    
+        
         return a;
     }
     
@@ -197,9 +217,15 @@
         throws Exception
     {
         List<Artifact> artifacts = new ArrayList<Artifact>();
-       
-        // repo browsing usedBy?
-       
+        List<String> observableRepos = xmlRpcUserRepositories.getObservableRepositories();
+        
+        List<ArchivaProjectModel> dependees = repoBrowsing.getUsedBy( "", observableRepos,
"org.apache.archiva", "archiva-test", "1.0" );
+        for( ArchivaProjectModel model : dependees )
+        {
+            Artifact artifact = new Artifact( "", model.getGroupId(), model.getArtifactId(),
model.getVersion(), "", model.getWhenIndexed() );
+            artifacts.add( artifact );
+        }
+        
         return artifacts;
     }
 }
\ No newline at end of file

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java?rev=711320&r1=711319&r2=711320&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-xmlrpc/archiva-xmlrpc-services/src/test/java/org/apache/archiva/web/xmlrpc/services/SearchServiceImplTest.java
Tue Nov  4 09:17:19 2008
@@ -27,6 +27,7 @@
 
 import org.apache.archiva.web.xmlrpc.api.SearchService;
 import org.apache.archiva.web.xmlrpc.api.beans.Artifact;
+import org.apache.archiva.web.xmlrpc.api.beans.Dependency;
 import org.apache.archiva.web.xmlrpc.security.XmlRpcAuthenticator;
 import org.apache.archiva.web.xmlrpc.security.XmlRpcUserRepositories;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
@@ -35,6 +36,7 @@
 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.database.ArchivaDAO;
 import org.apache.maven.archiva.database.ArtifactDAO;
+import org.apache.maven.archiva.database.ObjectNotFoundException;
 import org.apache.maven.archiva.database.browsing.BrowsingResults;
 import org.apache.maven.archiva.database.browsing.RepositoryBrowsing;
 import org.apache.maven.archiva.database.constraints.ArtifactsByChecksumConstraint;
@@ -45,6 +47,7 @@
 import org.apache.maven.archiva.indexer.search.SearchResults;
 import org.apache.maven.archiva.model.ArchivaArtifact;
 import org.apache.maven.archiva.model.ArchivaArtifactModel;
+import org.apache.maven.archiva.model.ArchivaProjectModel;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
 import org.apache.maven.archiva.repository.RepositoryContentFactory;
@@ -347,14 +350,73 @@
     
     public void testGetDependenciesArtifactExists()
         throws Exception
-    {
-    
+    {   
+        List<String> observableRepoIds = new ArrayList<String>();
+        observableRepoIds.add( "repo1.mirror" );
+        observableRepoIds.add( "public.releases" );
+        
+        ArchivaProjectModel model = new ArchivaProjectModel();
+        model.setGroupId( "org.apache.archiva" );
+        model.setArtifactId( "archiva-test" );
+        model.setVersion( "1.0" );
+        
+        org.apache.maven.archiva.model.Dependency dependency = new org.apache.maven.archiva.model.Dependency();
+        dependency.setGroupId( "commons-logging" );
+        dependency.setArtifactId( "commons-logging" );
+        dependency.setVersion( "2.0" );
+        
+        model.addDependency( dependency );
+        
+        dependency = new org.apache.maven.archiva.model.Dependency();
+        dependency.setGroupId( "junit" );
+        dependency.setArtifactId( "junit" );
+        dependency.setVersion( "2.4" );
+        dependency.setScope( "test" );
+        
+        model.addDependency( dependency );
+        
+        userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds
);        
+        repoBrowsingControl.expectAndReturn( 
+                 repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva",
"archiva-test", "1.0" ), model );
+        
+        repoBrowsingControl.replay(); 
+        userReposControl.replay();
+        
+        List<Dependency> dependencies = searchService.getDependencies( "org.apache.archiva",
"archiva-test", "1.0" );
+        
+        repoBrowsingControl.verify();
+        userReposControl.verify();
+        
+        assertNotNull( dependencies );
+        assertEquals( 2, dependencies.size() );
     }
     
     public void testGetDependenciesArtifactDoesNotExist()
         throws Exception
     {
-    
+        List<String> observableRepoIds = new ArrayList<String>();
+        observableRepoIds.add( "repo1.mirror" );
+        observableRepoIds.add( "public.releases" );
+        
+        userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds
);
+        repoBrowsingControl.expectAndThrow( 
+               repoBrowsing.selectVersion( "", observableRepoIds, "org.apache.archiva", "archiva-test",
"1.0" ), new ObjectNotFoundException( "Artifact does not exist." ) );
+        
+        userReposControl.replay();
+        repoBrowsingControl.replay();
+        
+        try
+        {
+            List<Dependency> dependencies = searchService.getDependencies( "org.apache.archiva",
"archiva-test", "1.0" );
+            fail( "An exception should have been thrown." );
+        }
+        catch ( Exception e )
+        {
+            assertEquals( "Artifact does not exist.", e.getMessage() );
+        }
+        
+        userReposControl.verify();
+        repoBrowsingControl.verify();
     }
     
 /* get dependency tree */
@@ -362,7 +424,7 @@
     public void testGetDependencyTreeArtifactExists()
         throws Exception
     {
-    
+        
     }
     
     public void testGetDependencyTreeArtifactDoesNotExist()
@@ -373,15 +435,87 @@
     
 /* get dependees */
     
-    public void testGetDependeneesArtifactExists()
+    public void testGetDependees()
         throws Exception
     {
-    
+        Date date = new Date();
+        List<String> observableRepoIds = new ArrayList<String>();
+        observableRepoIds.add( "repo1.mirror" );
+        observableRepoIds.add( "public.releases" );
+        
+        List dependeeModels = new ArrayList();
+        ArchivaProjectModel dependeeModel = new ArchivaProjectModel();
+        dependeeModel.setGroupId( "org.apache.archiva" );
+        dependeeModel.setArtifactId( "archiva-dependee-one" );
+        dependeeModel.setVersion( "1.0" );
+        dependeeModel.setWhenIndexed( date );
+        dependeeModels.add( dependeeModel );
+        
+        dependeeModel = new ArchivaProjectModel();
+        dependeeModel.setGroupId( "org.apache.archiva" );
+        dependeeModel.setArtifactId( "archiva-dependee-two" );
+        dependeeModel.setVersion( "1.0" );
+        dependeeModel.setWhenIndexed( date );
+        dependeeModels.add( dependeeModel );
+        
+        userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds
);
+        repoBrowsingControl.expectAndReturn( repoBrowsing.getUsedBy( "", observableRepoIds,
"org.apache.archiva", "archiva-test", "1.0" ), dependeeModels );
+        
+        repoBrowsingControl.replay(); 
+        userReposControl.replay();
+
+        List<Artifact> dependees = searchService.getDependees( "org.apache.archiva",
"archiva-test", "1.0" );
+        
+        repoBrowsingControl.verify();
+        userReposControl.verify();
+        
+        assertNotNull( dependees );
+        assertEquals( 2, dependees.size() );
     }
     
-    public void testGetDependeneesArtifactDoesNotExist()
+    /*public void testGetDependeesArtifactDoesNotExist()
         throws Exception
     {
-    
-    }
+        Date date = new Date();
+        List<String> observableRepoIds = new ArrayList<String>();
+        observableRepoIds.add( "repo1.mirror" );
+        observableRepoIds.add( "public.releases" );
+        
+        List dependeeModels = new ArrayList();
+        ArchivaProjectModel dependeeModel = new ArchivaProjectModel();
+        dependeeModel.setGroupId( "org.apache.archiva" );
+        dependeeModel.setArtifactId( "archiva-dependee-one" );
+        dependeeModel.setVersion( "1.0" );
+        dependeeModel.setWhenIndexed( date );
+        dependeeModels.add( dependeeModel );
+        
+        dependeeModel = new ArchivaProjectModel();
+        dependeeModel.setGroupId( "org.apache.archiva" );
+        dependeeModel.setArtifactId( "archiva-dependee-two" );
+        dependeeModel.setVersion( "1.0" );
+        dependeeModel.setWhenIndexed( date );
+        dependeeModels.add( dependeeModel );
+        
+        userReposControl.expectAndReturn( userRepos.getObservableRepositories(), observableRepoIds
);
+        repoBrowsingControl.expectAndReturn( repoBrowsing.getUsedBy( "", observableRepoIds,
"org.apache.archiva", "archiva-test", "1.0" ), dependeeModels );
+        
+        repoBrowsingControl.replay(); 
+        userReposControl.replay();
+
+        try
+        {
+            List<Artifact> dependees = searchService.getDependees( "org.apache.archiva",
"archiva-test", "1.0" );
+            fail( "An exception should have been thrown." );
+        }
+        catch ( Exception e )
+        {
+            assertEquals( "Artifact does not exist." )
+        }
+        
+        repoBrowsingControl.verify();
+        userReposControl.verify();
+        
+        assertNotNull( dependees );
+        assertEquals( 2, dependees.size() );
+    }*/
 }
\ No newline at end of file



Mime
View raw message