]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1504] new repository admin : more use of new api in webapp : in the repositories...
authorOlivier Lamy <olamy@apache.org>
Tue, 6 Sep 2011 21:05:02 +0000 (21:05 +0000)
committerOlivier Lamy <olamy@apache.org>
Tue, 6 Sep 2011 21:05:02 +0000 (21:05 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1165842 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/admin/repositories/RepositoriesAction.java
archiva-modules/archiva-web/archiva-webapp/src/main/webapp/WEB-INF/jsp/admin/repositories.jsp

diff --git a/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java b/archiva-modules/archiva-base/archiva-repository-admin/src/main/java/org/apache/archiva/admin/repository/utils/RepositoryComparator.java
new file mode 100644 (file)
index 0000000..f9b9369
--- /dev/null
@@ -0,0 +1,51 @@
+package org.apache.archiva.admin.repository.utils;
+/*
+ * 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 org.apache.archiva.admin.repository.AbstractRepository;
+
+import java.util.Comparator;
+
+/**
+ * @author Olivier Lamy
+ * @since 1.4
+ */
+public class RepositoryComparator
+    implements Comparator<AbstractRepository>
+{
+    public int compare( AbstractRepository o1, AbstractRepository o2 )
+    {
+        if ( o1 == null && o2 == null )
+        {
+            return 0;
+        }
+
+        if ( o1 == null )
+        {
+            return -1;
+        }
+
+        if ( o2 == null )
+        {
+            return 1;
+        }
+
+        return o1.getId().compareToIgnoreCase( o2.getId() );
+    }
+}
index b2cc646189796be461d99d2fd9dc1bf76fe4cbd8..1975b097f9ef59c8084ead4b6beb424719ba6cbe 100644 (file)
@@ -20,19 +20,22 @@ package org.apache.maven.archiva.web.action.admin.repositories;
  */
 
 import com.opensymphony.xwork2.Preparable;
+import org.apache.archiva.admin.repository.RepositoryAdminException;
+import org.apache.archiva.admin.repository.managed.ManagedRepository;
+import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
+import org.apache.archiva.admin.repository.remote.RemoteRepository;
+import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
+import org.apache.archiva.admin.repository.utils.RepositoryComparator;
 import org.apache.archiva.metadata.repository.MetadataRepository;
 import org.apache.archiva.metadata.repository.MetadataRepositoryException;
 import org.apache.archiva.metadata.repository.RepositorySession;
 import org.apache.archiva.metadata.repository.stats.RepositoryStatistics;
 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
 import org.apache.archiva.security.common.ArchivaRoleConstants;
+import org.apache.archiva.web.util.ContextUtils;
 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
 import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.functors.RepositoryConfigurationComparator;
 import org.apache.maven.archiva.web.action.AbstractActionSupport;
-import org.apache.archiva.web.util.ContextUtils;
 import org.apache.struts2.interceptor.ServletRequestAware;
 import org.codehaus.plexus.redback.rbac.Resource;
 import org.codehaus.redback.integration.interceptor.SecureAction;
@@ -41,13 +44,13 @@ import org.codehaus.redback.integration.interceptor.SecureActionException;
 import org.springframework.context.annotation.Scope;
 import org.springframework.stereotype.Controller;
 
+import javax.inject.Inject;
+import javax.servlet.http.HttpServletRequest;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import javax.inject.Inject;
-import javax.servlet.http.HttpServletRequest;
 
 /**
  * Shows the Repositories Tab for the administrator.
@@ -64,9 +67,15 @@ public class RepositoriesAction
     @Inject
     private ArchivaConfiguration archivaConfiguration;
 
-    private List<ManagedRepositoryConfiguration> managedRepositories;
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    @Inject
+    private RemoteRepositoryAdmin remoteRepositoryAdmin;
 
-    private List<RemoteRepositoryConfiguration> remoteRepositories;
+    private List<ManagedRepository> managedRepositories;
+
+    private List<RemoteRepository> remoteRepositories;
 
     private Map<String, RepositoryStatistics> repositoryStatistics;
 
@@ -100,22 +109,23 @@ public class RepositoriesAction
 
     @SuppressWarnings( "unchecked" )
     public void prepare()
+        throws RepositoryAdminException
     {
         Configuration config = archivaConfiguration.getConfiguration();
 
-        remoteRepositories = new ArrayList<RemoteRepositoryConfiguration>( config.getRemoteRepositories() );
-        managedRepositories = new ArrayList<ManagedRepositoryConfiguration>( config.getManagedRepositories() );
+        remoteRepositories = new ArrayList<RemoteRepository>( getRemoteRepositoryAdmin().getRemoteRepositories() );
+        managedRepositories = new ArrayList<ManagedRepository>( getManagedRepositoryAdmin().getManagedRepositories() );
         repositoryToGroupMap = config.getRepositoryToGroupMap();
 
-        Collections.sort( managedRepositories, new RepositoryConfigurationComparator() );
-        Collections.sort( remoteRepositories, new RepositoryConfigurationComparator() );
+        Collections.sort( managedRepositories, new RepositoryComparator() );
+        Collections.sort( remoteRepositories, new RepositoryComparator() );
 
         repositoryStatistics = new HashMap<String, RepositoryStatistics>();
         RepositorySession repositorySession = repositorySessionFactory.createSession();
         try
         {
             MetadataRepository metadataRepository = repositorySession.getRepository();
-            for ( ManagedRepositoryConfiguration repo : managedRepositories )
+            for ( ManagedRepository repo : managedRepositories )
             {
                 RepositoryStatistics stats = null;
                 try
@@ -140,10 +150,10 @@ public class RepositoriesAction
         }
     }
 
-    public List<ManagedRepositoryConfiguration> getManagedRepositories()
+    public List<ManagedRepository> getManagedRepositories()
     {
-        List<ManagedRepositoryConfiguration> managedRepositoriesList = new ArrayList<ManagedRepositoryConfiguration>();
-        for ( ManagedRepositoryConfiguration repoConfig : managedRepositories )
+        List<ManagedRepository> managedRepositoriesList = new ArrayList<ManagedRepository>();
+        for ( ManagedRepository repoConfig : managedRepositories )
         {
             if ( !repoConfig.getId().endsWith( "-stage" ) )
             {
@@ -153,7 +163,7 @@ public class RepositoriesAction
         return managedRepositoriesList;
     }
 
-    public List<RemoteRepositoryConfiguration> getRemoteRepositories()
+    public List<RemoteRepository> getRemoteRepositories()
     {
         return remoteRepositories;
     }
@@ -172,4 +182,24 @@ public class RepositoriesAction
     {
         return repositoryToGroupMap;
     }
+
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+
+    public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
+    {
+        return remoteRepositoryAdmin;
+    }
+
+    public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
+    {
+        this.remoteRepositoryAdmin = remoteRepositoryAdmin;
+    }
 }
index 46fa53d01dde31527a576f36f6eddd32c061d6c8..deafa6fbce7ba46e52d2fe891fcab0ae47ffae52 100644 (file)
   <th>Directory</th>
   <td><c:out value="${repository.location}" /></td>
 </tr>
-<c:if test="${!empty (repository.indexDir)}">
+<c:if test="${!empty (repository.indexDirectory)}">
        <tr>
          <th>Index Directory</th>
-         <td><c:out value="${repository.indexDir}" /></td>
+         <td><c:out value="${repository.indexDirectory}" /></td>
        </tr>
 </c:if>
 <tr>
 <c:if test="${repository.scanned}">
   <tr>
     <th>Scanning Cron</th>
-    <td><c:out value="${repository.refreshCronExpression}" /></td>
+    <td><c:out value="${repository.cronExpression}" /></td>
   </tr>
   <tr>
     <th>