]> source.dussan.org Git - archiva.git/blob
bdc558afd509f6602cd919e2ba8a089cc8c5d665
[archiva.git] /
1 package org.apache.archiva.web.xmlrpc.services;
2
3 /*
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
11  *
12  *  http://www.apache.org/licenses/LICENSE-2.0
13  *
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
19  * under the License.
20  */
21
22 import org.apache.archiva.admin.AuditInformation;
23 import org.apache.archiva.admin.repository.RepositoryAdminException;
24 import org.apache.archiva.admin.repository.managed.ManagedRepositoryAdmin;
25 import org.apache.archiva.admin.repository.remote.RemoteRepositoryAdmin;
26 import org.apache.archiva.audit.AuditEvent;
27 import org.apache.archiva.audit.AuditListener;
28 import org.apache.archiva.metadata.model.ArtifactMetadata;
29 import org.apache.archiva.metadata.repository.MetadataRepository;
30 import org.apache.archiva.metadata.repository.RepositorySession;
31 import org.apache.archiva.metadata.repository.RepositorySessionFactory;
32 import org.apache.archiva.metadata.repository.filter.Filter;
33 import org.apache.archiva.metadata.repository.filter.IncludesFilter;
34 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
35 import org.apache.archiva.repository.events.RepositoryListener;
36 import org.apache.archiva.repository.scanner.RepositoryContentConsumers;
37 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
38 import org.apache.archiva.scheduler.repository.RepositoryTask;
39 import org.apache.archiva.stagerepository.merge.RepositoryMerger;
40 import org.apache.archiva.web.xmlrpc.api.AdministrationService;
41 import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
42 import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
43 import org.apache.commons.io.FileUtils;
44 import org.apache.commons.lang.StringUtils;
45 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
46 import org.apache.maven.archiva.configuration.Configuration;
47 import org.apache.maven.archiva.configuration.IndeterminateConfigurationException;
48 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
49 import org.apache.maven.archiva.configuration.ProxyConnectorConfiguration;
50 import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
51 import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
52 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
53 import org.apache.maven.archiva.model.VersionedReference;
54 import org.apache.maven.archiva.repository.ContentNotFoundException;
55 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
56 import org.apache.maven.archiva.repository.RepositoryContentFactory;
57 import org.apache.maven.archiva.repository.RepositoryException;
58 import org.apache.maven.archiva.repository.RepositoryNotFoundException;
59 import org.codehaus.plexus.registry.RegistryException;
60 import org.slf4j.Logger;
61 import org.slf4j.LoggerFactory;
62
63 import java.io.File;
64 import java.io.IOException;
65 import java.util.ArrayList;
66 import java.util.Collection;
67 import java.util.Date;
68 import java.util.List;
69 import java.util.Map;
70
71 /**
72  * AdministrationServiceImpl
73  *
74  * @version $Id: AdministrationServiceImpl.java
75  */
76 public class AdministrationServiceImpl
77     implements AdministrationService
78 {
79     protected Logger log = LoggerFactory.getLogger( getClass() );
80
81     private ArchivaConfiguration archivaConfiguration;
82
83     private RepositoryContentConsumers repoConsumersUtil;
84
85     private RepositoryContentFactory repoFactory;
86
87     private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
88
89     private Collection<RepositoryListener> listeners;
90
91     private RepositoryStatisticsManager repositoryStatisticsManager;
92
93     private RepositoryMerger repositoryMerger;
94
95     private static final String STAGE = "-stage";
96
97     private AuditListener auditListener;
98
99     private RepositorySessionFactory repositorySessionFactory;
100
101     private ManagedRepositoryAdmin managedRepositoryAdmin;
102
103     private RemoteRepositoryAdmin remoteRepositoryAdmin;
104
105     private static final String REPOSITORY_ID_VALID_EXPRESSION = "^[a-zA-Z0-9._-]+$";
106
107     private static final String REPOSITORY_NAME_VALID_EXPRESSION = "^([a-zA-Z0-9.)/_(-]|\\s)+$";
108
109     private static final String REPOSITORY_LOCATION_VALID_EXPRESSION = "^[-a-zA-Z0-9._/~:?!&amp;=\\\\]+$";
110
111     public AdministrationServiceImpl( ArchivaConfiguration archivaConfig, RepositoryContentConsumers repoConsumersUtil,
112                                       RepositoryContentFactory repoFactory,
113                                       RepositorySessionFactory repositorySessionFactory,
114                                       RepositoryArchivaTaskScheduler repositoryTaskScheduler,
115                                       Collection<RepositoryListener> listeners,
116                                       RepositoryStatisticsManager repositoryStatisticsManager,
117                                       RepositoryMerger repositoryMerger, AuditListener auditListener,
118                                       ManagedRepositoryAdmin managedRepositoryAdmin,
119                                       RemoteRepositoryAdmin remoteRepositoryAdmin )
120     {
121         this.archivaConfiguration = archivaConfig;
122         this.repoConsumersUtil = repoConsumersUtil;
123         this.repoFactory = repoFactory;
124         this.repositoryTaskScheduler = repositoryTaskScheduler;
125         this.listeners = listeners;
126         this.repositorySessionFactory = repositorySessionFactory;
127         this.repositoryStatisticsManager = repositoryStatisticsManager;
128         this.repositoryMerger = repositoryMerger;
129         this.auditListener = auditListener;
130         this.managedRepositoryAdmin = managedRepositoryAdmin;
131         this.remoteRepositoryAdmin = remoteRepositoryAdmin;
132     }
133
134     /**
135      * @see AdministrationService#configureRepositoryConsumer(String, String, boolean)
136      */
137     public Boolean configureRepositoryConsumer( String repoId, String consumerId, boolean enable )
138         throws Exception
139     {
140         // TODO use repoId once consumers are configured per repository! (MRM-930)
141
142         List<KnownRepositoryContentConsumer> knownConsumers = repoConsumersUtil.getAvailableKnownConsumers();
143         List<InvalidRepositoryContentConsumer> invalidConsumers = repoConsumersUtil.getAvailableInvalidConsumers();
144
145         boolean found = false;
146         boolean isKnownContentConsumer = false;
147         for ( KnownRepositoryContentConsumer consumer : knownConsumers )
148         {
149             if ( consumer.getId().equals( consumerId ) )
150             {
151                 found = true;
152                 isKnownContentConsumer = true;
153                 break;
154             }
155         }
156
157         if ( !found )
158         {
159             for ( InvalidRepositoryContentConsumer consumer : invalidConsumers )
160             {
161                 if ( consumer.getId().equals( consumerId ) )
162                 {
163                     found = true;
164                     break;
165                 }
166             }
167         }
168
169         if ( !found )
170         {
171             throw new Exception( "Invalid repository consumer." );
172         }
173
174         Configuration config = archivaConfiguration.getConfiguration();
175         RepositoryScanningConfiguration repoScanningConfig = config.getRepositoryScanning();
176
177         if ( isKnownContentConsumer )
178         {
179             repoScanningConfig.addKnownContentConsumer( consumerId );
180         }
181         else
182         {
183             repoScanningConfig.addInvalidContentConsumer( consumerId );
184         }
185
186         config.setRepositoryScanning( repoScanningConfig );
187         saveConfiguration( config );
188
189         return true;
190     }
191
192     /**
193      * @see AdministrationService#deleteArtifact(String, String, String, String)
194      */
195     public Boolean deleteArtifact( String repoId, String groupId, String artifactId, String version )
196         throws Exception
197     {
198         // TODO: remove duplication with web
199
200         Configuration config = archivaConfiguration.getConfiguration();
201         ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repoId );
202
203         if ( repoConfig == null )
204         {
205             throw new Exception( "Repository does not exist." );
206         }
207
208         RepositorySession repositorySession = repositorySessionFactory.createSession();
209         try
210         {
211             ManagedRepositoryContent repoContent = repoFactory.getManagedRepositoryContent( repoId );
212             VersionedReference ref = new VersionedReference();
213             ref.setGroupId( groupId );
214             ref.setArtifactId( artifactId );
215             ref.setVersion( version );
216
217             // delete from file system
218             repoContent.deleteVersion( ref );
219
220             MetadataRepository metadataRepository = repositorySession.getRepository();
221             Collection<ArtifactMetadata> artifacts =
222                 metadataRepository.getArtifacts( repoId, groupId, artifactId, version );
223
224             for ( ArtifactMetadata artifact : artifacts )
225             {
226                 // TODO: mismatch between artifact (snapshot) version and project (base) version here
227                 if ( artifact.getVersion().equals( version ) )
228                 {
229                     metadataRepository.removeArtifact( artifact.getRepositoryId(), artifact.getNamespace(),
230                                                        artifact.getProject(), artifact.getVersion(), artifact.getId() );
231
232                     // TODO: move into the metadata repository proper - need to differentiate attachment of
233                     // repository metadata to an artifact
234                     for ( RepositoryListener listener : listeners )
235                     {
236                         listener.deleteArtifact( metadataRepository, repoId, artifact.getNamespace(),
237                                                  artifact.getProject(), artifact.getVersion(), artifact.getId() );
238                     }
239                 }
240             }
241             repositorySession.save();
242         }
243         catch ( ContentNotFoundException e )
244         {
245             throw new Exception( "Artifact does not exist." );
246         }
247         catch ( RepositoryNotFoundException e )
248         {
249             throw new Exception( "Repository does not exist." );
250         }
251         catch ( RepositoryException e )
252         {
253             throw new Exception( "Repository exception occurred." );
254         }
255         finally
256         {
257             repositorySession.close();
258         }
259
260         return true;
261     }
262
263     /**
264      * @see AdministrationService#executeRepositoryScanner(String)
265      */
266     public Boolean executeRepositoryScanner( String repoId )
267         throws Exception
268     {
269         Configuration config = archivaConfiguration.getConfiguration();
270         if ( config.findManagedRepositoryById( repoId ) == null )
271         {
272             throw new Exception( "Repository does not exist." );
273         }
274
275         if ( repositoryTaskScheduler.isProcessingRepositoryTask( repoId ) )
276         {
277             return false;
278         }
279
280         RepositoryTask task = new RepositoryTask();
281         task.setRepositoryId( repoId );
282         repositoryTaskScheduler.queueTask( task );
283
284         return true;
285     }
286
287     /**
288      * @see AdministrationService#getAllRepositoryConsumers()
289      */
290     public List<String> getAllRepositoryConsumers()
291     {
292         List<String> consumers = new ArrayList<String>();
293
294         List<KnownRepositoryContentConsumer> knownConsumers = repoConsumersUtil.getAvailableKnownConsumers();
295         List<InvalidRepositoryContentConsumer> invalidConsumers = repoConsumersUtil.getAvailableInvalidConsumers();
296
297         for ( KnownRepositoryContentConsumer consumer : knownConsumers )
298         {
299             consumers.add( consumer.getId() );
300         }
301
302         for ( InvalidRepositoryContentConsumer consumer : invalidConsumers )
303         {
304             consumers.add( consumer.getId() );
305         }
306
307         return consumers;
308     }
309
310     /**
311      * @see AdministrationService#getAllManagedRepositories()
312      */
313     public List<ManagedRepository> getAllManagedRepositories()
314         throws RepositoryAdminException
315     {
316         List<ManagedRepository> managedRepos = new ArrayList<ManagedRepository>();
317
318         for ( org.apache.archiva.admin.repository.managed.ManagedRepository repoConfig : managedRepositoryAdmin.getManagedRepositories() )
319         {
320             ManagedRepository repo =
321                 new ManagedRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getLocation(),
322                                        repoConfig.getLayout(), repoConfig.isSnapshots(), repoConfig.isReleases() );
323             managedRepos.add( repo );
324         }
325
326         return managedRepos;
327     }
328
329     /**
330      * @see AdministrationService#getAllRemoteRepositories()
331      */
332     public List<RemoteRepository> getAllRemoteRepositories()
333         throws RepositoryAdminException
334     {
335         List<RemoteRepository> remoteRepos = new ArrayList<RemoteRepository>();
336
337         for ( org.apache.archiva.admin.repository.remote.RemoteRepository repoConfig : remoteRepositoryAdmin.getRemoteRepositories() )
338         {
339             RemoteRepository repo = new RemoteRepository( repoConfig.getId(), repoConfig.getName(), repoConfig.getUrl(),
340                                                           repoConfig.getLayout() );
341             remoteRepos.add( repo );
342         }
343
344         return remoteRepos;
345     }
346
347     private void saveConfiguration( Configuration config )
348         throws Exception
349     {
350         try
351         {
352             archivaConfiguration.save( config );
353         }
354         catch ( RegistryException e )
355         {
356             throw new Exception( "Error occurred in the registry." );
357         }
358         catch ( IndeterminateConfigurationException e )
359         {
360             throw new Exception( "Error occurred while saving the configuration." );
361         }
362     }
363
364     public Boolean addManagedRepository( String repoId, String layout, String name, String location,
365                                          boolean blockRedeployments, boolean releasesIncluded,
366                                          boolean snapshotsIncluded, boolean stageRepoNeeded, String cronExpression,
367                                          int daysOlder, int retentionCount, boolean deleteReleasedSnapshots )
368         throws Exception
369     {
370
371         org.apache.archiva.admin.repository.managed.ManagedRepository repository =
372             new org.apache.archiva.admin.repository.managed.ManagedRepository( repoId, name, location, layout,
373                                                                                snapshotsIncluded, releasesIncluded,
374                                                                                blockRedeployments, cronExpression, null,
375                                                                                false, daysOlder, retentionCount,
376                                                                                deleteReleasedSnapshots );
377         return managedRepositoryAdmin.addManagedRepository( repository, stageRepoNeeded, getAuditInformation() );
378
379     }
380
381     public Boolean deleteManagedRepository( String repoId )
382         throws Exception
383     {
384         Configuration config = archivaConfiguration.getConfiguration();
385
386         ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repoId );
387
388         if ( repository == null )
389         {
390             throw new Exception( "A repository with that id does not exist" );
391         }
392
393         RepositorySession repositorySession = repositorySessionFactory.createSession();
394         try
395         {
396             MetadataRepository metadataRepository = repositorySession.getRepository();
397             metadataRepository.removeRepository( repository.getId() );
398             repositoryStatisticsManager.deleteStatistics( metadataRepository, repository.getId() );
399             repositorySession.save();
400         }
401         finally
402         {
403             repositorySession.close();
404         }
405         config.removeManagedRepository( repository );
406
407         try
408         {
409             saveConfiguration( config );
410         }
411         catch ( Exception e )
412         {
413             throw new Exception( "Error saving configuration for delete action" + e.getMessage() );
414         }
415
416         File dir = new File( repository.getLocation() );
417         if ( !FileUtils.deleteQuietly( dir ) )
418         {
419             throw new IOException( "Cannot delete repository " + dir );
420         }
421
422         List<ProxyConnectorConfiguration> proxyConnectors = config.getProxyConnectors();
423         for ( ProxyConnectorConfiguration proxyConnector : proxyConnectors )
424         {
425             if ( StringUtils.equals( proxyConnector.getSourceRepoId(), repository.getId() ) )
426             {
427                 archivaConfiguration.getConfiguration().removeProxyConnector( proxyConnector );
428             }
429         }
430
431         Map<String, List<String>> repoToGroupMap = archivaConfiguration.getConfiguration().getRepositoryToGroupMap();
432         if ( repoToGroupMap != null )
433         {
434             if ( repoToGroupMap.containsKey( repository.getId() ) )
435             {
436                 List<String> repoGroups = repoToGroupMap.get( repository.getId() );
437                 for ( String repoGroup : repoGroups )
438                 {
439                     archivaConfiguration.getConfiguration().findRepositoryGroupById( repoGroup ).removeRepository(
440                         repository.getId() );
441                 }
442             }
443         }
444
445         return Boolean.TRUE;
446     }
447
448     public Boolean deleteManagedRepositoryContent( String repoId )
449         throws Exception
450     {
451         Configuration config = archivaConfiguration.getConfiguration();
452
453         ManagedRepositoryConfiguration repository = config.findManagedRepositoryById( repoId );
454
455         if ( repository == null )
456         {
457             throw new Exception( "Repository Id : " + repoId + " not found." );
458         }
459
460         RepositorySession repositorySession = repositorySessionFactory.createSession();
461         try
462         {
463             MetadataRepository metadataRepository = repositorySession.getRepository();
464             metadataRepository.removeRepository( repository.getId() );
465             repositorySession.save();
466         }
467         finally
468         {
469             repositorySession.close();
470         }
471
472         File repoDir = new File( repository.getLocation() );
473         File[] children = repoDir.listFiles();
474
475         if ( children != null )
476         {
477             for ( File child : children )
478             {
479                 FileUtils.deleteQuietly( child );
480             }
481
482             if ( repoDir.listFiles().length > 0 )
483             {
484                 throw new IOException( "Cannot delete repository contents of " + repoDir );
485             }
486         }
487
488         return Boolean.TRUE;
489     }
490
491     public ManagedRepository getManagedRepository( String repoId )
492         throws Exception
493     {
494         Configuration config = archivaConfiguration.getConfiguration();
495         ManagedRepositoryConfiguration managedRepository = config.findManagedRepositoryById( repoId );
496         if ( managedRepository == null )
497         {
498             throw new Exception( "A repository with that id does not exist" );
499         }
500         ManagedRepository repo = new ManagedRepository( managedRepository.getId(), managedRepository.getName(), "URL",
501                                                         managedRepository.getLayout(), managedRepository.isSnapshots(),
502                                                         managedRepository.isReleases() );
503
504         return repo;
505     }
506
507     public boolean merge( String repoId, boolean skipConflicts )
508         throws Exception
509     {
510         String stagingId = repoId + STAGE;
511         ManagedRepositoryConfiguration repoConfig;
512         ManagedRepositoryConfiguration stagingConfig;
513
514         Configuration config = archivaConfiguration.getConfiguration();
515         repoConfig = config.findManagedRepositoryById( repoId );
516
517         log.debug( "Retrieved repository configuration for repo '" + repoId + "'" );
518
519         RepositorySession repositorySession = repositorySessionFactory.createSession();
520         try
521         {
522             MetadataRepository metadataRepository = repositorySession.getRepository();
523             if ( repoConfig != null )
524             {
525                 stagingConfig = config.findManagedRepositoryById( stagingId );
526
527                 if ( stagingConfig != null )
528                 {
529                     List<ArtifactMetadata> sourceArtifacts = metadataRepository.getArtifacts( stagingId );
530
531                     if ( repoConfig.isReleases() && !repoConfig.isSnapshots() )
532                     {
533                         log.info( "Repository to be merged contains releases only.." );
534                         if ( skipConflicts )
535                         {
536                             List<ArtifactMetadata> conflicts =
537                                 repositoryMerger.getConflictingArtifacts( metadataRepository, repoId, stagingId );
538
539                             if ( log.isDebugEnabled() )
540                             {
541                                 log.debug( "Artifacts in conflict.." );
542                                 for ( ArtifactMetadata metadata : conflicts )
543                                 {
544                                     log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":"
545                                                    + metadata.getProjectVersion() );
546                                 }
547                             }
548
549                             sourceArtifacts.removeAll( conflicts );
550
551                             log.debug( "Source artifacts size :: " + sourceArtifacts.size() );
552                             mergeWithOutSnapshots( sourceArtifacts, stagingId, repoId, metadataRepository );
553                         }
554                         else
555                         {
556                             log.debug( "Source artifacts size :: " + sourceArtifacts.size() );
557                             mergeWithOutSnapshots( sourceArtifacts, stagingId, repoId, metadataRepository );
558                         }
559                     }
560                     else
561                     {
562                         log.info( "Repository to be merged has snapshot artifacts.." );
563                         if ( skipConflicts )
564                         {
565                             List<ArtifactMetadata> conflicts =
566                                 repositoryMerger.getConflictingArtifacts( metadataRepository, repoId, stagingId );
567
568                             if ( log.isDebugEnabled() )
569                             {
570                                 log.debug( "Artifacts in conflict.." );
571                                 for ( ArtifactMetadata metadata : conflicts )
572                                 {
573                                     log.debug( metadata.getNamespace() + ":" + metadata.getProject() + ":"
574                                                    + metadata.getProjectVersion() );
575                                 }
576                             }
577
578                             sourceArtifacts.removeAll( conflicts );
579
580                             log.debug( "Source artifacts size :: " + sourceArtifacts.size() );
581
582                             Filter<ArtifactMetadata> artifactsWithOutConflicts =
583                                 new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
584                             repositoryMerger.merge( metadataRepository, stagingId, repoId, artifactsWithOutConflicts );
585
586                             log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '"
587                                           + repoId + "'." );
588                         }
589                         else
590                         {
591                             repositoryMerger.merge( metadataRepository, stagingId, repoId );
592
593                             log.info( "Staging repository '" + stagingId + "' merged successfully with managed repo '"
594                                           + repoId + "'." );
595                         }
596                     }
597                 }
598                 else
599                 {
600                     throw new Exception( "Staging Id : " + stagingId + " not found." );
601                 }
602             }
603             else
604             {
605                 throw new Exception( "Repository Id : " + repoId + " not found." );
606             }
607
608             if ( !repositoryTaskScheduler.isProcessingRepositoryTask( repoId ) )
609             {
610                 RepositoryTask task = new RepositoryTask();
611                 task.setRepositoryId( repoId );
612
613                 repositoryTaskScheduler.queueTask( task );
614             }
615
616             AuditEvent event = createAuditEvent( repoConfig );
617
618             // add event for audit log reports
619             metadataRepository.addMetadataFacet( event.getRepositoryId(), event );
620
621             // log event in archiva audit log
622             auditListener.auditEvent( createAuditEvent( repoConfig ) );
623             repositorySession.save();
624         }
625         finally
626         {
627             repositorySession.close();
628         }
629
630         return true;
631     }
632
633     // todo: setting userid of audit event
634     private AuditEvent createAuditEvent( ManagedRepositoryConfiguration repoConfig )
635     {
636
637         AuditEvent event = new AuditEvent();
638         event.setAction( AuditEvent.MERGE_REPO_REMOTE );
639         event.setRepositoryId( repoConfig.getId() );
640         event.setResource( repoConfig.getLocation() );
641         event.setTimestamp( new Date() );
642
643         return event;
644     }
645
646     private void mergeWithOutSnapshots( List<ArtifactMetadata> sourceArtifacts, String sourceRepoId, String repoid,
647                                         MetadataRepository metadataRepository )
648         throws Exception
649     {
650         List<ArtifactMetadata> artifactsWithOutSnapshots = new ArrayList<ArtifactMetadata>();
651         for ( ArtifactMetadata metadata : sourceArtifacts )
652         {
653
654             if ( metadata.getProjectVersion().contains( "SNAPSHOT" ) )
655             {
656                 artifactsWithOutSnapshots.add( metadata );
657             }
658
659         }
660         sourceArtifacts.removeAll( artifactsWithOutSnapshots );
661
662         Filter<ArtifactMetadata> artifactListWithOutSnapShots = new IncludesFilter<ArtifactMetadata>( sourceArtifacts );
663
664         repositoryMerger.merge( metadataRepository, sourceRepoId, repoid, artifactListWithOutSnapShots );
665     }
666
667     private ManagedRepositoryConfiguration getStageRepoConfig( ManagedRepositoryConfiguration repository )
668     {
669         ManagedRepositoryConfiguration stagingRepository = new ManagedRepositoryConfiguration();
670         stagingRepository.setId( repository.getId() + "-stage" );
671         stagingRepository.setLayout( repository.getLayout() );
672         stagingRepository.setName( repository.getName() + "-stage" );
673         stagingRepository.setBlockRedeployments( repository.isBlockRedeployments() );
674         stagingRepository.setDaysOlder( repository.getDaysOlder() );
675         stagingRepository.setDeleteReleasedSnapshots( repository.isDeleteReleasedSnapshots() );
676         stagingRepository.setIndexDir( repository.getIndexDir() );
677         String path = repository.getLocation();
678         int lastIndex = path.lastIndexOf( '/' );
679         stagingRepository.setLocation( path.substring( 0, lastIndex ) + "/" + stagingRepository.getId() );
680         stagingRepository.setRefreshCronExpression( repository.getRefreshCronExpression() );
681         stagingRepository.setReleases( repository.isReleases() );
682         stagingRepository.setRetentionCount( repository.getRetentionCount() );
683         stagingRepository.setScanned( repository.isScanned() );
684         stagingRepository.setSnapshots( repository.isSnapshots() );
685         return stagingRepository;
686     }
687
688     // FIXME find a way to get user id and adress
689     private AuditInformation getAuditInformation()
690     {
691         return new AuditInformation( null, null );
692     }
693 }