001package org.apache.archiva.repository.maven2; 002 003/* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022import org.apache.archiva.common.filelock.FileLockManager; 023import org.apache.archiva.configuration.*; 024import org.apache.archiva.repository.*; 025import org.apache.archiva.event.Event; 026import org.apache.archiva.repository.features.ArtifactCleanupFeature; 027import org.apache.archiva.repository.features.IndexCreationFeature; 028import org.apache.archiva.repository.features.RemoteIndexFeature; 029import org.apache.archiva.repository.features.StagingRepositoryFeature; 030import org.apache.archiva.repository.base.BasicManagedRepository; 031import org.apache.archiva.repository.base.PasswordCredentials; 032import org.apache.archiva.repository.storage.FilesystemStorage; 033import org.apache.commons.lang3.StringUtils; 034import org.slf4j.Logger; 035import org.slf4j.LoggerFactory; 036import org.springframework.stereotype.Service; 037 038import javax.inject.Inject; 039import java.io.IOException; 040import java.net.URI; 041import java.net.URISyntaxException; 042import java.nio.file.Files; 043import java.nio.file.Path; 044import java.nio.file.Paths; 045import java.time.Duration; 046import java.time.Period; 047import java.time.temporal.ChronoUnit; 048import java.util.HashSet; 049import java.util.Set; 050import java.util.stream.Collectors; 051 052import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_INDEX_PATH; 053import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_PACKED_INDEX_PATH; 054 055/** 056 * Provider for the maven2 repository implementations 057 */ 058@Service("mavenRepositoryProvider") 059public class MavenRepositoryProvider implements RepositoryProvider { 060 061 062 @Inject 063 private ArchivaConfiguration archivaConfiguration; 064 065 @Inject 066 private FileLockManager fileLockManager; 067 068 private static final Logger log = LoggerFactory.getLogger(MavenRepositoryProvider.class); 069 070 static final Set<RepositoryType> TYPES = new HashSet<>(); 071 072 static { 073 TYPES.add(RepositoryType.MAVEN); 074 } 075 076 @Override 077 public Set<RepositoryType> provides() { 078 return TYPES; 079 } 080 081 @Override 082 public MavenManagedRepository createManagedInstance(String id, String name) { 083 return createManagedInstance(id, name, archivaConfiguration.getRemoteRepositoryBaseDir()); 084 } 085 086 public MavenManagedRepository createManagedInstance(String id, String name, Path baseDir) { 087 FilesystemStorage storage = null; 088 try { 089 storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager); 090 } catch (IOException e) { 091 log.error("Could not initialize fileystem for repository {}", id); 092 throw new RuntimeException(e); 093 } 094 return new MavenManagedRepository(id, name, storage); 095 } 096 097 @Override 098 public MavenRemoteRepository createRemoteInstance(String id, String name) { 099 return createRemoteInstance(id, name, archivaConfiguration.getRemoteRepositoryBaseDir()); 100 } 101 102 public MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir) { 103 FilesystemStorage storage = null; 104 try { 105 storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager); 106 } catch (IOException e) { 107 log.error("Could not initialize fileystem for repository {}", id); 108 throw new RuntimeException(e); 109 } 110 return new MavenRemoteRepository(id, name, storage); 111 } 112 113 @Override 114 public EditableRepositoryGroup createRepositoryGroup(String id, String name) { 115 return createRepositoryGroup(id, name, archivaConfiguration.getRepositoryBaseDir()); 116 } 117 118 public MavenRepositoryGroup createRepositoryGroup(String id, String name, Path baseDir) { 119 FilesystemStorage storage = null; 120 try { 121 storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager); 122 } catch (IOException e) { 123 log.error("Could not initialize fileystem for repository {}", id); 124 throw new RuntimeException(e); 125 } 126 return new MavenRepositoryGroup(id, name, storage); 127 } 128 129 private URI getURIFromString(String uriStr) throws RepositoryException { 130 URI uri; 131 try { 132 if (StringUtils.isEmpty(uriStr)) { 133 return new URI(""); 134 } 135 if (uriStr.startsWith("/")) { 136 // only absolute paths are prepended with file scheme 137 uri = new URI("file://" + uriStr); 138 } else { 139 uri = new URI(uriStr); 140 } 141 if (uri.getScheme() != null && !"file".equals(uri.getScheme())) { 142 log.error("Bad URI scheme found: {}, URI={}", uri.getScheme(), uri); 143 throw new RepositoryException("The uri " + uriStr + " is not valid. Only file:// URI is allowed for maven."); 144 } 145 } catch (URISyntaxException e) { 146 String newCfg = "file://" + uriStr; 147 try { 148 uri = new URI(newCfg); 149 } catch (URISyntaxException e1) { 150 log.error("Could not create URI from {} -> ", uriStr, newCfg); 151 throw new RepositoryException("The config entry " + uriStr + " cannot be converted to URI."); 152 } 153 } 154 log.debug("Setting location uri: {}", uri); 155 return uri; 156 } 157 158 @Override 159 public ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg) throws RepositoryException { 160 MavenManagedRepository repo = createManagedInstance(cfg.getId(), cfg.getName(), Paths.get(cfg.getLocation()).getParent()); 161 updateManagedInstance(repo, cfg); 162 return repo; 163 } 164 165 @Override 166 public void updateManagedInstance(EditableManagedRepository repo, ManagedRepositoryConfiguration cfg) throws RepositoryException { 167 try { 168 repo.setLocation(getURIFromString(cfg.getLocation())); 169 } catch (UnsupportedURIException e) { 170 throw new RepositoryException("The location entry is not a valid uri: " + cfg.getLocation()); 171 } 172 setBaseConfig(repo, cfg); 173 Path repoDir = repo.getAsset("").getFilePath(); 174 if (!Files.exists(repoDir)) { 175 log.debug("Creating repo directory {}", repoDir); 176 try { 177 Files.createDirectories(repoDir); 178 } catch (IOException e) { 179 log.error("Could not create directory {} for repository {}", repoDir, repo.getId(), e); 180 throw new RepositoryException("Could not create directory for repository " + repoDir); 181 } 182 } 183 repo.setSchedulingDefinition(cfg.getRefreshCronExpression()); 184 repo.setBlocksRedeployment(cfg.isBlockRedeployments()); 185 repo.setScanned(cfg.isScanned()); 186 if (cfg.isReleases()) { 187 repo.addActiveReleaseScheme(ReleaseScheme.RELEASE); 188 } else { 189 repo.removeActiveReleaseScheme(ReleaseScheme.RELEASE); 190 } 191 if (cfg.isSnapshots()) { 192 repo.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT); 193 } else { 194 repo.removeActiveReleaseScheme(ReleaseScheme.SNAPSHOT); 195 } 196 197 StagingRepositoryFeature stagingRepositoryFeature = repo.getFeature(StagingRepositoryFeature.class).get(); 198 stagingRepositoryFeature.setStageRepoNeeded(cfg.isStageRepoNeeded()); 199 200 IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); 201 indexCreationFeature.setSkipPackedIndexCreation(cfg.isSkipPackedIndexCreation()); 202 String indexDir = StringUtils.isEmpty( cfg.getIndexDir() ) ? DEFAULT_INDEX_PATH : cfg.getIndexDir(); 203 String packedIndexDir = StringUtils.isEmpty( cfg.getPackedIndexDir() ) ? DEFAULT_PACKED_INDEX_PATH : cfg.getPackedIndexDir(); 204 indexCreationFeature.setIndexPath(getURIFromString(indexDir)); 205 indexCreationFeature.setPackedIndexPath(getURIFromString(packedIndexDir)); 206 207 ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class).get(); 208 209 artifactCleanupFeature.setDeleteReleasedSnapshots(cfg.isDeleteReleasedSnapshots()); 210 artifactCleanupFeature.setRetentionCount(cfg.getRetentionCount()); 211 artifactCleanupFeature.setRetentionPeriod(Period.ofDays(cfg.getRetentionPeriod())); 212 } 213 214 215 @Override 216 public ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration) throws RepositoryException { 217 log.debug("Creating staging instance for {}", baseConfiguration.getId()); 218 return createManagedInstance(getStageRepoConfig(baseConfiguration)); 219 } 220 221 222 @Override 223 public RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg) throws RepositoryException { 224 MavenRemoteRepository repo = createRemoteInstance(cfg.getId(), cfg.getName(), archivaConfiguration.getRemoteRepositoryBaseDir()); 225 updateRemoteInstance(repo, cfg); 226 return repo; 227 } 228 229 private String convertUriToPath(URI uri) { 230 if (uri.getScheme() == null) { 231 return uri.getPath(); 232 } else if ("file".equals(uri.getScheme())) { 233 return Paths.get(uri).toString(); 234 } else { 235 return uri.toString(); 236 } 237 } 238 239 @Override 240 public void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg) throws RepositoryException { 241 setBaseConfig(repo, cfg); 242 repo.setCheckPath(cfg.getCheckPath()); 243 repo.setSchedulingDefinition(cfg.getRefreshCronExpression()); 244 try { 245 repo.setLocation(new URI(cfg.getUrl())); 246 } catch (UnsupportedURIException | URISyntaxException e) { 247 log.error("Could not set remote url " + cfg.getUrl()); 248 throw new RepositoryException("The url config is not a valid uri: " + cfg.getUrl()); 249 } 250 repo.setTimeout(Duration.ofSeconds(cfg.getTimeout())); 251 RemoteIndexFeature remoteIndexFeature = repo.getFeature(RemoteIndexFeature.class).get(); 252 remoteIndexFeature.setDownloadRemoteIndex(cfg.isDownloadRemoteIndex()); 253 remoteIndexFeature.setDownloadRemoteIndexOnStartup(cfg.isDownloadRemoteIndexOnStartup()); 254 remoteIndexFeature.setDownloadTimeout(Duration.ofSeconds(cfg.getRemoteDownloadTimeout())); 255 remoteIndexFeature.setProxyId(cfg.getRemoteDownloadNetworkProxyId()); 256 if (cfg.isDownloadRemoteIndex()) { 257 try { 258 remoteIndexFeature.setIndexUri(new URI(cfg.getRemoteIndexUrl())); 259 } catch (URISyntaxException e) { 260 log.error("Could not set remote index url " + cfg.getRemoteIndexUrl()); 261 remoteIndexFeature.setDownloadRemoteIndex(false); 262 remoteIndexFeature.setDownloadRemoteIndexOnStartup(false); 263 } 264 } 265 for ( Object key : cfg.getExtraHeaders().keySet() ) { 266 repo.addExtraHeader( key.toString(), cfg.getExtraHeaders().get(key).toString() ); 267 } 268 for ( Object key : cfg.getExtraParameters().keySet() ) { 269 repo.addExtraParameter( key.toString(), cfg.getExtraParameters().get(key).toString() ); 270 } 271 PasswordCredentials credentials = new PasswordCredentials("", new char[0]); 272 if (cfg.getPassword() != null && cfg.getUsername() != null) { 273 credentials.setPassword(cfg.getPassword().toCharArray()); 274 credentials.setUsername(cfg.getUsername()); 275 repo.setCredentials(credentials); 276 } else { 277 credentials.setPassword(new char[0]); 278 } 279 IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get(); 280 if (cfg.getIndexDir() != null) { 281 indexCreationFeature.setIndexPath(getURIFromString(cfg.getIndexDir())); 282 } 283 if (cfg.getPackedIndexDir() != null) { 284 indexCreationFeature.setPackedIndexPath(getURIFromString(cfg.getPackedIndexDir())); 285 } 286 log.debug("Updated remote instance {}", repo); 287 } 288 289 @Override 290 public RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException { 291 Path repositoryGroupBase = getArchivaConfiguration().getRepositoryGroupBaseDir(); 292 MavenRepositoryGroup newGrp = createRepositoryGroup(configuration.getId(), configuration.getName(), 293 repositoryGroupBase); 294 updateRepositoryGroupInstance(newGrp, configuration); 295 return newGrp; 296 } 297 298 @Override 299 public void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException { 300 repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), configuration.getName()); 301 repositoryGroup.setMergedIndexTTL(configuration.getMergedIndexTtl()); 302 repositoryGroup.setSchedulingDefinition(configuration.getCronExpression()); 303 if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) { 304 IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get(); 305 indexCreationFeature.setIndexPath( getURIFromString(configuration.getMergedIndexPath()) ); 306 Path localPath = Paths.get(configuration.getMergedIndexPath()); 307 Path repoGroupPath = repositoryGroup.getAsset("").getFilePath().toAbsolutePath(); 308 if (localPath.isAbsolute() && !localPath.startsWith(repoGroupPath)) { 309 try { 310 FilesystemStorage storage = new FilesystemStorage(localPath.getParent(), fileLockManager); 311 indexCreationFeature.setLocalIndexPath(storage.getAsset(localPath.getFileName().toString())); 312 } catch (IOException e) { 313 throw new RepositoryException("Could not initialize storage for index path "+localPath); 314 } 315 } else if (localPath.isAbsolute()) { 316 indexCreationFeature.setLocalIndexPath(repositoryGroup.getAsset(repoGroupPath.relativize(localPath).toString())); 317 } else 318 { 319 indexCreationFeature.setLocalIndexPath(repositoryGroup.getAsset(localPath.toString())); 320 } 321 } 322 // References to other repositories are set filled by the registry 323 } 324 325 @Override 326 public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException { 327 if (!(remoteRepository instanceof MavenRemoteRepository)) { 328 log.error("Wrong remote repository type " + remoteRepository.getClass().getName()); 329 throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName()); 330 } 331 RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration(); 332 cfg.setType(remoteRepository.getType().toString()); 333 cfg.setId(remoteRepository.getId()); 334 cfg.setName(remoteRepository.getName()); 335 cfg.setDescription(remoteRepository.getDescription()); 336 cfg.setUrl(remoteRepository.getLocation().toString()); 337 cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000); 338 cfg.setCheckPath(remoteRepository.getCheckPath()); 339 RepositoryCredentials creds = remoteRepository.getLoginCredentials(); 340 if (creds != null) { 341 if (creds instanceof PasswordCredentials) { 342 PasswordCredentials pCreds = (PasswordCredentials) creds; 343 cfg.setPassword(new String(pCreds.getPassword())); 344 cfg.setUsername(pCreds.getUsername()); 345 } 346 } 347 cfg.setLayout(remoteRepository.getLayout()); 348 cfg.setExtraParameters(remoteRepository.getExtraParameters()); 349 cfg.setExtraHeaders(remoteRepository.getExtraHeaders()); 350 cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition()); 351 352 IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get(); 353 cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); 354 cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); 355 356 RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get(); 357 if (remoteIndexFeature.getIndexUri() != null) { 358 cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString()); 359 } 360 cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS)); 361 cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup()); 362 cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex()); 363 cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); 364 if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) { 365 cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId()); 366 } else { 367 cfg.setRemoteDownloadNetworkProxyId(""); 368 } 369 370 371 372 373 return cfg; 374 375 } 376 377 @Override 378 public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException { 379 if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) { 380 log.error("Wrong remote repository type " + managedRepository.getClass().getName()); 381 throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName()); 382 } 383 ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration(); 384 cfg.setType(managedRepository.getType().toString()); 385 cfg.setId(managedRepository.getId()); 386 cfg.setName(managedRepository.getName()); 387 cfg.setDescription(managedRepository.getDescription()); 388 cfg.setLocation(convertUriToPath(managedRepository.getLocation())); 389 cfg.setLayout(managedRepository.getLayout()); 390 cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition()); 391 cfg.setScanned(managedRepository.isScanned()); 392 cfg.setBlockRedeployments(managedRepository.blocksRedeployments()); 393 StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get(); 394 cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded()); 395 IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get(); 396 cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath())); 397 cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath())); 398 cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation()); 399 400 ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get(); 401 cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount()); 402 cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays()); 403 cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots()); 404 405 if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.RELEASE)) { 406 cfg.setReleases(true); 407 } else { 408 cfg.setReleases(false); 409 } 410 if (managedRepository.getActiveReleaseSchemes().contains(ReleaseScheme.SNAPSHOT)) { 411 cfg.setSnapshots(true); 412 } else { 413 cfg.setSnapshots(false); 414 } 415 return cfg; 416 417 } 418 419 @Override 420 public RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException { 421 if (repositoryGroup.getType() != RepositoryType.MAVEN) { 422 throw new RepositoryException("The given repository group is not of MAVEN type"); 423 } 424 RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration(); 425 cfg.setId(repositoryGroup.getId()); 426 cfg.setName(repositoryGroup.getName()); 427 if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) 428 { 429 IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get(); 430 431 cfg.setMergedIndexPath( indexCreationFeature.getIndexPath().toString() ); 432 } 433 cfg.setMergedIndexTtl(repositoryGroup.getMergedIndexTTL()); 434 cfg.setRepositories(repositoryGroup.getRepositories().stream().map(r -> r.getId()).collect(Collectors.toList())); 435 cfg.setCronExpression(repositoryGroup.getSchedulingDefinition()); 436 return cfg; 437 } 438 439 private ManagedRepositoryConfiguration getStageRepoConfig(ManagedRepositoryConfiguration repository) { 440 ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration(); 441 stagingRepository.setId(repository.getId() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); 442 stagingRepository.setLayout(repository.getLayout()); 443 stagingRepository.setName(repository.getName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); 444 stagingRepository.setBlockRedeployments(repository.isBlockRedeployments()); 445 stagingRepository.setRetentionPeriod(repository.getRetentionPeriod()); 446 stagingRepository.setDeleteReleasedSnapshots(repository.isDeleteReleasedSnapshots()); 447 stagingRepository.setStageRepoNeeded(false); 448 449 String path = repository.getLocation(); 450 int lastIndex = path.replace('\\', '/').lastIndexOf('/'); 451 stagingRepository.setLocation(path.substring(0, lastIndex) + "/" + stagingRepository.getId()); 452 453 if (StringUtils.isNotBlank(repository.getIndexDir())) { 454 Path indexDir = null; 455 try { 456 indexDir = Paths.get(new URI(repository.getIndexDir().startsWith("file://") ? repository.getIndexDir() : "file://" + repository.getIndexDir())); 457 if (indexDir.isAbsolute()) { 458 Path newDir = indexDir.getParent().resolve(indexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); 459 log.debug("Changing index directory {} -> {}", indexDir, newDir); 460 stagingRepository.setIndexDir(newDir.toString()); 461 } else { 462 log.debug("Keeping index directory {}", repository.getIndexDir()); 463 stagingRepository.setIndexDir(repository.getIndexDir()); 464 } 465 } catch (URISyntaxException e) { 466 log.error("Could not parse index path as uri {}", repository.getIndexDir()); 467 stagingRepository.setIndexDir(""); 468 } 469 // in case of absolute dir do not use the same 470 } 471 if (StringUtils.isNotBlank(repository.getPackedIndexDir())) { 472 Path packedIndexDir = null; 473 packedIndexDir = Paths.get(repository.getPackedIndexDir()); 474 if (packedIndexDir.isAbsolute()) { 475 Path newDir = packedIndexDir.getParent().resolve(packedIndexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX); 476 log.debug("Changing index directory {} -> {}", packedIndexDir, newDir); 477 stagingRepository.setPackedIndexDir(newDir.toString()); 478 } else { 479 log.debug("Keeping index directory {}", repository.getPackedIndexDir()); 480 stagingRepository.setPackedIndexDir(repository.getPackedIndexDir()); 481 } 482 // in case of absolute dir do not use the same 483 } 484 stagingRepository.setRefreshCronExpression(repository.getRefreshCronExpression()); 485 stagingRepository.setReleases(repository.isReleases()); 486 stagingRepository.setRetentionCount(repository.getRetentionCount()); 487 stagingRepository.setScanned(repository.isScanned()); 488 stagingRepository.setSnapshots(repository.isSnapshots()); 489 stagingRepository.setSkipPackedIndexCreation(repository.isSkipPackedIndexCreation()); 490 // do not duplicate description 491 //stagingRepository.getDescription("") 492 return stagingRepository; 493 } 494 495 private void setBaseConfig(EditableRepository repo, AbstractRepositoryConfiguration cfg) throws RepositoryException { 496 497 URI baseUri = archivaConfiguration.getRepositoryBaseDir().toUri(); 498 repo.setBaseUri(baseUri); 499 500 repo.setName(repo.getPrimaryLocale(), cfg.getName()); 501 repo.setDescription(repo.getPrimaryLocale(), cfg.getDescription()); 502 repo.setLayout(cfg.getLayout()); 503 } 504 505 public ArchivaConfiguration getArchivaConfiguration() { 506 return archivaConfiguration; 507 } 508 509 public void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration) { 510 this.archivaConfiguration = archivaConfiguration; 511 } 512 513 @Override 514 public void handle(Event event) { 515 // 516 } 517 518}