View Javadoc
1   package org.apache.maven.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 java.util.List;
23  import java.util.Map;
24  import java.util.Set;
25  
26  import org.apache.maven.artifact.Artifact;
27  import org.apache.maven.artifact.repository.ArtifactRepository;
28  
29  /**
30   *
31   *
32   * @author Oleg Gusakov
33   *
34   */
35  public class MetadataResolutionRequest
36  {
37      private MavenArtifactMetadata mad;
38  
39      private String scope;
40  
41      // Needs to go away
42      private Set<Artifact> artifactDependencies;
43  
44      private ArtifactRepository localRepository;
45  
46      private List<ArtifactRepository> remoteRepositories;
47  
48      // This is like a filter but overrides all transitive versions
49      private Map managedVersionMap;
50  
51      /** result type - flat list; the default */
52      private boolean asList = true;
53  
54      /** result type - dirty tree */
55      private boolean asDirtyTree = false;
56  
57      /** result type - resolved tree */
58      private boolean asResolvedTree = false;
59  
60      /** result type - graph */
61      private boolean asGraph = false;
62  
63      public MetadataResolutionRequest()
64      {
65      }
66  
67      public MetadataResolutionRequest( MavenArtifactMetadata md, ArtifactRepository localRepository,
68                                        List<ArtifactRepository> remoteRepositories )
69      {
70          this.mad = md;
71          this.localRepository = localRepository;
72          this.remoteRepositories = remoteRepositories;
73      }
74  
75      public MavenArtifactMetadata getArtifactMetadata()
76      {
77          return mad;
78      }
79  
80      public MetadataResolutionRequest setArtifactMetadata( MavenArtifactMetadata md )
81      {
82          this.mad = md;
83  
84          return this;
85      }
86  
87      public MetadataResolutionRequest setArtifactDependencies( Set<Artifact> artifactDependencies )
88      {
89          this.artifactDependencies = artifactDependencies;
90  
91          return this;
92      }
93  
94      public Set<Artifact> getArtifactDependencies()
95      {
96          return artifactDependencies;
97      }
98  
99      public ArtifactRepository getLocalRepository()
100     {
101         return localRepository;
102     }
103 
104     public MetadataResolutionRequest setLocalRepository( ArtifactRepository localRepository )
105     {
106         this.localRepository = localRepository;
107 
108         return this;
109     }
110 
111     /**
112      * @deprecated instead use {@link #getRemoteRepositories()}
113      */
114     @Deprecated
115     public List<ArtifactRepository> getRemoteRepostories()
116     {
117         return remoteRepositories;
118     }
119 
120     public List<ArtifactRepository> getRemoteRepositories()
121     {
122         return getRemoteRepostories();
123     }
124 
125     /**
126      * @deprecated instead use {@link #setRemoteRepositories(List)}
127      */
128     @Deprecated
129     public MetadataResolutionRequest setRemoteRepostories( List<ArtifactRepository> remoteRepostories )
130     {
131         this.remoteRepositories = remoteRepostories;
132 
133         return this;
134     }
135 
136     public MetadataResolutionRequest setRemoteRepositories( List<ArtifactRepository> remoteRepositories )
137     {
138         return setRemoteRepostories( remoteRepositories );
139     }
140 
141     public Map getManagedVersionMap()
142     {
143         return managedVersionMap;
144     }
145 
146     public MetadataResolutionRequest setManagedVersionMap( Map managedVersionMap )
147     {
148         this.managedVersionMap = managedVersionMap;
149 
150         return this;
151     }
152 
153     public String toString()
154     {
155         StringBuilder sb = new StringBuilder()
156                 .append( "REQUEST: " ).append(  "\n" )
157                 .append( "artifact: " ).append( mad ).append(  "\n" )
158                 .append( artifactDependencies ).append(  "\n" )
159                 .append( "localRepository: " ).append(  localRepository ).append(  "\n" )
160                 .append( "remoteRepositories: " ).append(  remoteRepositories ).append(  "\n" )
161                 ;
162 
163         return sb.toString();
164     }
165 
166     public boolean isAsList()
167     {
168         return asList;
169     }
170 
171     public MetadataResolutionRequest setAsList( boolean asList )
172     {
173         this.asList = asList;
174         return this;
175     }
176 
177     public boolean isAsDirtyTree()
178     {
179         return asDirtyTree;
180     }
181 
182     public MetadataResolutionRequest setAsDirtyTree( boolean asDirtyTree )
183     {
184         this.asDirtyTree = asDirtyTree;
185         return this;
186     }
187 
188     public boolean isAsResolvedTree()
189     {
190         return asResolvedTree;
191     }
192 
193     public MetadataResolutionRequest setAsResolvedTree( boolean asResolvedTree )
194     {
195         this.asResolvedTree = asResolvedTree;
196         return this;
197     }
198 
199     public boolean isAsGraph()
200     {
201         return asGraph;
202     }
203 
204     public MetadataResolutionRequest setAsGraph( boolean asGraph )
205     {
206         this.asGraph = asGraph;
207         return this;
208     }
209 
210     public MetadataResolutionRequest setScope( String scope )
211     {
212         this.scope = scope;
213         return this;
214     }
215 
216     public String getScope()
217     {
218         return scope;
219     }
220 }