archiva-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ol...@apache.org
Subject svn commit: r1343826 - in /archiva/trunk/archiva-modules/archiva-web: archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/ archiva-rest/archiva-...
Date Tue, 29 May 2012 16:34:22 GMT
Author: olamy
Date: Tue May 29 16:34:21 2012
New Revision: 1343826

URL: http://svn.apache.org/viewvc?rev=1343826&view=rev
Log:
simplify by reusing an existing class

Removed:
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactDownloadInfo.java
Modified:
    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/BrowseService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
    archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java
    archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

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=1343826&r1=1343825&r2=1343826&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 May 29 16:34:21 2012
@@ -134,6 +134,12 @@ public class Artifact
      */
     private String fileExtension;
 
+    /**
+     * human readable size : not available for all services
+     * @since 1.4-M3
+     */
+    private String size;
+
 
     public Artifact()
     {
@@ -358,6 +364,16 @@ public class Artifact
         this.fileExtension = fileExtension;
     }
 
+    public String getSize()
+    {
+        return size;
+    }
+
+    public void setSize( String size )
+    {
+        this.size = size;
+    }
+
     @Override
     public String toString()
     {

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.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/BrowseService.java?rev=1343826&r1=1343825&r2=1343826&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/services/BrowseService.java
Tue May 29 16:34:21 2012
@@ -24,7 +24,6 @@ import org.apache.archiva.redback.author
 import org.apache.archiva.rest.api.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactContent;
 import org.apache.archiva.rest.api.model.ArtifactContentEntry;
-import org.apache.archiva.rest.api.model.ArtifactDownloadInfo;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.Entry;
 import org.apache.archiva.rest.api.model.TreeEntry;
@@ -165,7 +164,7 @@ public interface BrowseService
     @GET
     @Produces( { MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML } )
     @RedbackAuthorization( noPermission = true, noRestriction = true )
-    List<ArtifactDownloadInfo> getArtifactDownloadInfos( @PathParam( "g" ) String groupId,
+    List<Artifact> getArtifactDownloadInfos( @PathParam( "g" ) String groupId,
                                                          @PathParam( "a" ) String artifactId,
                                                          @PathParam( "v" ) String version,
                                                          @QueryParam( "repositoryId" ) String
repositoryId )

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.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/DefaultBrowseService.java?rev=1343826&r1=1343825&r2=1343826&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
Tue May 29 16:34:21 2012
@@ -41,7 +41,6 @@ import org.apache.archiva.repository.Rep
 import org.apache.archiva.rest.api.model.Artifact;
 import org.apache.archiva.rest.api.model.ArtifactContent;
 import org.apache.archiva.rest.api.model.ArtifactContentEntry;
-import org.apache.archiva.rest.api.model.ArtifactDownloadInfo;
 import org.apache.archiva.rest.api.model.BrowseResult;
 import org.apache.archiva.rest.api.model.BrowseResultEntry;
 import org.apache.archiva.rest.api.model.Entry;
@@ -661,13 +660,13 @@ public class DefaultBrowseService
         return Collections.emptyList();
     }
 
-    public List<ArtifactDownloadInfo> getArtifactDownloadInfos( String groupId, String
artifactId, String version,
-                                                                String repositoryId )
+    public List<Artifact> getArtifactDownloadInfos( String groupId, String artifactId,
String version,
+                                                    String repositoryId )
         throws ArchivaRestServiceException
     {
         List<String> selectedRepos = getSelectedRepos( repositoryId );
 
-        List<ArtifactDownloadInfo> artifactDownloadInfos = new ArrayList<ArtifactDownloadInfo>();
+        List<Artifact> artifactDownloadInfos = new ArrayList<Artifact>();
 
         RepositorySession session = repositorySessionFactory.createSession();
 

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.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/utils/ArtifactDownloadInfoBuilder.java?rev=1343826&r1=1343825&r2=1343826&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactDownloadInfoBuilder.java
Tue May 29 16:34:21 2012
@@ -22,7 +22,11 @@ import org.apache.archiva.metadata.model
 import org.apache.archiva.metadata.repository.storage.maven2.MavenArtifactFacet;
 import org.apache.archiva.model.ArtifactReference;
 import org.apache.archiva.repository.ManagedRepositoryContent;
-import org.apache.archiva.rest.api.model.ArtifactDownloadInfo;
+import org.apache.archiva.rest.api.model.Artifact;
+
+import java.text.DecimalFormat;
+import java.text.DecimalFormatSymbols;
+import java.util.Locale;
 
 /**
  * @author Olivier Lamy
@@ -53,14 +57,14 @@ public class ArtifactDownloadInfoBuilder
         return this;
     }
 
-    public ArtifactDownloadInfo build()
+    public Artifact build()
     {
         ArtifactReference ref = new ArtifactReference();
         ref.setArtifactId( artifactMetadata.getProject() );
         ref.setGroupId( artifactMetadata.getNamespace() );
         ref.setVersion( artifactMetadata.getVersion() );
         String path = managedRepositoryContent.toPath( ref );
-        path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifactMetadata.getId();
+        //path = path.substring( 0, path.lastIndexOf( "/" ) + 1 ) + artifactMetadata.getId();
 
         String type = null, classifier = null;
 
@@ -71,8 +75,32 @@ public class ArtifactDownloadInfoBuilder
             classifier = facet.getClassifier();
         }
 
-        ArtifactDownloadInfo artifactDownloadInfo =
-            new ArtifactDownloadInfo( this.artifactMetadata, path, type, classifier );
+        Artifact artifactDownloadInfo = new Artifact( ref.getGroupId(), ref.getArtifactId(),
ref.getVersion() );
+        artifactDownloadInfo.setClassifier( classifier );
+        artifactDownloadInfo.setPackaging( type );
+        // TODO: find a reusable formatter for this
+        double s = this.artifactMetadata.getSize();
+        String symbol = "b";
+        if ( s > 1024 )
+        {
+            symbol = "K";
+            s /= 1024;
+
+            if ( s > 1024 )
+            {
+                symbol = "M";
+                s /= 1024;
+
+                if ( s > 1024 )
+                {
+                    symbol = "G";
+                    s /= 1024;
+                }
+            }
+        }
+
+        DecimalFormat df = new DecimalFormat( "#,###.##", new DecimalFormatSymbols( Locale.US
) );
+        artifactDownloadInfo.setSize( df.format( s ) + " " + symbol );
         return artifactDownloadInfo;
 
     }

Modified: archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
URL: http://svn.apache.org/viewvc/archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html?rev=1343826&r1=1343825&r2=1343826&view=diff
==============================================================================
--- archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
(original)
+++ archiva/trunk/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html
Tue May 29 16:34:21 2012
@@ -811,8 +811,8 @@
         <div class="span5">
            <ul id="artifact-content-list-files">
            {{each artifactDownloadInfos}}
-             <li id="${$value.classifier}:${$value.version}:${$value.type}">
-               <a href="#">${$value.type}:${$value.version}&nbsp;-&nbsp;${$value.size}</a>
+             <li id="${$value.classifier}:${$value.version}:${$value.packaging}">
+               <a href="#">${$value.packaging}:${$value.version}&nbsp;-&nbsp;${$value.size}</a>
              </li>
            {{/each}}
            </ul>



Mime
View raw message