archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1170261 - in /archiva/trunk/archiva-modules: archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/ archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ archiva-web/archiva-rest/...
Date Tue, 13 Sep 2011 17:31:28 GMT
Author: olamy
Date: Tue Sep 13 17:31:27 2011
New Revision: 1170261

URL: http://svn.apache.org/viewvc?rev=1170261&view=rev
Log:
[MRM-1490] Expose Archiva services trough REST : search service more impl

Modified:
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
    archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j.xml

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/NexusRepositorySearch.java
Tue Sep 13 17:31:27 2011
@@ -381,6 +381,18 @@ public class NexusRepositorySearch
                 hit.setBundleExportService( artifactInfo.bundleExportService );
                 hit.setBundleSymbolicName( artifactInfo.bundleSymbolicName );
                 hit.setBundleVersion( artifactInfo.bundleVersion );
+                hit.setBundleDescription( artifactInfo.bundleDescription );
+                hit.setBundleDocUrl( artifactInfo.bundleDocUrl );
+
+                hit.setBundleRequireBundle( artifactInfo.bundleRequireBundle );
+                hit.setBundleImportPackage( artifactInfo.bundleImportPackage );
+                hit.setBundleLicense( artifactInfo.bundleLicense );
+                hit.setBundleName( artifactInfo.bundleName );
+                hit.setContext( artifactInfo.context );
+                hit.setGoals( artifactInfo.goals );
+                hit.setPrefix( artifactInfo.prefix );
+                // sure ??
+                hit.setUrl( artifactInfo.remoteUrl );
             }
 
             results.addHit( id, hit );

Modified: archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java
(original)
+++ archiva/trunk/archiva-modules/archiva-base/archiva-indexer/src/main/java/org/apache/archiva/indexer/search/SearchResultHit.java
Tue Sep 13 17:31:27 2011
@@ -40,42 +40,81 @@ public class SearchResultHit
 
     //  Advanced hit, reference to artifactId.
     private String artifactId;
-
-    // TODO: remove/deprecate this field!
-    private String version = "";
     
     private String repositoryId = "";
 
     private List<String> versions = new ArrayList<String>();
-
+    
+    /**
+     * Plugin goal prefix (only if packaging is "maven-plugin")
+     */
+    public String prefix;
 
     /**
+     * Plugin goals (only if packaging is "maven-plugin")
+     */
+    public List<String> goals; 
+    
+    /**
      * contains osgi metadata Bundle-Version if available
-     *
      * @since 1.4
      */
-    private String bundleVersion;
+    public String bundleVersion;
 
     /**
      * contains osgi metadata Bundle-SymbolicName if available
-     *
      * @since 1.4
      */
-    private String bundleSymbolicName;
+    public String bundleSymbolicName;
 
     /**
      * contains osgi metadata Export-Package if available
-     *
      * @since 1.4
      */
-    private String bundleExportPackage;
+    public String bundleExportPackage;
 
     /**
      * contains osgi metadata Export-Service if available
-     *
      * @since 1.4
      */
-    private String bundleExportService;
+    public String bundleExportService;
+
+    /**
+     * contains osgi metadata Bundle-Description if available
+     * @since 1.4
+     */
+    public String bundleDescription;
+
+    /**
+     * contains osgi metadata Bundle-Name if available
+     * @since 1.4
+     */
+    public String bundleName;
+
+    /**
+     * contains osgi metadata Bundle-License if available
+     * @since 1.4
+     */
+    public String bundleLicense;
+
+    /**
+     * contains osgi metadata Bundle-DocURL if available
+     * @since 1.4
+     */
+    public String bundleDocUrl;
+
+    /**
+     * contains osgi metadata Import-Package if available
+     * @since 1.4
+     */
+    public String bundleImportPackage;
+
+    /**
+     * contains osgi metadata Require-Bundle if available
+     * @since 1.4
+     */
+    public String bundleRequireBundle;    
+    
 
     public String getContext()
     {
@@ -122,16 +161,6 @@ public class SearchResultHit
         this.groupId = groupId;
     }
 
