]> source.dussan.org Git - archiva.git/blob
5e121406e0f2d62298c6256bfc2b1ec32b798080
[archiva.git] /
1 package org.apache.archiva.webdav;
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.model.RepositoryAdminException;
23 import org.apache.archiva.admin.model.beans.ManagedRepository;
24 import org.apache.archiva.admin.model.beans.RemoteRepository;
25 import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
26 import org.apache.archiva.admin.model.remote.RemoteRepositoryAdmin;
27 import org.apache.archiva.audit.AuditEvent;
28 import org.apache.archiva.audit.AuditListener;
29 import org.apache.archiva.audit.Auditable;
30 import org.apache.archiva.common.plexusbridge.PlexusSisuBridge;
31 import org.apache.archiva.common.plexusbridge.PlexusSisuBridgeException;
32 import org.apache.archiva.common.utils.PathUtil;
33 import org.apache.archiva.common.utils.VersionUtil;
34 import org.apache.archiva.configuration.ArchivaConfiguration;
35 import org.apache.archiva.configuration.RepositoryGroupConfiguration;
36 import org.apache.archiva.indexer.merger.IndexMerger;
37 import org.apache.archiva.indexer.merger.IndexMergerException;
38 import org.apache.archiva.indexer.merger.IndexMergerRequest;
39 import org.apache.archiva.indexer.merger.TemporaryGroupIndex;
40 import org.apache.archiva.indexer.search.RepositorySearch;
41 import org.apache.archiva.maven2.metadata.MavenMetadataReader;
42 import org.apache.archiva.metadata.repository.storage.RepositoryStorage;
43 import org.apache.archiva.model.ArchivaRepositoryMetadata;
44 import org.apache.archiva.model.ArtifactReference;
45 import org.apache.archiva.policies.ProxyDownloadException;
46 import org.apache.archiva.proxy.model.RepositoryProxyConnectors;
47 import org.apache.archiva.redback.authentication.AuthenticationException;
48 import org.apache.archiva.redback.authentication.AuthenticationResult;
49 import org.apache.archiva.redback.authorization.AuthorizationException;
50 import org.apache.archiva.redback.authorization.UnauthorizedException;
51 import org.apache.archiva.redback.integration.filter.authentication.HttpAuthenticator;
52 import org.apache.archiva.redback.policy.AccountLockedException;
53 import org.apache.archiva.redback.policy.MustChangePasswordException;
54 import org.apache.archiva.redback.system.SecuritySession;
55 import org.apache.archiva.redback.users.User;
56 import org.apache.archiva.redback.users.UserManager;
57 import org.apache.archiva.repository.ManagedRepositoryContent;
58 import org.apache.archiva.repository.RepositoryContentFactory;
59 import org.apache.archiva.repository.RepositoryException;
60 import org.apache.archiva.repository.RepositoryNotFoundException;
61 import org.apache.archiva.repository.content.legacy.LegacyPathParser;
62 import org.apache.archiva.repository.content.maven2.RepositoryRequest;
63 import org.apache.archiva.repository.layout.LayoutException;
64 import org.apache.archiva.repository.metadata.MetadataTools;
65 import org.apache.archiva.repository.metadata.RepositoryMetadataException;
66 import org.apache.archiva.repository.metadata.RepositoryMetadataMerge;
67 import org.apache.archiva.repository.metadata.RepositoryMetadataWriter;
68 import org.apache.archiva.scheduler.repository.model.RepositoryArchivaTaskScheduler;
69 import org.apache.archiva.security.ServletAuthenticator;
70 import org.apache.archiva.webdav.util.MimeTypes;
71 import org.apache.archiva.webdav.util.RepositoryPathUtil;
72 import org.apache.archiva.webdav.util.TemporaryGroupIndexSessionCleaner;
73 import org.apache.archiva.webdav.util.WebdavMethodUtil;
74 import org.apache.archiva.xml.XMLException;
75 import org.apache.commons.io.FileUtils;
76 import org.apache.commons.io.FilenameUtils;
77 import org.apache.commons.lang.StringUtils;
78 import org.apache.commons.lang.SystemUtils;
79 import org.apache.jackrabbit.webdav.DavException;
80 import org.apache.jackrabbit.webdav.DavResource;
81 import org.apache.jackrabbit.webdav.DavResourceFactory;
82 import org.apache.jackrabbit.webdav.DavResourceLocator;
83 import org.apache.jackrabbit.webdav.DavServletRequest;
84 import org.apache.jackrabbit.webdav.DavServletResponse;
85 import org.apache.jackrabbit.webdav.DavSession;
86 import org.apache.jackrabbit.webdav.lock.LockManager;
87 import org.apache.jackrabbit.webdav.lock.SimpleLockManager;
88 import org.apache.maven.index.context.IndexingContext;
89 import org.codehaus.plexus.digest.ChecksumFile;
90 import org.codehaus.plexus.digest.Digester;
91 import org.codehaus.plexus.digest.DigesterException;
92 import org.slf4j.Logger;
93 import org.slf4j.LoggerFactory;
94 import org.slf4j.MarkerFactory;
95 import org.springframework.context.ApplicationContext;
96 import org.springframework.stereotype.Service;
97
98 import javax.annotation.PostConstruct;
99 import javax.inject.Inject;
100 import javax.inject.Named;
101 import javax.servlet.http.HttpServletResponse;
102 import javax.servlet.http.HttpSession;
103 import java.io.File;
104 import java.io.IOException;
105 import java.util.ArrayList;
106 import java.util.Date;
107 import java.util.HashMap;
108 import java.util.HashSet;
109 import java.util.List;
110 import java.util.Map;
111 import java.util.Set;
112
113 /**
114  *
115  */
116 @Service( "davResourceFactory#archiva" )
117 public class ArchivaDavResourceFactory
118     implements DavResourceFactory, Auditable
119 {
120     private static final String PROXIED_SUFFIX = " (proxied)";
121
122     private static final String HTTP_PUT_METHOD = "PUT";
123
124     private Logger log = LoggerFactory.getLogger( ArchivaDavResourceFactory.class );
125
126     @Inject
127     private List<AuditListener> auditListeners = new ArrayList<AuditListener>();
128
129     @Inject
130     private RepositoryContentFactory repositoryFactory;
131
132     private RepositoryRequest repositoryRequest;
133
134     @Inject
135     @Named( value = "repositoryProxyConnectors#default" )
136     private RepositoryProxyConnectors connectors;
137
138     @Inject
139     private MetadataTools metadataTools;
140
141     @Inject
142     private MimeTypes mimeTypes;
143
144     private ArchivaConfiguration archivaConfiguration;
145
146     @Inject
147     private ServletAuthenticator servletAuth;
148
149     @Inject
150     @Named( value = "httpAuthenticator#basic" )
151     private HttpAuthenticator httpAuth;
152
153     @Inject
154     private RemoteRepositoryAdmin remoteRepositoryAdmin;
155
156     @Inject
157     private ManagedRepositoryAdmin managedRepositoryAdmin;
158
159     @Inject
160     private IndexMerger indexMerger;
161
162     @Inject
163     private RepositorySearch repositorySearch;
164
165     /**
166      * Lock Manager - use simple implementation from JackRabbit
167      */
168     private final LockManager lockManager = new SimpleLockManager();
169
170     private ChecksumFile checksum;
171
172     private Digester digestSha1;
173
174     private Digester digestMd5;
175
176     @Inject
177     @Named( value = "archivaTaskScheduler#repository" )
178     private RepositoryArchivaTaskScheduler scheduler;
179
180     private ApplicationContext applicationContext;
181
182     @Inject
183     public ArchivaDavResourceFactory( ApplicationContext applicationContext, PlexusSisuBridge plexusSisuBridge,
184                                       ArchivaConfiguration archivaConfiguration )
185         throws PlexusSisuBridgeException
186     {
187         this.archivaConfiguration = archivaConfiguration;
188         this.applicationContext = applicationContext;
189         this.checksum = plexusSisuBridge.lookup( ChecksumFile.class );
190
191         this.digestMd5 = plexusSisuBridge.lookup( Digester.class, "md5" );
192         this.digestSha1 = plexusSisuBridge.lookup( Digester.class, "sha1" );
193
194         // TODO remove this hard dependency on maven !!
195         repositoryRequest = new RepositoryRequest( new LegacyPathParser( archivaConfiguration ) );
196     }
197
198     @PostConstruct
199     public void initialize()
200     {
201
202     }
203
204     public DavResource createResource( final DavResourceLocator locator, final DavServletRequest request,
205                                        final DavServletResponse response )
206         throws DavException
207     {
208         ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );
209
210         RepositoryGroupConfiguration repoGroupConfig =
211             archivaConfiguration.getConfiguration().getRepositoryGroupsAsMap().get( archivaLocator.getRepositoryId() );
212
213         String activePrincipal = getActivePrincipal( request );
214
215         List<String> resourcesInAbsolutePath = new ArrayList<String>();
216
217         boolean readMethod = WebdavMethodUtil.isReadMethod( request.getMethod() );
218         DavResource resource;
219         if ( repoGroupConfig != null )
220         {
221             if ( !readMethod )
222             {
223                 throw new DavException( HttpServletResponse.SC_METHOD_NOT_ALLOWED,
224                                         "Write method not allowed for repository groups." );
225             }
226
227             log.debug( "Repository group '{}' accessed by '{}", repoGroupConfig.getId(), activePrincipal );
228
229             // handle browse requests for virtual repos
230             if ( RepositoryPathUtil.getLogicalResource( archivaLocator.getOrigResourcePath() ).endsWith( "/" ) )
231             {
232                 return getResourceFromGroup( request, repoGroupConfig.getRepositories(), archivaLocator,
233                                              repoGroupConfig );
234             }
235             else
236             {
237                 // make a copy to avoid potential concurrent modifications (eg. by configuration)
238                 // TODO: ultimately, locking might be more efficient than copying in this fashion since updates are
239                 //  infrequent
240                 List<String> repositories = new ArrayList<String>( repoGroupConfig.getRepositories() );
241                 resource = processRepositoryGroup( request, archivaLocator, repositories, activePrincipal,
242                                                    resourcesInAbsolutePath, repoGroupConfig );
243             }
244         }
245         else
246         {
247
248             try
249             {
250                 RemoteRepository remoteRepository =
251                     remoteRepositoryAdmin.getRemoteRepository( archivaLocator.getRepositoryId() );
252
253                 if ( remoteRepository != null )
254                 {
255                     String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
256                     IndexingContext indexingContext = remoteRepositoryAdmin.createIndexContext( remoteRepository );
257                     File resourceFile = StringUtils.equals( logicalResource, "/" )
258                         ? new File( indexingContext.getIndexDirectoryFile().getParent() )
259                         : new File( indexingContext.getIndexDirectoryFile().getParent(), logicalResource );
260                     resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), locator.getResourcePath(), null,
261                                                        request.getRemoteAddr(), activePrincipal,
262                                                        request.getDavSession(), archivaLocator, this, mimeTypes,
263                                                        auditListeners, scheduler );
264                     setHeaders( response, locator, resource );
265                     return resource;
266                 }
267             }
268             catch ( RepositoryAdminException e )
269             {
270                 log.debug( "RepositoryException remote repository with d'{}' not found, msg: {}",
271                            archivaLocator.getRepositoryId(), e.getMessage() );
272             }
273
274             ManagedRepositoryContent managedRepositoryContent = null;
275
276             try
277             {
278                 managedRepositoryContent = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
279             }
280             catch ( RepositoryNotFoundException e )
281             {
282                 throw new DavException( HttpServletResponse.SC_NOT_FOUND,
283                                         "Invalid repository: " + archivaLocator.getRepositoryId() );
284             }
285             catch ( RepositoryException e )
286             {
287                 throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
288             }
289
290             log.debug( "Managed repository '{}' accessed by '{}'", managedRepositoryContent.getId(), activePrincipal );
291
292             try
293             {
294                 resource = processRepository( request, archivaLocator, activePrincipal, managedRepositoryContent,
295                                               managedRepositoryAdmin.getManagedRepository( archivaLocator.getRepositoryId() ) );
296             }
297             catch ( RepositoryAdminException e )
298             {
299                 throw new DavException( 500, e );
300             }
301
302             String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
303             resourcesInAbsolutePath.add(
304                 new File( managedRepositoryContent.getRepoRoot(), logicalResource ).getAbsolutePath() );
305         }
306
307         String requestedResource = request.getRequestURI();
308
309         // MRM-872 : merge all available metadata
310         // merge metadata only when requested via the repo group
311         if ( ( repositoryRequest.isMetadata( requestedResource ) || repositoryRequest.isMetadataSupportFile(
312             requestedResource ) ) && repoGroupConfig != null )
313         {
314             // this should only be at the project level not version level!
315             if ( isProjectReference( requestedResource ) )
316             {
317
318                 ArchivaDavResource res = (ArchivaDavResource) resource;
319                 String filePath =
320                     StringUtils.substringBeforeLast( res.getLocalResource().getAbsolutePath().replace( '\\', '/' ),
321                                                      "/" );
322                 filePath = filePath + "/maven-metadata-" + repoGroupConfig.getId() + ".xml";
323
324                 // for MRM-872 handle checksums of the merged metadata files
325                 if ( repositoryRequest.isSupportFile( requestedResource ) )
326                 {
327                     File metadataChecksum =
328                         new File( filePath + "." + StringUtils.substringAfterLast( requestedResource, "." ) );
329                     if ( metadataChecksum.exists() )
330                     {
331                         LogicalResource logicalResource =
332                             new LogicalResource( RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );
333
334                         resource =
335                             new ArchivaDavResource( metadataChecksum.getAbsolutePath(), logicalResource.getPath(), null,
336                                                     request.getRemoteAddr(), activePrincipal, request.getDavSession(),
337                                                     archivaLocator, this, mimeTypes, auditListeners, scheduler );
338                     }
339                 }
340                 else
341                 {
342                     if ( resourcesInAbsolutePath != null && resourcesInAbsolutePath.size() > 1 )
343                     {
344                         // merge the metadata of all repos under group
345                         ArchivaRepositoryMetadata mergedMetadata = new ArchivaRepositoryMetadata();
346                         for ( String resourceAbsPath : resourcesInAbsolutePath )
347                         {
348                             try
349                             {
350                                 File metadataFile = new File( resourceAbsPath );
351                                 ArchivaRepositoryMetadata repoMetadata = MavenMetadataReader.read( metadataFile );
352                                 mergedMetadata = RepositoryMetadataMerge.merge( mergedMetadata, repoMetadata );
353                             }
354                             catch ( XMLException e )
355                             {
356                                 throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
357                                                         "Error occurred while reading metadata file." );
358                             }
359                             catch ( RepositoryMetadataException r )
360                             {
361                                 throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
362                                                         "Error occurred while merging metadata file." );
363                             }
364                         }
365
366                         try
367                         {
368                             File resourceFile = writeMergedMetadataToFile( mergedMetadata, filePath );
369
370                             LogicalResource logicalResource = new LogicalResource(
371                                 RepositoryPathUtil.getLogicalResource( locator.getResourcePath() ) );
372
373                             resource =
374                                 new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(), null,
375                                                         request.getRemoteAddr(), activePrincipal,
376                                                         request.getDavSession(), archivaLocator, this, mimeTypes,
377                                                         auditListeners, scheduler );
378                         }
379                         catch ( RepositoryMetadataException r )
380                         {
381                             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
382                                                     "Error occurred while writing metadata file." );
383                         }
384                         catch ( IOException ie )
385                         {
386                             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
387                                                     "Error occurred while generating checksum files." );
388                         }
389                         catch ( DigesterException de )
390                         {
391                             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
392                                                     "Error occurred while generating checksum files." );
393                         }
394                     }
395                 }
396             }
397         }
398
399         setHeaders( response, locator, resource );
400
401         // compatibility with MRM-440 to ensure browsing the repository works ok
402         if ( resource.isCollection() && !request.getRequestURI().endsWith( "/" ) )
403         {
404             throw new BrowserRedirectException( resource.getHref() );
405         }
406         resource.addLockManager( lockManager );
407         return resource;
408     }
409
410     private DavResource processRepositoryGroup( final DavServletRequest request,
411                                                 ArchivaDavResourceLocator archivaLocator, List<String> repositories,
412                                                 String activePrincipal, List<String> resourcesInAbsolutePath,
413                                                 RepositoryGroupConfiguration repoGroupConfig )
414         throws DavException
415     {
416         DavResource resource = null;
417         List<DavException> storedExceptions = new ArrayList<DavException>();
418
419         String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
420
421         String rootPath = StringUtils.substringBeforeLast( pathInfo, "/" );
422
423         if ( StringUtils.endsWith( rootPath, repoGroupConfig.getMergedIndexPath() ) )
424         {
425             // we are in the case of index file request
426             String requestedFileName = StringUtils.substringAfterLast( pathInfo, "/" );
427             File temporaryIndexDirectory =
428                 buildMergedIndexDirectory( repositories, activePrincipal, request, repoGroupConfig );
429
430             File resourceFile = new File( temporaryIndexDirectory, requestedFileName );
431             resource = new ArchivaDavResource( resourceFile.getAbsolutePath(), requestedFileName, null,
432                                                request.getRemoteAddr(), activePrincipal, request.getDavSession(),
433                                                archivaLocator, this, mimeTypes, auditListeners, scheduler );
434
435         }
436         else
437         {
438             for ( String repositoryId : repositories )
439             {
440                 ManagedRepositoryContent managedRepository;
441                 try
442                 {
443                     managedRepository = repositoryFactory.getManagedRepositoryContent( repositoryId );
444                 }
445                 catch ( RepositoryNotFoundException e )
446                 {
447                     throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
448                 }
449                 catch ( RepositoryException e )
450                 {
451                     throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
452                 }
453
454                 try
455                 {
456                     DavResource updatedResource =
457                         processRepository( request, archivaLocator, activePrincipal, managedRepository,
458                                            managedRepositoryAdmin.getManagedRepository( repositoryId ) );
459                     if ( resource == null )
460                     {
461                         resource = updatedResource;
462                     }
463
464                     String logicalResource = RepositoryPathUtil.getLogicalResource( archivaLocator.getResourcePath() );
465                     if ( logicalResource.endsWith( "/" ) )
466                     {
467                         logicalResource = logicalResource.substring( 1 );
468                     }
469                     resourcesInAbsolutePath.add(
470                         new File( managedRepository.getRepoRoot(), logicalResource ).getAbsolutePath() );
471                 }
472                 catch ( DavException e )
473                 {
474                     storedExceptions.add( e );
475                 }
476                 catch ( RepositoryAdminException e )
477                 {
478                     storedExceptions.add( new DavException( 500, e ) );
479                 }
480             }
481         }
482         if ( resource == null )
483         {
484             if ( !storedExceptions.isEmpty() )
485             {
486                 // MRM-1232
487                 for ( DavException e : storedExceptions )
488                 {
489                     if ( 401 == e.getErrorCode() )
490                     {
491                         throw e;
492                     }
493                 }
494
495                 throw new DavException( HttpServletResponse.SC_NOT_FOUND );
496             }
497             else
498             {
499                 throw new DavException( HttpServletResponse.SC_NOT_FOUND );
500             }
501         }
502         return resource;
503     }
504
505     private DavResource processRepository( final DavServletRequest request, ArchivaDavResourceLocator archivaLocator,
506                                            String activePrincipal, ManagedRepositoryContent managedRepositoryContent,
507                                            ManagedRepository managedRepository )
508         throws DavException
509     {
510         DavResource resource = null;
511         if ( isAuthorized( request, managedRepositoryContent.getId() ) )
512         {
513             RepositoryStorage repositoryStorage =
514                 this.applicationContext.getBean( "repositoryStorage#" + managedRepository.getLayout(),
515                                                  RepositoryStorage.class );
516             String path = repositoryStorage.getFilePath( archivaLocator.getResourcePath(), managedRepository );
517             if ( path.startsWith( "/" ) )
518             {
519                 path = path.substring( 1 );
520             }
521             LogicalResource logicalResource = new LogicalResource( path );
522             File resourceFile = new File( managedRepositoryContent.getRepoRoot(), path );
523             resource =
524                 new ArchivaDavResource( resourceFile.getAbsolutePath(), path, managedRepositoryContent.getRepository(),
525                                         request.getRemoteAddr(), activePrincipal, request.getDavSession(),
526                                         archivaLocator, this, mimeTypes, auditListeners, scheduler );
527
528             if ( WebdavMethodUtil.isReadMethod( request.getMethod() ) )
529             {
530                 if ( archivaLocator.getHref( false ).endsWith( "/" ) && !resourceFile.isDirectory() )
531                 {
532                     // force a resource not found
533                     throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource does not exist" );
534                 }
535                 else
536                 {
537                     if ( !resource.isCollection() )
538                     {
539                         boolean previouslyExisted = resourceFile.exists();
540
541                         // Attempt to fetch the resource from any defined proxy.
542                         boolean fromProxy =
543                             fetchContentFromProxies( managedRepositoryContent, request, logicalResource );
544
545                         // At this point the incoming request can either be in default or
546                         // legacy layout format.
547                         try
548                         {
549                             // Perform an adjustment of the resource to the managed
550                             // repository expected path.
551                             String localResourcePath =
552                                 repositoryRequest.toNativePath( logicalResource.getPath(), managedRepositoryContent );
553                             resourceFile = new File( managedRepositoryContent.getRepoRoot(), localResourcePath );
554                             resource =
555                                 new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource.getPath(),
556                                                         managedRepositoryContent.getRepository(),
557                                                         request.getRemoteAddr(), activePrincipal,
558                                                         request.getDavSession(), archivaLocator, this, mimeTypes,
559                                                         auditListeners, scheduler );
560                         }
561                         catch ( LayoutException e )
562                         {
563                             if ( !resourceFile.exists() )
564                             {
565                                 throw new DavException( HttpServletResponse.SC_NOT_FOUND, e );
566                             }
567                         }
568
569                         if ( fromProxy )
570                         {
571                             String event = ( previouslyExisted ? AuditEvent.MODIFY_FILE : AuditEvent.CREATE_FILE )
572                                 + PROXIED_SUFFIX;
573
574                             log.debug( "Proxied artifact '{}' in repository '{}' (current user '{}')",
575                                        resourceFile.getName(), managedRepositoryContent.getId(), activePrincipal );
576
577                             triggerAuditEvent( request.getRemoteAddr(), archivaLocator.getRepositoryId(),
578                                                logicalResource.getPath(), event, activePrincipal );
579                         }
580
581                         if ( !resourceFile.exists() )
582                         {
583                             throw new DavException( HttpServletResponse.SC_NOT_FOUND, "Resource does not exist" );
584                         }
585                     }
586                 }
587             }
588
589             if ( request.getMethod().equals( HTTP_PUT_METHOD ) )
590             {
591                 String resourcePath = logicalResource.getPath();
592
593                 // check if target repo is enabled for releases
594                 // we suppose that release-artifacts can be deployed only to repos enabled for releases
595                 if ( managedRepositoryContent.getRepository().isReleases() && !repositoryRequest.isMetadata(
596                     resourcePath ) && !repositoryRequest.isSupportFile( resourcePath ) )
597                 {
598                     ArtifactReference artifact = null;
599                     try
600                     {
601                         artifact = managedRepositoryContent.toArtifactReference( resourcePath );
602
603                         if ( !VersionUtil.isSnapshot( artifact.getVersion() ) )
604                         {
605                             // check if artifact already exists and if artifact re-deployment to the repository is allowed
606                             if ( managedRepositoryContent.hasContent( artifact )
607                                 && managedRepositoryContent.getRepository().isBlockRedeployments() )
608                             {
609                                 log.warn( "Overwriting released artifacts in repository '{}' is not allowed.",
610                                           managedRepositoryContent.getId() );
611                                 throw new DavException( HttpServletResponse.SC_CONFLICT,
612                                                         "Overwriting released artifacts is not allowed." );
613                             }
614                         }
615                     }
616                     catch ( LayoutException e )
617                     {
618                         log.warn( "Artifact path '{}' is invalid.", resourcePath );
619                     }
620                 }
621
622                 /*
623                  * Create parent directories that don't exist when writing a file This actually makes this
624                  * implementation not compliant to the WebDAV RFC - but we have enough knowledge about how the
625                  * collection is being used to do this reasonably and some versions of Maven's WebDAV don't correctly
626                  * create the collections themselves.
627                  */
628
629                 File rootDirectory = new File( managedRepositoryContent.getRepoRoot() );
630                 File destDir = new File( rootDirectory, logicalResource.getPath() ).getParentFile();
631
632                 if ( !destDir.exists() )
633                 {
634                     destDir.mkdirs();
635                     String relPath = PathUtil.getRelative( rootDirectory.getAbsolutePath(), destDir );
636
637                     log.debug( "Creating destination directory '{}' (current user '{}')", destDir.getName(),
638                                activePrincipal );
639
640                     triggerAuditEvent( request.getRemoteAddr(), managedRepositoryContent.getId(), relPath,
641                                        AuditEvent.CREATE_DIR, activePrincipal );
642                 }
643             }
644         } return resource;
645     }
646
647     public DavResource createResource( final DavResourceLocator locator, final DavSession davSession )
648         throws DavException
649     {
650         ArchivaDavResourceLocator archivaLocator = checkLocatorIsInstanceOfRepositoryLocator( locator );
651
652         ManagedRepositoryContent managedRepository;
653         try
654         {
655             managedRepository = repositoryFactory.getManagedRepositoryContent( archivaLocator.getRepositoryId() );
656         }
657         catch ( RepositoryNotFoundException e )
658         {
659             throw new DavException( HttpServletResponse.SC_NOT_FOUND,
660                                     "Invalid repository: " + archivaLocator.getRepositoryId() );
661         }
662         catch ( RepositoryException e )
663         {
664             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e );
665         }
666
667         String logicalResource = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
668         if ( logicalResource.startsWith( "/" ) )
669         {
670             logicalResource = logicalResource.substring( 1 );
671         }
672         File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource );
673         DavResource resource =
674             new ArchivaDavResource( resourceFile.getAbsolutePath(), logicalResource, managedRepository.getRepository(),
675                                     davSession, archivaLocator, this, mimeTypes, auditListeners, scheduler );
676
677         resource.addLockManager( lockManager );
678         return resource;
679     }
680
681     private boolean fetchContentFromProxies( ManagedRepositoryContent managedRepository, DavServletRequest request,
682                                              LogicalResource resource )
683         throws DavException
684     {
685         String path = resource.getPath();
686         if ( repositoryRequest.isSupportFile( path ) )
687         {
688             File proxiedFile = connectors.fetchFromProxies( managedRepository, path );
689
690             return ( proxiedFile != null );
691         }
692
693         // Is it a Metadata resource?
694         if ( repositoryRequest.isDefault( path ) && repositoryRequest.isMetadata( path ) )
695         {
696             return connectors.fetchMetatadaFromProxies( managedRepository, path ) != null;
697         }
698
699         // Is it an Archetype Catalog?
700         if ( repositoryRequest.isArchetypeCatalog( path ) )
701         {
702             // FIXME we must implement a merge of remote archetype catalog from remote servers.
703             File proxiedFile = connectors.fetchFromProxies( managedRepository, path );
704
705             return ( proxiedFile != null );
706         }
707
708         // Not any of the above? Then it's gotta be an artifact reference.
709         try
710         {
711             // Get the artifact reference in a layout neutral way.
712             ArtifactReference artifact = repositoryRequest.toArtifactReference( path );
713
714             if ( artifact != null )
715             {
716                 String repositoryLayout = managedRepository.getRepository().getLayout();
717
718                 RepositoryStorage repositoryStorage =
719                     this.applicationContext.getBean( "repositoryStorage#" + repositoryLayout, RepositoryStorage.class );
720                 repositoryStorage.applyServerSideRelocation( managedRepository, artifact );
721
722                 File proxiedFile = connectors.fetchFromProxies( managedRepository, artifact );
723
724                 resource.setPath( managedRepository.toPath( artifact ) );
725
726                 log.debug( "Proxied artifact '{}:{}:{}'", artifact.getGroupId(), artifact.getArtifactId(),
727                            artifact.getVersion() );
728
729                 return ( proxiedFile != null );
730             }
731         }
732         catch ( LayoutException e )
733         {
734             /* eat it */
735         }
736         catch ( ProxyDownloadException e )
737         {
738             log.error( e.getMessage(), e );
739             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
740                                     "Unable to fetch artifact resource." );
741         }
742         return false;
743     }
744
745     // TODO: remove?
746
747     private void triggerAuditEvent( String remoteIP, String repositoryId, String resource, String action,
748                                     String principal )
749     {
750         AuditEvent event = new AuditEvent( repositoryId, principal, resource, action );
751         event.setRemoteIP( remoteIP );
752
753         for ( AuditListener listener : auditListeners )
754         {
755             listener.auditEvent( event );
756         }
757     }
758
759     public void addAuditListener( AuditListener listener )
760     {
761         this.auditListeners.add( listener );
762     }
763
764     public void clearAuditListeners()
765     {
766         this.auditListeners.clear();
767     }
768
769     public void removeAuditListener( AuditListener listener )
770     {
771         this.auditListeners.remove( listener );
772     }
773
774     private void setHeaders( DavServletResponse response, DavResourceLocator locator, DavResource resource )
775     {
776         // [MRM-503] - Metadata file need Pragma:no-cache response
777         // header.
778         if ( locator.getResourcePath().endsWith( "/maven-metadata.xml" )
779             || ( (ArchivaDavResource) resource ).getLocalResource().isDirectory() )
780         {
781             response.setHeader( "Pragma", "no-cache" );
782             response.setHeader( "Cache-Control", "no-cache" );
783             response.setDateHeader( "Last-Modified", new Date().getTime() );
784         }
785         // if the resource is a directory don't cache it as new groupId deployed will be available
786         // without need of refreshing browser
787         else
788         {
789             // We need to specify this so connecting wagons can work correctly
790             response.setDateHeader( "Last-Modified", resource.getModificationTime() );
791         }
792         // TODO: [MRM-524] determine http caching options for other types of files (artifacts, sha1, md5, snapshots)
793     }
794
795     private ArchivaDavResourceLocator checkLocatorIsInstanceOfRepositoryLocator( DavResourceLocator locator )
796         throws DavException
797     {
798         if ( !( locator instanceof ArchivaDavResourceLocator ) )
799         {
800             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
801                                     "Locator does not implement RepositoryLocator" );
802         }
803
804         // Hidden paths
805         if ( locator.getResourcePath().startsWith( ArchivaDavResource.HIDDEN_PATH_PREFIX ) )
806         {
807             throw new DavException( HttpServletResponse.SC_NOT_FOUND );
808         }
809
810         ArchivaDavResourceLocator archivaLocator = (ArchivaDavResourceLocator) locator;
811
812         // MRM-419 - Windows Webdav support. Should not 404 if there is no content.
813         if ( StringUtils.isEmpty( archivaLocator.getRepositoryId() ) )
814         {
815             throw new DavException( HttpServletResponse.SC_NO_CONTENT );
816         }
817         return archivaLocator;
818     }
819
820     private static class LogicalResource
821     {
822         private String path;
823
824         public LogicalResource( String path )
825         {
826             this.path = path;
827         }
828
829         public String getPath()
830         {
831             return path;
832         }
833
834         public void setPath( String path )
835         {
836             this.path = path;
837         }
838     }
839
840     protected boolean isAuthorized( DavServletRequest request, String repositoryId )
841         throws DavException
842     {
843         try
844         {
845             AuthenticationResult result = httpAuth.getAuthenticationResult( request, null );
846             SecuritySession securitySession = httpAuth.getSecuritySession( request.getSession( true ) );
847
848             return servletAuth.isAuthenticated( request, result ) && servletAuth.isAuthorized( request, securitySession,
849                                                                                                repositoryId,
850                                                                                                WebdavMethodUtil.getMethodPermission(
851                                                                                                    request.getMethod() ) );
852         }
853         catch ( AuthenticationException e )
854         {
855             // safety check for MRM-911
856             String guest = UserManager.GUEST_USERNAME;
857             try
858             {
859                 if ( servletAuth.isAuthorized( guest,
860                                                ( (ArchivaDavResourceLocator) request.getRequestLocator() ).getRepositoryId(),
861                                                WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) )
862                 {
863                     return true;
864                 }
865             }
866             catch ( UnauthorizedException ae )
867             {
868                 throw new UnauthorizedDavException( repositoryId,
869                                                     "You are not authenticated and authorized to access any repository." );
870             }
871
872             throw new UnauthorizedDavException( repositoryId, "You are not authenticated" );
873         }
874         catch ( MustChangePasswordException e )
875         {
876             throw new UnauthorizedDavException( repositoryId, "You must change your password." );
877         }
878         catch ( AccountLockedException e )
879         {
880             throw new UnauthorizedDavException( repositoryId, "User account is locked." );
881         }
882         catch ( AuthorizationException e )
883         {
884             throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
885                                     "Fatal Authorization Subsystem Error." );
886         }
887         catch ( UnauthorizedException e )
888         {
889             throw new UnauthorizedDavException( repositoryId, e.getMessage() );
890         }
891     }
892
893     private DavResource getResourceFromGroup( DavServletRequest request, List<String> repositories,
894                                               ArchivaDavResourceLocator locator,
895                                               RepositoryGroupConfiguration repositoryGroupConfiguration )
896         throws DavException
897     {
898         List<File> mergedRepositoryContents = new ArrayList<File>();
899         String path = RepositoryPathUtil.getLogicalResource( locator.getResourcePath() );
900         if ( path.startsWith( "/" ) )
901         {
902             path = path.substring( 1 );
903         }
904         LogicalResource logicalResource = new LogicalResource( path );
905
906         // flow:
907         // if the current user logged in has permission to any of the repositories, allow user to
908         // browse the repo group but displaying only the repositories which the user has permission to access.
909         // otherwise, prompt for authentication.
910
911         String activePrincipal = getActivePrincipal( request );
912
913         boolean allow = isAllowedToContinue( request, repositories, activePrincipal );
914
915         // remove last /
916         String pathInfo = StringUtils.removeEnd( request.getPathInfo(), "/" );
917
918         if ( allow )
919         {
920
921             if ( StringUtils.endsWith( pathInfo, repositoryGroupConfiguration.getMergedIndexPath() ) )
922             {
923                 File mergedRepoDir =
924                     buildMergedIndexDirectory( repositories, activePrincipal, request, repositoryGroupConfiguration );
925                 mergedRepositoryContents.add( mergedRepoDir );
926             }
927             else
928             {
929                 if ( StringUtils.equalsIgnoreCase( pathInfo, "/" + repositoryGroupConfiguration.getId() ) )
930                 {
931                     File tmpDirectory = new File( SystemUtils.getJavaIoTmpDir(),
932                                                   repositoryGroupConfiguration.getId() + "/"
933                                                       + repositoryGroupConfiguration.getMergedIndexPath() );
934                     if ( !tmpDirectory.exists() )
935                     {
936                         synchronized ( tmpDirectory.getAbsolutePath() )
937                         {
938                             if ( !tmpDirectory.exists() )
939                             {
940                                 tmpDirectory.mkdirs();
941                             }
942                         }
943                     }
944                     mergedRepositoryContents.add( tmpDirectory.getParentFile() );
945                 }
946                 for ( String repository : repositories )
947                 {
948                     ManagedRepositoryContent managedRepository = null;
949
950                     try
951                     {
952                         managedRepository = repositoryFactory.getManagedRepositoryContent( repository );
953                     }
954                     catch ( RepositoryNotFoundException e )
955                     {
956                         throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
957                                                 "Invalid managed repository <" + repository + ">: " + e.getMessage() );
958                     }
959                     catch ( RepositoryException e )
960                     {
961                         throw new DavException( HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
962                                                 "Invalid managed repository <" + repository + ">: " + e.getMessage() );
963                     }
964
965                     File resourceFile = new File( managedRepository.getRepoRoot(), logicalResource.getPath() );
966                     if ( resourceFile.exists() )
967                     {
968                         // in case of group displaying index directory doesn't have sense !!
969                         String repoIndexDirectory = managedRepository.getRepository().getIndexDirectory();
970                         if ( StringUtils.isNotEmpty( repoIndexDirectory ) )
971                         {
972                             if ( !new File( repoIndexDirectory ).isAbsolute() )
973                             {
974                                 repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
975                                                                StringUtils.isEmpty( repoIndexDirectory )
976                                                                    ? ".indexer"
977                                                                    : repoIndexDirectory ).getAbsolutePath();
978                             }
979                         }
980                         if ( StringUtils.isEmpty( repoIndexDirectory ) )
981                         {
982                             repoIndexDirectory = new File( managedRepository.getRepository().getLocation(),
983                                                            ".indexer" ).getAbsolutePath();
984                         }
985
986                         if ( !StringUtils.equals( FilenameUtils.normalize( repoIndexDirectory ),
987                                                   FilenameUtils.normalize( resourceFile.getAbsolutePath() ) ) )
988                         {
989                             // for prompted authentication
990                             if ( httpAuth.getSecuritySession( request.getSession( true ) ) != null )
991                             {
992                                 try
993                                 {
994                                     if ( isAuthorized( request, repository ) )
995                                     {
996                                         mergedRepositoryContents.add( resourceFile );
997                                         log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
998                                     }
999                                 }
1000                                 catch ( DavException e )
1001                                 {
1002                                     // TODO: review exception handling
1003
1004                                     log.debug( "Skipping repository '{}' for user '{}': {}", managedRepository,
1005                                                activePrincipal, e.getMessage() );
1006
1007                                 }
1008
1009                             }
1010                             else
1011                             {
1012                                 // for the current user logged in
1013                                 try
1014                                 {
1015                                     if ( servletAuth.isAuthorized( activePrincipal, repository,
1016                                                                    WebdavMethodUtil.getMethodPermission(
1017                                                                        request.getMethod() ) ) )
1018                                     {
1019                                         mergedRepositoryContents.add( resourceFile );
1020                                         log.debug( "Repository '{}' accessed by '{}'", repository, activePrincipal );
1021                                     }
1022                                 }
1023                                 catch ( UnauthorizedException e )
1024                                 {
1025                                     // TODO: review exception handling
1026
1027                                     log.debug( "Skipping repository '{}' for user '{}': {}", managedRepository,
1028                                                activePrincipal, e.getMessage() );
1029
1030                                 }
1031                             }
1032                         }
1033                     }
1034                 }
1035             }
1036         }
1037         else
1038         {
1039             throw new UnauthorizedDavException( locator.getRepositoryId(), "User not authorized." );
1040         }
1041
1042         ArchivaVirtualDavResource resource =
1043             new ArchivaVirtualDavResource( mergedRepositoryContents, logicalResource.getPath(), mimeTypes, locator,
1044                                            this );
1045
1046         // compatibility with MRM-440 to ensure browsing the repository group works ok
1047         if ( resource.isCollection() && !request.getRequestURI().endsWith( "/" ) )
1048         {
1049             throw new BrowserRedirectException( resource.getHref() );
1050         }
1051
1052         return resource;
1053     }
1054
1055     protected String getActivePrincipal( DavServletRequest request )
1056     {
1057         User sessionUser = httpAuth.getSessionUser( request.getSession() );
1058         return sessionUser != null ? sessionUser.getUsername() : UserManager.GUEST_USERNAME;
1059     }
1060
1061     /**
1062      * Check if the current user is authorized to access any of the repos
1063      *
1064      * @param request
1065      * @param repositories
1066      * @param activePrincipal
1067      * @return
1068      */
1069     private boolean isAllowedToContinue( DavServletRequest request, List<String> repositories, String activePrincipal )
1070     {
1071         // when no repositories configured it's impossible to browse nothing !
1072         // at least make possible to see nothing :-)
1073         if ( repositories == null || repositories.isEmpty() )
1074         {
1075             return true;
1076         }
1077
1078         boolean allow = false;
1079
1080         // if securitySession != null, it means that the user was prompted for authentication
1081         if ( httpAuth.getSecuritySession( request.getSession() ) != null )
1082         {
1083             for ( String repository : repositories )
1084             {
1085                 try
1086                 {
1087                     if ( isAuthorized( request, repository ) )
1088                     {
1089                         allow = true;
1090                         break;
1091                     }
1092                 }
1093                 catch ( DavException e )
1094                 {
1095                     continue;
1096                 }
1097             }
1098         }
1099         else
1100         {
1101             for ( String repository : repositories )
1102             {
1103                 try
1104                 {
1105                     if ( servletAuth.isAuthorized( activePrincipal, repository,
1106                                                    WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) )
1107                     {
1108                         allow = true;
1109                         break;
1110                     }
1111                 }
1112                 catch ( UnauthorizedException e )
1113                 {
1114                     continue;
1115                 }
1116             }
1117         }
1118
1119         return allow;
1120     }
1121
1122     private File writeMergedMetadataToFile( ArchivaRepositoryMetadata mergedMetadata, String outputFilename )
1123         throws RepositoryMetadataException, DigesterException, IOException
1124     {
1125         File outputFile = new File( outputFilename );
1126         if ( outputFile.exists() )
1127         {
1128             FileUtils.deleteQuietly( outputFile );
1129         }
1130
1131         outputFile.getParentFile().mkdirs();
1132         RepositoryMetadataWriter.write( mergedMetadata, outputFile );
1133
1134         createChecksumFile( outputFilename, digestSha1 );
1135         createChecksumFile( outputFilename, digestMd5 );
1136
1137         return outputFile;
1138     }
1139
1140     private void createChecksumFile( String path, Digester digester )
1141         throws DigesterException, IOException
1142     {
1143         File checksumFile = new File( path + digester.getFilenameExtension() );
1144         if ( !checksumFile.exists() )
1145         {
1146             FileUtils.deleteQuietly( checksumFile );
1147             checksum.createChecksum( new File( path ), digester );
1148         }
1149         else if ( !checksumFile.isFile() )
1150         {
1151             log.error( "Checksum file is not a file." );
1152         }
1153     }
1154
1155     private boolean isProjectReference( String requestedResource )
1156     {
1157         try
1158         {
1159             metadataTools.toVersionedReference( requestedResource );
1160             return false;
1161         }
1162         catch ( RepositoryMetadataException re )
1163         {
1164             return true;
1165         }
1166     }
1167
1168     protected File buildMergedIndexDirectory( List<String> repositories, String activePrincipal,
1169                                               DavServletRequest request,
1170                                               RepositoryGroupConfiguration repositoryGroupConfiguration )
1171         throws DavException
1172     {
1173
1174         try
1175         {
1176             HttpSession session = request.getSession();
1177
1178             Map<String, TemporaryGroupIndex> temporaryGroupIndexMap =
1179                 (Map<String, TemporaryGroupIndex>) session.getAttribute(
1180                     TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY );
1181             if ( temporaryGroupIndexMap == null )
1182             {
1183                 temporaryGroupIndexMap = new HashMap<String, TemporaryGroupIndex>();
1184             }
1185
1186             TemporaryGroupIndex tmp = temporaryGroupIndexMap.get( repositoryGroupConfiguration.getId() );
1187
1188             if ( tmp != null && tmp.getDirectory() != null && tmp.getDirectory().exists() )
1189             {
1190                 if ( System.currentTimeMillis() - tmp.getCreationTime() > (
1191                     repositoryGroupConfiguration.getMergedIndexTtl() * 60 * 1000 ) )
1192                 {
1193                     log.debug( MarkerFactory.getMarker( "group.merged.index" ),
1194                                "tmp group index '{}' is too old so delete it", repositoryGroupConfiguration.getId() );
1195                     indexMerger.cleanTemporaryGroupIndex( tmp );
1196                 }
1197                 else
1198                 {
1199                     log.debug( MarkerFactory.getMarker( "group.merged.index" ),
1200                                "merged index for group '{}' found in cache", repositoryGroupConfiguration.getId() );
1201                     return tmp.getDirectory();
1202                 }
1203             }
1204
1205             Set<String> authzRepos = new HashSet<String>();
1206             for ( String repository : repositories )
1207             {
1208                 try
1209                 {
1210                     if ( servletAuth.isAuthorized( activePrincipal, repository,
1211                                                    WebdavMethodUtil.getMethodPermission( request.getMethod() ) ) )
1212                     {
1213                         authzRepos.add( repository );
1214                         authzRepos.addAll( this.repositorySearch.getRemoteIndexingContextIds( repository ) );
1215                     }
1216                 }
1217                 catch ( UnauthorizedException e )
1218                 {
1219                     // TODO: review exception handling
1220
1221                     log.debug( "Skipping repository '{}' for user '{}': {}", repository, activePrincipal,
1222                                e.getMessage() );
1223                 }
1224             }
1225             log.info( "generate temporary merged index for repository group '{}' for repositories '{}'",
1226                       repositoryGroupConfiguration.getId(), authzRepos );
1227             IndexingContext indexingContext = indexMerger.buildMergedIndex(
1228                 new IndexMergerRequest( authzRepos, true, repositoryGroupConfiguration.getId(),
1229                                         repositoryGroupConfiguration.getMergedIndexPath(),
1230                                         repositoryGroupConfiguration.getMergedIndexTtl() ) );
1231             File mergedRepoDir = indexingContext.getIndexDirectoryFile();
1232             TemporaryGroupIndex temporaryGroupIndex =
1233                 new TemporaryGroupIndex( mergedRepoDir, indexingContext.getId(), repositoryGroupConfiguration.getId(),
1234                                          repositoryGroupConfiguration.getMergedIndexTtl() ).setCreationTime(
1235                     new Date().getTime() );
1236             temporaryGroupIndexMap.put( repositoryGroupConfiguration.getId(), temporaryGroupIndex );
1237             session.setAttribute( TemporaryGroupIndexSessionCleaner.TEMPORARY_INDEX_SESSION_KEY,
1238                                   temporaryGroupIndexMap );
1239             return mergedRepoDir;
1240         }
1241         catch ( RepositoryAdminException e )
1242         {
1243             throw new DavException( 500, e );
1244         }
1245         catch ( IndexMergerException e )
1246         {
1247             throw new DavException( 500, e );
1248         }
1249     }
1250
1251
1252     public void setServletAuth( ServletAuthenticator servletAuth )
1253     {
1254         this.servletAuth = servletAuth;
1255     }
1256
1257     public void setHttpAuth( HttpAuthenticator httpAuth )
1258     {
1259         this.httpAuth = httpAuth;
1260     }
1261
1262     public void setScheduler( RepositoryArchivaTaskScheduler scheduler )
1263     {
1264         this.scheduler = scheduler;
1265     }
1266
1267     public void setArchivaConfiguration( ArchivaConfiguration archivaConfiguration )
1268     {
1269         this.archivaConfiguration = archivaConfiguration;
1270     }
1271
1272     public void setRepositoryFactory( RepositoryContentFactory repositoryFactory )
1273     {
1274         this.repositoryFactory = repositoryFactory;
1275     }
1276
1277     public void setRepositoryRequest( RepositoryRequest repositoryRequest )
1278     {
1279         this.repositoryRequest = repositoryRequest;
1280     }
1281
1282     public void setConnectors( RepositoryProxyConnectors connectors )
1283     {
1284         this.connectors = connectors;
1285     }
1286
1287     public RemoteRepositoryAdmin getRemoteRepositoryAdmin()
1288     {
1289         return remoteRepositoryAdmin;
1290     }
1291
1292     public void setRemoteRepositoryAdmin( RemoteRepositoryAdmin remoteRepositoryAdmin )
1293     {
1294         this.remoteRepositoryAdmin = remoteRepositoryAdmin;
1295     }
1296
1297     public ManagedRepositoryAdmin getManagedRepositoryAdmin()
1298     {
1299         return managedRepositoryAdmin;
1300     }
1301
1302     public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
1303     {
1304         this.managedRepositoryAdmin = managedRepositoryAdmin;
1305     }
1306 }