use of org.apache.archiva.admin.model.beans.ManagedRepository in project archiva by apache.
the class RepositoriesServiceTest method initSnapshotRepo.
protected Path initSnapshotRepo() throws Exception {
Path targetRepo = getBasedir().resolve("target/repo-with-snapshots");
if (Files.exists(targetRepo)) {
org.apache.archiva.common.utils.FileUtils.deleteDirectory(targetRepo);
}
assertFalse(Files.exists(targetRepo));
FileUtils.copyDirectoryToDirectory(getBasedir().resolve("src/test/repo-with-snapshots").toFile(), targetRepo.getParent().toFile());
if (getManagedRepositoriesService(authorizationHeader).getManagedRepository(SNAPSHOT_REPO_ID) != null) {
getManagedRepositoriesService(authorizationHeader).deleteManagedRepository(SNAPSHOT_REPO_ID, true);
assertNull(getManagedRepositoriesService(authorizationHeader).getManagedRepository(SNAPSHOT_REPO_ID));
}
ManagedRepository managedRepository = getTestManagedRepository(SNAPSHOT_REPO_ID, "repo-with-snapshots");
/*managedRepository.setId( SNAPSHOT_REPO_ID );
managedRepository.setLocation( );
managedRepository.setCronExpression( "* * * * * ?" );*/
getManagedRepositoriesService(authorizationHeader).addManagedRepository(managedRepository);
assertNotNull(getManagedRepositoriesService(authorizationHeader).getManagedRepository(SNAPSHOT_REPO_ID));
return targetRepo;
}
use of org.apache.archiva.admin.model.beans.ManagedRepository in project archiva by apache.
the class RepositoryServletTest method testGetRepositoryAfterDelete.
@Test
public void testGetRepositoryAfterDelete() throws Exception {
RepositoryServlet servlet = RepositoryServlet.class.cast(findServlet("repository"));
assertNotNull(servlet);
ArchivaConfiguration archivaConfiguration = servlet.getConfiguration();
Configuration c = archivaConfiguration.getConfiguration();
c.removeManagedRepository(c.findManagedRepositoryById(REPOID_INTERNAL));
saveConfiguration(archivaConfiguration);
ManagedRepository repository = servlet.getRepository(REPOID_INTERNAL);
assertNull(repository);
}
use of org.apache.archiva.admin.model.beans.ManagedRepository in project archiva by apache.
the class Maven3DependencyTreeBuilder method buildDependencyTree.
@Override
public void buildDependencyTree(List<String> repositoryIds, String groupId, String artifactId, String version, DependencyVisitor dependencyVisitor) throws DependencyTreeBuilderException {
Artifact projectArtifact = factory.createProjectArtifact(groupId, artifactId, version);
ManagedRepository repository = null;
try {
repository = findArtifactInRepositories(repositoryIds, projectArtifact);
} catch (RepositoryAdminException e) {
// FIXME better exception
throw new DependencyTreeBuilderException("Cannot build project dependency tree " + e.getMessage(), e);
}
if (repository == null) {
// metadata could not be resolved
return;
}
List<RemoteRepository> remoteRepositories = new ArrayList<>();
Map<String, NetworkProxy> networkProxies = new HashMap<>();
try {
// MRM-1411
// TODO: this is a workaround for a lack of proxy capability in the resolvers - replace when it can all be
// handled there. It doesn't cache anything locally!
Map<String, List<ProxyConnector>> proxyConnectorsMap = proxyConnectorAdmin.getProxyConnectorAsMap();
List<ProxyConnector> proxyConnectors = proxyConnectorsMap.get(repository.getId());
if (proxyConnectors != null) {
for (ProxyConnector proxyConnector : proxyConnectors) {
remoteRepositories.add(remoteRepositoryAdmin.getRemoteRepository(proxyConnector.getTargetRepoId()));
NetworkProxy networkProxyConfig = networkProxyAdmin.getNetworkProxy(proxyConnector.getProxyId());
if (networkProxyConfig != null) {
// key/value: remote repo ID/proxy info
networkProxies.put(proxyConnector.getTargetRepoId(), networkProxyConfig);
}
}
}
} catch (RepositoryAdminException e) {
throw new DependencyTreeBuilderException(e.getMessage(), e);
}
// FIXME take care of relative path
ResolveRequest resolveRequest = new ResolveRequest();
resolveRequest.dependencyVisitor = dependencyVisitor;
resolveRequest.localRepoDir = repository.getLocation();
resolveRequest.groupId = groupId;
resolveRequest.artifactId = artifactId;
resolveRequest.version = version;
resolveRequest.remoteRepositories = remoteRepositories;
resolveRequest.networkProxies = networkProxies;
resolve(resolveRequest);
}
use of org.apache.archiva.admin.model.beans.ManagedRepository in project archiva by apache.
the class RepositoryGroupAdminTest method testAddAndUpdateGroupWithInvalidMergedIndexTtl.
@Test(expected = RepositoryAdminException.class)
public void testAddAndUpdateGroupWithInvalidMergedIndexTtl() throws Exception {
try {
ManagedRepository managedRepositoryOne = getTestManagedRepository("test-new-one", Paths.get(APPSERVER_BASE_PATH, "test-new-one").toString());
ManagedRepository managedRepositoryTwo = getTestManagedRepository("test-new-two", Paths.get(APPSERVER_BASE_PATH, "test-new-two").toString());
managedRepositoryAdmin.addManagedRepository(managedRepositoryOne, false, getFakeAuditInformation());
managedRepositoryAdmin.addManagedRepository(managedRepositoryTwo, false, getFakeAuditInformation());
RepositoryGroup repositoryGroup = new RepositoryGroup("repo-group-one", Arrays.asList("test-new-one", "test-new-two"));
mockAuditListener.clearEvents();
repositoryGroupAdmin.addRepositoryGroup(repositoryGroup, getFakeAuditInformation());
assertEquals(1, repositoryGroupAdmin.getRepositoriesGroups().size());
assertEquals("repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get(0).getId());
assertEquals(2, repositoryGroupAdmin.getRepositoriesGroups().get(0).getRepositories().size());
assertEquals(Arrays.asList("test-new-one", "test-new-two"), repositoryGroupAdmin.getRepositoriesGroups().get(0).getRepositories());
// verify if default values were saved
assertEquals(30, repositoryGroupAdmin.getRepositoriesGroups().get(0).getMergedIndexTtl());
assertEquals(".indexer", repositoryGroupAdmin.getRepositoriesGroups().get(0).getMergedIndexPath());
repositoryGroup = repositoryGroupAdmin.getRepositoryGroup("repo-group-one");
assertNotNull(repositoryGroup);
repositoryGroup.mergedIndexTtl(-1);
repositoryGroupAdmin.updateRepositoryGroup(repositoryGroup, getFakeAuditInformation());
} finally {
mockAuditListener.clearEvents();
managedRepositoryAdmin.deleteManagedRepository("test-new-one", getFakeAuditInformation(), true);
managedRepositoryAdmin.deleteManagedRepository("test-new-two", getFakeAuditInformation(), true);
}
}
use of org.apache.archiva.admin.model.beans.ManagedRepository in project archiva by apache.
the class RepositoryGroupAdminTest method addAndDeleteGroup.
@Test
public void addAndDeleteGroup() throws Exception {
try {
Repository repo = repositoryRegistry.getRepository("test-new-one");
if (repo != null) {
repositoryRegistry.removeRepository(repo);
}
repo = repositoryRegistry.getRepository("test-new-two");
if (repo != null) {
repositoryRegistry.removeRepository(repo);
}
ManagedRepository managedRepositoryOne = getTestManagedRepository("test-new-one", Paths.get(APPSERVER_BASE_PATH, "test-new-one").toString());
ManagedRepository managedRepositoryTwo = getTestManagedRepository("test-new-two", Paths.get(APPSERVER_BASE_PATH, "test-new-two").toString());
managedRepositoryAdmin.addManagedRepository(managedRepositoryOne, false, getFakeAuditInformation());
managedRepositoryAdmin.addManagedRepository(managedRepositoryTwo, false, getFakeAuditInformation());
RepositoryGroup repositoryGroup = new RepositoryGroup("repo-group-one", Arrays.asList("test-new-one", "test-new-two"));
// repositoryGroupAdmin.deleteRepositoryGroup("repo-group-one", null);
mockAuditListener.clearEvents();
repositoryGroupAdmin.addRepositoryGroup(repositoryGroup, getFakeAuditInformation());
assertEquals(1, repositoryGroupAdmin.getRepositoriesGroups().size());
assertEquals("repo-group-one", repositoryGroupAdmin.getRepositoriesGroups().get(0).getId());
assertEquals(2, repositoryGroupAdmin.getRepositoriesGroups().get(0).getRepositories().size());
assertEquals(Arrays.asList("test-new-one", "test-new-two"), repositoryGroupAdmin.getRepositoriesGroups().get(0).getRepositories());
// verify if default values were saved
assertEquals(30, repositoryGroupAdmin.getRepositoriesGroups().get(0).getMergedIndexTtl());
assertEquals(".indexer", repositoryGroupAdmin.getRepositoriesGroups().get(0).getMergedIndexPath());
repositoryGroupAdmin.deleteRepositoryGroup("repo-group-one", getFakeAuditInformation());
assertEquals(0, repositoryGroupAdmin.getRepositoriesGroups().size());
assertEquals(2, mockAuditListener.getAuditEvents().size());
assertEquals(AuditEvent.ADD_REPO_GROUP, mockAuditListener.getAuditEvents().get(0).getAction());
assertEquals(AuditEvent.DELETE_REPO_GROUP, mockAuditListener.getAuditEvents().get(1).getAction());
} finally {
mockAuditListener.clearEvents();
repositoryRegistry.removeRepository(repositoryRegistry.getManagedRepository("test-new-one"));
repositoryRegistry.removeRepository(repositoryRegistry.getManagedRepository("test-new-two"));
}
}
Aggregations