-    public String getVersion()
-    {
-        return version;
-    }
-
-    public void setVersion(String version)
-    {
-        this.version = version;
-    }
-
     public List<String> getVersions()
     {
         return versions;
@@ -197,6 +226,86 @@ public class SearchResultHit
         this.bundleExportService = bundleExportService;
     }
 
+    public String getPrefix()
+    {
+        return prefix;
+    }
+
+    public void setPrefix( String prefix )
+    {
+        this.prefix = prefix;
+    }
+
+    public List<String> getGoals()
+    {
+        return goals;
+    }
+
+    public void setGoals( List<String> goals )
+    {
+        this.goals = goals;
+    }
+
+    public String getBundleDescription()
+    {
+        return bundleDescription;
+    }
+
+    public void setBundleDescription( String bundleDescription )
+    {
+        this.bundleDescription = bundleDescription;
+    }
+
+    public String getBundleName()
+    {
+        return bundleName;
+    }
+
+    public void setBundleName( String bundleName )
+    {
+        this.bundleName = bundleName;
+    }
+
+    public String getBundleLicense()
+    {
+        return bundleLicense;
+    }
+
+    public void setBundleLicense( String bundleLicense )
+    {
+        this.bundleLicense = bundleLicense;
+    }
+
+    public String getBundleDocUrl()
+    {
+        return bundleDocUrl;
+    }
+
+    public void setBundleDocUrl( String bundleDocUrl )
+    {
+        this.bundleDocUrl = bundleDocUrl;
+    }
+
+    public String getBundleImportPackage()
+    {
+        return bundleImportPackage;
+    }
+
+    public void setBundleImportPackage( String bundleImportPackage )
+    {
+        this.bundleImportPackage = bundleImportPackage;
+    }
+
+    public String getBundleRequireBundle()
+    {
+        return bundleRequireBundle;
+    }
+
+    public void setBundleRequireBundle( String bundleRequireBundle )
+    {
+        this.bundleRequireBundle = bundleRequireBundle;
+    }
+
     @Override
     public String toString()
     {
@@ -206,13 +315,20 @@ public class SearchResultHit
         sb.append( ", url='" ).append( url ).append( '\'' );
         sb.append( ", groupId='" ).append( groupId ).append( '\'' );
         sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
-        sb.append( ", version='" ).append( version ).append( '\'' );
         sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
         sb.append( ", versions=" ).append( versions );
+        sb.append( ", prefix='" ).append( prefix ).append( '\'' );
+        sb.append( ", goals=" ).append( goals );
         sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
         sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
         sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\''
);
         sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\''
);
+        sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
+        sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
+        sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
+        sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
+        sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\''
);
+        sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\''
);
         sb.append( '}' );
         return sb.toString();
     }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/Artifact.java
Tue Sep 13 17:31:27 2011
@@ -21,22 +21,37 @@ package org.apache.archiva.rest.api.mode
 
 import javax.xml.bind.annotation.XmlRootElement;
 import java.io.Serializable;
