1
2
3
4
5
6 package org.repoweb.model.jar;
7 import java.net.URL;
8 import org.apache.commons.logging.Log;
9 import org.apache.commons.logging.LogFactory;
10 import org.repoweb.model.Artifact;
11 import org.repoweb.model.ArtifactList;
12 import org.repoweb.model.BuildFailureException;
13 import org.repoweb.model.Group;
14 import org.repoweb.model.GroupList;
15 import org.repoweb.model.Repository;
16 import org.repoweb.model.UnknownArtifactException;
17 import org.repoweb.model.common.AbstractArtifact;
18 import org.repoweb.pom.Project;
19 /***
20 * Represent a maven repository located in the same jar file of this class. Use ClassLoader mechanism.
21 */
22 public class JarRepository implements Repository {
23 private static final Log LOG = LogFactory.getLog(JarRepository.class);
24 private final String _root;
25
26 public JarRepository(String rootPath) {
27 this._root = rootPath;
28 }
29
30 public GroupList getAllGroups() {
31 throw new UnsupportedOperationException();
32 }
33
34
35 public Group getGroup(String groupId) {
36 throw new UnsupportedOperationException();
37 }
38
39
40 public Artifact getArtifact(String groupId, String typeId, String filename)
41 throws UnknownArtifactException {
42 String path = _root + groupId + "/" + typeId + "s/" + filename;
43 URL url = JarRepository.class.getResource(path);
44 if (url == null) {
45 throw new UnknownArtifactException();
46 }
47
48 try {
49 return new JArtifact(url);
50 }
51 catch (AbstractArtifact.BadArtifactFileException ex) {
52 LOG.error("Bad artifact file detected " + path, ex);
53 throw new UnknownArtifactException();
54 }
55 }
56
57
58 public GroupList findGroups(String pattern) {
59 throw new UnsupportedOperationException();
60 }
61
62
63 public ArtifactList findArtifacts(String groupId, String typeId, String filename) {
64 throw new UnsupportedOperationException();
65 }
66
67
68 public ArtifactList findArtifactByClass(String fullClassName) {
69 throw new UnsupportedOperationException();
70 }
71
72
73 public Artifact buildPom(Project project) throws BuildFailureException {
74 throw new UnsupportedOperationException();
75 }
76 }