diff options
author | Brett Porter <brett@apache.org> | 2009-12-02 02:33:02 +0000 |
---|---|---|
committer | Brett Porter <brett@apache.org> | 2009-12-02 02:33:02 +0000 |
commit | 7a63bee6dedc4a58acbbac36ff18a6c18e500275 (patch) | |
tree | e652379eba390bb9f0695f6940747ee280a75770 /archiva-modules/archiva-database | |
parent | cb96e18f97711202e3c33a00aca2095a02b582a1 (diff) | |
download | archiva-7a63bee6dedc4a58acbbac36ff18a6c18e500275.tar.gz archiva-7a63bee6dedc4a58acbbac36ff18a6c18e500275.zip |
[MRM-1025] remove project model as this is all now in the metadata repository
git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/MRM-1025@886037 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'archiva-modules/archiva-database')
26 files changed, 9 insertions, 1869 deletions
diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java index 76566b4d7..581c3db81 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ArchivaDAO.java @@ -49,8 +49,6 @@ public interface ArchivaDAO ArtifactDAO getArtifactDAO(); - ProjectModelDAO getProjectModelDAO(); - RepositoryProblemDAO getRepositoryProblemDAO(); RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO(); diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ProjectModelDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ProjectModelDAO.java deleted file mode 100644 index 743c3735c..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/ProjectModelDAO.java +++ /dev/null @@ -1,67 +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.ArchivaProjectModel; - -import java.util.List; - -/** - * ProjectModelDAO - * - * @version $Id$ - */ -public interface ProjectModelDAO -{ - /* 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 ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ); - - public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version ) - throws ObjectNotFoundException, ArchivaDatabaseException; - - public List<ArchivaProjectModel> queryProjectModels( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException; - - public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException; - - public void deleteProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException; -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java index c18f587b2..ba916d5fe 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/RepositoryDatabaseEventListener.java @@ -23,15 +23,13 @@ import java.util.List; import org.apache.maven.archiva.database.constraints.RepositoryProblemByArtifactConstraint; import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaProjectModel; import org.apache.maven.archiva.model.RepositoryProblem; import org.apache.maven.archiva.repository.ManagedRepositoryContent; import org.apache.maven.archiva.repository.events.RepositoryListener; -import org.codehaus.plexus.cache.Cache; /** * Process repository management events and respond appropriately. - * + * * @plexus.component role="org.apache.maven.archiva.repository.events.RepositoryListener" role-hint="database" */ public class RepositoryDatabaseEventListener @@ -47,23 +45,13 @@ public class RepositoryDatabaseEventListener */ private RepositoryProblemDAO repositoryProblemDAO; - /** - * @plexus.requirement role-hint="jdo" - */ - private ProjectModelDAO projectModelDAO; - - /** - * @plexus.requirement role-hint="effective-project-cache" - */ - private Cache effectiveProjectCache; - public void deleteArtifact( ManagedRepositoryContent repository, ArchivaArtifact artifact ) { try { ArchivaArtifact queriedArtifact = artifactDAO.getArtifact( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), - artifact.getClassifier(), artifact.getType() , repository.getId()); + artifact.getClassifier(), artifact.getType(), repository.getId() ); artifactDAO.deleteArtifact( queriedArtifact ); } catch ( ArchivaDatabaseException e ) @@ -90,42 +78,5 @@ public class RepositoryDatabaseEventListener { // ignored } - - if ( "pom".equals( artifact.getType() ) ) - { - try - { - ArchivaProjectModel projectModel = - projectModelDAO.getProjectModel( artifact.getGroupId(), artifact.getArtifactId(), - artifact.getVersion() ); - - projectModelDAO.deleteProjectModel( projectModel ); - - // Force removal of project model from effective cache - String projectKey = toProjectKey( projectModel ); - synchronized ( effectiveProjectCache ) - { - if ( effectiveProjectCache.hasKey( projectKey ) ) - { - effectiveProjectCache.remove( projectKey ); - } - } - } - catch ( ArchivaDatabaseException e ) - { - // ignored - } - } - } - - private String toProjectKey( ArchivaProjectModel project ) - { - StringBuilder key = new StringBuilder(); - - key.append( project.getGroupId() ).append( ":" ); - key.append( project.getArtifactId() ).append( ":" ); - key.append( project.getVersion() ); - - return key.toString(); } } diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/BrowsingResults.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/BrowsingResults.java deleted file mode 100644 index efa808a01..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/BrowsingResults.java +++ /dev/null @@ -1,125 +0,0 @@ -package org.apache.maven.archiva.database.browsing; - -/* - * 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.commons.collections.CollectionUtils; - -import java.util.List; - -/** - * BrowsingResults - * - * @version $Id$ - */ -public class BrowsingResults -{ - private String selectedGroupId; - - private String selectedArtifactId; - - private List<String> selectedRepositoryIds = null; - - private List<String> groupIds = null; - - private List<String> artifacts = null; - - private List<String> versions = null; - - public BrowsingResults() - { - /* do nothing, this is the results of the root */ - } - - public BrowsingResults( String groupId ) - { - this.selectedGroupId = groupId; - } - - public BrowsingResults( String groupId, String artifactId ) - { - this.selectedGroupId = groupId; - this.selectedArtifactId = artifactId; - } - - public List<String> getArtifacts() - { - return artifacts; - } - - public List<String> getGroupIds() - { - return groupIds; - } - - public String getSelectedArtifactId() - { - return selectedArtifactId; - } - - public String getSelectedGroupId() - { - return selectedGroupId; - } - - public List<String> getVersions() - { - return versions; - } - - public boolean hasArtifacts() - { - return CollectionUtils.isNotEmpty( artifacts ); - } - - public boolean hasGroupIds() - { - return CollectionUtils.isNotEmpty( groupIds ); - } - - public boolean hasVersions() - { - return CollectionUtils.isNotEmpty( versions ); - } - - public void setArtifacts( List<String> artifacts ) - { - this.artifacts = artifacts; - } - - public void setGroupIds( List<String> groupIds ) - { - this.groupIds = groupIds; - } - - public void setVersions( List<String> versions ) - { - this.versions = versions; - } - - public List<String> getSelectedRepositoryIds() - { - return selectedRepositoryIds; - } - - public void setSelectedRepositoryIds( List<String> selectedRepositoryIds ) - { - this.selectedRepositoryIds = selectedRepositoryIds; - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/GroupIdFilter.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/GroupIdFilter.java deleted file mode 100644 index cd2e9b9da..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/browsing/GroupIdFilter.java +++ /dev/null @@ -1,170 +0,0 @@ -package org.apache.maven.archiva.database.browsing; - -/* - * 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 java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; -import java.util.TreeMap; - -/** - * GroupIdFilter - utility methods for filtering groupIds. - * - * @version $Id$ - */ -public class GroupIdFilter -{ - private static final String GROUP_SEPARATOR = "."; - - /** - * <p> - * Filter out excessive groupId naming. (to provide a tree-ish view of the list of groupIds). - * </p> - * - * <pre> - * // Input List - * commons-lang - * com.jsch - * org.apache.apache - * org.apache.maven - * org.codehaus.modello - * // Filtered List - * commons-lang - * com.jsch - * org - * </pre> - * - * <pre> - * // Input List - * commons-lang - * commons-io - * commons-pool - * com.jsch - * com.jsch.lib - * com.jsch.providers - * org.apache.apache - * org.apache.maven - * org.apache.maven.archiva - * org.apache.maven.shared - * // Filtered List - * commons-lang - * commons-io - * commons-pool - * com.jsch - * org.apache - * </pre> - * - * @param groups the list of groupIds. - * @return - */ - public static List<String> filterGroups( List<String> groups ) - { - GroupTreeNode tree = buildGroupTree( groups ); - return collateGroups( tree ); - } - - public static GroupTreeNode buildGroupTree( List<String> groups ) - { - GroupTreeNode rootNode = new GroupTreeNode(); - - // build a tree structure - for ( String groupId : groups ) - { - StringTokenizer tok = new StringTokenizer( groupId, GROUP_SEPARATOR ); - - GroupTreeNode node = rootNode; - - while ( tok.hasMoreTokens() ) - { - String part = tok.nextToken(); - - if ( !node.getChildren().containsKey( part ) ) - { - GroupTreeNode newNode = new GroupTreeNode( part, node ); - node.addChild( newNode ); - node = newNode; - } - else - { - node = node.getChildren().get( part ); - } - } - } - - return rootNode; - } - - private static List<String> collateGroups( GroupTreeNode rootNode ) - { - List<String> groups = new ArrayList<String>(); - for ( GroupTreeNode node : rootNode.getChildren().values() ) - { - while ( node.getChildren().size() == 1 ) - { - node = node.getChildren().values().iterator().next(); - } - - groups.add( node.getFullName() ); - } - return groups; - } - - private static class GroupTreeNode - { - private final String name; - - private final String fullName; - - private final Map<String, GroupTreeNode> children = new TreeMap<String, GroupTreeNode>(); - - GroupTreeNode() - { - name = null; - fullName = null; - } - - GroupTreeNode( String name, GroupTreeNode parent ) - { - this.name = name; - this.fullName = parent.fullName != null ? parent.fullName + GROUP_SEPARATOR + name : name; - } - - public String getName() - { - return name; - } - - public String getFullName() - { - return fullName; - } - - public Map<String, GroupTreeNode> getChildren() - { - return children; - } - - public void addChild( GroupTreeNode newNode ) - { - children.put( newNode.name, newNode ); - } - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraint.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraint.java deleted file mode 100644 index 7dc57c5fe..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraint.java +++ /dev/null @@ -1,80 +0,0 @@ -package org.apache.maven.archiva.database.constraints; - -/* - * 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.DeclarativeConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.Dependency; - -/** - * ProjectsByArtifactUsageConstraint - * - * @version $Id$ - */ -public class ProjectsByArtifactUsageConstraint - extends AbstractDeclarativeConstraint - implements DeclarativeConstraint -{ - private String filter; - - public ProjectsByArtifactUsageConstraint( ArchivaArtifact artifact ) - { - this( artifact.getGroupId(), artifact.getArtifactId(), artifact.getBaseVersion() ); - } - - public ProjectsByArtifactUsageConstraint( String groupId, String artifactId, String version ) - { - super.declImports = new String[] { - "import " + Dependency.class.getName() - }; - - super.variables = new String[] { - "Dependency dep" - }; - - super.declParams = new String[] { - "String selectedGroupId", - "String selectedArtifactId", - "String selectedVersion" - }; - - filter = "dependencies.contains( dep ) && " + - "dep.groupId == selectedGroupId && " + - "dep.artifactId == selectedArtifactId && " + - "dep.version == selectedVersion"; - - super.params = new Object[] { groupId, artifactId, version }; - } - - public String getSortColumn() - { - return "groupId"; - } - - public String getWhereCondition() - { - return null; - } - - public String getFilter() - { - return filter; - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java index 54d30af86..f5b579475 100644 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java +++ b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAO.java @@ -19,16 +19,15 @@ package org.apache.maven.archiva.database.jdo; * under the License. */ +import java.io.Serializable; +import java.util.List; + 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.RepositoryContentStatisticsDAO; import org.apache.maven.archiva.database.RepositoryProblemDAO; import org.apache.maven.archiva.database.SimpleConstraint; -import java.io.Serializable; -import java.util.List; - /** * JdoArchivaDAO * @@ -52,11 +51,6 @@ public class JdoArchivaDAO /** * @plexus.requirement role-hint="jdo" */ - private ProjectModelDAO projectModelDAO; - - /** - * @plexus.requirement role-hint="jdo" - */ private RepositoryProblemDAO repositoryProblemDAO; /** @@ -64,6 +58,10 @@ public class JdoArchivaDAO */ private RepositoryContentStatisticsDAO repositoryContentStatisticsDAO; + public JdoArchivaDAO() + { + super(); //To change body of overridden methods use File | Settings | File Templates. + } public List<?> query( SimpleConstraint constraint ) { @@ -80,11 +78,6 @@ public class JdoArchivaDAO return artifactDAO; } - public ProjectModelDAO getProjectModelDAO() - { - return projectModelDAO; - } - public RepositoryProblemDAO getRepositoryProblemDAO() { return repositoryProblemDAO; diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java deleted file mode 100644 index 12c223018..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAO.java +++ /dev/null @@ -1,94 +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.ProjectModelDAO; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.jpox.ArchivaProjectModelKey; - -import java.util.List; - -/** - * JdoProjectModelDAO - * - * @version $Id$ - * - * @plexus.component role-hint="jdo" - */ -public class JdoProjectModelDAO - implements ProjectModelDAO -{ - /** - * @plexus.requirement role-hint="archiva" - */ - private JdoAccess jdo; - - public ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version ) - { - ArchivaProjectModel model; - - try - { - model = getProjectModel( groupId, artifactId, version ); - } - catch ( ArchivaDatabaseException e ) - { - model = new ArchivaProjectModel(); - model.setGroupId( groupId ); - model.setArtifactId( artifactId ); - model.setVersion( version ); - } - - return model; - } - - public ArchivaProjectModel getProjectModel( String groupId, String artifactId, String version ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - ArchivaProjectModelKey key = new ArchivaProjectModelKey(); - key.groupId = groupId; - key.artifactId = artifactId; - key.version = version; - - return (ArchivaProjectModel) jdo.getObjectById( ArchivaProjectModel.class, key, null ); - } - - @SuppressWarnings("unchecked") - public List<ArchivaProjectModel> queryProjectModels( Constraint constraint ) - throws ObjectNotFoundException, ArchivaDatabaseException - { - return (List<ArchivaProjectModel>) jdo.queryObjects( ArchivaProjectModel.class, constraint ); - } - - public ArchivaProjectModel saveProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException - { - return (ArchivaProjectModel) jdo.saveObject( model ); - } - - public void deleteProjectModel( ArchivaProjectModel model ) - throws ArchivaDatabaseException - { - jdo.removeObject( model ); - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/DatabaseProjectModelResolver.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/DatabaseProjectModelResolver.java deleted file mode 100644 index c05b624ec..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/DatabaseProjectModelResolver.java +++ /dev/null @@ -1,65 +0,0 @@ -package org.apache.maven.archiva.database.project; - -/* - * 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.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; - -/** - * Resolves a project model from the database. - * - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelResolver" - * role-hint="database" - */ -public class DatabaseProjectModelResolver - implements ProjectModelResolver -{ - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - public ArchivaProjectModel resolveProjectModel( VersionedReference reference ) - throws ProjectModelException - { - try - { - ArchivaProjectModel model = dao.getProjectModelDAO().getProjectModel( reference.getGroupId(), - reference.getArtifactId(), - reference.getVersion() ); - return model; - } - catch ( ObjectNotFoundException e ) - { - return null; - } - catch ( ArchivaDatabaseException e ) - { - return null; - } - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java deleted file mode 100644 index edba43335..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/project/ProjectModelToDatabaseListener.java +++ /dev/null @@ -1,157 +0,0 @@ -package org.apache.maven.archiva.database.project; - -/* - * 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 java.util.List; - -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.ObjectNotFoundException; -import org.apache.maven.archiva.model.ArchivaModelCloner; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.VersionedReference; -import org.apache.maven.archiva.repository.project.ProjectModelException; -import org.apache.maven.archiva.repository.project.ProjectModelResolver; -import org.apache.maven.archiva.repository.project.resolvers.FilesystemBasedResolver; -import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolutionListener; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Just in Time save of project models to the database, implemented as a listener - * on {@link ProjectModelResolver} objects that implement {@link FilesystemBasedResolver}. - * - * @version $Id$ - * - * @plexus.component - * role="org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolutionListener" - * role-hint="model-to-db" - */ -public class ProjectModelToDatabaseListener - implements ProjectModelResolutionListener -{ - private Logger log = LoggerFactory.getLogger( ProjectModelToDatabaseListener.class ); - - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - private void saveInDatabase( ArchivaProjectModel model ) - throws ProjectModelException - { - try - { - dao.getProjectModelDAO().saveProjectModel( model ); - } - catch ( ArchivaDatabaseException e ) - { - throw new ProjectModelException( "Unable to save model to database: " + e.getMessage(), e ); - } - } - - private void removeFromDatabase( ArchivaProjectModel model ) - throws ProjectModelException - { - try - { - dao.getProjectModelDAO().deleteProjectModel( model ); - } - catch ( ArchivaDatabaseException e ) - { - throw new ProjectModelException( "Unable to remove existing model from database: " + e.getMessage(), e ); - } - } - - private boolean existsInDatabase( ArchivaProjectModel model ) - throws ProjectModelException - { - try - { - ArchivaProjectModel dbmodel = dao.getProjectModelDAO().getProjectModel( model.getGroupId(), - model.getArtifactId(), - model.getVersion() ); - - return ( dbmodel != null ); - } - catch ( ObjectNotFoundException e ) - { - return false; - } - catch ( ArchivaDatabaseException e ) - { - throw new ProjectModelException( "Unable to check for existing model from database: " + e.getMessage(), e ); - } - } - - public void resolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver ) - { - /* do nothing */ - } - - public void resolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause ) - { - /* do nothing */ - } - - public void resolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver ) - { - /* do nothing */ - } - - public void resolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolverList ) - { - /* do nothing */ - } - - public void resolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolverList ) - { - /* do nothing */ - } - - public void resolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver, - ArchivaProjectModel model ) - { - if ( !( resolver instanceof FilesystemBasedResolver ) ) - { - // Nothing to do. skip it. - return; - } - - // Clone model, since DAO while detachingCopy resets contents of the model - // this changes behaviour of EffectiveProjectModelFilter - model = ArchivaModelCloner.clone( model ); - - try - { - // Test if it exists. - if ( existsInDatabase( model ) ) - { - removeFromDatabase( model ); - } - - saveInDatabase( model ); - } - catch ( ProjectModelException e ) - { - log.warn( e.getMessage(), e ); - } - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java deleted file mode 100644 index ed0fad974..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseConsumers.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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 java.util.ArrayList; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.Predicate; -import org.apache.commons.collections.functors.OrPredicate; -import org.apache.maven.archiva.configuration.ArchivaConfiguration; -import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration; -import org.apache.maven.archiva.consumers.functors.PermanentConsumerPredicate; -import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException; -import org.springframework.beans.BeansException; -import org.springframework.context.ApplicationContext; -import org.springframework.context.ApplicationContextAware; - -/** - * DatabaseConsumers - * - * @version $Id$ - */ -public class DatabaseConsumers - implements ApplicationContextAware -{ - private ArchivaConfiguration archivaConfiguration; - - private Predicate selectedUnprocessedConsumers; - - private ApplicationContext applicationContext; - - public DatabaseConsumers( ArchivaConfiguration archivaConfiguration ) - { - this.archivaConfiguration = archivaConfiguration; - - Predicate permanentConsumers = new PermanentConsumerPredicate(); - - selectedUnprocessedConsumers = new OrPredicate( permanentConsumers, new SelectedUnprocessedConsumersPredicate() ); - } - - class SelectedUnprocessedConsumersPredicate - implements Predicate - { - public boolean evaluate( Object object ) - { - boolean satisfies = false; - - if ( object instanceof DatabaseUnprocessedArtifactConsumer ) - { - DatabaseUnprocessedArtifactConsumer consumer = (DatabaseUnprocessedArtifactConsumer) object; - DatabaseScanningConfiguration config = archivaConfiguration.getConfiguration().getDatabaseScanning(); - - return config.getUnprocessedConsumers().contains( consumer.getId() ); - } - - return satisfies; - } - } - - public void initialize() - throws InitializationException - { - Predicate permanentConsumers = new PermanentConsumerPredicate(); - - selectedUnprocessedConsumers = new OrPredicate( permanentConsumers, new SelectedUnprocessedConsumersPredicate() ); - } - - public void setApplicationContext( ApplicationContext applicationContext ) - throws BeansException - { - this.applicationContext = applicationContext; - } - - /** - * Get the {@link List} of {@link DatabaseUnprocessedArtifactConsumer} objects - * for those consumers selected due to the configuration. - * - * @return the list of selected {@link DatabaseUnprocessedArtifactConsumer} objects. - */ - @SuppressWarnings("unchecked") - public List<ArchivaArtifactConsumer> getSelectedUnprocessedConsumers() - { - List<ArchivaArtifactConsumer> ret = new ArrayList<ArchivaArtifactConsumer>(); - ret.addAll( CollectionUtils.select( getAvailableUnprocessedConsumers(), selectedUnprocessedConsumers ) ); - return ret; - } - - /** - * Get the complete {@link List} of {@link DatabaseUnprocessedArtifactConsumer} objects - * that are available in the system, regardless of configuration. - * - * @return the list of all available {@link DatabaseUnprocessedArtifactConsumer} objects. - */ - @SuppressWarnings("unchecked") - public List<DatabaseUnprocessedArtifactConsumer> getAvailableUnprocessedConsumers() - { - return new ArrayList<DatabaseUnprocessedArtifactConsumer>( applicationContext.getBeansOfType( DatabaseUnprocessedArtifactConsumer.class ).values() ); - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUnprocessedArtifactConsumer.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUnprocessedArtifactConsumer.java deleted file mode 100644 index a3cde7eaa..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUnprocessedArtifactConsumer.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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. - */ - -/** - * DatabaseUnprocessedArtifactConsumer - * - * @version $Id$ - */ -public interface DatabaseUnprocessedArtifactConsumer - extends ArchivaArtifactConsumer -{ - -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUpdater.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUpdater.java deleted file mode 100644 index b6e5b0fba..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/DatabaseUpdater.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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.model.ArchivaArtifact; - -/** - * The database update component. - * - * @version $Id$ - */ -public interface DatabaseUpdater -{ - /** - * Update all unprocessed content. - * - * @throws ArchivaDatabaseException if there was a fatal error with the database. - */ - public void updateAllUnprocessed() - throws ArchivaDatabaseException; - - /** - * Update specific unprocessed content. - * - * @throws ArchivaDatabaseException if there was a fatal error with the database. - */ - public void updateUnprocessed( ArchivaArtifact artifact ) - throws ArchivaDatabaseException; -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java deleted file mode 100644 index cde8fc8af..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/JdoDatabaseUpdater.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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 java.util.Date; -import java.util.Iterator; -import java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.apache.commons.collections.IteratorUtils; -import org.apache.commons.collections.Predicate; -import org.apache.maven.archiva.database.ArchivaDAO; -import org.apache.maven.archiva.database.ArchivaDatabaseException; -import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.functors.UnprocessedArtifactPredicate; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * JdoDatabaseUpdater - * - * @version $Id$ - * - * @plexus.component role="org.apache.maven.archiva.database.updater.DatabaseUpdater" - * role-hint="jdo" - */ -public class JdoDatabaseUpdater - implements DatabaseUpdater -{ - private Logger log = LoggerFactory.getLogger( JdoDatabaseUpdater.class ); - - /** - * @plexus.requirement role-hint="jdo" - */ - private ArchivaDAO dao; - - /** - * @plexus.requirement - */ - private DatabaseConsumers dbConsumers; - - private ProcessArchivaArtifactClosure processArtifactClosure = new ProcessArchivaArtifactClosure(); - - public void updateAllUnprocessed() - throws ArchivaDatabaseException - { - List<ArchivaArtifact> unprocessedArtifacts = dao.getArtifactDAO().queryArtifacts( new ArtifactsProcessedConstraint( false ) ); - - beginConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() ); - - try - { - // Process each consumer. - Predicate predicate = UnprocessedArtifactPredicate.getInstance(); - - Iterator<ArchivaArtifact> it = IteratorUtils.filteredIterator( unprocessedArtifacts.iterator(), predicate ); - while ( it.hasNext() ) - { - ArchivaArtifact artifact = it.next(); - updateUnprocessed( artifact ); - } - } - finally - { - endConsumerLifecycle( dbConsumers.getSelectedUnprocessedConsumers() ); - } - } - - private void endConsumerLifecycle( List<ArchivaArtifactConsumer> consumers ) - { - for ( ArchivaArtifactConsumer consumer : consumers ) - { - consumer.completeScan(); - } - } - - private void beginConsumerLifecycle( List<ArchivaArtifactConsumer> consumers ) - { - for ( ArchivaArtifactConsumer consumer : consumers ) - { - consumer.beginScan(); - } - } - - public void updateUnprocessed( ArchivaArtifact artifact ) - throws ArchivaDatabaseException - { - List<ArchivaArtifactConsumer> consumers = dbConsumers.getSelectedUnprocessedConsumers(); - - if ( CollectionUtils.isEmpty( consumers ) ) - { - log.warn( "There are no selected consumers for unprocessed artifacts." ); - return; - } - - this.processArtifactClosure.setArtifact( artifact ); - CollectionUtils.forAllDo( consumers, this.processArtifactClosure ); - - artifact.getModel().setWhenProcessed( new Date() ); - dao.getArtifactDAO().saveArtifact( artifact ); - } -} diff --git a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/ProcessArchivaArtifactClosure.java b/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/ProcessArchivaArtifactClosure.java deleted file mode 100644 index eee178b8f..000000000 --- a/archiva-modules/archiva-database/src/main/java/org/apache/maven/archiva/database/updater/ProcessArchivaArtifactClosure.java +++ /dev/null @@ -1,67 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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.commons.collections.Closure; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * ProcessArchivaArtifactClosure - * - * @version $Id$ - */ -class ProcessArchivaArtifactClosure - implements Closure -{ - private Logger log = LoggerFactory.getLogger( ProcessArchivaArtifactClosure.class ); - - private ArchivaArtifact artifact; - - public void execute( Object input ) - { - if ( input instanceof ArchivaArtifactConsumer ) - { - ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) input; - - try - { - consumer.processArchivaArtifact( artifact ); - } - catch ( ConsumerException e ) - { - log.warn( "Unable to process artifact [" + artifact + "] with consumer [" + consumer.getId() + "]", e ); - } - } - - } - - public ArchivaArtifact getArtifact() - { - return artifact; - } - - public void setArtifact( ArchivaArtifact artifact ) - { - this.artifact = artifact; - } -} diff --git a/archiva-modules/archiva-database/src/main/resources/META-INF/spring-context.xml b/archiva-modules/archiva-database/src/main/resources/META-INF/spring-context.xml deleted file mode 100644 index 53b798ec8..000000000 --- a/archiva-modules/archiva-database/src/main/resources/META-INF/spring-context.xml +++ /dev/null @@ -1,11 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<beans xmlns="http://www.springframework.org/schema/beans" - xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd"> - - <bean id="databaseConsumers" class="org.apache.maven.archiva.database.updater.DatabaseConsumers" scope="prototype"> - <constructor-arg> - <ref bean="archivaConfiguration"/> - </constructor-arg> - </bean> -</beans>
\ No newline at end of file diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java index 3a8865b73..7c5321553 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/AbstractArchivaDatabaseTestCase.java @@ -29,8 +29,6 @@ import javax.jdo.PersistenceManager; import javax.jdo.PersistenceManagerFactory; import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer; -import org.apache.maven.archiva.database.updater.TestDatabaseUnprocessedConsumer; import org.apache.maven.archiva.model.ArtifactReference; import org.apache.maven.archiva.model.VersionedReference; import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory; @@ -128,16 +126,6 @@ public abstract class AbstractArchivaDatabaseTestCase this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" ); } - protected TestDatabaseUnprocessedConsumer lookupTestUnprocessedConsumer() - throws Exception - { - TestDatabaseUnprocessedConsumer consumer = (TestDatabaseUnprocessedConsumer) lookup( - DatabaseUnprocessedArtifactConsumer.class, - "test-db-unprocessed" ); - assertNotNull( "Test Database Unprocessed Consumer should not be null.", consumer ); - return consumer; - } - protected Date toDate( String txt ) throws Exception { diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java deleted file mode 100644 index 7795b3a9a..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/constraints/ProjectsByArtifactUsageConstraintTest.java +++ /dev/null @@ -1,115 +0,0 @@ -package org.apache.maven.archiva.database.constraints; - -/* - * 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.DeclarativeConstraint; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.model.ArtifactReference; -import org.apache.maven.archiva.model.Dependency; -import org.apache.maven.archiva.model.VersionedReference; - -import java.util.Date; -import java.util.List; - -/** - * ProjectsByArtifactUsageConstraintTest - * - * @version $Id$ - */ -public class ProjectsByArtifactUsageConstraintTest - extends AbstractArchivaDatabaseTestCase -{ - @Override - protected void setUp() - throws Exception - { - super.setUp(); - } - - private void saveModel( String modelId, String deps[] ) - throws Exception - { - ArchivaProjectModel model = new ArchivaProjectModel(); - // Piece together a simple model. - VersionedReference ref = toVersionedReference( modelId ); - model.setGroupId( ref.getGroupId() ); - model.setArtifactId( ref.getArtifactId() ); - model.setVersion( ref.getVersion() ); - model.setPackaging( "jar" ); - model.setOrigin( "testcase" ); - - if ( deps != null ) - { - for ( int i = 0; i < deps.length; i++ ) - { - ArtifactReference artiref = toArtifactReference( deps[i] ); - Dependency dep = new Dependency(); - dep.setGroupId( artiref.getGroupId() ); - dep.setArtifactId( artiref.getArtifactId() ); - dep.setVersion( artiref.getVersion() ); - dep.setClassifier( artiref.getClassifier() ); - dep.setClassifier( artiref.getType() ); - - model.addDependency( dep ); - } - } - - dao.getProjectModelDAO().saveProjectModel( model ); - } - - public ArchivaArtifact toArtifact( String id ) - { - ArtifactReference ref = toArtifactReference( id ); - - ArchivaArtifact artifact = new ArchivaArtifact( ref.getGroupId(), ref.getArtifactId(), ref.getVersion(), ref - .getClassifier(), ref.getType(), "testable_repo" ); - artifact.getModel().setLastModified( new Date() ); - artifact.getModel().setRepositoryId( "testable_repo" ); - return artifact; - } - - public void testContraint() - throws Exception - { - saveModel( "org.apache.maven.archiva:archiva-configuration:1.0", - new String[] { "org.codehaus.plexus:plexus-digest:1.0::jar:" } ); - - saveModel( "org.apache.maven.archiva:archiva-common:1.0", new String[] { - "org.codehaus.plexus:plexus-digest:1.0::jar:", - "junit:junit:3.8.1::jar:" } ); - - ArchivaArtifact artifact; - - artifact = toArtifact( "org.foo:bar:4.0::jar:" ); - assertConstraint( 0, new ProjectsByArtifactUsageConstraint( artifact ) ); - artifact = toArtifact( "org.codehaus.plexus:plexus-digest:1.0::jar:testable_repo" ); - assertConstraint( 2, new ProjectsByArtifactUsageConstraint( artifact ) ); - } - - private void assertConstraint( int expectedHits, DeclarativeConstraint constraint ) - throws Exception - { - List<ArchivaProjectModel> results = dao.getProjectModelDAO().queryProjectModels( constraint ); - assertNotNull( "Projects By Artifact Usage: Not Null", results ); - assertEquals( "Projects By Artifact Usage: Results.size", expectedHits, results.size() ); - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java index 2ec9cde2b..c0c06bb1d 100644 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java +++ b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoArchivaDAOTest.java @@ -32,7 +32,6 @@ public class JdoArchivaDAOTest public void testSubDAOs() { assertNotNull( "Artifact DAO", dao.getArtifactDAO() ); - assertNotNull( "Project Model DAO", dao.getProjectModelDAO() ); assertNotNull( "Repository Problem DAO", dao.getRepositoryProblemDAO() ); } } diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java deleted file mode 100644 index c51168468..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/jdo/JdoProjectModelDAOTest.java +++ /dev/null @@ -1,168 +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 java.io.File; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.jdo.JDOHelper; - -import org.apache.commons.beanutils.PropertyUtils; -import org.apache.commons.lang.StringUtils; -import org.apache.maven.archiva.database.AbstractArchivaDatabaseTestCase; -import org.apache.maven.archiva.database.ProjectModelDAO; -import org.apache.maven.archiva.model.ArchivaProjectModel; -import org.apache.maven.archiva.repository.project.ProjectModelReader; -import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader; - -/** - * JdoProjectModelDAOTest - * - * @version $Id$ - */ -public class JdoProjectModelDAOTest - extends AbstractArchivaDatabaseTestCase -{ - public void testProjectModelCRUD() - throws Exception - { - ProjectModelDAO projectDao = dao.getProjectModelDAO(); - - // Create it - ArchivaProjectModel model = projectDao.createProjectModel( "org.apache.maven.archiva", "archiva-test-module", - "1.0" ); - assertNotNull( model ); - - // Set some mandatory values - model.setPackaging( "pom" ); - model.setWhenIndexed( new Date() ); - model.setOrigin( "test" ); - - // Save it. - ArchivaProjectModel savedModel = projectDao.saveProjectModel( model ); - assertNotNull( savedModel ); - String savedKeyId = JDOHelper.getObjectId( savedModel ).toString(); - assertEquals( "org.apache.maven.archiva:archiva-test-module:1.0", savedKeyId ); - - // Test that something has been saved. - List<ArchivaProjectModel> projects = projectDao.queryProjectModels( null ); - assertNotNull( projects ); - assertEquals( 1, projects.size() ); - - // Test that retrieved object is what we expect. - ArchivaProjectModel firstModel = (ArchivaProjectModel) projects.get( 0 ); - assertNotNull( firstModel ); - assertEquals( "org.apache.maven.archiva", firstModel.getGroupId() ); - assertEquals( "archiva-test-module", firstModel.getArtifactId() ); - assertEquals( "1.0", firstModel.getVersion() ); - - // Change value and save. - savedModel.setOrigin( "changed" ); - projectDao.saveProjectModel( savedModel ); - - // Test that only 1 object is saved. - assertEquals( 1, projectDao.queryProjectModels( null ).size() ); - - // Get the specific artifact. - ArchivaProjectModel actualModel = projectDao.getProjectModel( "org.apache.maven.archiva", - "archiva-test-module", "1.0" ); - assertNotNull( actualModel ); - - // Test expected values. - assertEquals( "archiva-test-module", actualModel.getArtifactId() ); - assertEquals( "changed", actualModel.getOrigin() ); - - // Test that only 1 object is saved. - assertEquals( 1, projectDao.queryProjectModels( null ).size() ); - - // Delete object. - projectDao.deleteProjectModel( actualModel ); - assertEquals( 0, projectDao.queryProjectModels( null ).size() ); - } - - public void testSaveGetRealProjectModel() - throws Exception - { - String groupId = "org.apache.maven.shared"; - String artifactId = "maven-shared-jar"; - String version = "1.0-SNAPSHOT"; - - ProjectModelDAO projectDao = dao.getProjectModelDAO(); - - ProjectModelReader modelReader = new ProjectModel400Reader(); - - File pomFile = getTestFile( "src/test/resources/projects/maven-shared-jar-1.0-SNAPSHOT.pom" ); - - assertTrue( "pom file should exist: " + pomFile.getAbsolutePath(), pomFile.exists() && pomFile.isFile() ); - - ArchivaProjectModel model = modelReader.read( pomFile ); - assertNotNull( "Model should not be null.", model ); - - /* NOTE: We are intentionally using a basic project model in this unit test. - * The expansion of expressions, resolving of dependencies, and merging - * of parent poms is *NOT* performed to keep this unit test simple. - */ - - // Fill in mandatory/missing fields - model.setGroupId( groupId ); - model.setOrigin( "testcase" ); - - projectDao.saveProjectModel( model ); - - ArchivaProjectModel savedModel = projectDao.getProjectModel( groupId, artifactId, version ); - assertNotNull( "Project model should not be null.", savedModel ); - - // Test proper detachment of sub-objects. - List<String> exprs = new ArrayList<String>(); - exprs.add( "parentProject.groupId" ); - exprs.add( "organization.name" ); - exprs.add( "issueManagement.system" ); - exprs.add( "ciManagement.system" ); - exprs.add( "scm.url" ); - exprs.add( "individuals[0].name" ); - exprs.add( "dependencies[0].groupId" ); - exprs.add( "dependencyManagement[0].artifactId" ); - exprs.add( "repositories[0].id" ); - exprs.add( "plugins[0].artifactId" ); - exprs.add( "reports[0].artifactId" ); - exprs.add( "buildExtensions[0].artifactId" ); - exprs.add( "licenses[0].url" ); - exprs.add( "mailingLists[0].name" ); - - for ( String expr : exprs ) - { - try - { - Object obj = PropertyUtils.getProperty( model, expr ); - assertNotNull( "Expr \"" + expr + "\" != null", obj ); - assertTrue( "Expr \"" + expr + "\" should be a String.", ( obj instanceof String ) ); - String value = (String) obj; - assertTrue( "Expr \"" + expr + "\" value should not be blank.", StringUtils.isNotBlank( value ) ); - } - catch ( IndexOutOfBoundsException e ) - { - fail( "Expr \"" + expr + "\" unable to get indexed property: " + e.getClass().getName() + ": " - + e.getMessage() ); - } - } - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java deleted file mode 100644 index c62f112f4..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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 java.util.List; - -import org.apache.commons.collections.CollectionUtils; -import org.codehaus.plexus.spring.PlexusInSpringTestCase; - -/** - * DatabaseConsumersTest - * - * @version $Id$ - */ -public class DatabaseConsumersTest - extends PlexusInSpringTestCase -{ - private DatabaseConsumers lookupDbConsumers() - throws Exception - { - DatabaseConsumers dbconsumers = (DatabaseConsumers) lookup( DatabaseConsumers.class ); - assertNotNull( "DatabaseConsumers should not be null.", dbconsumers ); - return dbconsumers; - } - - public void testGetAvailableUnprocessedConsumers() - throws Exception - { - DatabaseConsumers dbconsumers = lookupDbConsumers(); - List<DatabaseUnprocessedArtifactConsumer> available = dbconsumers.getAvailableUnprocessedConsumers(); - assertNotNull( "Available Unprocessed Consumers should never be null.", available ); - - assertTrue( "Available Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) ); - } - - public void testGetSelectedUnprocessedConsumers() - throws Exception - { - DatabaseConsumers dbconsumers = lookupDbConsumers(); - List<ArchivaArtifactConsumer> available = dbconsumers.getSelectedUnprocessedConsumers(); - assertNotNull( "Selected Unprocessed Consumers should never be null.", available ); - - assertTrue( "Selected Unprocessed Consumers should have entries.", CollectionUtils.isNotEmpty( available ) ); - } - -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.java deleted file mode 100644 index 2056123b3..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.java +++ /dev/null @@ -1,103 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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.ArtifactDAO; -import org.apache.maven.archiva.model.ArchivaArtifact; - -import java.util.Date; - -/** - * DatabaseUpdaterTest - * - * @version $Id$ - */ -public class DatabaseUpdaterTest - extends AbstractArchivaDatabaseTestCase -{ - private DatabaseUpdater dbupdater; - - public ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String whenProcessed ) - throws Exception - { - ArchivaArtifact artifact = dao.getArtifactDAO().createArtifact( groupId, artifactId, version, "", "jar", "testrepo" ); - assertNotNull( "Artifact should not be null.", artifact ); - Date dateWhenProcessed = null; - - if ( whenProcessed != null ) - { - dateWhenProcessed = toDate( whenProcessed ); - } - - artifact.getModel().setWhenProcessed( dateWhenProcessed ); - - // Satisfy table / column requirements. - artifact.getModel().setLastModified( new Date() ); - - return artifact; - } - - @Override - protected void setUp() - throws Exception - { - super.setUp(); - - ArtifactDAO adao = dao.getArtifactDAO(); - assertNotNull( "Artifact DAO should not be null.", adao ); - - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-common", "1.0-SNAPSHOT", null ) ); - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-utils", "1.0-SNAPSHOT", null ) ); - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-old", "0.1", "2004/02/15 9:01:00" ) ); - adao.saveArtifact( createArtifact( "org.apache.maven.archiva", "archiva-database", "1.0-SNAPSHOT", null ) ); - - dbupdater = (DatabaseUpdater) lookup( DatabaseUpdater.class, "jdo" ); - assertNotNull( "DatabaseUpdater should not be null.", dbupdater ); - } - - public void testUpdateUnprocessed() - throws Exception - { - String groupId = "org.apache.maven.archiva"; - String artifactId = "archiva-utils"; - String version = "1.0-SNAPSHOT"; - String classifier = ""; - String type = "jar"; - - TestDatabaseUnprocessedConsumer consumer = lookupTestUnprocessedConsumer(); - consumer.resetCount(); - - // Check the state of the artifact in the DB. - ArchivaArtifact savedArtifact = dao.getArtifactDAO().getArtifact( groupId, artifactId, version, classifier, - type, "testrepo" ); - assertFalse( "Artifact should not be considered processed (yet).", savedArtifact.getModel().isProcessed() ); - - // Update the artifact - dbupdater.updateUnprocessed( savedArtifact ); - - // Check the update. - ArchivaArtifact processed = dao.getArtifactDAO().getArtifact( groupId, artifactId, version, classifier, type, "testrepo" ); - assertTrue( "Artifact should be flagged as processed.", processed.getModel().isProcessed() ); - - // Did the unprocessed consumer do it's thing? - assertEquals( "Processed Count.", 1, consumer.getCountProcessed() ); - } -} diff --git a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java b/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java deleted file mode 100644 index f35dd67d6..000000000 --- a/archiva-modules/archiva-database/src/test/java/org/apache/maven/archiva/database/updater/TestDatabaseUnprocessedConsumer.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.apache.maven.archiva.database.updater; - -/* - * 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 java.util.ArrayList; -import java.util.List; - -import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer; -import org.apache.maven.archiva.consumers.ConsumerException; -import org.apache.maven.archiva.model.ArchivaArtifact; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * TestDatabaseUnprocessedConsumer - * - * @version $Id$ - */ -public class TestDatabaseUnprocessedConsumer - extends AbstractMonitoredConsumer - implements DatabaseUnprocessedArtifactConsumer -{ - private Logger log = LoggerFactory.getLogger( TestDatabaseUnprocessedConsumer.class ); - - private int countBegin = 0; - - private int countComplete = 0; - - private int countProcessed = 0; - - public void resetCount() - { - countBegin = 0; - countProcessed = 0; - countComplete = 0; - } - - public void beginScan() - { - countBegin++; - } - - public void completeScan() - { - countComplete++; - } - - public List<String> getIncludedTypes() - { - List<String> types = new ArrayList<String>(); - types.add( "pom" ); - types.add( "jar" ); - return types; - } - - public void processArchivaArtifact( ArchivaArtifact artifact ) - throws ConsumerException - { - log.info( "Processing Artifact: " + artifact ); - countProcessed++; - } - - public String getDescription() - { - return "Test Consumer for Database Unprocessed"; - } - - public String getId() - { - return "test-db-unprocessed"; - } - - public boolean isPermanent() - { - return false; - } - - public int getCountBegin() - { - return countBegin; - } - - public int getCountComplete() - { - return countComplete; - } - - public int getCountProcessed() - { - return countProcessed; - } -} diff --git a/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml b/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml index 4783e9e1f..0e6441f55 100644 --- a/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml +++ b/archiva-modules/archiva-database/src/test/resources/META-INF/plexus/components.xml @@ -14,12 +14,6 @@ </otherProperties> </configuration> </component> - - <component> - <role>org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer</role> - <role-hint>test-db-unprocessed</role-hint> - <implementation>org.apache.maven.archiva.database.updater.TestDatabaseUnprocessedConsumer</implementation> - </component> </components> </component-set> diff --git a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml b/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml deleted file mode 100644 index c9e47bd41..000000000 --- a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseConsumersTest.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" ?> - -<component-set> - <components> - <component> - <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> - <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> - <field-name>prePolicies</field-name> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> - <field-name>postPolicies</field-name> - </requirement> - </requirements> - </component> - <component> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> - <configuration> - <properties> - <system/> - <xml fileName="${basedir}/src/test/resources/archiva-test.xml" - config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> - </properties> - </configuration> - </component> - </components> -</component-set> - diff --git a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml b/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml deleted file mode 100644 index c9e47bd41..000000000 --- a/archiva-modules/archiva-database/src/test/resources/org/apache/maven/archiva/database/updater/DatabaseUpdaterTest.xml +++ /dev/null @@ -1,37 +0,0 @@ -<?xml version="1.0" ?> - -<component-set> - <components> - <component> - <role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role> - <implementation>org.apache.maven.archiva.configuration.DefaultArchivaConfiguration</implementation> - <requirements> - <requirement> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PreDownloadPolicy</role> - <field-name>prePolicies</field-name> - </requirement> - <requirement> - <role>org.apache.maven.archiva.policies.PostDownloadPolicy</role> - <field-name>postPolicies</field-name> - </requirement> - </requirements> - </component> - <component> - <role>org.codehaus.plexus.registry.Registry</role> - <role-hint>configured</role-hint> - <implementation>org.codehaus.plexus.registry.commons.CommonsConfigurationRegistry</implementation> - <configuration> - <properties> - <system/> - <xml fileName="${basedir}/src/test/resources/archiva-test.xml" - config-name="org.apache.maven.archiva" config-at="org.apache.maven.archiva"/> - </properties> - </configuration> - </component> - </components> -</component-set> - |