+import java.util.List;
 
 @XmlRootElement( name = "artifact" )
 public class Artifact
     implements Serializable
 {
-    private String repositoryId;
+    // The (optional) context for this result.
+    private String context;
+
+    // Basic hit, direct to non-artifact resource.
+    private String url;
 
+    // Advanced hit, reference to groupId.
     private String groupId;
 
+    //  Advanced hit, reference to artifactId.
     private String artifactId;
 
+    private String repositoryId;
+
     private String version;
 
-    private String type;
+    /**
+     * Plugin goal prefix (only if packaging is "maven-plugin")
+     */
+    private String prefix;
 
-    private String url;
+    /**
+     * Plugin goals (only if packaging is "maven-plugin")
+     */
+    private List<String> goals;
 
     /**
      * contains osgi metadata Bundle-Version if available
@@ -66,21 +81,54 @@ public class Artifact
      */
     private String bundleExportService;
 
+    /**
+     * contains osgi metadata Bundle-Description if available
+     *
+     * @since 1.4
+     */
+    private String bundleDescription;
+
+    /**
+     * contains osgi metadata Bundle-Name if available
+     *
+     * @since 1.4
+     */
+    private String bundleName;
+
+    /**
+     * contains osgi metadata Bundle-License if available
+     *
+     * @since 1.4
+     */
+    private String bundleLicense;
+
+    /**
+     * contains osgi metadata Bundle-DocURL if available
+     *
+     * @since 1.4
+     */
+    private String bundleDocUrl;
+
+    /**
+     * contains osgi metadata Import-Package if available
+     *
+     * @since 1.4
+     */
+    private String bundleImportPackage;
+
+    /**
+     * contains osgi metadata Require-Bundle if available
+     *
+     * @since 1.4
+     */
+    private String bundleRequireBundle;
+
 
     public Artifact()
     {
         // no op
     }
 
-    public Artifact( String repositoryId, String groupId, String artifactId, String version,
String type )
-    {
-        this.repositoryId = repositoryId;
-        this.groupId = groupId;
-        this.artifactId = artifactId;
-        this.version = version;
-        this.type = type;
-    }
-
     public String getGroupId()
     {
         return groupId;
@@ -96,11 +144,6 @@ public class Artifact
         return version;
     }
 
-    public String getType()
-    {
-        return type;
-    }
-
     public String getRepositoryId()
     {
         return repositoryId;
@@ -121,63 +164,149 @@ public class Artifact
         this.version = version;
     }
 
-    public void setType( String type )
+    public void setRepositoryId( String repositoryId )
     {
-        this.type = type;
+        this.repositoryId = repositoryId;
     }
 
-    public void setRepositoryId( String repositoryId )
+    public String getContext()
     {
-        this.repositoryId = repositoryId;
+        return context;
     }
 
-    @Override
-    public boolean equals( Object o )
+    public void setContext( String context )
+    {
+        this.context = context;
+    }
+
+    public String getUrl()
     {
-        if ( this == o )
-        {
-            return true;
-        }
-        if ( o == null || getClass() != o.getClass() )
-        {
-            return false;
-        }
-
-        Artifact artifact = (Artifact) o;
-
-        if ( !artifactId.equals( artifact.artifactId ) )
-        {
-            return false;
-        }
-        if ( !groupId.equals( artifact.groupId ) )
-        {
-            return false;
-        }
-        if ( !repositoryId.equals( artifact.repositoryId ) )
-        {
-            return false;
-        }
-        if ( type != null ? !type.equals( artifact.type ) : artifact.type != null )
-        {
-            return false;
-        }
-        if ( !version.equals( artifact.version ) )
-        {
-            return false;
-        }
+        return url;
+    }
 
-        return true;
+    public void setUrl( String url )
+    {
+        this.url = url;
     }
 
-    @Override
-    public int hashCode()
+    public String getPrefix()
+    {
+        return prefix;
+    }
+
+    public void setPrefix( String prefix )
+    {
+        this.prefix = prefix;
+    }
+
+    public List<String> getGoals()
+    {
+        return goals;
+    }
+
+    public void setGoals( List<String> goals )
+    {
+        this.goals = goals;
+    }
+
+    public String getBundleVersion()
+    {
+        return bundleVersion;
+    }
+
+    public void setBundleVersion( String bundleVersion )
+    {
+        this.bundleVersion = bundleVersion;
+    }
+
+    public String getBundleSymbolicName()
+    {
+        return bundleSymbolicName;
+    }
+
+    public void setBundleSymbolicName( String bundleSymbolicName )
+    {
+        this.bundleSymbolicName = bundleSymbolicName;
+    }
+
+    public String getBundleExportPackage()
+    {
+        return bundleExportPackage;
+    }
+
+    public void setBundleExportPackage( String bundleExportPackage )
+    {
+        this.bundleExportPackage = bundleExportPackage;
+    }
+
+    public String getBundleExportService()
+    {
+        return bundleExportService;
+    }
+
+    public void setBundleExportService( String bundleExportService )
+    {
+        this.bundleExportService = bundleExportService;
+    }
+
+    public String getBundleDescription()
+    {
+        return bundleDescription;
+    }
+
+    public void setBundleDescription( String bundleDescription )
+    {
+        this.bundleDescription = bundleDescription;
+    }
+
+    public String getBundleName()
+    {
+        return bundleName;
+    }
+
+    public void setBundleName( String bundleName )
+    {
+        this.bundleName = bundleName;
+    }
+
+    public String getBundleLicense()
+    {
+        return bundleLicense;
+    }
+
+    public void setBundleLicense( String bundleLicense )
+    {
+        this.bundleLicense = bundleLicense;
+    }
+
+    public String getBundleDocUrl()
+    {
+        return bundleDocUrl;
+    }
+
+    public void setBundleDocUrl( String bundleDocUrl )
+    {
+        this.bundleDocUrl = bundleDocUrl;
+    }
+
+    public String getBundleImportPackage()
+    {
+        return bundleImportPackage;
+    }
+
+    public void setBundleImportPackage( String bundleImportPackage )
+    {
+        this.bundleImportPackage = bundleImportPackage;
+    }
+
+    public String getBundleRequireBundle()
+    {
+        return bundleRequireBundle;
+    }
+
+    public void setBundleRequireBundle( String bundleRequireBundle )
     {
-        int result = repositoryId.hashCode();
-        result = 31 * result + groupId.hashCode();
-        result = 31 * result + artifactId.hashCode();
-        result = 31 * result + version.hashCode();
-        result = 31 * result + ( type != null ? type.hashCode() : 0 );
-        return result;
+        this.bundleRequireBundle = bundleRequireBundle;
     }
 
     @Override
@@ -185,11 +314,24 @@ public class Artifact
     {
         final StringBuilder sb = new StringBuilder();
         sb.append( "Artifact" );
-        sb.append( "{repositoryId='" ).append( repositoryId ).append( '\'' );
+        sb.append( "{context='" ).append( context ).append( '\'' );
+        sb.append( ", url='" ).append( url ).append( '\'' );
         sb.append( ", groupId='" ).append( groupId ).append( '\'' );
         sb.append( ", artifactId='" ).append( artifactId ).append( '\'' );
+        sb.append( ", repositoryId='" ).append( repositoryId ).append( '\'' );
         sb.append( ", version='" ).append( version ).append( '\'' );
-        sb.append( ", type='" ).append( type ).append( '\'' );
+        sb.append( ", prefix='" ).append( prefix ).append( '\'' );
+        sb.append( ", goals=" ).append( goals );
+        sb.append( ", bundleVersion='" ).append( bundleVersion ).append( '\'' );
+        sb.append( ", bundleSymbolicName='" ).append( bundleSymbolicName ).append( '\'' );
+        sb.append( ", bundleExportPackage='" ).append( bundleExportPackage ).append( '\''
);
+        sb.append( ", bundleExportService='" ).append( bundleExportService ).append( '\''
);
+        sb.append( ", bundleDescription='" ).append( bundleDescription ).append( '\'' );
+        sb.append( ", bundleName='" ).append( bundleName ).append( '\'' );
+        sb.append( ", bundleLicense='" ).append( bundleLicense ).append( '\'' );
+        sb.append( ", bundleDocUrl='" ).append( bundleDocUrl ).append( '\'' );
+        sb.append( ", bundleImportPackage='" ).append( bundleImportPackage ).append( '\''
);
+        sb.append( ", bundleRequireBundle='" ).append( bundleRequireBundle ).append( '\''
);
         sb.append( '}' );
         return sb.toString();
     }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ManagedRepositoriesService.java
Tue Sep 13 17:31:27 2011
@@ -60,7 +60,7 @@ public interface ManagedRepositoriesServ
     @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
)
     Boolean deleteManagedRepository( @QueryParam( "repositoryId" ) String repositoryId,
                                      @QueryParam( "deleteContent" ) boolean deleteContent
)
-        throws Exception;
+        throws ArchivaRestServiceException;
 
 
     @Path( "addManagedRepository" )
