--- /dev/null
+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() );
+ }
+}
*/
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;
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.
@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;
@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
}
}
- 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" ) )
{
return managedRepositoriesList;
}
- public List<RemoteRepositoryConfiguration> getRemoteRepositories()
+ public List<RemoteRepository> getRemoteRepositories()
{
return remoteRepositories;
}
{
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;
+ }
}