Coverage Report - org.apache.maven.artifact.repository.DefaultArtifactRepository
 
Classes in this File Line Coverage Branch Coverage Complexity
DefaultArtifactRepository
81 %
21/26
100 %
4/4
1,154
 
 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.Artifact;
 23  
 import org.apache.maven.artifact.metadata.ArtifactMetadata;
 24  
 import org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout;
 25  
 import org.apache.maven.wagon.repository.Repository;
 26  
 
 27  
 /**
 28  
  * This class is an abstraction of the location from/to resources can be
 29  
  * transfered.
 30  
  *
 31  
  * @author <a href="michal.maczka@dimatics.com">Michal Maczka </a>
 32  
  * @version $Id: DefaultArtifactRepository.java 495147 2007-01-11 07:47:53Z jvanzyl $
 33  
  */
 34  
 public class DefaultArtifactRepository
 35  
     extends Repository
 36  
     implements ArtifactRepository
 37  
 {
 38  
     private final ArtifactRepositoryLayout layout;
 39  
 
 40  
     private ArtifactRepositoryPolicy snapshots;
 41  
 
 42  
     private ArtifactRepositoryPolicy releases;
 43  
 
 44  
     private boolean uniqueVersion;
 45  
 
 46  
     private boolean blacklisted;
 47  
 
 48  
     /**
 49  
      * Create a local repository or a test repository.
 50  
      *
 51  
      * @param id the unique identifier of the repository
 52  
      * @param url the URL of the repository
 53  
      * @param layout the layout of the repository
 54  
      */
 55  
     public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout )
 56  
     {
 57  118
         this( id, url, layout, null, null );
 58  118
     }
 59  
 
 60  
     /**
 61  
      * Create a remote deployment repository.
 62  
      *
 63  
      * @param id the unique identifier of the repository
 64  
      * @param url the URL of the repository
 65  
      * @param layout the layout of the repository
 66  
      * @param uniqueVersion whether to assign each snapshot a unique version
 67  
      */
 68  
     public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout, boolean uniqueVersion )
 69  
     {
 70  0
         super( id, url );
 71  0
         this.layout = layout;
 72  0
         this.uniqueVersion = uniqueVersion;
 73  0
     }
 74  
 
 75  
     /**
 76  
      * Create a remote download repository.
 77  
      *
 78  
      * @param id the unique identifier of the repository
 79  
      * @param url the URL of the repository
 80  
      * @param layout the layout of the repository
 81  
      * @param snapshots the policies to use for snapshots
 82  
      * @param releases the policies to use for releases
 83  
      */
 84  
     public DefaultArtifactRepository( String id, String url, ArtifactRepositoryLayout layout,
 85  
                                       ArtifactRepositoryPolicy snapshots, ArtifactRepositoryPolicy releases )
 86  
     {
 87  149
         super( id, url );
 88  
 
 89  149
         this.layout = layout;
 90  
 
 91  149
         if ( snapshots == null )
 92  
         {
 93  118
             snapshots = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
 94  
                                                       ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
 95  
         }
 96  
 
 97  149
         this.snapshots = snapshots;
 98  
 
 99  149
         if ( releases == null )
 100  
         {
 101  118
             releases = new ArtifactRepositoryPolicy( true, ArtifactRepositoryPolicy.UPDATE_POLICY_ALWAYS,
 102  
                                                      ArtifactRepositoryPolicy.CHECKSUM_POLICY_IGNORE );
 103  
         }
 104  
 
 105  149
         this.releases = releases;
 106  149
     }
 107  
 
 108  
     public String pathOf( Artifact artifact )
 109  
     {
 110  70
         return layout.pathOf( artifact );
 111  
     }
 112  
 
 113  
     public String pathOfRemoteRepositoryMetadata( ArtifactMetadata artifactMetadata )
 114  
     {
 115  2
         return layout.pathOfRemoteRepositoryMetadata( artifactMetadata );
 116  
     }
 117  
 
 118  
     public String pathOfLocalRepositoryMetadata( ArtifactMetadata metadata, ArtifactRepository repository )
 119  
     {
 120  3
         return layout.pathOfLocalRepositoryMetadata( metadata, repository );
 121  
     }
 122  
 
 123  
     public ArtifactRepositoryLayout getLayout()
 124  
     {
 125  15
         return layout;
 126  
     }
 127  
 
 128  
     public ArtifactRepositoryPolicy getSnapshots()
 129  
     {
 130  13
         return snapshots;
 131  
     }
 132  
 
 133  
     public ArtifactRepositoryPolicy getReleases()
 134  
     {
 135  28
         return releases;
 136  
     }
 137  
 
 138  
     public String getKey()
 139  
     {
 140  3
         return getId();
 141  
     }
 142  
 
 143  
     public boolean isUniqueVersion()
 144  
     {
 145  0
         return uniqueVersion;
 146  
     }
 147  
 
 148  
     public boolean isBlacklisted()
 149  
     {
 150  17
         return blacklisted;
 151  
     }
 152  
 
 153  
     public void setBlacklisted( boolean blacklisted )
 154  
     {
 155  13
         this.blacklisted = blacklisted;
 156  13
     }
 157  
 }