Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
DatabaseProjectModelResolver |
|
| 5.0;5 |
1 | package org.apache.maven.archiva.database.project; | |
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.archiva.database.ArchivaDAO; | |
23 | import org.apache.maven.archiva.database.ArchivaDatabaseException; | |
24 | import org.apache.maven.archiva.database.ObjectNotFoundException; | |
25 | import org.apache.maven.archiva.model.ArchivaProjectModel; | |
26 | import org.apache.maven.archiva.model.VersionedReference; | |
27 | import org.apache.maven.archiva.repository.project.ProjectModelException; | |
28 | import org.apache.maven.archiva.repository.project.ProjectModelResolver; | |
29 | ||
30 | /** | |
31 | * Resolves a project model from the database. | |
32 | * | |
33 | * @version $Id: DatabaseProjectModelResolver.java 718864 2008-11-19 06:33:35Z brett $ | |
34 | * | |
35 | * @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelResolver" | |
36 | * role-hint="database" | |
37 | */ | |
38 | 0 | public class DatabaseProjectModelResolver |
39 | implements ProjectModelResolver | |
40 | { | |
41 | /** | |
42 | * @plexus.requirement role-hint="jdo" | |
43 | */ | |
44 | private ArchivaDAO dao; | |
45 | ||
46 | public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) | |
47 | throws ProjectModelException | |
48 | { | |
49 | try | |
50 | { | |
51 | 0 | ArchivaProjectModel model = dao.getProjectModelDAO().getProjectModel( reference.getGroupId(), |
52 | reference.getArtifactId(), | |
53 | reference.getVersion() ); | |
54 | 0 | return model; |
55 | } | |
56 | 0 | catch ( ObjectNotFoundException e ) |
57 | { | |
58 | 0 | return null; |
59 | } | |
60 | 0 | catch ( ArchivaDatabaseException e ) |
61 | { | |
62 | 0 | return null; |
63 | } | |
64 | } | |
65 | } |