diff options
author | Joakim Erdfelt <joakime@apache.org> | 2007-10-08 22:07:39 +0000 |
---|---|---|
committer | Joakim Erdfelt <joakime@apache.org> | 2007-10-08 22:07:39 +0000 |
commit | 8af86cd884b34ecfa98c6a42d2975fdd45c48fff (patch) | |
tree | 3747df8c304e8c84090f325abab84775e961db6e /archiva-database | |
parent | 4b9cf4b9298b9906ae4975146706e6a870349e43 (diff) | |
download | archiva-8af86cd884b34ecfa98c6a42d2975fdd45c48fff.tar.gz archiva-8af86cd884b34ecfa98c6a42d2975fdd45c48fff.zip |
Finishing the Repository split work that brett started.
ArchivaRepository has been removed from model.
This work was needed before repository layout/detection proposal work is started.
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@582987 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-database')
6 files changed, 2 insertions, 299 deletions
diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java index bfe15ef0c..18b1821d3 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java @@ -52,7 +52,5 @@ public interface ArchivaDAO ProjectModelDAO getProjectModelDAO(); - RepositoryDAO getRepositoryDAO(); - RepositoryProblemDAO getRepositoryProblemDAO(); } diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDAO.java deleted file mode 100644 index 15a1b265e..000000000 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDAO.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.apache.maven.archiva.database; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.model.ArchivaRepository; - -import java.util.List; - -/** - * RepositoryDAO - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public interface RepositoryDAO -{ - /* NOTE TO ARCHIVA DEVELOPERS. - * - * Please keep this interface clean and lean. - * We don't want a repeat of the Continuum Store. - * You should have the following methods per object type ... - * - * (Required Methods) - * - * DatabaseObject .createDatabaseObject( Required Params ) ; - * List .queryDatabaseObject( Constraint ) throws ObjectNotFoundException, DatabaseException; - * DatabaseObject .saveDatabaseObject( DatabaseObject ) throws DatabaseException; - * - * (Optional Methods) - * - * DatabaseObject .getDatabaseObject( Id ) throws ObjectNotFoundException, DatabaseException; - * List .getDatabaseObjects() throws ObjectNotFoundException, DatabaseException; - * void .deleteDatabaseObject( DatabaseObject ) throws DatabaseException; - * - * This is the only list of options created in this DAO. - */ - - public ArchivaRepository createRepository( String id, String name, String url ); - - public List /*<ArchivaRepository>*/getRepositories() - throws ObjectNotFoundException, ArchivaDatabaseException; - - public ArchivaRepository getRepository( String id ) - throws ObjectNotFoundException, ArchivaDatabaseException; - - public List /*<ArchivaRepository>*/queryRepositories( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException; - - public ArchivaRepository saveRepository( ArchivaRepository repository ) - throws ArchivaDatabaseException; - - public void deleteRepository( ArchivaRepository repository ) - throws ArchivaDatabaseException; -} diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java index 40d9f4228..639106184 100644 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java +++ b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java @@ -22,7 +22,6 @@ package org.apache.maven.archiva.database.jdo; import org.apache.maven.archiva.database.ArchivaDAO; import org.apache.maven.archiva.database.ArtifactDAO; import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.database.RepositoryDAO; import org.apache.maven.archiva.database.RepositoryProblemDAO; import org.apache.maven.archiva.database.SimpleConstraint; import org.codehaus.plexus.logging.AbstractLogEnabled; @@ -60,11 +59,6 @@ public class JdoArchivaDAO /** * @plexus.requirement role-hint="jdo" */ - private RepositoryDAO repositoryDAO; - - /** - * @plexus.requirement role-hint="jdo" - */ private RepositoryProblemDAO repositoryProblemDAO; public List query( SimpleConstraint constraint ) @@ -87,11 +81,6 @@ public class JdoArchivaDAO return projectModelDAO; } - public RepositoryDAO getRepositoryDAO() - { - return repositoryDAO; - } - public RepositoryProblemDAO getRepositoryProblemDAO() { return repositoryProblemDAO; diff --git a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryDAO.java b/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryDAO.java deleted file mode 100644 index eaef9bd88..000000000 --- a/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoRepositoryDAO.java +++ /dev/null @@ -1,118 +0,0 @@ -package org.apache.maven.archiva.database.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.Constraint; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.database.RepositoryDAO; -import org.apache.maven.archiva.model.ArchivaRepository; -import org.apache.maven.archiva.model.ArchivaRepositoryModel; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -/** - * JdoRepositoryDAO - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - * - * @plexus.component role-hint="jdo" - */ -public class JdoRepositoryDAO - implements RepositoryDAO -{ - /** - * @plexus.requirement role-hint="archiva" - */ - private JdoAccess jdo; - - /* .\ Archiva Repository \.____________________________________________________________ */ - - public ArchivaRepository createRepository( String id, String name, String url ) - { - ArchivaRepository repo; - - try - { - repo = getRepository( id ); - } - catch ( ArchivaDatabaseException e ) - { - repo = new ArchivaRepository( id, name, url ); - } - - return repo; - } - - public List getRepositories() - throws ObjectNotFoundException, ArchivaDatabaseException - { - return queryRepositories( null ); - } - - public ArchivaRepository getRepository( String id ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - ArchivaRepositoryModel model = (ArchivaRepositoryModel) jdo.getObjectById( ArchivaRepositoryModel.class, id, - null ); - return new ArchivaRepository( model ); - } - - public List queryRepositories( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - List results = jdo.queryObjects( ArchivaRepositoryModel.class, constraint ); - - if ( ( results == null ) || results.isEmpty() ) - { - return results; - } - - List ret = new ArrayList(); - Iterator it = results.iterator(); - while ( it.hasNext() ) - { - ArchivaRepositoryModel model = (ArchivaRepositoryModel) it.next(); - ret.add( new ArchivaRepository( model ) ); - } - - return ret; - } - - public ArchivaRepository saveRepository( ArchivaRepository repository ) - { - ArchivaRepositoryModel model = (ArchivaRepositoryModel) jdo.saveObject( repository.getModel() ); - if ( model == null ) - { - return null; - } - - return new ArchivaRepository( model ); - } - - public void deleteRepository( ArchivaRepository repository ) - throws ArchivaDatabaseException - { - jdo.removeObject( repository.getModel() ); - } -} diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java index df0de8692..4f51e5bb5 100644 --- a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java +++ b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java @@ -33,6 +33,7 @@ public class JdoArchivaDAOTest public void testSubDAOs() { assertNotNull( "Artifact DAO", dao.getArtifactDAO() ); - assertNotNull( "Repository DAO", dao.getRepositoryDAO() ); + assertNotNull( "Project Model DAO", dao.getProjectModelDAO() ); + assertNotNull( "Repository Problem DAO", dao.getRepositoryProblemDAO() ); } } diff --git a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryDAOTest.java b/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryDAOTest.java deleted file mode 100644 index 3398ab712..000000000 --- a/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoRepositoryDAOTest.java +++ /dev/null @@ -1,96 +0,0 @@ -package org.apache.maven.archiva.database.jdo; - -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF licenses this file - * to you under the Apache License, Version 2.0 (the - * "License"); you may not use this file except in compliance - * with the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ - -import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.RepositoryDAO; -import org.apache.maven.archiva.model.ArchivaRepository; - -import java.util.List; - -import javax.jdo.JDOHelper; - -/** - * JdoRepositoryDAOTest - * - * @author <a href="mailto:joakime@apache.org">Joakim Erdfelt</a> - * @version $Id$ - */ -public class JdoRepositoryDAOTest - extends AbstractArchivaDatabaseTestCase -{ - public void testRepositoryCRUD() - throws ArchivaDatabaseException - { - RepositoryDAO repoDao = dao.getRepositoryDAO(); - - // Create it - ArchivaRepository repo = repoDao.createRepository( "testRepo", "Test Repository", - "http://localhost:8080/repository/foo" ); - assertNotNull( repo ); - - // Set some mandatory values - repo.getModel().setCreationSource( "Test Case" ); - repo.getModel().setLayoutName( "default" ); - - // Save it. - ArchivaRepository repoSaved = repoDao.saveRepository( repo ); - assertNotNull( repoSaved ); - assertNotNull( repoSaved.getModel() ); - assertEquals( "testRepo", JDOHelper.getObjectId( repoSaved.getModel() ).toString() ); - - // Test that something has been saved. - List repos = repoDao.getRepositories(); - assertNotNull( repos ); - assertEquals( 1, repos.size() ); - - // Test that retreived object is what we expect. - ArchivaRepository firstRepo = (ArchivaRepository) repos.get( 0 ); - assertNotNull( firstRepo ); - assertEquals( "testRepo", repo.getId() ); - assertEquals( "Test Repository", repo.getModel().getName() ); - assertEquals( "Test Case", repo.getModel().getCreationSource() ); - assertEquals( "default", repo.getModel().getLayoutName() ); - - // Change value and save. - repoSaved.getModel().setCreationSource( "Changed" ); - repoDao.saveRepository( repoSaved ); - - // Test that only 1 object is saved. - assertEquals( 1, repoDao.getRepositories().size() ); - - // Get the specific repo. - ArchivaRepository actualRepo = repoDao.getRepository( "testRepo" ); - assertNotNull( actualRepo ); - - // Test expected values. - assertEquals( "testRepo", actualRepo.getId() ); - assertEquals( "http://localhost:8080/repository/foo", actualRepo.getUrl().toString() ); - assertEquals( "Changed", actualRepo.getModel().getCreationSource() ); - - // Test that only 1 object is saved. - assertEquals( 1, repoDao.getRepositories().size() ); - - // Delete object. - repoDao.deleteRepository( actualRepo ); - assertEquals( 0, repoDao.getRepositories().size() ); - } -} |