1 package org.apache.archiva.repository.maven;
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements. See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership. The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License. You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied. See the License for the
18 * specific language governing permissions and limitations
22 import org.apache.archiva.common.filelock.FileLockManager;
23 import org.apache.archiva.configuration.AbstractRepositoryConfiguration;
24 import org.apache.archiva.configuration.ArchivaConfiguration;
25 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
26 import org.apache.archiva.configuration.RemoteRepositoryConfiguration;
27 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
28 import org.apache.archiva.event.Event;
29 import org.apache.archiva.event.EventHandler;
30 import org.apache.archiva.repository.EditableManagedRepository;
31 import org.apache.archiva.repository.EditableRemoteRepository;
32 import org.apache.archiva.repository.EditableRepository;
33 import org.apache.archiva.repository.EditableRepositoryGroup;
34 import org.apache.archiva.repository.ManagedRepository;
35 import org.apache.archiva.repository.ReleaseScheme;
36 import org.apache.archiva.repository.RemoteRepository;
37 import org.apache.archiva.repository.Repository;
38 import org.apache.archiva.repository.RepositoryCredentials;
39 import org.apache.archiva.repository.RepositoryException;
40 import org.apache.archiva.repository.RepositoryGroup;
41 import org.apache.archiva.repository.RepositoryProvider;
42 import org.apache.archiva.repository.RepositoryType;
43 import org.apache.archiva.repository.UnsupportedURIException;
44 import org.apache.archiva.repository.base.managed.BasicManagedRepository;
45 import org.apache.archiva.repository.base.PasswordCredentials;
46 import org.apache.archiva.repository.event.RepositoryEvent;
47 import org.apache.archiva.repository.features.ArtifactCleanupFeature;
48 import org.apache.archiva.repository.features.IndexCreationFeature;
49 import org.apache.archiva.repository.features.RemoteIndexFeature;
50 import org.apache.archiva.repository.features.StagingRepositoryFeature;
51 import org.apache.archiva.repository.storage.fs.FilesystemStorage;
52 import org.apache.commons.lang3.StringUtils;
53 import org.slf4j.Logger;
54 import org.slf4j.LoggerFactory;
55 import org.springframework.stereotype.Service;
57 import javax.inject.Inject;
58 import java.io.IOException;
60 import java.net.URISyntaxException;
61 import java.nio.file.Files;
62 import java.nio.file.Path;
63 import java.nio.file.Paths;
64 import java.time.Duration;
65 import java.time.Period;
66 import java.time.temporal.ChronoUnit;
67 import java.util.ArrayList;
68 import java.util.HashSet;
69 import java.util.List;
71 import java.util.stream.Collectors;
73 import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_INDEX_PATH;
74 import static org.apache.archiva.indexer.ArchivaIndexManager.DEFAULT_PACKED_INDEX_PATH;
77 * Provider for the maven2 repository implementation
79 @Service("mavenRepositoryProvider")
80 public class MavenRepositoryProvider implements RepositoryProvider {
84 private ArchivaConfiguration archivaConfiguration;
87 private FileLockManager fileLockManager;
89 private final List<EventHandler<? super RepositoryEvent>> repositoryEventHandlers = new ArrayList<>( );
91 private static final Logger log = LoggerFactory.getLogger(MavenRepositoryProvider.class);
93 static final Set<RepositoryType> TYPES = new HashSet<>();
96 TYPES.add(RepositoryType.MAVEN);
100 public Set<RepositoryType> provides() {
105 public MavenManagedRepository createManagedInstance(String id, String name) {
106 return createManagedInstance(id, name, archivaConfiguration.getRemoteRepositoryBaseDir());
109 public MavenManagedRepository createManagedInstance(String id, String name, Path baseDir) {
110 FilesystemStorage storage;
112 storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
113 } catch (IOException e) {
114 log.error("Could not initialize fileystem for repository {}", id);
115 throw new RuntimeException(e);
117 MavenManagedRepository repo = new MavenManagedRepository( id, name, storage );
118 registerEventHandler( repo );
123 public MavenRemoteRepository createRemoteInstance(String id, String name) {
124 return createRemoteInstance(id, name, archivaConfiguration.getRemoteRepositoryBaseDir());
127 public MavenRemoteRepository createRemoteInstance(String id, String name, Path baseDir) {
128 FilesystemStorage storage;
130 storage = new FilesystemStorage(baseDir.resolve(id), fileLockManager);
131 } catch (IOException e) {
132 log.error("Could not initialize filesystem for repository {}: '{}'", id, e.getMessage());
133 throw new RuntimeException(e);
135 MavenRemoteRepository repo = new MavenRemoteRepository( id, name, storage );
136 registerEventHandler( repo );
141 public EditableRepositoryGroup createRepositoryGroup(String id, String name) {
142 return createRepositoryGroup(id, name, archivaConfiguration.getRepositoryGroupBaseDir().resolve( id ));
145 public MavenRepositoryGroup createRepositoryGroup(String id, String name, Path repositoryPath) {
146 FilesystemStorage storage;
148 storage = new FilesystemStorage(repositoryPath, fileLockManager);
149 } catch (IOException e) {
150 log.error("Could not initialize filesystem for repository {}: '{}'", id, e.getMessage());
151 throw new RuntimeException(e);
153 MavenRepositoryGroup group = new MavenRepositoryGroup( id, name, storage );
154 registerEventHandler( group );
158 private void registerEventHandler( Repository repo ) {
159 for (EventHandler<? super RepositoryEvent> eventHandler : repositoryEventHandlers) {
160 repo.registerEventHandler( RepositoryEvent.ANY, eventHandler );
164 private URI getURIFromString(String uriStr) throws RepositoryException {
167 if (StringUtils.isEmpty(uriStr)) {
170 if (uriStr.startsWith("/")) {
171 // only absolute paths are prepended with file scheme
172 uri = new URI("file://" + uriStr);
173 } else if (uriStr.contains(":\\")) {
174 //windows absolute path drive
175 uri = new URI("file:///" + uriStr.replaceAll("\\\\", "/"));
177 uri = new URI(uriStr);
179 if (uri.getScheme() != null && !"file".equals(uri.getScheme())) {
180 log.error("Bad URI scheme found: {}, URI={}", uri.getScheme(), uri);
181 throw new RepositoryException("The uri " + uriStr + " is not valid. Only file:// URI is allowed for maven.");
183 } catch (URISyntaxException e) {
184 String newCfg = "file://" + uriStr;
186 uri = new URI(newCfg);
187 } catch (URISyntaxException e1) {
188 log.error("Could not create URI from {} -> {}", uriStr, newCfg);
189 throw new RepositoryException("The config entry " + uriStr + " cannot be converted to URI.");
192 log.debug("Setting location uri: {}", uri);
197 public ManagedRepository createManagedInstance(ManagedRepositoryConfiguration cfg) throws RepositoryException {
198 MavenManagedRepository repo = createManagedInstance(cfg.getId(), cfg.getName(), Paths.get(cfg.getLocation()).getParent());
199 updateManagedInstance(repo, cfg);
204 public void updateManagedInstance(EditableManagedRepository repo, ManagedRepositoryConfiguration cfg) throws RepositoryException {
206 repo.setLocation(getURIFromString(cfg.getLocation()));
207 } catch (UnsupportedURIException e) {
208 throw new RepositoryException("The location entry is not a valid uri: " + cfg.getLocation());
210 setBaseConfig(repo, cfg);
211 Path repoDir = repo.getRoot().getFilePath();
212 if (!Files.exists(repoDir)) {
213 log.debug("Creating repo directory {}", repoDir);
215 Files.createDirectories(repoDir);
216 } catch (IOException e) {
217 log.error("Could not create directory {} for repository {}", repoDir, repo.getId(), e);
218 throw new RepositoryException("Could not create directory for repository " + repoDir);
221 repo.setSchedulingDefinition(cfg.getRefreshCronExpression());
222 repo.setBlocksRedeployment(cfg.isBlockRedeployments());
223 repo.setScanned(cfg.isScanned());
224 if (cfg.isReleases()) {
225 repo.addActiveReleaseScheme(ReleaseScheme.RELEASE);
227 repo.removeActiveReleaseScheme(ReleaseScheme.RELEASE);
229 if (cfg.isSnapshots()) {
230 repo.addActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
232 repo.removeActiveReleaseScheme(ReleaseScheme.SNAPSHOT);
235 StagingRepositoryFeature stagingRepositoryFeature = repo.getFeature(StagingRepositoryFeature.class).get();
236 stagingRepositoryFeature.setStageRepoNeeded(cfg.isStageRepoNeeded());
238 IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get();
239 indexCreationFeature.setSkipPackedIndexCreation(cfg.isSkipPackedIndexCreation());
240 String indexDir = StringUtils.isEmpty( cfg.getIndexDir() ) ? DEFAULT_INDEX_PATH : cfg.getIndexDir();
241 String packedIndexDir = StringUtils.isEmpty( cfg.getPackedIndexDir() ) ? DEFAULT_PACKED_INDEX_PATH : cfg.getPackedIndexDir();
242 indexCreationFeature.setIndexPath(getURIFromString(indexDir));
243 indexCreationFeature.setPackedIndexPath(getURIFromString(packedIndexDir));
245 ArtifactCleanupFeature artifactCleanupFeature = repo.getFeature(ArtifactCleanupFeature.class).get();
247 artifactCleanupFeature.setDeleteReleasedSnapshots(cfg.isDeleteReleasedSnapshots());
248 artifactCleanupFeature.setRetentionCount(cfg.getRetentionCount());
249 artifactCleanupFeature.setRetentionPeriod(Period.ofDays(cfg.getRetentionPeriod()));
254 public ManagedRepository createStagingInstance(ManagedRepositoryConfiguration baseConfiguration) throws RepositoryException {
255 log.debug("Creating staging instance for {}", baseConfiguration.getId());
256 return createManagedInstance(getStageRepoConfig(baseConfiguration));
261 public RemoteRepository createRemoteInstance(RemoteRepositoryConfiguration cfg) throws RepositoryException {
262 MavenRemoteRepository repo = createRemoteInstance(cfg.getId(), cfg.getName(), archivaConfiguration.getRemoteRepositoryBaseDir());
263 updateRemoteInstance(repo, cfg);
267 private String convertUriToPath(URI uri) {
268 if (uri.getScheme() == null) {
269 return uri.getPath();
270 } else if ("file".equals(uri.getScheme())) {
271 return Paths.get(uri).toString();
273 return uri.toString();
278 public void updateRemoteInstance(EditableRemoteRepository repo, RemoteRepositoryConfiguration cfg) throws RepositoryException {
279 setBaseConfig(repo, cfg);
280 repo.setCheckPath(cfg.getCheckPath());
281 repo.setSchedulingDefinition(cfg.getRefreshCronExpression());
283 repo.setLocation(new URI(cfg.getUrl()));
284 } catch (UnsupportedURIException | URISyntaxException e) {
285 log.error("Could not set remote url " + cfg.getUrl());
286 throw new RepositoryException("The url config is not a valid uri: " + cfg.getUrl());
288 repo.setTimeout(Duration.ofSeconds(cfg.getTimeout()));
289 RemoteIndexFeature remoteIndexFeature = repo.getFeature(RemoteIndexFeature.class).get();
290 remoteIndexFeature.setDownloadRemoteIndex(cfg.isDownloadRemoteIndex());
291 remoteIndexFeature.setDownloadRemoteIndexOnStartup(cfg.isDownloadRemoteIndexOnStartup());
292 remoteIndexFeature.setDownloadTimeout(Duration.ofSeconds(cfg.getRemoteDownloadTimeout()));
293 remoteIndexFeature.setProxyId(cfg.getRemoteDownloadNetworkProxyId());
294 if (cfg.isDownloadRemoteIndex()) {
296 remoteIndexFeature.setIndexUri(new URI(cfg.getRemoteIndexUrl()));
297 } catch (URISyntaxException e) {
298 log.error("Could not set remote index url " + cfg.getRemoteIndexUrl());
299 remoteIndexFeature.setDownloadRemoteIndex(false);
300 remoteIndexFeature.setDownloadRemoteIndexOnStartup(false);
303 for ( Object key : cfg.getExtraHeaders().keySet() ) {
304 repo.addExtraHeader( key.toString(), cfg.getExtraHeaders().get(key).toString() );
306 for ( Object key : cfg.getExtraParameters().keySet() ) {
307 repo.addExtraParameter( key.toString(), cfg.getExtraParameters().get(key).toString() );
309 PasswordCredentials credentials = new PasswordCredentials("", new char[0]);
310 if (cfg.getPassword() != null && cfg.getUsername() != null) {
311 credentials.setPassword(cfg.getPassword().toCharArray());
312 credentials.setUsername(cfg.getUsername());
313 repo.setCredentials(credentials);
315 credentials.setPassword(new char[0]);
317 IndexCreationFeature indexCreationFeature = repo.getFeature(IndexCreationFeature.class).get();
318 if (cfg.getIndexDir() != null) {
319 indexCreationFeature.setIndexPath(getURIFromString(cfg.getIndexDir()));
321 if (cfg.getPackedIndexDir() != null) {
322 indexCreationFeature.setPackedIndexPath(getURIFromString(cfg.getPackedIndexDir()));
324 log.debug("Updated remote instance {}", repo);
328 public RepositoryGroup createRepositoryGroup(RepositoryGroupConfiguration configuration) throws RepositoryException {
329 Path repositoryPath = getRepositoryGroupPath( configuration );
330 MavenRepositoryGroup newGrp = createRepositoryGroup(configuration.getId(), configuration.getName(),
332 updateRepositoryGroupInstance(newGrp, configuration);
336 private Path getRepositoryGroupPath(RepositoryGroupConfiguration configuration) {
337 if (StringUtils.isNotEmpty( configuration.getLocation() )) {
338 return Paths.get( configuration.getLocation( ) );
340 return getArchivaConfiguration( ).getRepositoryGroupBaseDir( ).resolve( configuration.getId( ) );
345 public void updateRepositoryGroupInstance(EditableRepositoryGroup repositoryGroup, RepositoryGroupConfiguration configuration) throws RepositoryException {
346 repositoryGroup.setName(repositoryGroup.getPrimaryLocale(), configuration.getName());
347 repositoryGroup.setMergedIndexTTL(configuration.getMergedIndexTtl());
348 repositoryGroup.setSchedulingDefinition(configuration.getCronExpression());
349 if (repositoryGroup.supportsFeature( IndexCreationFeature.class )) {
350 IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
351 indexCreationFeature.setIndexPath( getURIFromString(configuration.getMergedIndexPath()) );
352 Path localPath = Paths.get(configuration.getMergedIndexPath());
353 Path repoGroupPath = repositoryGroup.getRoot().getFilePath().toAbsolutePath();
354 if (localPath.isAbsolute() && !localPath.startsWith(repoGroupPath)) {
356 FilesystemStorage storage = new FilesystemStorage(localPath.getParent(), fileLockManager);
357 indexCreationFeature.setLocalIndexPath(storage.getAsset(localPath.getFileName().toString()));
358 } catch (IOException e) {
359 throw new RepositoryException("Could not initialize storage for index path "+localPath);
361 } else if (localPath.isAbsolute()) {
362 indexCreationFeature.setLocalIndexPath(repositoryGroup.getAsset(repoGroupPath.relativize(localPath).toString()));
365 indexCreationFeature.setLocalIndexPath(repositoryGroup.getAsset(localPath.toString()));
368 // References to other repositories are set filled by the registry
372 public RemoteRepositoryConfiguration getRemoteConfiguration(RemoteRepository remoteRepository) throws RepositoryException {
373 if (!(remoteRepository instanceof MavenRemoteRepository)) {
374 log.error("Wrong remote repository type " + remoteRepository.getClass().getName());
375 throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + remoteRepository.getClass().getName());
377 RemoteRepositoryConfiguration cfg = new RemoteRepositoryConfiguration();
378 cfg.setType(remoteRepository.getType().toString());
379 cfg.setId(remoteRepository.getId());
380 cfg.setName(remoteRepository.getName());
381 cfg.setDescription(remoteRepository.getDescription());
382 cfg.setUrl(remoteRepository.getLocation().toString());
383 cfg.setTimeout((int) remoteRepository.getTimeout().toMillis() / 1000);
384 cfg.setCheckPath(remoteRepository.getCheckPath());
385 RepositoryCredentials creds = remoteRepository.getLoginCredentials();
387 if (creds instanceof PasswordCredentials) {
388 PasswordCredentials pCreds = (PasswordCredentials) creds;
389 cfg.setPassword(new String(pCreds.getPassword()));
390 cfg.setUsername(pCreds.getUsername());
393 cfg.setLayout(remoteRepository.getLayout());
394 cfg.setExtraParameters(remoteRepository.getExtraParameters());
395 cfg.setExtraHeaders(remoteRepository.getExtraHeaders());
396 cfg.setRefreshCronExpression(remoteRepository.getSchedulingDefinition());
398 IndexCreationFeature indexCreationFeature = remoteRepository.getFeature(IndexCreationFeature.class).get();
399 cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath()));
400 cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath()));
402 RemoteIndexFeature remoteIndexFeature = remoteRepository.getFeature(RemoteIndexFeature.class).get();
403 if (remoteIndexFeature.getIndexUri() != null) {
404 cfg.setRemoteIndexUrl(remoteIndexFeature.getIndexUri().toString());
406 cfg.setRemoteDownloadTimeout((int) remoteIndexFeature.getDownloadTimeout().get(ChronoUnit.SECONDS));
407 cfg.setDownloadRemoteIndexOnStartup(remoteIndexFeature.isDownloadRemoteIndexOnStartup());
408 cfg.setDownloadRemoteIndex(remoteIndexFeature.isDownloadRemoteIndex());
409 cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId());
410 if (!StringUtils.isEmpty(remoteIndexFeature.getProxyId())) {
411 cfg.setRemoteDownloadNetworkProxyId(remoteIndexFeature.getProxyId());
413 cfg.setRemoteDownloadNetworkProxyId("");
424 public ManagedRepositoryConfiguration getManagedConfiguration(ManagedRepository managedRepository) throws RepositoryException {
425 if (!(managedRepository instanceof MavenManagedRepository || managedRepository instanceof BasicManagedRepository )) {
426 log.error("Wrong remote repository type " + managedRepository.getClass().getName());
427 throw new RepositoryException("The given repository type cannot be handled by the maven provider: " + managedRepository.getClass().getName());
429 ManagedRepositoryConfiguration cfg = new ManagedRepositoryConfiguration();
430 cfg.setType(managedRepository.getType().toString());
431 cfg.setId(managedRepository.getId());
432 cfg.setName(managedRepository.getName());
433 cfg.setDescription(managedRepository.getDescription());
434 cfg.setLocation(convertUriToPath(managedRepository.getLocation()));
435 cfg.setLayout(managedRepository.getLayout());
436 cfg.setRefreshCronExpression(managedRepository.getSchedulingDefinition());
437 cfg.setScanned(managedRepository.isScanned());
438 cfg.setBlockRedeployments(managedRepository.blocksRedeployments());
439 StagingRepositoryFeature stagingRepositoryFeature = managedRepository.getFeature(StagingRepositoryFeature.class).get();
440 cfg.setStageRepoNeeded(stagingRepositoryFeature.isStageRepoNeeded());
441 IndexCreationFeature indexCreationFeature = managedRepository.getFeature(IndexCreationFeature.class).get();
442 cfg.setIndexDir(convertUriToPath(indexCreationFeature.getIndexPath()));
443 cfg.setPackedIndexDir(convertUriToPath(indexCreationFeature.getPackedIndexPath()));
444 cfg.setSkipPackedIndexCreation(indexCreationFeature.isSkipPackedIndexCreation());
446 ArtifactCleanupFeature artifactCleanupFeature = managedRepository.getFeature(ArtifactCleanupFeature.class).get();
447 cfg.setRetentionCount(artifactCleanupFeature.getRetentionCount());
448 cfg.setRetentionPeriod(artifactCleanupFeature.getRetentionPeriod().getDays());
449 cfg.setDeleteReleasedSnapshots(artifactCleanupFeature.isDeleteReleasedSnapshots());
451 cfg.setReleases( managedRepository.getActiveReleaseSchemes( ).contains( ReleaseScheme.RELEASE ) );
452 cfg.setSnapshots( managedRepository.getActiveReleaseSchemes( ).contains( ReleaseScheme.SNAPSHOT ) );
458 public RepositoryGroupConfiguration getRepositoryGroupConfiguration(RepositoryGroup repositoryGroup) throws RepositoryException {
459 if (repositoryGroup.getType() != RepositoryType.MAVEN) {
460 throw new RepositoryException("The given repository group is not of MAVEN type");
462 RepositoryGroupConfiguration cfg = new RepositoryGroupConfiguration();
463 cfg.setId(repositoryGroup.getId());
464 cfg.setName(repositoryGroup.getName());
465 if (repositoryGroup.supportsFeature( IndexCreationFeature.class ))
467 IndexCreationFeature indexCreationFeature = repositoryGroup.getFeature( IndexCreationFeature.class ).get();
469 cfg.setMergedIndexPath( indexCreationFeature.getIndexPath().toString() );
471 cfg.setMergedIndexTtl(repositoryGroup.getMergedIndexTTL());
472 cfg.setRepositories(repositoryGroup.getRepositories().stream().map( Repository::getId ).collect(Collectors.toList()));
473 cfg.setCronExpression(repositoryGroup.getSchedulingDefinition());
478 public void addRepositoryEventHandler( EventHandler<? super RepositoryEvent> eventHandler )
480 this.repositoryEventHandlers.add( eventHandler );
483 private ManagedRepositoryConfiguration getStageRepoConfig(ManagedRepositoryConfiguration repository) {
484 ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
485 stagingRepository.setId(repository.getId() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
486 stagingRepository.setLayout(repository.getLayout());
487 stagingRepository.setName(repository.getName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
488 stagingRepository.setBlockRedeployments(repository.isBlockRedeployments());
489 stagingRepository.setRetentionPeriod(repository.getRetentionPeriod());
490 stagingRepository.setDeleteReleasedSnapshots(repository.isDeleteReleasedSnapshots());
491 stagingRepository.setStageRepoNeeded(false);
493 String path = repository.getLocation();
494 int lastIndex = path.replace('\\', '/').lastIndexOf('/');
495 stagingRepository.setLocation(path.substring(0, lastIndex) + "/" + stagingRepository.getId());
497 if (StringUtils.isNotBlank(repository.getIndexDir())) {
500 indexDir = Paths.get(new URI(repository.getIndexDir().startsWith("file://") ? repository.getIndexDir() : "file://" + repository.getIndexDir()));
501 if (indexDir.isAbsolute()) {
502 Path newDir = indexDir.getParent().resolve(indexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
503 log.debug("Changing index directory {} -> {}", indexDir, newDir);
504 stagingRepository.setIndexDir(newDir.toString());
506 log.debug("Keeping index directory {}", repository.getIndexDir());
507 stagingRepository.setIndexDir(repository.getIndexDir());
509 } catch (URISyntaxException e) {
510 log.error("Could not parse index path as uri {}", repository.getIndexDir());
511 stagingRepository.setIndexDir("");
513 // in case of absolute dir do not use the same
515 if (StringUtils.isNotBlank(repository.getPackedIndexDir())) {
517 packedIndexDir = Paths.get(repository.getPackedIndexDir());
518 if (packedIndexDir.isAbsolute()) {
519 Path newDir = packedIndexDir.getParent().resolve(packedIndexDir.getFileName() + StagingRepositoryFeature.STAGING_REPO_POSTFIX);
520 log.debug("Changing index directory {} -> {}", packedIndexDir, newDir);
521 stagingRepository.setPackedIndexDir(newDir.toString());
523 log.debug("Keeping index directory {}", repository.getPackedIndexDir());
524 stagingRepository.setPackedIndexDir(repository.getPackedIndexDir());
526 // in case of absolute dir do not use the same
528 stagingRepository.setRefreshCronExpression(repository.getRefreshCronExpression());
529 stagingRepository.setReleases(repository.isReleases());
530 stagingRepository.setRetentionCount(repository.getRetentionCount());
531 stagingRepository.setScanned(repository.isScanned());
532 stagingRepository.setSnapshots(repository.isSnapshots());
533 stagingRepository.setSkipPackedIndexCreation(repository.isSkipPackedIndexCreation());
534 // do not duplicate description
535 //stagingRepository.getDescription("")
536 return stagingRepository;
539 private void setBaseConfig( EditableRepository repo, AbstractRepositoryConfiguration cfg)
542 URI baseUri = archivaConfiguration.getRepositoryBaseDir().toUri();
543 repo.setBaseUri(baseUri);
545 repo.setName(repo.getPrimaryLocale(), cfg.getName());
546 repo.setDescription(repo.getPrimaryLocale(), cfg.getDescription());
547 repo.setLayout(cfg.getLayout());
550 public ArchivaConfiguration getArchivaConfiguration() {
551 return archivaConfiguration;
554 public void setArchivaConfiguration(ArchivaConfiguration archivaConfiguration) {
555 this.archivaConfiguration = archivaConfiguration;
559 public void handle(Event event) {