import org.apache.archiva.admin.model.RepositoryAdminException;
import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
+import org.apache.archiva.common.utils.PathUtil;
import org.apache.archiva.configuration.Configuration;
import org.apache.archiva.configuration.ProxyConnectorConfiguration;
import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
import org.apache.archiva.repository.RepositoryCredentials;
import org.apache.archiva.repository.RepositoryException;
import org.apache.archiva.repository.RepositoryRegistry;
+import org.apache.archiva.repository.features.IndexCreationEvent;
+import org.apache.archiva.repository.features.IndexCreationFeature;
import org.apache.archiva.repository.features.RemoteIndexFeature;
import org.apache.commons.lang.StringUtils;
import org.apache.maven.index.NexusIndexer;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
import java.io.IOException;
+import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
adminRepo.setDownloadRemoteIndexOnStartup( rif.isDownloadRemoteIndexOnStartup() );
adminRepo.setRemoteDownloadTimeout( (int) rif.getDownloadTimeout().getSeconds() );
}
+ if (repo.supportsFeature(IndexCreationFeature.class)) {
+ IndexCreationFeature icf = repo.getFeature(IndexCreationFeature.class).get();
+ adminRepo.setIndexDirectory(PathUtil.getPathFromUri(icf.getIndexPath()).toString());
+ }
+ adminRepo.setDescription(repo.getDescription());
return adminRepo;
}
repoConfig.setRemoteDownloadNetworkProxyId( repo.getRemoteDownloadNetworkProxyId() );
repoConfig.setDownloadRemoteIndexOnStartup( repo.isDownloadRemoteIndexOnStartup() );
repoConfig.setRemoteDownloadTimeout( repo.getRemoteDownloadTimeout() );
+ repoConfig.setDescription(repo.getDescription());
+ repoConfig.setIndexDir(repo.getIndexDirectory());
return repoConfig;
}
throw new RepositoryAdminException( "Could not delete remote repository"+(e.getMessage()==null?"":": "+e.getMessage()) );
}
- // TODO use ProxyConnectorAdmin interface ?
- // [MRM-520] Proxy Connectors are not deleted with the deletion of a Repository.
- List<ProxyConnectorConfiguration> proxyConnectors = new ArrayList<>( configuration.getProxyConnectors() );
- for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
- {
- if ( StringUtils.equals( proxyConnector.getTargetRepoId(), repositoryId ) )
- {
- configuration.removeProxyConnector( proxyConnector );
- }
- }
-
saveConfiguration( configuration );
return Boolean.TRUE;
}
- protected String calculateIndexRemoteUrl( org.apache.archiva.admin.model.beans.RemoteRepository remoteRepository )
- {
- if ( StringUtils.startsWith( remoteRepository.getRemoteIndexUrl(), "http" ) )
- {
- String baseUrl = remoteRepository.getRemoteIndexUrl();
- return baseUrl.endsWith( "/" ) ? StringUtils.substringBeforeLast( baseUrl, "/" ) : baseUrl;
- }
- String baseUrl = StringUtils.endsWith( remoteRepository.getUrl(), "/" ) ? StringUtils.substringBeforeLast(
- remoteRepository.getUrl(), "/" ) : remoteRepository.getUrl();
-
- baseUrl = StringUtils.isEmpty( remoteRepository.getRemoteIndexUrl() )
- ? baseUrl + "/.index"
- : baseUrl + "/" + remoteRepository.getRemoteIndexUrl();
- return baseUrl;
-
- }