]> source.dussan.org Git - archiva.git/commitdiff
simplication remove non needed field
authorOlivier Lamy <olamy@apache.org>
Wed, 16 May 2012 22:19:07 +0000 (22:19 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 16 May 2012 22:19:07 +0000 (22:19 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1339399 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/ArtifactContentEntry.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultBrowseService.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/utils/ArtifactContentEntryComparator.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/ArtifactContentEntriesTests.java
archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/test/java/org/apache/archiva/rest/services/BrowseServiceTest.java
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/search.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/search.html

index 82bf58bf06c108e716a28b618cec5b38611f3d39..b74a143b94c2045fd41aa45bcc3e1147ebbd1de3 100644 (file)
@@ -29,40 +29,32 @@ import java.io.Serializable;
 public class ArtifactContentEntry
     implements Serializable
 {
-    private String text;
+    private String path;
 
     private boolean file;
 
     private int depth;
 
-    private boolean hasChildren;
-
     public ArtifactContentEntry()
     {
         // no op
     }
 
-    public ArtifactContentEntry( String text, boolean file, int depth, boolean hasChildren )
+    public ArtifactContentEntry( String path, boolean file, int depth )
     {
-        this.text = text;
+        this.path = path;
         this.file = file;
         this.depth = depth;
-        this.hasChildren = hasChildren;
-    }
-
-    public String getText()
-    {
-        return text;
     }
 
-    public String getId()
+    public String getPath()
     {
-        return text;
+        return path;
     }
 
-    public void setText( String text )
+    public void setPath( String path )
     {
-        this.text = text;
+        this.path = path;
     }
 
     public boolean isFile()
@@ -85,18 +77,6 @@ public class ArtifactContentEntry
         this.depth = depth;
     }
 
-    public boolean isHasChildren()
-    {
-        return hasChildren;
-    }
-
-    public void setHasChildren( boolean hasChildren )
-    {
-        this.hasChildren = hasChildren;
-    }
-
-
-
     @Override
     public boolean equals( Object o )
     {
@@ -111,10 +91,6 @@ public class ArtifactContentEntry
 
         ArtifactContentEntry that = (ArtifactContentEntry) o;
 
-        if ( hasChildren != that.hasChildren )
-        {
-            return false;
-        }
         if ( depth != that.depth )
         {
             return false;
@@ -123,7 +99,7 @@ public class ArtifactContentEntry
         {
             return false;
         }
-        if ( text != null ? !text.equals( that.text ) : that.text != null )
+        if ( path != null ? !path.equals( that.path ) : that.path != null )
         {
             return false;
         }
@@ -134,10 +110,9 @@ public class ArtifactContentEntry
     @Override
     public int hashCode()
     {
-        int result = text != null ? text.hashCode() : 0;
+        int result = path != null ? path.hashCode() : 0;
         result = 31 * result + ( file ? 1 : 0 );
         result = 31 * result + depth;
-        result = 31 * result + ( hasChildren ? 1 : 0 );
         return result;
     }
 
@@ -146,10 +121,9 @@ public class ArtifactContentEntry
     {
         final StringBuilder sb = new StringBuilder();
         sb.append( "ArtifactContentEntry" );
-        sb.append( "{text='" ).append( text ).append( '\'' );
+        sb.append( "{text='" ).append( path ).append( '\'' );
         sb.append( ", file=" ).append( file );
         sb.append( ", depth=" ).append( depth );
-        sb.append( ", children=" ).append( hasChildren );
         sb.append( '}' );
         return sb.toString();
     }
index 6e692202b43678cae952d4f3831a9b4016be5fe7..d94f2923108d248dbf266af7e4e085bbf1ac01e5 100644 (file)
@@ -682,7 +682,7 @@ public class DefaultBrowseService
 
                     artifactContentEntryMap.put( entryRootPath,
                                                  new ArtifactContentEntry( entryRootPath, !currentEntry.isDirectory(),
-                                                                           depth, true ) );
+                                                                           depth ) );
                 }
                 else
                 {
@@ -691,7 +691,7 @@ public class DefaultBrowseService
                     {
                         artifactContentEntryMap.put( cleanedEntryName, new ArtifactContentEntry( cleanedEntryName,
                                                                                                  !currentEntry.isDirectory(),
-                                                                                                 depth, true ) );
+                                                                                                 depth ) );
                     }
                 }
             }
