1 package org.apache.maven.archiva.database.browsing;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
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.database.constraints.UniqueArtifactIdConstraint;
26 import org.apache.maven.archiva.database.constraints.UniqueGroupIdConstraint;
27 import org.apache.maven.archiva.database.constraints.UniqueVersionConstraint;
28 import org.apache.maven.archiva.model.ArchivaProjectModel;
29 import org.codehaus.plexus.logging.AbstractLogEnabled;
31 import java.util.List;
34 * DefaultRepositoryBrowsing
36 * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
39 * @plexus.component role="org.apache.maven.archiva.database.browsing.RepositoryBrowsing"
42 public class DefaultRepositoryBrowsing
43 extends AbstractLogEnabled
44 implements RepositoryBrowsing
49 private ArchivaDAO dao;
51 public BrowsingResults getRoot()
53 List groups = dao.query( new UniqueGroupIdConstraint() );
55 BrowsingResults results = new BrowsingResults();
57 results.setGroupIds( GroupIdFilter.filterGroups( groups ) );
62 public BrowsingResults selectArtifactId( String groupId, String artifactId )
64 // List groups = dao.query( new UniqueGroupIdConstraint( groupId ) );
65 // List artifacts = dao.query( new UniqueArtifactIdConstraint( groupId ) );
66 List versions = dao.query( new UniqueVersionConstraint( groupId, artifactId ) );
68 BrowsingResults results = new BrowsingResults( groupId, artifactId );
70 // results.setGroupIds( groups );
71 // results.setArtifacts( artifacts );
72 results.setArtifacts( versions );
77 public BrowsingResults selectGroupId( String groupId )
79 List groups = dao.query( new UniqueGroupIdConstraint( groupId ) );
80 List artifacts = dao.query( new UniqueArtifactIdConstraint( groupId ) );
82 BrowsingResults results = new BrowsingResults( groupId );
83 results.setGroupIds( groups );
84 results.setArtifacts( artifacts );
89 public ArchivaProjectModel selectVersion( String groupId, String artifactId, String version )
90 throws ObjectNotFoundException, ArchivaDatabaseException
92 ArchivaProjectModel model = dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version );
94 // TODO: if the model isn't found. load it from disk, insert into DB, and then return it.