@@ -69,7 +69,7 @@ public interface ManagedRepositoriesServ
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
     @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
)
     Boolean addManagedRepository( ManagedRepository managedRepository )
-        throws Exception;
+        throws ArchivaRestServiceException;
 
 
     @Path( "updateManagedRepository" )
@@ -78,7 +78,7 @@ public interface ManagedRepositoriesServ
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
     @RedbackAuthorization( permission = ArchivaRoleConstants.OPERATION_MANAGE_CONFIGURATION
)
     Boolean updateManagedRepository( ManagedRepository managedRepository )
-        throws Exception;
+        throws ArchivaRestServiceException;
 
 
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/SearchService.java
Tue Sep 13 17:31:27 2011
@@ -50,13 +50,6 @@ public interface SearchService
     List<Artifact> quickSearch( @QueryParam( "queryString" ) String queryString )
         throws ArchivaRestServiceException;
 
-    @Path( "getArtifactByChecksum" )
-    @GET
-    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
-    @RedbackAuthorization( noPermission = true, noRestriction = true )
-    List<Artifact> getArtifactByChecksum( @QueryParam( "checksum" ) String checksum
)
-        throws ArchivaRestServiceException;
-
     @Path( "getArtifactVersions" )
     @GET
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
@@ -74,4 +67,11 @@ public interface SearchService
                                       @QueryParam( "version" ) String version )
         throws ArchivaRestServiceException;
 