index 98a5498785f6897555510deb70314f6b256b3aac..088520078335caac4e8c013c1ac2d8a6fcb675fc 100644 (file)
@@ -33,6 +33,6 @@ public class ArtifactContentEntryComparator
     public int compare( ArtifactContentEntry artifactContentEntry, ArtifactContentEntry artifactContentEntry1 )
     {
         // include depth too in comparaison ?
-        return artifactContentEntry.getText().compareTo( artifactContentEntry1.getText() );
+        return artifactContentEntry.getPath().compareTo( artifactContentEntry1.getPath() );
     }
 }
index cf805f40c63e508b8017edfd9d12153070de927c..18c4942d993446187012ed4d1845901004e9be31 100644 (file)
@@ -63,7 +63,7 @@ public class ArtifactContentEntriesTests
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
-            new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+            new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
 
     }
 
@@ -80,7 +80,7 @@ public class ArtifactContentEntriesTests
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
-            new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+            new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
 
     }
 
@@ -97,7 +97,7 @@ public class ArtifactContentEntriesTests
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
-            new ArtifactContentEntry( "org", false, 0, true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+            new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
 
     }
 
@@ -114,7 +114,7 @@ public class ArtifactContentEntriesTests
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
-            new ArtifactContentEntry( "org/apache", false, 1, true ) );
+            new ArtifactContentEntry( "org/apache", false, 1 ) );
 
     }
 
@@ -132,7 +132,7 @@ public class ArtifactContentEntriesTests
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 16 ).contains(
-            new ArtifactContentEntry( "org/apache/commons/logging/impl/AvalonLogger.class", true, 5, true ) );
+            new ArtifactContentEntry( "org/apache/commons/logging/impl/AvalonLogger.class", true, 5 ) );
 
     }
 
@@ -150,8 +150,8 @@ public class ArtifactContentEntriesTests
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
-            new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, true ),
-            new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, true ) );
+            new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4 ),
+            new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4 ) );
 
     }
 
index 384e27d06abd87028d70665de0622ddf32a2ffe6..21ecc85402229ad31b16626aa58e62f9eb03c001 100644 (file)
@@ -246,7 +246,7 @@ public class BrowseServiceTest
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 2 ).contains(
-            new ArtifactContentEntry( "org", false, 0,true ), new ArtifactContentEntry( "META-INF", false, 0, true ) );
+            new ArtifactContentEntry( "org", false, 0 ), new ArtifactContentEntry( "META-INF", false, 0 ) );
         deleteTestRepo( testRepoId );
     }
 
@@ -272,7 +272,7 @@ public class BrowseServiceTest
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 1 ).contains(
-            new ArtifactContentEntry( "org/apache", false, 1, true ) );
+            new ArtifactContentEntry( "org/apache", false, 1 ) );
         deleteTestRepo( testRepoId );
     }
 
@@ -298,8 +298,8 @@ public class BrowseServiceTest
         log.info( "artifactContentEntries: {}", artifactContentEntries );
 
         assertThat( artifactContentEntries ).isNotNull().isNotEmpty().hasSize( 10 ).contains(
-            new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4, true ),
-            new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4, true ) );
+            new ArtifactContentEntry( "org/apache/commons/logging/impl", false, 4 ),
+            new ArtifactContentEntry( "org/apache/commons/logging/LogSource.class", true, 4 ) );
         deleteTestRepo( testRepoId );
     }
 
index 5961a36fec7c9a1a0ef3b9ed33d172d6461d97f4..8b8d609e23134723153d0f9655becb9eb4178686 100644 (file)
@@ -282,28 +282,9 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
                     script: entriesUrl,
                     root: ""
                        },function(file) {
-                         alert(file);
+                         //alert(file);
                        });
