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.archiva.configuration.ArchivaConfiguration;
26 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
27 import org.apache.commons.lang3.StringUtils;
29 import java.util.ArrayList;
30 import java.util.List;
31 import java.util.Locale;
35 * @author Olivier Lamy
37 public class MockManagedRepositoryAdmin
38 implements ManagedRepositoryAdmin
40 private ArchivaConfiguration archivaConfiguration;
43 public List<ManagedRepository> getManagedRepositories()
44 throws RepositoryAdminException
46 List<ManagedRepositoryConfiguration> managedRepoConfigs =
47 getArchivaConfiguration().getConfiguration().getManagedRepositories();
49 List<ManagedRepository> managedRepos = new ArrayList<>( managedRepoConfigs.size() );
51 for ( ManagedRepositoryConfiguration repoConfig : managedRepoConfigs )
53 // TODO add staging repo information back too
54 ManagedRepository repo =
55 new ManagedRepository( Locale.getDefault( ), repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
56 repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases(),
57 repoConfig.isBlockRedeployments(), repoConfig.getRefreshCronExpression(),
58 repoConfig.getIndexDir(), repoConfig.isScanned(), repoConfig.getRetentionPeriod(),
59 repoConfig.getRetentionCount(), repoConfig.isDeleteReleasedSnapshots(), true );
61 managedRepos.add( repo );
68 public Map<String, ManagedRepository> getManagedRepositoriesAsMap()
69 throws RepositoryAdminException
75 public ManagedRepository getManagedRepository( String repositoryId )
76 throws RepositoryAdminException
78 List<ManagedRepository> repos = getManagedRepositories();
79 for ( ManagedRepository repo : repos )
81 if ( StringUtils.equals( repo.getId(), repositoryId ) )
90 public Boolean deleteManagedRepository( String repositoryId, AuditInformation auditInformation,
91 boolean deleteContent )
92 throws RepositoryAdminException
98 public Boolean addManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
99 AuditInformation auditInformation )
100 throws RepositoryAdminException
106 public Boolean updateManagedRepository( ManagedRepository managedRepository, boolean needStageRepo,
107 AuditInformation auditInformation, boolean resetStats )
108 throws RepositoryAdminException
113 public ArchivaConfiguration getArchivaConfiguration()
115 return archivaConfiguration;
118 public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
120 this.archivaConfiguration = archivaConfiguration;