+    @Path( "getArtifactByChecksum" )
+    @GET
+    @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML, MediaType.TEXT_PLAIN
} )
+    @RedbackAuthorization( noPermission = true, noRestriction = true )
+    List<Artifact> getArtifactByChecksum( @QueryParam( "checksum" ) String checksum
)
+    throws ArchivaRestServiceException;
+
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/AbstractRestService.java
Tue Sep 13 17:31:27 2011
@@ -23,6 +23,8 @@ import org.apache.archiva.audit.AuditLis
 import org.codehaus.plexus.redback.users.User;
 import org.codehaus.redback.rest.services.RedbackAuthenticationThreadLocal;
 import org.codehaus.redback.rest.services.RedbackRequestInformation;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import javax.inject.Inject;
 import java.util.ArrayList;
@@ -37,6 +39,8 @@ import java.util.List;
 public abstract class AbstractRestService
 {
 
+    protected Logger log = LoggerFactory.getLogger( getClass() );
+
     @Inject
     private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultManagedRepositoriesService.java
Tue Sep 13 17:31:27 2011
@@ -20,6 +20,7 @@ package org.apache.archiva.rest.services
 
 import org.apache.archiva.admin.model.RepositoryAdminException;
 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
 import org.apache.archiva.rest.api.model.ManagedRepository;
 import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
 import org.apache.archiva.rest.api.services.ManagedRepositoriesService;
@@ -43,6 +44,10 @@ public class DefaultManagedRepositoriesS
     @Inject
     private ManagedRepositoryAdmin managedRepositoryAdmin;
 
+    @Inject
+    private PlexusSisuBridge plexusSisuBridge;
+
+
     public List<ManagedRepository> getManagedRepositories()
         throws ArchivaRestServiceException
     {
@@ -87,14 +92,22 @@ public class DefaultManagedRepositoriesS
 
 
     public Boolean deleteManagedRepository( String repoId, boolean deleteContent )
-        throws Exception
+        throws ArchivaRestServiceException
     {
 
-        return managedRepositoryAdmin.deleteManagedRepository( repoId, getAuditInformation(),
deleteContent );
+        try
+        {
+            return managedRepositoryAdmin.deleteManagedRepository( repoId, getAuditInformation(),
deleteContent );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            log.error( e.getMessage(), e );
+            throw new ArchivaRestServiceException( e.getMessage() );
+        }
     }
 
     public Boolean addManagedRepository( ManagedRepository managedRepository )
-        throws Exception
+        throws ArchivaRestServiceException
     {
         org.apache.archiva.admin.model.managed.ManagedRepository repo =
             new org.apache.archiva.admin.model.managed.ManagedRepository();
@@ -106,13 +119,20 @@ public class DefaultManagedRepositoriesS
         repo.setName( managedRepository.getName() );
         repo.setReleases( managedRepository.isReleases() );
         repo.setSnapshots( managedRepository.isSnapshots() );
-        return managedRepositoryAdmin.addManagedRepository( repo, managedRepository.isStageRepoNeeded(),
-                                                            getAuditInformation() );
+        try
+        {
+            return managedRepositoryAdmin.addManagedRepository( repo, managedRepository.isStageRepoNeeded(),
+                                                                getAuditInformation() );
+        }
+        catch ( RepositoryAdminException e )
+        {
+            throw new ArchivaRestServiceException( e.getMessage() );
+        }
     }
 
 
     public Boolean updateManagedRepository( ManagedRepository managedRepository )
-        throws Exception
+        throws ArchivaRestServiceException
     {
         org.apache.archiva.admin.model.managed.ManagedRepository repo =
             new org.apache.archiva.admin.model.managed.ManagedRepository();
@@ -124,9 +144,16 @@ public class DefaultManagedRepositoriesS
         repo.setName( managedRepository.getName() );
         repo.setReleases( managedRepository.isReleases() );
         repo.setSnapshots( managedRepository.isSnapshots() );
-        return managedRepositoryAdmin.updateManagedRepository( repo, managedRepository.isStageRepoNeeded(),
-                                                               getAuditInformation(),
-                                                               managedRepository.isResetStats()
);
+        try
+        {
+            return managedRepositoryAdmin.updateManagedRepository( repo, managedRepository.isStageRepoNeeded(),
+                                                                   getAuditInformation(),
+                                                                   managedRepository.isResetStats()
);
+        }
+        catch ( RepositoryAdminException e )
+        {
+            throw new ArchivaRestServiceException( e.getMessage() );
+        }
     }
 
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRepositoriesService.java
Tue Sep 13 17:31:27 2011
@@ -126,6 +126,7 @@ public class DefaultRepositoriesService
                                                         mavenIndexerUtils.getAllIndexCreators()
) );
             ArtifactIndexingTask task =
                 new ArtifactIndexingTask( repository, null, ArtifactIndexingTask.Action.FINISH,
context );
+
             task.setExecuteOnEntireRepo( true );
             task.setOnlyUpdate( false );
 
