View Javadoc
1   /**
2    * Copyright 2010-2014 The Kuali Foundation
3    *
4    * Licensed under the Educational Community License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    * http://www.opensource.org/licenses/ecl2.php
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package org.kuali.common.util.maven;
17  
18  import static org.kuali.common.util.base.Precondition.checkNotNull;
19  import static org.kuali.common.util.maven.RepositoryUtils.getDefaultLocalRepository;
20  
21  import java.io.File;
22  import java.util.ArrayList;
23  import java.util.List;
24  
25  import org.kuali.common.util.file.CanonicalFile;
26  import org.kuali.common.util.maven.model.Artifact;
27  
28  public final class DefaultLocalRepositoryService implements LocalRepositoryService {
29  
30  	private final File localRepository;
31  
32  	public DefaultLocalRepositoryService() {
33  		this(getDefaultLocalRepository());
34  	}
35  
36  	public DefaultLocalRepositoryService(File localRepository) {
37  		this.localRepository = new CanonicalFile(checkNotNull(localRepository, "localRepository"));
38  	}
39  
40  	@Override
41  	public List<File> getFiles(List<Artifact> artifacts) {
42  		List<File> files = new ArrayList<File>();
43  		for (Artifact artifact : artifacts) {
44  			File file = getFile(artifact);
45  			files.add(file);
46  		}
47  		return files;
48  	}
49  
50  	@Override
51  	public File getFile(Artifact artifact) {
52  		return RepositoryUtils.getFile(localRepository, artifact);
53  	}
54  
55  	@Override
56  	public File getLocalRepository() {
57  		return localRepository;
58  	}
59  
60  }