-                  return;
-
-                  var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
-                  entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
-                  entriesUrl+="?repositoryId="+encodeURIComponent(self.repositoryId);
-                  $.ajax(entriesUrl,{
-                    type: "GET",
-                    dataType: 'json',
-                    success: function(data) {
-                      //$("#artifact-details-file-content").html($("#artifact_content_tmpl").tmpl());//{artifactContentEntries:mapArtifactContentEntries(data)}));
-                      //artifact_content_tmpl
-                      var artifactContentEntryViewModel=
-                          new ArtifactContentEntryViewModel(self.groupId,self.artifactId,self.version,[]);
-                      artifactContentEntryViewModel.show();
-                      //ko.applyBindings(artifactContentEntryViewModel,mainContent.find("#artifact_file_content_div").get(0));
-                    }
-                  });
                 }
-
-
               });
             }
           });
@@ -402,11 +383,10 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
 
   }
 
-  ArtifactContentEntry=function(text,file,depth,id){
-    this.text=text;
+  ArtifactContentEntry=function(path,file,depth){
+    this.path=path;
     this.file=file;
     this.depth=depth;
-    this.id=id;
   }
 
   mapArtifactContentEntries=function(data){
@@ -415,54 +395,10 @@ define("search",["jquery","i18n","jquery.tmpl","choosen","order!knockout","knock
     }
     if ( $.isArray(data)){
       return $.map(data,function(e){
-        return new ArtifactContentEntry(e.text,e.file,e.depth,e.id);
+        return new ArtifactContentEntry(e.path,e.file,e.depth);
       })
     }
-    return new ArtifactContentEntry(data.text,data.file,data.depth,e.id);
-  }
-
-  ArtifactContentEntryViewModel=function(groupId,artifactId,version,artifactContentEntries){
-    var self=this;
-    this.groupId=groupId;
-    this.artifactId=artifactId;
-    this.version=version;
-    this.artifactContentEntries=ko.observableArray(artifactContentEntries);
-    this.currentPath=ko.observable();
-
-    this.show=function(){
-      var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
-      entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
-      entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
-      //entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
-
-      $("#main-content #artifact_content_tree").fileTree({
-        script: entriesUrl
-               },function(file) {
-                 alert(file);
-               });
-    }
-
-    entries=function(){
-      return self.artifactContentEntries;
-    }
-
-    displayPath=function(artifactContentEntry){
-      $.log("ArtifactContentEntryViewModel#displayPath:"+artifactContentEntry.name);
-
-      var entriesUrl = "restServices/archivaServices/browseService/artifactContentEntries/"+encodeURIComponent(self.groupId);
-      entriesUrl+="/"+encodeURIComponent(self.artifactId)+"/"+encodeURIComponent(self.version);
-      entriesUrl+="?repositoryId="+encodeURIComponent(getSelectedBrowsingRepository());
-      entriesUrl+="&p="+encodeURIComponent(artifactContentEntry.name);
-      self.currentPath(artifactContentEntry.name);
-      $.ajax(entriesUrl,{
-        type: "GET",
-        dataType: 'json',
-        success: function(data) {
-          self.artifactContentEntries(mapArtifactContentEntries(data));
-        }
-      });
-
-    }
+    return new ArtifactContentEntry(data.path,data.file,data.depth);
   }
 
   MetadataEntry=function(key,value,editable){
index 5edbbb8b955238cb2bb3714e35008e70da3e6c80..76d1d9e2ec194c390a10884638b184faff4218e2 100644 (file)
     </tbody>
 </script>
 
-<script id="artifact_content_main_tmpl" type="text/html">
-  <div id="artifact_file_content_div" data-bind='template:{name:"artifact_content_tmpl"}'>
-  </div>
-</script>
-
-<script id="artifact_content_tmpl" type="text/html">
-    <div id="artifact_content_tree">
-    </div>
-</script>
-
 <script id="artifact_content_tree_partial" type="text/html">
   <ul class="jqueryFileTree" style="display: none;">
     {{each artifactContentEntries}}
     <li class="directory collapsed">
-      <a href="#" rel="${$value.text}/">${$value.text}</a>
+      <a href="#" rel="${$value.path}/">${$value.path}</a>
     </li>
     {{/each}}
   </ul>