@@ -134,6 +135,7 @@ public class DefaultRepositoriesService
         }
         catch ( Exception e )
         {
+            log.error( e.getMessage(), e );
             throw new ArchivaRestServiceException( e.getMessage() );
         }
     }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultSearchService.java
Tue Sep 13 17:31:27 2011
@@ -21,6 +21,7 @@ package org.apache.archiva.rest.services
 import net.sf.beanlib.provider.replicator.BeanReplicator;
 import org.apache.archiva.indexer.search.RepositorySearch;
 import org.apache.archiva.indexer.search.RepositorySearchException;
+import org.apache.archiva.indexer.search.SearchFields;
 import org.apache.archiva.indexer.search.SearchResultHit;
 import org.apache.archiva.indexer.search.SearchResultLimits;
 import org.apache.archiva.indexer.search.SearchResults;
@@ -85,19 +86,39 @@ public class DefaultSearchService
         }
     }
 
-    public List<Artifact> getArtifactByChecksum( String checksum )
+    public List<Artifact> getArtifactVersions( String groupId, String artifactId )
         throws ArchivaRestServiceException
     {
-        return null;  //To change body of implemented methods use File | Settings | File
Templates.
+        if ( StringUtils.isBlank( groupId ) || StringUtils.isBlank( artifactId ) )
+        {
+            return Collections.emptyList();
+        }
+        SearchFields searchField = new SearchFields();
+        searchField.setGroupId( groupId );
+        searchField.setArtifactId( artifactId );
+        SearchResultLimits limits = new SearchResultLimits( 0 );
+
+        try
+        {
+            SearchResults searchResults = repositorySearch.search( getPrincipal(), searchField,
limits );
+            return getArtifacts( searchResults );
+        }
+        catch ( RepositorySearchException e )
+        {
+            log.error( e.getMessage(), e );
+            throw new ArchivaRestServiceException( e.getMessage() );
+        }
+
+
     }
 
