]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1579] rewrite repositories scanning admin page
authorOlivier Lamy <olamy@apache.org>
Wed, 7 Mar 2012 22:01:13 +0000 (22:01 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 7 Mar 2012 22:01:13 +0000 (22:01 +0000)
start some refactoring to ease implementation (reusable beans)

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1298148 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AdminRepositoryConsumer.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js
archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/templates/menu.html
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AddAdminRepoConsumerClosure.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java [deleted file]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumerComparator.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java

diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AdminRepositoryConsumer.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-api/src/main/java/org/apache/archiva/rest/api/model/AdminRepositoryConsumer.java
new file mode 100644 (file)
index 0000000..539980a
--- /dev/null
@@ -0,0 +1,79 @@
+package org.apache.archiva.rest.api.model;
+
+/*
+ * 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 javax.xml.bind.annotation.XmlRootElement;
+
+/**
+ * AdminRepositoryConsumer
+ *
+ * @version $Id$
+ */
+@XmlRootElement( name = "adminRepositoryConsumer" )
+public class AdminRepositoryConsumer
+{
+    private boolean enabled = false;
+
+    private String id;
+
+    private String description;
+
+    public AdminRepositoryConsumer()
+    {
+        // no op
+    }
+
+    public AdminRepositoryConsumer( boolean enabled, String id, String description )
+    {
+        this.enabled = enabled;
+        this.id = id;
+        this.description = description;
+    }
+
+    public String getDescription()
+    {
+        return description;
+    }
+
+    public String getId()
+    {
+        return id;
+    }
+
+    public boolean isEnabled()
+    {
+        return enabled;
+    }
+
+    public void setDescription( String description )
+    {
+        this.description = description;
+    }
+
+    public void setEnabled( boolean enabled )
+    {
+        this.enabled = enabled;
+    }
+
+    public void setId( String id )
+    {
+        this.id = id;
+    }
+}
index 0b72d7ac2e3b90af00717f5df1797f33d04037fd..1a6cfcc51ece021e79cd1713ca23a66144884ca0 100644 (file)
@@ -296,4 +296,43 @@ $(function() {
   }
 
 
+  //---------------------------
+  // repository scanning part
+  //---------------------------
+
+  FileType=function(id,patterns){
+    //private String id;
+    this.id=ko.observable(id);
+
+    //private List<String> patterns;
+    this.patterns=ko.observableArray(patterns);
+
+  }
+
+  mapFileType=function(data){
+    return new FileType(data.id,data.patterns);
+  }
+
+  mapFileTypes=function(data){
+    if (data!=null){
+      return $.isArray(data)? $.map(data,function(item){
+        return mapFileType(item)
+      }):[mapFileType(data)];
+    }
+    return [];
+  }
+
+  displayRepositoryScanning=function(){
+
+    $.ajax("restServices/archivaServices/archivaAdministrationService/getFileTypes", {
+        type: "GET",
+        dataType: 'json',
+        success: function(data){
+          var fileTypes=mapFileTypes(data);
+        }
+    });
+
+  }
+
+
 });
\ No newline at end of file
index 9d3125a1ab03f7cb23d49c85ff198933f3de314d..b87ac8b289b2b73cc83de4015ea378d052b9abe9 100644 (file)
@@ -45,6 +45,9 @@
       <li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
         <a href="#" id="menu-legacy-support-list-a" onclick="displayLegacyArtifactPathSupport()">${$.i18n.prop('menu.legacy-artifact-support')}</a>
       </li>
+      <li style="display: none" redback-permissions="{permissions: ['archiva-manage-configuration']}">
+        <a href="#" id="menu-repository-scanning-list-a" onclick="displayRepositoryScanning()">${$.i18n.prop('menu.repository-scanning')}</a>
+      </li>
     </ul>
 
     <ul class="nav nav-list" redback-permissions="{permissions: ['archiva-manage-users']}">
index 34f9c775883b618dcd4f761788967780fc602e61..34023bb2171ea0535a5d65975e1c6a38628aaed4 100644 (file)
@@ -19,6 +19,7 @@ package org.apache.archiva.web.action.admin.scanning;
  * under the License.
  */
 
+import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
 import org.apache.commons.collections.Closure;
 import org.apache.archiva.consumers.RepositoryContentConsumer;
 
diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/AdminRepositoryConsumer.java
deleted file mode 100644 (file)
index 5d71413..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-package org.apache.archiva.web.action.admin.scanning;
-
-/*
- * 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.
- */
-
-/**
- * AdminRepositoryConsumer 
- *
- * @version $Id$
- */
-public class AdminRepositoryConsumer
-{
-    private boolean enabled = false;
-    private String id;
-    private String description;
-    
-    public String getDescription()
-    {
-        return description;
-    }
-
-    public String getId()
-    {
-        return id;
-    }
-
-    public boolean isEnabled()
-    {
-        return enabled;
-    }
-
-    public void setDescription( String description )
-    {
-        this.description = description;
-    }
-
-    public void setEnabled( boolean enabled )
-    {
-        this.enabled = enabled;
-    }
-
-    public void setId( String id )
-    {
-        this.id = id;
-    }
-}
index 99391e3e17e6608bd5ff055a266ae79fdc2afc20..36117aeeff51bc728701535c92f490f1f421b567 100644 (file)
@@ -27,6 +27,7 @@ import org.apache.archiva.admin.model.beans.FileType;
 import org.apache.archiva.admin.repository.admin.FiletypeToMapClosure;
 import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
+import org.apache.archiva.rest.api.model.AdminRepositoryConsumer;
 import org.apache.archiva.security.common.ArchivaRoleConstants;
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.commons.lang.StringUtils;
@@ -67,7 +68,7 @@ public class RepositoryScanningAction
     private List<String> fileTypeIds;
 
     /**
-     * List of {@link AdminRepositoryConsumer} objects for consumers of known content.
+     * List of {@link org.apache.archiva.rest.api.model.AdminRepositoryConsumer} objects for consumers of known content.
      */
     private List<AdminRepositoryConsumer> knownContentConsumers;
 
@@ -102,6 +103,30 @@ public class RepositoryScanningAction
         log.info( "[ActionMessage] {}", aMessage );
     }
 
+    public void prepare()
+        throws Exception
+    {
+        FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
+
+        CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
+        fileTypeMap = filetypeToMapClosure.getMap();
+
+        AddAdminRepoConsumerClosure addAdminRepoConsumer =
+            new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
+        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
+        this.knownContentConsumers = addAdminRepoConsumer.getList();
+        Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
+
+        addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
+        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
+        this.invalidContentConsumers = addAdminRepoConsumer.getList();
+        Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
+
+        fileTypeIds = new ArrayList<String>();
+        fileTypeIds.addAll( fileTypeMap.keySet() );
+        Collections.sort( fileTypeIds );
+    }
+
     public String addFiletypePattern()
     {
         log.info( "Add New File Type Pattern [{}:{}]", getFileTypeId(), getPattern() );
@@ -187,32 +212,6 @@ public class RepositoryScanningAction
         return bundle;
     }
 
-    public void prepare()
-        throws Exception
-    {
-
-
-        FiletypeToMapClosure filetypeToMapClosure = new FiletypeToMapClosure();
-
-        CollectionUtils.forAllDo( archivaAdministration.getFileTypes(), filetypeToMapClosure );
-        fileTypeMap = filetypeToMapClosure.getMap();
-
-        AddAdminRepoConsumerClosure addAdminRepoConsumer =
-            new AddAdminRepoConsumerClosure( archivaAdministration.getKnownContentConsumers() );
-        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableKnownConsumers(), addAdminRepoConsumer );
-        this.knownContentConsumers = addAdminRepoConsumer.getList();
-        Collections.sort( knownContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
-
-        addAdminRepoConsumer = new AddAdminRepoConsumerClosure( archivaAdministration.getInvalidContentConsumers() );
-        CollectionUtils.forAllDo( repoconsumerUtil.getAvailableInvalidConsumers(), addAdminRepoConsumer );
-        this.invalidContentConsumers = addAdminRepoConsumer.getList();
-        Collections.sort( invalidContentConsumers, AdminRepositoryConsumerComparator.getInstance() );
-
-        fileTypeIds = new ArrayList<String>();
-        fileTypeIds.addAll( fileTypeMap.keySet() );
-        Collections.sort( fileTypeIds );
-    }
-
     public void setFileTypeId( String fileTypeId )
     {
         this.fileTypeId = fileTypeId;