use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryConfigurationComparatorTest method createRepository.
private ManagedRepositoryConfiguration createRepository(String id) {
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
repo.setId(id);
return repo;
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class AbstractMavenRepositorySearch method createRepositoryConfig.
protected ManagedRepositoryConfiguration createRepositoryConfig(String repository) {
ManagedRepositoryConfiguration repositoryConfig = new ManagedRepositoryConfiguration();
repositoryConfig.setId(repository);
repositoryConfig.setLocation(org.apache.archiva.common.utils.FileUtils.getBasedir() + "/target/repos/" + repository);
Path f = Paths.get(repositoryConfig.getLocation());
if (!Files.exists(f)) {
try {
Files.createDirectories(f);
} catch (IOException e) {
log.error("Could not create directories for {}", f);
}
}
repositoryConfig.setLayout("default");
repositoryConfig.setName(repository);
repositoryConfig.setScanned(true);
repositoryConfig.setSnapshots(false);
repositoryConfig.setReleases(true);
repositoryConfig.setIndexDir(".indexer");
return repositoryConfig;
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryServletRepositoryGroupTest method setUp.
@Override
@Before
public void setUp() throws Exception {
super.setUp();
String appserverBase = System.getProperty("appserver.base");
Configuration configuration = archivaConfiguration.getConfiguration();
repoRootFirst = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_FIRST);
repoRootLast = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_LAST);
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
List<String> managedRepoIds = new ArrayList<>();
managedRepoIds.add(MANAGED_REPO_FIRST);
managedRepoIds.add(MANAGED_REPO_LAST);
configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_VALID_REPOS, managedRepoIds));
// Create the repository group with an invalid managed repository
repoRootInvalid = Paths.get(appserverBase, "data/repositories/" + MANAGED_REPO_INVALID);
ManagedRepositoryConfiguration managedRepositoryConfiguration = createManagedRepository(MANAGED_REPO_INVALID, "Invalid Test Repo", repoRootInvalid, true);
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_FIRST, "First Test Repo", repoRootFirst, true));
configuration.addManagedRepository(managedRepositoryConfiguration);
configuration.addManagedRepository(createManagedRepository(MANAGED_REPO_LAST, "Last Test Repo", repoRootLast, true));
List<String> invalidManagedRepoIds = new ArrayList<>();
invalidManagedRepoIds.add(MANAGED_REPO_FIRST);
invalidManagedRepoIds.add(MANAGED_REPO_INVALID);
invalidManagedRepoIds.add(MANAGED_REPO_LAST);
configuration.addRepositoryGroup(createRepositoryGroup(REPO_GROUP_WITH_INVALID_REPOS, invalidManagedRepoIds));
configuration.removeManagedRepository(managedRepositoryConfiguration);
org.apache.archiva.common.utils.FileUtils.deleteDirectory(repoRootInvalid);
repositoryRegistry.reload();
saveConfiguration(archivaConfiguration);
startRepository();
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryServletSecurityTest method setUp.
@Before
@Override
public void setUp() throws Exception {
super.setUp();
String appserverBase = System.getProperty("appserver.base", Paths.get("target/appserver-base").toAbsolutePath().toString());
Path testConf = Paths.get("src/test/resources/repository-archiva.xml");
Path testConfDest = Paths.get(appserverBase, "conf/archiva.xml");
FileUtils.copyFile(testConf.toFile(), testConfDest.toFile());
Configuration config = archivaConfiguration.getConfiguration();
// clear managed repository
List<ManagedRepositoryConfiguration> f1 = new ArrayList<>(config.getManagedRepositories());
for (ManagedRepositoryConfiguration f : f1) {
config.removeManagedRepository(f);
}
assertEquals(0, config.getManagedRepositories().size());
// add internal repo
config.addManagedRepository(createManagedRepository(REPOID_INTERNAL, "Internal Test Repo", repoRootInternal.getRoot()));
saveConfiguration(archivaConfiguration);
CacheManager.getInstance().clearAll();
servletAuthControl = EasyMock.createControl();
servletAuth = servletAuthControl.createMock(ServletAuthenticator.class);
httpAuthControl = EasyMock.createControl();
httpAuth = httpAuthControl.createMock(HttpAuthenticator.class);
davSessionProvider = new ArchivaDavSessionProvider(servletAuth, httpAuth);
final MockServletContext mockServletContext = new MockServletContext();
WebApplicationContext webApplicationContext = new AbstractRepositoryServletTestCase.TestWebapplicationContext(applicationContext, mockServletContext);
mockServletContext.setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, webApplicationContext);
MockServletConfig mockServletConfig = new MockServletConfig() {
@Override
public ServletContext getServletContext() {
return mockServletContext;
}
};
servlet = new RepositoryServlet();
servlet.init(mockServletConfig);
}
use of org.apache.archiva.configuration.ManagedRepositoryConfiguration in project archiva by apache.
the class RepositoryServletSecurityTest method createManagedRepository.
protected ManagedRepositoryConfiguration createManagedRepository(String id, String name, Path location) {
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
repo.setId(id);
repo.setName(name);
repo.setLocation(location.toAbsolutePath().toString());
return repo;
}
Aggregations