@Test public void getRemoteConfiguration() throws Exception { MavenRemoteRepository repo = MavenRemoteRepository.newLocalInstance( "test01", "My Test repo", Paths.get("target/remotes") ); repo.setLocation( new URI("https: repo.setScanned( true ); repo.setDescription( repo.getPrimaryLocale(), "This is a description" ); repo.setLayout( "maven2" ); repo.setName( repo.getPrimaryLocale(), "test0003" ); repo.setSchedulingDefinition( "0 0 05 ? * WED" ); RemoteIndexFeature remoteIndexFeature = repo.getFeature( RemoteIndexFeature.class ).get(); remoteIndexFeature.setProxyId( "proxyabc" ); remoteIndexFeature.setDownloadTimeout( Duration.ofSeconds( 54 ) ); remoteIndexFeature.setDownloadRemoteIndex( false ); remoteIndexFeature.setIndexUri( new URI("/this/remote/.index") ); remoteIndexFeature.setDownloadRemoteIndexOnStartup( true ); IndexCreationFeature indexCreationFeature = repo.getFeature( IndexCreationFeature.class ).get(); indexCreationFeature.setIndexPath( new URI("/this/local/.index") ); RemoteRepositoryConfiguration cfg = provider.getRemoteConfiguration( repo ); assertEquals("https: assertEquals( "This is a description", cfg.getDescription() ); assertEquals("maven2", cfg.getLayout()); assertEquals("test0003", cfg.getName()); assertEquals("0 0 05 ? * WED", cfg.getRefreshCronExpression()); assertEquals("/this/remote/.index", cfg.getRemoteIndexUrl()); assertEquals("proxyabc", cfg.getRemoteDownloadNetworkProxyId()); assertEquals(54, cfg.getRemoteDownloadTimeout()); assertFalse(cfg.isDownloadRemoteIndex()); assertTrue(cfg.isDownloadRemoteIndexOnStartup()); assertEquals("/this/local/.index", cfg.getIndexDir()); }
@Override public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { if (!(remoteRepository instanceof MavenRemoteRepository)) { log.error("Wrong remote repository type " + remoteRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName()); } RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration(); cfg.setType(remoteRepository.getType().toString()); cfg.setId(remoteRepository.getId()); cfg.setName(remoteRepository.getName()); cfg.setDescription(remoteRepository.getDescription()); cfg.setUrl(remoteRepository.getLocation().toString()); cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000); cfg.setCheckPath(remoteRepository.getCheckPath()); RepositoryCredentials creds = remoteRepository.getLoginCredentials(); if (creds != null) { if (creds instanceof PasswordCredentials) { PasswordCredentials pCreds = (PasswordCredentials) creds; cfg.setPassword(new String(pCreds.getPassword())); cfg.setUsername(pCreds.getUsername()); } } cfg.setLayout(remoteRepository.getLayout()); cfg.setExtraParameters(remoteRepository.getExtraParameters()); cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); if (remoteIndexFeature.getIndexUri() != null) { cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); } cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS)); cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup()); cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex()); cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) { cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); } else { cfg.setRemoteDownloadNetworkProxyId(""); } return cfg; }
MavenRepositoryProvider implements RepositoryProvider { @Override public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { if (!(remoteRepository instanceof MavenRemoteRepository)) { log.error("Wrong remote repository type " + remoteRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName()); } RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration(); cfg.setType(remoteRepository.getType().toString()); cfg.setId(remoteRepository.getId()); cfg.setName(remoteRepository.getName()); cfg.setDescription(remoteRepository.getDescription()); cfg.setUrl(remoteRepository.getLocation().toString()); cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000); cfg.setCheckPath(remoteRepository.getCheckPath()); RepositoryCredentials creds = remoteRepository.getLoginCredentials(); if (creds != null) { if (creds instanceof PasswordCredentials) { PasswordCredentials pCreds = (PasswordCredentials) creds; cfg.setPassword(new String(pCreds.getPassword())); cfg.setUsername(pCreds.getUsername()); } } cfg.setLayout(remoteRepository.getLayout()); cfg.setExtraParameters(remoteRepository.getExtraParameters()); cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); if (remoteIndexFeature.getIndexUri() != null) { cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); } cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS)); cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup()); cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex()); cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) { cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); } else { cfg.setRemoteDownloadNetworkProxyId(""); } return cfg; } }
MavenRepositoryProvider implements RepositoryProvider { @Override public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { if (!(remoteRepository instanceof MavenRemoteRepository)) { log.error("Wrong remote repository type " + remoteRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName()); } RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration(); cfg.setType(remoteRepository.getType().toString()); cfg.setId(remoteRepository.getId()); cfg.setName(remoteRepository.getName()); cfg.setDescription(remoteRepository.getDescription()); cfg.setUrl(remoteRepository.getLocation().toString()); cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000); cfg.setCheckPath(remoteRepository.getCheckPath()); RepositoryCredentials creds = remoteRepository.getLoginCredentials(); if (creds != null) { if (creds instanceof PasswordCredentials) { PasswordCredentials pCreds = (PasswordCredentials) creds; cfg.setPassword(new String(pCreds.getPassword())); cfg.setUsername(pCreds.getUsername()); } } cfg.setLayout(remoteRepository.getLayout()); cfg.setExtraParameters(remoteRepository.getExtraParameters()); cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); if (remoteIndexFeature.getIndexUri() != null) { cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); } cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS)); cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup()); cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex()); cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) { cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); } else { cfg.setRemoteDownloadNetworkProxyId(""); } return cfg; }  }
MavenRepositoryProvider implements RepositoryProvider { @Override public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { if (!(remoteRepository instanceof MavenRemoteRepository)) { log.error("Wrong remote repository type " + remoteRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName()); } RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration(); cfg.setType(remoteRepository.getType().toString()); cfg.setId(remoteRepository.getId()); cfg.setName(remoteRepository.getName()); cfg.setDescription(remoteRepository.getDescription()); cfg.setUrl(remoteRepository.getLocation().toString()); cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000); cfg.setCheckPath(remoteRepository.getCheckPath()); RepositoryCredentials creds = remoteRepository.getLoginCredentials(); if (creds != null) { if (creds instanceof PasswordCredentials) { PasswordCredentials pCreds = (PasswordCredentials) creds; cfg.setPassword(new String(pCreds.getPassword())); cfg.setUsername(pCreds.getUsername()); } } cfg.setLayout(remoteRepository.getLayout()); cfg.setExtraParameters(remoteRepository.getExtraParameters()); cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); if (remoteIndexFeature.getIndexUri() != null) { cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); } cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS)); cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup()); cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex()); cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) { cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); } else { cfg.setRemoteDownloadNetworkProxyId(""); } return cfg; }  @Override Set<RepositoryType> provides(); @Override MavenManagedRepository createManagedInstance(String id, String name); MavenManagedRepository createManagedInstance(String id, String name, Path baseDir); @Override MavenRemoteRepository createRemoteInstance(String id, String name); MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir); @Override EditableRepositoryGroup createRepositoryGroup(String id, String name); MavenRepositoryGroup createRepositoryGroup(String id, String name, Path baseDir); @Override ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg); @Override void updateManagedInstance(EditableManagedRepository repo, ManagedRepositoryConfiguration cfg); @Override ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration); @Override RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg); @Override void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg); @Override RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration); @Override void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration); @Override RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository); @Override ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository); @Override RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup); ArchivaConfiguration getArchivaConfiguration(); void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration); @Override void handle(Event event); }
MavenRepositoryProvider implements RepositoryProvider { @Override public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { if (!(remoteRepository instanceof MavenRemoteRepository)) { log.error("Wrong remote repository type " + remoteRepository.getClass().getName()); throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName()); } RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration(); cfg.setType(remoteRepository.getType().toString()); cfg.setId(remoteRepository.getId()); cfg.setName(remoteRepository.getName()); cfg.setDescription(remoteRepository.getDescription()); cfg.setUrl(remoteRepository.getLocation().toString()); cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000); cfg.setCheckPath(remoteRepository.getCheckPath()); RepositoryCredentials creds = remoteRepository.getLoginCredentials(); if (creds != null) { if (creds instanceof PasswordCredentials) { PasswordCredentials pCreds = (PasswordCredentials) creds; cfg.setPassword(new String(pCreds.getPassword())); cfg.setUsername(pCreds.getUsername()); } } cfg.setLayout(remoteRepository.getLayout()); cfg.setExtraParameters(remoteRepository.getExtraParameters()); cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); if (remoteIndexFeature.getIndexUri() != null) { cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); } cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS)); cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup()); cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex()); cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) { cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); } else { cfg.setRemoteDownloadNetworkProxyId(""); } return cfg; }  @Override Set<RepositoryType> provides(); @Override MavenManagedRepository createManagedInstance(String id, String name); MavenManagedRepository createManagedInstance(String id, String name, Path baseDir); @Override MavenRemoteRepository createRemoteInstance(String id, String name); MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir); @Override EditableRepositoryGroup createRepositoryGroup(String id, String name); MavenRepositoryGroup createRepositoryGroup(String id, String name, Path baseDir); @Override ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg); @Override void updateManagedInstance(EditableManagedRepository repo, ManagedRepositoryConfiguration cfg); @Override ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration); @Override RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg); @Override void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg); @Override RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration); @Override void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration); @Override RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository); @Override ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository); @Override RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup); ArchivaConfiguration getArchivaConfiguration(); void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration); @Override void handle(Event event);  }