1 package org.apache.archiva.mock;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.admin.model.AuditInformation;
22 import org.apache.archiva.admin.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.beans.ManagedRepository;
24 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
25 import org.apache.commons.lang.StringUtils;
26 import org.apache.archiva.configuration.ArchivaConfiguration;
27 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
29 import java.util.ArrayList;
30 import java.util.List;
34 * @author Olivier Lamy
36 public class MockManagedRepositoryAdmin
37 implements ManagedRepositoryAdmin
39 private ArchivaConfiguration archivaConfiguration;
41 public List<ManagedRepository> getManagedRepositories()
42 throws RepositoryAdminException
44 List<ManagedRepositoryConfiguration> managedRepoConfigs =
45 getArchivaConfiguration().getConfiguration().getManagedRepositories();
47 List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>( managedRepoConfigs.size() );
49 for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
51 // TODO add staging repo information back too
52 ManagedRepository repo =
53 new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
54 repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
55 repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
56 repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getDaysOlder(),
57 repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), true );
59 managedRepos.add( repo );
65 public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
66 throws RepositoryAdminException
71 public ManagedRepository getManagedRepository( String repositoryId )
72 throws RepositoryAdminException
74 List<ManagedRepository> repos = getManagedRepositories();
75 for ( ManagedRepository repo : repos )
77 if ( StringUtils.equals( repo.getId(), repositoryId ) )
85 public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
86 boolean deleteContent )
87 throws RepositoryAdminException
92 public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
93 AuditInformation auditInformation )
94 throws RepositoryAdminException
99 public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
100 AuditInformation auditInformation, boolean resetStats )
101 throws RepositoryAdminException
106 public ArchivaConfiguration getArchivaConfiguration()
108 return archivaConfiguration;
111 public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
113 this.archivaConfiguration = archivaConfiguration;