-    public List<Artifact> getArtifactVersions( String groupId, String artifactId )
+    public List<Dependency> getDependencies( String groupId, String artifactId, String
version )
         throws ArchivaRestServiceException
     {
         return null;  //To change body of implemented methods use File | Settings | File
Templates.
     }
 
-    public List<Dependency> getDependencies( String groupId, String artifactId, String
version )
+    public List<Artifact> getArtifactByChecksum( String checksum )
         throws ArchivaRestServiceException
     {
         return null;  //To change body of implemented methods use File | Settings | File
Templates.
@@ -144,18 +165,45 @@ public class DefaultSearchService
             return Collections.emptyList();
         }
         List<Artifact> artifacts = new ArrayList<Artifact>( searchResults.getReturnedHitsCount()
);
-        for ( SearchResultHit searchResultHit : searchResults.getHits() )
+        for ( SearchResultHit hit : searchResults.getHits() )
         {
-            Artifact artifact = new BeanReplicator().replicateBean( searchResultHit, Artifact.class
);
-            artifacts.add( artifact );
             // duplicate Artifact one per available version
-            if ( searchResultHit.getVersions().size() > 1 )
+            if ( hit.getVersions().size() > 0 )
             {
-                for ( String version : searchResultHit.getVersions() )
+                for ( String version : hit.getVersions() )
                 {
-                    Artifact versionned = new BeanReplicator().replicateBean( searchResultHit,
Artifact.class );
-                    versionned.setVersion( version );
-                    artifacts.add( versionned );
+                    /*
+                    Artifact versionned = new Artifact(  );
+                    versionned.setArtifactId( hit.getArtifactId());
+                    versionned.setGroupId( hit.getGroupId() );
+                    versionned.setRepositoryId(hit.getRepositoryId() );
+
+
+                    versionned.setBundleExportPackage( hit.getBundleExportPackage() );
+                    versionned.setBundleExportService( hit.getBundleExportService());
+                    versionned.setBundleSymbolicName(hit.getBundleSymbolicName() );
+                    versionned.setBundleVersion( artifactInfo.bundleVersion );
+                    versionned.setBundleDescription( artifactInfo.bundleDescription );
+                    versionned.setBundleDocUrl( artifactInfo.bundleDocUrl );
+
+                    versionned.setBundleRequireBundle( artifactInfo.bundleRequireBundle );
+                    versionned.setBundleImportPackage( artifactInfo.bundleImportPackage );
+                    versionned.setBundleLicense( artifactInfo.bundleLicense );
+                    versionned.setBundleName( artifactInfo.bundleName );
+                    versionned.setContext( artifactInfo.context );
+                    versionned.setGoals( artifactInfo.goals );
+                    versionned.setPrefix( artifactInfo.prefix );
+                    // sure ??
+                    versionned.setUrl( artifactInfo.remoteUrl );
+                    */
+                    // FIXME archiva url ??
+
+                    Artifact versionned = new BeanReplicator().replicateBean( hit, Artifact.class
);
+                    if ( StringUtils.isNotBlank( version ) )
+                    {
+                        versionned.setVersion( version );
+                        artifacts.add( versionned );
+                    }
                 }
             }
         }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/SearchServiceTest.java
Tue Sep 13 17:31:27 2011
@@ -34,6 +34,8 @@ import java.util.List;
 public class SearchServiceTest
     extends AbstractArchivaRestTest
 {
+
+
     @Test
     public void quickSearchOnArtifactId()
         throws Exception
@@ -46,29 +48,50 @@ public class SearchServiceTest
             assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
         }
 
-        createAndIndexRepo( testRepoId );
+        File targetRepo = createAndIndexRepo( testRepoId );
 
         SearchService searchService = getSearchService( authorizationHeader );
 
         List<Artifact> artifacts = searchService.quickSearch( "commons-logging" );
 
         assertNotNull( artifacts );
-        assertTrue( " empty results for commons-logging search", artifacts.size() > 0
);
-        log.info( "artifacts for commons-logginf search {}", artifacts );
+        assertTrue( " empty results for commons-logging search", artifacts.size() == 6 );
+        log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts
);
 
