001    package org.apache.maven.repository;
002    
003    /*
004     * Licensed to the Apache Software Foundation (ASF) under one
005     * or more contributor license agreements.  See the NOTICE file
006     * distributed with this work for additional information
007     * regarding copyright ownership.  The ASF licenses this file
008     * to you under the Apache License, Version 2.0 (the
009     * "License"); you may not use this file except in compliance
010     * with the License.  You may obtain a copy of the License at
011     *
012     *   http://www.apache.org/licenses/LICENSE-2.0
013     *
014     * Unless required by applicable law or agreed to in writing,
015     * software distributed under the License is distributed on an
016     * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017     * KIND, either express or implied.  See the License for the
018     * specific language governing permissions and limitations
019     * under the License.
020     */
021    
022    import java.util.List;
023    import java.util.Map;
024    import java.util.Set;
025    
026    import org.apache.maven.artifact.Artifact;
027    import org.apache.maven.artifact.repository.ArtifactRepository;
028    
029    /**
030     *
031     *
032     * @author Oleg Gusakov
033     *
034     */
035    public class MetadataResolutionRequest
036    {
037        private MavenArtifactMetadata mad;
038    
039        private String scope;
040    
041        // Needs to go away
042        private Set<Artifact> artifactDependencies;
043    
044        private ArtifactRepository localRepository;
045    
046        private List<ArtifactRepository> remoteRepositories;
047    
048        // This is like a filter but overrides all transitive versions
049        private Map managedVersionMap;
050    
051        /** result type - flat list; the default */
052        private boolean asList = true;
053    
054        /** result type - dirty tree */
055        private boolean asDirtyTree = false;
056    
057        /** result type - resolved tree */
058        private boolean asResolvedTree = false;
059    
060        /** result type - graph */
061        private boolean asGraph = false;
062    
063        public MetadataResolutionRequest()
064        {
065        }
066    
067        public MetadataResolutionRequest( MavenArtifactMetadata md, ArtifactRepository localRepository,
068                                          List<ArtifactRepository> remoteRepositories )
069        {
070            this.mad = md;
071            this.localRepository = localRepository;
072            this.remoteRepositories = remoteRepositories;
073        }
074    
075        public MavenArtifactMetadata getArtifactMetadata()
076        {
077            return mad;
078        }
079    
080        public MetadataResolutionRequest setArtifactMetadata( MavenArtifactMetadata md )
081        {
082            this.mad = md;
083    
084            return this;
085        }
086    
087        public MetadataResolutionRequest setArtifactDependencies( Set<Artifact> artifactDependencies )
088        {
089            this.artifactDependencies = artifactDependencies;
090    
091            return this;
092        }
093    
094        public Set<Artifact> getArtifactDependencies()
095        {
096            return artifactDependencies;
097        }
098    
099        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        public List<ArtifactRepository> getRemoteRepostories()
112        {
113            return remoteRepositories;
114        }
115    
116        public MetadataResolutionRequest setRemoteRepostories( List<ArtifactRepository> remoteRepostories )
117        {
118            this.remoteRepositories = remoteRepostories;
119    
120            return this;
121        }
122    
123        public Map getManagedVersionMap()
124        {
125            return managedVersionMap;
126        }
127    
128        public MetadataResolutionRequest setManagedVersionMap( Map managedVersionMap )
129        {
130            this.managedVersionMap = managedVersionMap;
131    
132            return this;
133        }
134    
135        public String toString()
136        {
137            StringBuilder sb = new StringBuilder()
138                    .append( "REQUEST: " ).append(  "\n" )
139                    .append( "artifact: " ).append( mad ).append(  "\n" )
140                    .append( artifactDependencies ).append(  "\n" )
141                    .append( "localRepository: " ).append(  localRepository ).append(  "\n" )
142                    .append( "remoteRepositories: " ).append(  remoteRepositories ).append(  "\n" )
143                    ;
144    
145            return sb.toString();
146        }
147    
148        public boolean isAsList()
149        {
150            return asList;
151        }
152    
153        public MetadataResolutionRequest setAsList( boolean asList )
154        {
155            this.asList = asList;
156            return this;
157        }
158    
159        public boolean isAsDirtyTree()
160        {
161            return asDirtyTree;
162        }
163    
164        public MetadataResolutionRequest setAsDirtyTree( boolean asDirtyTree )
165        {
166            this.asDirtyTree = asDirtyTree;
167            return this;
168        }
169    
170        public boolean isAsResolvedTree()
171        {
172            return asResolvedTree;
173        }
174    
175        public MetadataResolutionRequest setAsResolvedTree( boolean asResolvedTree )
176        {
177            this.asResolvedTree = asResolvedTree;
178            return this;
179        }
180    
181        public boolean isAsGraph()
182        {
183            return asGraph;
184        }
185    
186        public MetadataResolutionRequest setAsGraph( boolean asGraph )
187        {
188            this.asGraph = asGraph;
189            return this;
190        }
191    
192        public MetadataResolutionRequest setScope( String scope )
193        {
194            this.scope = scope;
195            return this;
196        }
197    
198        public String getScope()
199        {
200            return scope;
201        }
202    }