Coverage Report - org.apache.maven.artifact.repository.DefaultArtifactRepositoryFactory
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultArtifactRepositoryFactory
58 %
15/26
67 %
8/12
2,5
 
 1  
 package org.apache.maven.artifact.repository;
 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.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 23  
 
 24  
 import java.util.HashMap;
 25  
 import java.util.Map;
 26  
 
 27  
 /**
 28  
  * @author jdcasey
 29  
  */
 30  27
 public class DefaultArtifactRepositoryFactory
 31  
     implements ArtifactRepositoryFactory
 32  
 {
 33  
     // TODO: use settings?
 34  
     private String globalUpdatePolicy;
 35  
 
 36  
     private String globalChecksumPolicy;
 37  
 
 38  27
     private final Map artifactRepositories = new HashMap();
 39  
 
 40  
     public ArtifactRepository createDeploymentArtifactRepository( String id, String url,
 41  
                                                                   ArtifactRepositoryLayout repositoryLayout,
 42  
                                                                   boolean uniqueVersion )
 43  
     {
 44  0
         return new DefaultArtifactRepository( id, url, repositoryLayout, uniqueVersion );
 45  
     }
 46  
 
 47  
     public ArtifactRepository createArtifactRepository( String id, String url,
 48  
                                                         ArtifactRepositoryLayout repositoryLayout,
 49  
                                                         ArtifactRepositoryPolicy snapshots,
 50  
                                                         ArtifactRepositoryPolicy releases )
 51  
     {
 52  13
         boolean blacklisted = false;
 53  13
         if ( artifactRepositories.containsKey( id ) )
 54  
         {
 55  4
             ArtifactRepository repository = (ArtifactRepository) artifactRepositories.get( id );
 56  
             // TODO: this should be an if there are duplicates?
 57  4
             if ( repository.getUrl().equals( url ) )
 58  
             {
 59  2
                 blacklisted = repository.isBlacklisted();
 60  
             }
 61  
         }
 62  
 
 63  13
         if ( snapshots == null )
 64  
         {
 65  0
             snapshots = new ArtifactRepositoryPolicy();
 66  
         }
 67  
 
 68  13
         if ( releases == null )
 69  
         {
 70  0
             releases = new ArtifactRepositoryPolicy();
 71  
         }
 72  
 
 73  13
         if ( globalUpdatePolicy != null )
 74  
         {
 75  0
             snapshots.setUpdatePolicy( globalUpdatePolicy );
 76  0
             releases.setUpdatePolicy( globalUpdatePolicy );
 77  
         }
 78  
 
 79  13
         if ( globalChecksumPolicy != null )
 80  
         {
 81  0
             snapshots.setChecksumPolicy( globalChecksumPolicy );
 82  0
             releases.setChecksumPolicy( globalChecksumPolicy );
 83  
         }
 84  
 
 85  13
         DefaultArtifactRepository repository = new DefaultArtifactRepository( id, url, repositoryLayout, snapshots,
 86  
                                                                               releases );
 87  13
         repository.setBlacklisted( blacklisted );
 88  
 
 89  13
         artifactRepositories.put( id, repository );
 90  
 
 91  13
         return repository;
 92  
     }
 93  
 
 94  
     public void setGlobalUpdatePolicy( String updatePolicy )
 95  
     {
 96  0
         this.globalUpdatePolicy = updatePolicy;
 97  0
     }
 98  
 
 99  
     public void setGlobalChecksumPolicy( String checksumPolicy )
 100  
     {
 101  0
         this.globalChecksumPolicy = checksumPolicy;
 102  0
     }
 103  
 }