-        deleteTestRepo( testRepoId );
+        deleteTestRepo( testRepoId, targetRepo );
     }
 
-    private void createAndIndexRepo( String testRepoId )
+    @Test
+    public void searchArtifactVersions()
         throws Exception
     {
-        File targetRepo = new File( System.getProperty( "targetDir", "./target" ), "test-repo"
);
 
-        if ( targetRepo.exists() )
+        String testRepoId = "test-repo";
+        // force guest user creation if not exists
+        if ( getUserService( authorizationHeader ).getGuestUser() == null )
         {
-            FileUtils.deleteDirectory( targetRepo );
+            assertNotNull( getUserService( authorizationHeader ).createGuestUser() );
         }
 
+        File targetRepo = createAndIndexRepo( testRepoId );
+
+        SearchService searchService = getSearchService( authorizationHeader );
+
+        List<Artifact> artifacts = searchService.getArtifactVersions( "commons-logging",
"commons-logging" );
+
+        assertNotNull( artifacts );
+        assertTrue( " empty results for commons-logging search", artifacts.size() == 6 );
+        log.info( "artifacts for commons-logging size {} search {}", artifacts.size(), artifacts
);
+
+        deleteTestRepo( testRepoId, targetRepo );
+    }
+
+    private File createAndIndexRepo( String testRepoId )
+        throws Exception
+    {
+        File targetRepo = new File( System.getProperty( "targetDir", "./target" ), "test-repo"
);
+        cleanupFiles( targetRepo );
+
         File sourceRepo = new File( "src/test/repo-with-osgi" );
 
         FileUtils.copyDirectory( sourceRepo, targetRepo );
@@ -76,24 +99,54 @@ public class SearchServiceTest
         ManagedRepository managedRepository = new ManagedRepository();
         managedRepository.setId( testRepoId );
         managedRepository.setName( "test repo" );
-        managedRepository.setCronExpression( "* * * * * ?" );
-        managedRepository.setScanned( false );
 
         managedRepository.setLocation( targetRepo.getPath() );
 
         ManagedRepositoriesService service = getManagedRepositoriesService( authorizationHeader
);
         service.addManagedRepository( managedRepository );
 
+
         getRepositoriesService( authorizationHeader ).scanRepositoryNow( testRepoId, true
);
+
+        return targetRepo;
     }
 
-    private void deleteTestRepo( String id )
+    private void deleteTestRepo( String id, File targetRepo )
         throws Exception
     {
         if ( getManagedRepositoriesService( authorizationHeader ).getManagedRepository( id
) != null )
         {
             getManagedRepositoriesService( authorizationHeader ).deleteManagedRepository(
id, true );
         }
+        cleanupFiles( targetRepo );
+
+    }
+
+    private void cleanupFiles(File targetRepo)
+        throws Exception
+    {
+
+        File indexerDir = new File( targetRepo, ".indexer" );
+
+        if ( targetRepo.exists() )
+        {
+            FileUtils.deleteDirectory( targetRepo );
+        }
+
+        if ( indexerDir.exists() )
+        {
+            FileUtils.deleteDirectory( indexerDir );
+        }
+
+        File lockFile = new File( indexerDir, "write.lock" );
+        if ( lockFile.exists() )
+        {
+            FileUtils.forceDelete( lockFile );
+        }
+
+        assertFalse( targetRepo.exists() );
+        assertFalse( indexerDir.exists() );
+        assertFalse( lockFile.exists() );
     }
 
 }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j.xml
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j.xml?rev=1170261&r1=1170260&r2=1170261&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j.xml
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/resources/log4j.xml
Tue Sep 13 17:31:27 2011
@@ -38,14 +38,14 @@
 
 
   <logger name="org.codehaus.redback.rest.services" >
-    <level value="debug"/>
+    <level value="ERROR"/>
   </logger>
   <logger name="JPOX">
     <level value="ERROR"/>
   </logger>
 
   <logger name="org.springframework">
-    <level value="info"/>
+    <level value="ERROR"/>
   </logger>
 
   <root>



Mime
View raw message