private RemoteRepositoryConfiguration getRemoteRepositoryConfiguration( RemoteRepository remoteRepository) { RemoteRepositoryConfiguration remoteRepositoryConfiguration = new RemoteRepositoryConfiguration(); remoteRepositoryConfiguration.setId(remoteRepository.getId()); remoteRepositoryConfiguration.setPassword(remoteRepository.getPassword()); remoteRepositoryConfiguration.setTimeout(remoteRepository.getTimeout()); remoteRepositoryConfiguration.setUrl(remoteRepository.getUrl()); remoteRepositoryConfiguration.setUsername(remoteRepository.getUserName()); remoteRepositoryConfiguration.setLayout(remoteRepository.getLayout()); remoteRepositoryConfiguration.setName(remoteRepository.getName()); remoteRepositoryConfiguration.setDownloadRemoteIndex(remoteRepository.isDownloadRemoteIndex()); remoteRepositoryConfiguration.setRemoteIndexUrl(remoteRepository.getRemoteIndexUrl()); remoteRepositoryConfiguration.setRefreshCronExpression(remoteRepository.getCronExpression()); remoteRepositoryConfiguration.setIndexDir(remoteRepository.getIndexDirectory()); remoteRepositoryConfiguration.setRemoteDownloadNetworkProxyId( remoteRepository.getRemoteDownloadNetworkProxyId()); remoteRepositoryConfiguration.setRemoteDownloadTimeout( remoteRepository.getRemoteDownloadTimeout()); remoteRepositoryConfiguration.setDownloadRemoteIndexOnStartup( remoteRepository.isDownloadRemoteIndexOnStartup()); remoteRepositoryConfiguration.setDescription(remoteRepository.getDescription()); remoteRepositoryConfiguration.setExtraHeaders(remoteRepository.getExtraHeaders()); remoteRepositoryConfiguration.setExtraParameters(remoteRepository.getExtraParameters()); return remoteRepositoryConfiguration; }
@Override public IndexingContext createIndexContext(RemoteRepository remoteRepository) throws RepositoryAdminException { try { String appServerBase = getRegistry().getString("appserver.base"); String contextKey = "remote-" + remoteRepository.getId(); IndexingContext indexingContext = indexer.getIndexingContexts().get(contextKey); if (indexingContext != null) { return indexingContext; } // create remote repository path File repoDir = new File(appServerBase, "data/remotes/" + remoteRepository.getId()); if (!repoDir.exists()) { repoDir.mkdirs(); } File indexDirectory = null; // is there configured indexDirectory ? String indexDirectoryPath = remoteRepository.getIndexDirectory(); if (StringUtils.isNotBlank(indexDirectoryPath)) { if (new File(indexDirectoryPath).isAbsolute()) { indexDirectory = new File(indexDirectoryPath); } else { indexDirectory = new File(repoDir, indexDirectoryPath); } } // if not configured use a default value if (indexDirectory == null) { indexDirectory = new File(repoDir, ".index"); } if (!indexDirectory.exists()) { indexDirectory.mkdirs(); } return indexer.addIndexingContext( contextKey, remoteRepository.getId(), repoDir, indexDirectory, remoteRepository.getUrl(), calculateIndexRemoteUrl(remoteRepository), mavenIndexerUtils.getAllIndexCreators()); } catch (MalformedURLException e) { throw new RepositoryAdminException(e.getMessage(), e); } catch (IOException e) { throw new RepositoryAdminException(e.getMessage(), e); } catch (UnsupportedExistingLuceneIndexException e) { throw new RepositoryAdminException(e.getMessage(), e); } }