mirror of https://github.com/apache/archiva.git
[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
This commit is contained in:
parent
cb96e18f97
commit
7a63bee6de
|
@ -1,353 +0,0 @@
|
|||
package org.apache.maven.archiva.consumers.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 java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.consumers.AbstractMonitoredConsumer;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
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.database.updater.DatabaseUnprocessedArtifactConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaModelCloner;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.Keys;
|
||||
import org.apache.maven.archiva.model.RepositoryProblem;
|
||||
import org.apache.maven.archiva.reporting.artifact.CorruptArtifactReport;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
import org.apache.maven.archiva.repository.content.ManagedLegacyRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.filters.EffectiveProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.cache.Cache;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* ProjectModelToDatabaseConsumer
|
||||
*
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer"
|
||||
* role-hint="update-db-project"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ProjectModelToDatabaseConsumer
|
||||
extends AbstractMonitoredConsumer
|
||||
implements DatabaseUnprocessedArtifactConsumer
|
||||
{
|
||||
private Logger log = LoggerFactory.getLogger( ProjectModelToDatabaseConsumer.class );
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="update-db-project"
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* @plexus.configuration default-value="Update database with project model information."
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
private ArchivaDAO dao;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryContentFactory repositoryFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.maven.archiva.repository.project.ProjectModelFilter"
|
||||
* role-hint="effective"
|
||||
*/
|
||||
private EffectiveProjectModelFilter effectiveModelFilter;
|
||||
|
||||
private List<String> includes;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="effective-project-cache"
|
||||
*/
|
||||
private Cache effectiveProjectCache;
|
||||
|
||||
public ProjectModelToDatabaseConsumer()
|
||||
{
|
||||
includes = new ArrayList<String>();
|
||||
includes.add( "pom" );
|
||||
}
|
||||
|
||||
public void beginScan()
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
public void completeScan()
|
||||
{
|
||||
/* nothing to do here */
|
||||
}
|
||||
|
||||
public List<String> getIncludedTypes()
|
||||
{
|
||||
return includes;
|
||||
}
|
||||
|
||||
public void processArchivaArtifact( ArchivaArtifact artifact )
|
||||
throws ConsumerException
|
||||
{
|
||||
if ( !StringUtils.equals( "pom", artifact.getType() ) )
|
||||
{
|
||||
// Not a pom. Skip it.
|
||||
return;
|
||||
}
|
||||
|
||||
ArchivaProjectModel model = null;
|
||||
|
||||
// remove old project model if it already exists in the database
|
||||
if ( ( model =
|
||||
getProjectModelFromDatabase( artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion() ) ) != null )
|
||||
{
|
||||
removeOldProjectModel( model );
|
||||
model = null;
|
||||
}
|
||||
|
||||
ManagedRepositoryContent repo = getRepository( artifact );
|
||||
File artifactFile = repo.toFile( artifact );
|
||||
|
||||
ProjectModelReader reader;
|
||||
if ( repo instanceof ManagedLegacyRepositoryContent )
|
||||
{
|
||||
reader = new ProjectModel300Reader();
|
||||
}
|
||||
else
|
||||
{
|
||||
reader = new ProjectModel400Reader();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
model = reader.read( artifactFile );
|
||||
|
||||
// The version should be updated to the artifact/filename version if it is a unique snapshot
|
||||
if ( VersionUtil.isUniqueSnapshot( artifact.getVersion() ) )
|
||||
{
|
||||
model.setVersion( artifact.getVersion() );
|
||||
}
|
||||
|
||||
// Resolve the project model (build effective model, resolve expressions)
|
||||
model = effectiveModelFilter.filter( model );
|
||||
|
||||
if ( isValidModel( model, repo, artifact ) )
|
||||
{
|
||||
log.debug( "Adding project model to database - " + Keys.toKey( model ) );
|
||||
|
||||
// Clone model, since DAO while detachingCopy resets its contents
|
||||
// This changes contents of the cache in EffectiveProjectModelFilter
|
||||
model = ArchivaModelCloner.clone( model );
|
||||
|
||||
dao.getProjectModelDAO().saveProjectModel( model );
|
||||
}
|
||||
else
|
||||
{
|
||||
log.warn( "Invalid or corrupt pom. Project model not added to database - " + Keys.toKey( model ) );
|
||||
}
|
||||
|
||||
}
|
||||
catch ( XMLException e )
|
||||
{
|
||||
log.warn( "Unable to read project model " + artifactFile + " : " + e.getMessage() );
|
||||
|
||||
addProblem( artifact, "Unable to read project model " + artifactFile + " : " + e.getMessage() );
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
{
|
||||
log.warn( "Unable to save project model " + artifactFile + " to the database : " + e.getMessage(), e );
|
||||
}
|
||||
catch ( Throwable t )
|
||||
{
|
||||
// Catch the other errors in the process to allow the rest of the process to complete.
|
||||
log.error( "Unable to process model " + artifactFile + " due to : " + t.getClass().getName() + " : " +
|
||||
t.getMessage(), t );
|
||||
}
|
||||
}
|
||||
|
||||
private ArchivaProjectModel getProjectModelFromDatabase( String groupId, String artifactId, String version )
|
||||
{
|
||||
try
|
||||
{
|
||||
ArchivaProjectModel model = dao.getProjectModelDAO().getProjectModel( groupId, artifactId, version );
|
||||
return model;
|
||||
}
|
||||
catch ( ObjectNotFoundException e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private ManagedRepositoryContent getRepository( ArchivaArtifact artifact )
|
||||
throws ConsumerException
|
||||
{
|
||||
String repoId = artifact.getModel().getRepositoryId();
|
||||
try
|
||||
{
|
||||
return repositoryFactory.getManagedRepositoryContent( repoId );
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
throw new ConsumerException( "Unable to process project model: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isPermanent()
|
||||
{
|
||||
// Tells the configuration that this consumer cannot be disabled.
|
||||
return true;
|
||||
}
|
||||
|
||||
private boolean isValidModel( ArchivaProjectModel model, ManagedRepositoryContent repo, ArchivaArtifact artifact )
|
||||
throws ConsumerException
|
||||
{
|
||||
File artifactFile = repo.toFile( artifact );
|
||||
|
||||
if ( !artifact.getArtifactId().equalsIgnoreCase( model.getArtifactId() ) )
|
||||
{
|
||||
StringBuffer emsg = new StringBuffer();
|
||||
emsg.append( "File " ).append( artifactFile.getName() );
|
||||
emsg.append( " has an invalid project model [" );
|
||||
appendModel( emsg, model );
|
||||
emsg.append( "]: The model artifactId [" ).append( model.getArtifactId() );
|
||||
emsg.append( "] does not match the artifactId portion of the filename: " ).append( artifact.getArtifactId() );
|
||||
|
||||
log.warn( emsg.toString() );
|
||||
addProblem( artifact, emsg.toString() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( !artifact.getVersion().equalsIgnoreCase( model.getVersion() ) &&
|
||||
!VersionUtil.getBaseVersion( artifact.getVersion() ).equalsIgnoreCase( model.getVersion() ) )
|
||||
{
|
||||
StringBuffer emsg = new StringBuffer();
|
||||
emsg.append( "File " ).append( artifactFile.getName() );
|
||||
emsg.append( " has an invalid project model [" );
|
||||
appendModel( emsg, model );
|
||||
emsg.append( "]; The model version [" ).append( model.getVersion() );
|
||||
emsg.append( "] does not match the version portion of the filename: " ).append( artifact.getVersion() );
|
||||
|
||||
log.warn( emsg.toString() );
|
||||
addProblem( artifact, emsg.toString() );
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void appendModel( StringBuffer buf, ArchivaProjectModel model )
|
||||
{
|
||||
buf.append( "groupId:" ).append( model.getGroupId() );
|
||||
buf.append( "|artifactId:" ).append( model.getArtifactId() );
|
||||
buf.append( "|version:" ).append( model.getVersion() );
|
||||
buf.append( "|packaging:" ).append( model.getPackaging() );
|
||||
}
|
||||
|
||||
private void addProblem( ArchivaArtifact artifact, String msg )
|
||||
throws ConsumerException
|
||||
{
|
||||
ManagedRepositoryContent repo = getRepository( artifact );
|
||||
|
||||
RepositoryProblem problem = new RepositoryProblem();
|
||||
problem.setRepositoryId( artifact.getModel().getRepositoryId() );
|
||||
problem.setPath( repo.toPath( artifact ) );
|
||||
problem.setGroupId( artifact.getGroupId() );
|
||||
problem.setArtifactId( artifact.getArtifactId() );
|
||||
problem.setVersion( artifact.getVersion() );
|
||||
problem.setType( CorruptArtifactReport.PROBLEM_TYPE_CORRUPT_ARTIFACT );
|
||||
problem.setOrigin( getId() );
|
||||
problem.setMessage( msg );
|
||||
|
||||
try
|
||||
{
|
||||
dao.getRepositoryProblemDAO().saveRepositoryProblem( problem );
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
{
|
||||
String emsg = "Unable to save problem with artifact location to DB: " + e.getMessage();
|
||||
log.warn( emsg, e );
|
||||
throw new ConsumerException( emsg, e );
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private void removeOldProjectModel( ArchivaProjectModel model )
|
||||
{
|
||||
try
|
||||
{
|
||||
dao.getProjectModelDAO().deleteProjectModel( model );
|
||||
}
|
||||
catch ( ArchivaDatabaseException ae )
|
||||
{
|
||||
log.error( "Unable to delete existing project model." );
|
||||
}
|
||||
|
||||
// Force removal of project model from effective cache
|
||||
String projectKey = toProjectKey( model );
|
||||
synchronized ( effectiveProjectCache )
|
||||
{
|
||||
if ( effectiveProjectCache.hasKey( projectKey ) )
|
||||
{
|
||||
effectiveProjectCache.remove( projectKey );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
package org.apache.maven.archiva.consumers.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.commons.io.FileUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifactModel;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
*/
|
||||
public abstract class AbstractDatabaseCleanupTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
ArchivaConfiguration archivaConfig;
|
||||
|
||||
RepositoryContentFactory repositoryFactory;
|
||||
|
||||
public static final String TEST_GROUP_ID = "org.apache.maven.archiva";
|
||||
|
||||
public static final String TEST_ARTIFACT_ID = "cleanup-artifact-test";
|
||||
|
||||
public static final String TEST_VERSION = "1.0";
|
||||
|
||||
public static final String TEST_REPO_ID = "test-repo";
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
// archiva configuration (need to update the repository url)
|
||||
File userFile = getTestFile( "target/test/repository-manager.xml" );
|
||||
userFile.delete();
|
||||
assertFalse( userFile.exists() );
|
||||
|
||||
userFile.getParentFile().mkdirs();
|
||||
FileUtils.copyFileToDirectory( getTestFile( "src/test/conf/repository-manager.xml" ),
|
||||
userFile.getParentFile() );
|
||||
|
||||
archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class, "database-cleanup" );
|
||||
|
||||
Configuration configuration = archivaConfig.getConfiguration();
|
||||
ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( TEST_REPO_ID );
|
||||
repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
|
||||
|
||||
archivaConfig.save( configuration );
|
||||
|
||||
repositoryFactory = (RepositoryContentFactory) lookup( RepositoryContentFactory.class );
|
||||
}
|
||||
|
||||
protected ArchivaArtifact createArtifact( String groupId, String artifactId, String version, String type )
|
||||
{
|
||||
ArchivaArtifactModel model = new ArchivaArtifactModel();
|
||||
model.setGroupId( groupId );
|
||||
model.setArtifactId( artifactId );
|
||||
model.setVersion( version );
|
||||
model.setType( type );
|
||||
model.setRepositoryId( TEST_REPO_ID );
|
||||
|
||||
return new ArchivaArtifact( model );
|
||||
}
|
||||
|
||||
protected ArchivaProjectModel createProjectModel( String groupId, String artifactId, String version )
|
||||
{
|
||||
ArchivaProjectModel projectModel = new ArchivaProjectModel();
|
||||
projectModel.setGroupId( groupId );
|
||||
projectModel.setArtifactId( artifactId );
|
||||
projectModel.setVersion( version );
|
||||
|
||||
return projectModel;
|
||||
}
|
||||
}
|
|
@ -1,122 +0,0 @@
|
|||
package org.apache.maven.archiva.consumers.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 java.io.File;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.Configuration;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.consumers.ConsumerException;
|
||||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.database.ObjectNotFoundException;
|
||||
import org.apache.maven.archiva.database.ProjectModelDAO;
|
||||
import org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifactModel;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.Keys;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
/**
|
||||
* Test for ProjectModelToDatabaseConsumerTest
|
||||
*
|
||||
*/
|
||||
public class ProjectModelToDatabaseConsumerTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
private ProjectModelToDatabaseConsumer consumer;
|
||||
|
||||
private ProjectModelDAO modelDao;
|
||||
|
||||
public void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
ArchivaConfiguration archivaConfig = (ArchivaConfiguration) lookup( ArchivaConfiguration.class );
|
||||
|
||||
Configuration configuration = archivaConfig.getConfiguration();
|
||||
ManagedRepositoryConfiguration repo = configuration.findManagedRepositoryById( "internal" );
|
||||
repo.setLocation( new File( getBasedir(), "src/test/resources/test-repo" ).toString() );
|
||||
|
||||
consumer =
|
||||
(ProjectModelToDatabaseConsumer) lookup( DatabaseUnprocessedArtifactConsumer.class, "update-db-project" );
|
||||
modelDao = (ProjectModelDAO) lookup( ProjectModelDAO.class, "jdo" );
|
||||
}
|
||||
|
||||
public void testProcess()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = processAndGetModel( "test-project", "test-project-endpoint-pom", "2.4.4" );
|
||||
assertNotNull( model.getParentProject() );
|
||||
assertEquals( "test-project:test-project:2.4.4", Keys.toKey( model.getParentProject() ) );
|
||||
|
||||
assertFalse( model.getDependencyManagement().isEmpty() );
|
||||
|
||||
model = processAndGetModel( "test-project", "test-project-endpoint-ejb", "2.4.4" );
|
||||
assertNotNull( model.getParentProject() );
|
||||
assertEquals( "test-project:test-project-endpoint-pom:2.4.4", Keys.toKey( model.getParentProject() ) );
|
||||
assertTrue( hasDependency( model, "test-project:test-project-api:2.4.4" ) );
|
||||
assertTrue( hasDependency( model, "commons-id:commons-id:0.1-dev" ) );
|
||||
|
||||
model = processAndGetModel( "test-project", "test-project", "2.4.4" );
|
||||
assertFalse( model.getDependencyManagement().isEmpty() );
|
||||
}
|
||||
|
||||
private boolean hasDependency( ArchivaProjectModel model, String key )
|
||||
{
|
||||
for ( Dependency dependency : model.getDependencies() )
|
||||
{
|
||||
if ( key.equals( Keys.toKey( dependency.getGroupId(), dependency.getArtifactId(), dependency.getVersion() ) ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
private ArchivaProjectModel processAndGetModel( String group, String artifactId, String version )
|
||||
throws ConsumerException, ObjectNotFoundException, ArchivaDatabaseException
|
||||
{
|
||||
ArchivaArtifact artifact = createArtifact( group, artifactId, version, "pom" );
|
||||
consumer.processArchivaArtifact( artifact );
|
||||
|
||||
ArchivaProjectModel model = modelDao.getProjectModel( group, artifactId, version );
|
||||
assertEquals( group, model.getGroupId() );
|
||||
assertEquals( artifactId, model.getArtifactId() );
|
||||
assertEquals( version, model.getVersion() );
|
||||
return model;
|
||||
}
|
||||
|
||||
protected ArchivaArtifact createArtifact( String group, String artifactId, String version, String type )
|
||||
{
|
||||
ArchivaArtifactModel model = new ArchivaArtifactModel();
|
||||
model.setGroupId( group );
|
||||
model.setArtifactId( artifactId );
|
||||
model.setVersion( version );
|
||||
model.setType( type );
|
||||
model.setRepositoryId( "internal" );
|
||||
|
||||
return new ArchivaArtifact( model );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<!-- JdoAccess -->
|
||||
<component>
|
||||
<role>org.apache.maven.archiva.database.jdo.JdoAccess</role>
|
||||
<role-hint>archiva</role-hint>
|
||||
<implementation>org.apache.maven.archiva.database.jdo.JdoAccess</implementation>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.jdo.JdoFactory</role>
|
||||
<role-hint>archiva</role-hint>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<!-- JDO Factory -->
|
||||
<component>
|
||||
<role>org.codehaus.plexus.jdo.JdoFactory</role>
|
||||
<role-hint>archiva</role-hint>
|
||||
<implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation>
|
||||
|
||||
<configuration>
|
||||
<!-- Database Configuration -->
|
||||
<driverName>org.hsqldb.jdbcDriver</driverName>
|
||||
<url>jdbc:hsqldb:mem:TESTDB</url>
|
||||
<userName>sa</userName>
|
||||
<password></password>
|
||||
|
||||
<!-- JPOX and JDO configuration -->
|
||||
<persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass>
|
||||
<otherProperties>
|
||||
<property>
|
||||
<name>javax.jdo.PersistenceManagerFactoryClass</name>
|
||||
<value>org.jpox.PersistenceManagerFactoryImpl</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>org.jpox.autoCreateSchema</name>
|
||||
<value>true</value>
|
||||
</property>
|
||||
</otherProperties>
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.codehaus.plexus.cache.Cache</role>
|
||||
<role-hint>effective-project-cache</role-hint>
|
||||
<implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
|
||||
<description>Effective Project Cache</description>
|
||||
<configuration>
|
||||
<disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
|
||||
<disk-persistent>true</disk-persistent>
|
||||
<disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path>
|
||||
<eternal>true</eternal>
|
||||
<max-elements-in-memory>1000</max-elements-in-memory>
|
||||
<memory-eviction-policy>LRU</memory-eviction-policy>
|
||||
<name>effective-project-cache</name>
|
||||
<overflow-to-disk>false</overflow-to-disk>
|
||||
<!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) -->
|
||||
<!-- 45 minutes = 2700 seconds -->
|
||||
<time-to-idle-seconds>2700</time-to-idle-seconds>
|
||||
<!-- 30 minutes = 1800 seconds -->
|
||||
<time-to-live-seconds>1800</time-to-live-seconds>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -19,10 +19,10 @@ package org.apache.maven.archiva.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbstractArtifactKey - a artifact reference to a versioned project.
|
||||
|
@ -44,14 +44,6 @@ import java.io.Serializable;
|
|||
* <th>Type</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractProjectKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractVersionedKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
|
|
|
@ -1,184 +0,0 @@
|
|||
package org.apache.maven.archiva.model;
|
||||
|
||||
/*
|
||||
* 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.lang.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbstractProjectKey - A versionless reference to a Project.
|
||||
* This refers to all versions, and all artifacts of a project.
|
||||
* This type of reference is typically used by {@link ArchivaRepositoryMetadata} objects.
|
||||
* </p>
|
||||
*
|
||||
* <p>
|
||||
* If you require things like "Version" or "Type", consider the other keys below.
|
||||
* </p>
|
||||
*
|
||||
* <table border="1" cellpadding="3">
|
||||
* <tr>
|
||||
* <th>Key Type</th>
|
||||
* <th>Group ID</th>
|
||||
* <th>Artifact ID</th>
|
||||
* <th>Version</th>
|
||||
* <th>Classifier</th>
|
||||
* <th>Type</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractProjectKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractVersionedKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractArtifactKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* <p>
|
||||
* NOTE: This is a jpox required compound key handler class.
|
||||
* </p>
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AbstractProjectKey
|
||||
implements CompoundKey, Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 4949927971768396064L;
|
||||
|
||||
/**
|
||||
* The Group ID. (JPOX Requires this remain public)
|
||||
*/
|
||||
public String groupId = "";
|
||||
|
||||
/**
|
||||
* The Artifact ID. (JPOX Requires this remain public)
|
||||
*/
|
||||
public String artifactId = "";
|
||||
|
||||
/**
|
||||
* Default Constructor. Required by JPOX.
|
||||
*/
|
||||
public AbstractProjectKey()
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
/**
|
||||
* Key Based Constructor. Required by JPOX.
|
||||
*
|
||||
* @param key the String representing this object's values.
|
||||
*/
|
||||
public AbstractProjectKey( String key )
|
||||
{
|
||||
String parts[] = StringUtils.splitPreserveAllTokens( key, ":" );
|
||||
groupId = parts[0];
|
||||
artifactId = parts[1];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the String representation of this object. - Required by JPOX.
|
||||
*/
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return StringUtils.join( new String[] { groupId, artifactId } );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the hashcode for this object's values - Required by JPOX.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int PRIME = 31;
|
||||
int result = super.hashCode();
|
||||
result = PRIME * result + ( ( groupId == null ) ? 0 : groupId.hashCode() );
|
||||
result = PRIME * result + ( ( artifactId == null ) ? 0 : artifactId.hashCode() );
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the equals for this object's values - Required by JPOX.
|
||||
*/
|
||||
@Override
|
||||
public boolean equals( Object obj )
|
||||
{
|
||||
if ( this == obj )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !super.equals( obj ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( getClass() != obj.getClass() )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
final AbstractProjectKey other = (AbstractProjectKey) obj;
|
||||
|
||||
if ( groupId == null )
|
||||
{
|
||||
if ( other.groupId != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( !groupId.equals( other.groupId ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if ( artifactId == null )
|
||||
{
|
||||
if ( other.artifactId != null )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else if ( !artifactId.equals( other.artifactId ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -19,10 +19,10 @@ package org.apache.maven.archiva.model;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* AbstractVersionedKey - a versioned reference to a Project.
|
||||
|
@ -44,14 +44,6 @@ import java.io.Serializable;
|
|||
* <th>Type</th>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractProjectKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* <td> </td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>{@link AbstractVersionedKey}</td>
|
||||
* <td align="center">Yes</td>
|
||||
* <td align="center">Yes</td>
|
||||
|
|
|
@ -21,7 +21,6 @@ package org.apache.maven.archiva.model;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
|
@ -32,43 +31,6 @@ import java.util.Properties;
|
|||
*/
|
||||
public class ArchivaModelCloner
|
||||
{
|
||||
public static ArchivaProjectModel clone( ArchivaProjectModel model )
|
||||
{
|
||||
if ( model == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
ArchivaProjectModel cloned = new ArchivaProjectModel();
|
||||
|
||||
cloned.setGroupId( model.getGroupId() );
|
||||
cloned.setArtifactId( model.getArtifactId() );
|
||||
cloned.setVersion( model.getVersion() );
|
||||
|
||||
cloned.setParentProject( clone( model.getParentProject() ) );
|
||||
|
||||
cloned.setName( model.getName() );
|
||||
cloned.setDescription( model.getDescription() );
|
||||
cloned.setUrl( model.getUrl() );
|
||||
cloned.setPackaging( model.getPackaging() );
|
||||
cloned.setOrigin( model.getOrigin() );
|
||||
|
||||
cloned.setMailingLists( cloneMailingLists( model.getMailingLists() ) );
|
||||
cloned.setCiManagement( clone( model.getCiManagement() ) );
|
||||
cloned.setIndividuals( cloneIndividuals( model.getIndividuals() ) );
|
||||
cloned.setIssueManagement( clone( model.getIssueManagement() ) );
|
||||
cloned.setLicenses( cloneLicenses( model.getLicenses() ) );
|
||||
cloned.setOrganization( clone( model.getOrganization() ) );
|
||||
cloned.setScm( clone( model.getScm() ) );
|
||||
cloned.setRepositories( cloneRepositories( model.getRepositories() ) );
|
||||
cloned.setDependencies( cloneDependencies( model.getDependencies() ) );
|
||||
cloned.setPlugins( clonePlugins( model.getPlugins() ) );
|
||||
cloned.setReports( cloneReports( model.getReports() ) );
|
||||
cloned.setDependencyManagement( cloneDependencies( model.getDependencyManagement() ) );
|
||||
cloned.setProperties( clone(model.getProperties() ) );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public static ArtifactReference clone( ArtifactReference artifactReference )
|
||||
{
|
||||
|
@ -88,101 +50,6 @@ public class ArchivaModelCloner
|
|||
return cloned;
|
||||
}
|
||||
|
||||
public static CiManagement clone( CiManagement ciManagement )
|
||||
{
|
||||
if ( ciManagement == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
CiManagement cloned = new CiManagement();
|
||||
|
||||
cloned.setSystem( ciManagement.getSystem() );
|
||||
cloned.setUrl( ciManagement.getUrl() );
|
||||
cloned.setCiUrl( ciManagement.getCiUrl() );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public static Dependency clone( Dependency dependency )
|
||||
{
|
||||
if ( dependency == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Dependency cloned = new Dependency();
|
||||
|
||||
// Identification
|
||||
cloned.setGroupId( dependency.getGroupId() );
|
||||
cloned.setArtifactId( dependency.getArtifactId() );
|
||||
cloned.setVersion( dependency.getVersion() );
|
||||
cloned.setClassifier( dependency.getClassifier() );
|
||||
cloned.setType( dependency.getType() );
|
||||
|
||||
// The rest.
|
||||
cloned.setTransitive( dependency.isTransitive() );
|
||||
cloned.setScope( dependency.getScope() );
|
||||
cloned.setOptional( dependency.isOptional() );
|
||||
cloned.setSystemPath( dependency.getSystemPath() );
|
||||
cloned.setUrl( dependency.getUrl() );
|
||||
cloned.setExclusions( cloneExclusions( dependency.getExclusions() ) );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public static IssueManagement clone( IssueManagement issueManagement )
|
||||
{
|
||||
if ( issueManagement == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IssueManagement cloned = new IssueManagement();
|
||||
|
||||
cloned.setIssueManagementUrl( issueManagement.getIssueManagementUrl() );
|
||||
cloned.setSystem( issueManagement.getSystem() );
|
||||
cloned.setUrl( issueManagement.getUrl() );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public static MailingList clone( MailingList mailingList )
|
||||
{
|
||||
if ( mailingList == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
MailingList cloned = new MailingList();
|
||||
|
||||
cloned.setName( mailingList.getName() );
|
||||
cloned.setSubscribeAddress( mailingList.getSubscribeAddress() );
|
||||
cloned.setUnsubscribeAddress( mailingList.getUnsubscribeAddress() );
|
||||
cloned.setPostAddress( mailingList.getPostAddress() );
|
||||
cloned.setMainArchiveUrl( mailingList.getMainArchiveUrl() );
|
||||
cloned.setOtherArchives( cloneSimpleStringList( mailingList.getOtherArchives() ) );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public static Organization clone( Organization organization )
|
||||
{
|
||||
if ( organization == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Organization cloned = new Organization();
|
||||
|
||||
cloned.setFavicon( organization.getFavicon() );
|
||||
cloned.setName( organization.getName() );
|
||||
cloned.setUrl( organization.getUrl() );
|
||||
cloned.setOrganizationName( organization.getOrganizationName() );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Properties clone( Properties properties )
|
||||
{
|
||||
|
@ -204,22 +71,6 @@ public class ArchivaModelCloner
|
|||
return cloned;
|
||||
}
|
||||
|
||||
public static Scm clone( Scm scm )
|
||||
{
|
||||
if ( scm == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Scm cloned = new Scm();
|
||||
|
||||
cloned.setConnection( scm.getConnection() );
|
||||
cloned.setDeveloperConnection( scm.getDeveloperConnection() );
|
||||
cloned.setUrl( scm.getUrl() );
|
||||
|
||||
return cloned;
|
||||
}
|
||||
|
||||
public static SnapshotVersion clone( SnapshotVersion snapshotVersion )
|
||||
{
|
||||
if ( snapshotVersion == null )
|
||||
|
@ -268,174 +119,6 @@ public class ArchivaModelCloner
|
|||
return ret;
|
||||
}
|
||||
|
||||
public static List<Dependency> cloneDependencies( List<Dependency> dependencies )
|
||||
{
|
||||
if ( dependencies == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Dependency> ret = new ArrayList<Dependency>();
|
||||
|
||||
for ( Dependency dep : dependencies )
|
||||
{
|
||||
if ( dep == null )
|
||||
{
|
||||
// Skip null dependency.
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.add( clone( dep ) );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<Exclusion> cloneExclusions( List<Exclusion> exclusions )
|
||||
{
|
||||
if ( exclusions == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<Exclusion> ret = new ArrayList<Exclusion>();
|
||||
|
||||
for ( Exclusion exclusion : exclusions )
|
||||
{
|
||||
Exclusion cloned = new Exclusion();
|
||||
|
||||
cloned.setGroupId( exclusion.getGroupId() );
|
||||
cloned.setArtifactId( exclusion.getArtifactId() );
|
||||
|
||||
ret.add( cloned );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<Individual> cloneIndividuals( List<Individual> individuals )
|
||||
{
|
||||
if ( individuals == null )
|
||||
{
|
||||
return individuals;
|
||||
}
|
||||
|
||||
List<Individual> ret = new ArrayList<Individual>();
|
||||
|
||||
Iterator<Individual> it = individuals.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Individual individual = it.next();
|
||||
Individual cloned = new Individual();
|
||||
|
||||
cloned.setPrincipal( individual.getPrincipal() );
|
||||
|
||||
cloned.setEmail( individual.getEmail() );
|
||||
cloned.setName( individual.getName() );
|
||||
cloned.setOrganization( individual.getOrganization() );
|
||||
cloned.setOrganizationUrl( individual.getOrganizationUrl() );
|
||||
cloned.setUrl( individual.getUrl() );
|
||||
cloned.setTimezone( individual.getTimezone() );
|
||||
cloned.setIndividualEmail( individual.getIndividualEmail() );
|
||||
|
||||
cloned.setRoles( cloneRoles( individual.getRoles() ) );
|
||||
cloned.setProperties( clone( individual.getProperties() ) );
|
||||
|
||||
ret.add( cloned );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<License> cloneLicenses( List<License> licenses )
|
||||
{
|
||||
if ( licenses == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<License> ret = new ArrayList<License>();
|
||||
|
||||
for ( License license : licenses )
|
||||
{
|
||||
License cloned = new License();
|
||||
|
||||
cloned.setId( license.getId() );
|
||||
cloned.setName( license.getName() );
|
||||
cloned.setUrl( license.getUrl() );
|
||||
cloned.setComments( license.getComments() );
|
||||
|
||||
ret.add( cloned );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<MailingList> cloneMailingLists( List<MailingList> mailingLists )
|
||||
{
|
||||
if ( mailingLists == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<MailingList> ret = new ArrayList<MailingList>();
|
||||
|
||||
for ( MailingList mailingList : mailingLists )
|
||||
{
|
||||
if ( mailingList == null )
|
||||
{
|
||||
// Skip null mailing list.
|
||||
continue;
|
||||
}
|
||||
|
||||
ret.add( clone( mailingList ) );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<ArtifactReference> clonePlugins( List<ArtifactReference> plugins )
|
||||
{
|
||||
return cloneArtifactReferences( plugins );
|
||||
}
|
||||
|
||||
public static List<ArtifactReference> cloneReports( List<ArtifactReference> reports )
|
||||
{
|
||||
return cloneArtifactReferences( reports );
|
||||
}
|
||||
|
||||
public static List<ProjectRepository> cloneRepositories( List<ProjectRepository> repositories )
|
||||
{
|
||||
if ( repositories == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
List<ProjectRepository> ret = new ArrayList<ProjectRepository>();
|
||||
|
||||
for ( ProjectRepository repository : repositories )
|
||||
{
|
||||
ProjectRepository cloned = new ProjectRepository();
|
||||
|
||||
cloned.setId( repository.getId() );
|
||||
cloned.setName( repository.getName() );
|
||||
cloned.setUrl( repository.getUrl() );
|
||||
cloned.setLayout( repository.getLayout() );
|
||||
cloned.setPlugins( repository.isPlugins() );
|
||||
cloned.setReleases( repository.isReleases() );
|
||||
cloned.setSnapshots( repository.isSnapshots() );
|
||||
|
||||
ret.add( cloned );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static List<String> cloneRoles( List<String> roles )
|
||||
{
|
||||
return cloneSimpleStringList( roles );
|
||||
}
|
||||
|
||||
private static List<String> cloneSimpleStringList( List<String> simple )
|
||||
{
|
||||
if ( simple == null )
|
||||
|
|
|
@ -1,102 +0,0 @@
|
|||
package org.apache.maven.archiva.model;
|
||||
|
||||
/*
|
||||
* 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.map.MultiValueMap;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
/**
|
||||
* DependencyScope - utility methods and constants for working with scopes.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DependencyScope
|
||||
{
|
||||
public static final String SYSTEM = "system";
|
||||
|
||||
public static final String COMPILE = "compile";
|
||||
|
||||
public static final String PROVIDED = "provided";
|
||||
|
||||
public static final String RUNTIME = "runtime";
|
||||
|
||||
public static final String TEST = "test";
|
||||
|
||||
private static final MultiValueMap scopeMap;
|
||||
|
||||
static
|
||||
{
|
||||
// Store the map of scopes to what other scopes are 'within' that scope.
|
||||
scopeMap = new MultiValueMap();
|
||||
|
||||
scopeMap.put( COMPILE, COMPILE );
|
||||
scopeMap.put( COMPILE, RUNTIME );
|
||||
scopeMap.put( COMPILE, PROVIDED );
|
||||
scopeMap.put( COMPILE, SYSTEM );
|
||||
|
||||
scopeMap.put( TEST, COMPILE );
|
||||
scopeMap.put( TEST, RUNTIME );
|
||||
scopeMap.put( TEST, PROVIDED );
|
||||
scopeMap.put( TEST, SYSTEM );
|
||||
scopeMap.put( TEST, TEST );
|
||||
|
||||
scopeMap.put( RUNTIME, RUNTIME );
|
||||
scopeMap.put( RUNTIME, PROVIDED );
|
||||
scopeMap.put( RUNTIME, SYSTEM );
|
||||
|
||||
scopeMap.put( PROVIDED, RUNTIME );
|
||||
scopeMap.put( PROVIDED, PROVIDED );
|
||||
scopeMap.put( PROVIDED, SYSTEM );
|
||||
|
||||
scopeMap.put( SYSTEM, SYSTEM );
|
||||
}
|
||||
|
||||
public static boolean isSystemScoped( Dependency dep )
|
||||
{
|
||||
return StringUtils.equals( SYSTEM, dep.getScope() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the provided scope against the desired scope to see if it is
|
||||
* within that scope's pervue.
|
||||
*
|
||||
* Examples:
|
||||
* actual:compile, desired:test = true
|
||||
* actual:compile, desired:compile = true
|
||||
* actual:test, desired:compile = false
|
||||
* actual:provided, desired:compile = false
|
||||
*
|
||||
* @param actualScope
|
||||
* @param desiredScope
|
||||
* @return
|
||||
*/
|
||||
public static boolean isWithinScope( String actualScope, String desiredScope )
|
||||
{
|
||||
if ( StringUtils.isBlank( desiredScope ) )
|
||||
{
|
||||
// nothing desired? everything should fail.
|
||||
return false;
|
||||
}
|
||||
|
||||
String scope = StringUtils.defaultIfEmpty( actualScope, COMPILE );
|
||||
|
||||
return scopeMap.containsValue( desiredScope, scope );
|
||||
}
|
||||
}
|
|
@ -28,11 +28,6 @@ import org.apache.commons.lang.StringUtils;
|
|||
*/
|
||||
public class Keys
|
||||
{
|
||||
public static String toKey( ArchivaProjectModel model )
|
||||
{
|
||||
return toKey( model.getGroupId(), model.getArtifactId(), model.getVersion() );
|
||||
}
|
||||
|
||||
public static String toKey( String groupId, String artifactId, String version, String classifier, String type )
|
||||
{
|
||||
StringBuffer key = new StringBuffer();
|
||||
|
|
|
@ -1,58 +0,0 @@
|
|||
package org.apache.maven.archiva.model.functors;
|
||||
|
||||
/*
|
||||
* 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.Predicate;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifactModel;
|
||||
|
||||
/**
|
||||
* Allows for selection of unprocessed artifacts.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class UnprocessedArtifactPredicate
|
||||
implements Predicate
|
||||
{
|
||||
private static UnprocessedArtifactPredicate INSTANCE = new UnprocessedArtifactPredicate();
|
||||
|
||||
public static UnprocessedArtifactPredicate getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public boolean evaluate( Object object )
|
||||
{
|
||||
boolean satisfies = false;
|
||||
|
||||
if ( object instanceof ArchivaArtifact )
|
||||
{
|
||||
ArchivaArtifact artifact = (ArchivaArtifact) object;
|
||||
satisfies = !artifact.getModel().isProcessed();
|
||||
}
|
||||
else if ( object instanceof ArchivaArtifactModel )
|
||||
{
|
||||
ArchivaArtifactModel model = (ArchivaArtifactModel) object;
|
||||
satisfies = !model.isProcessed();
|
||||
}
|
||||
|
||||
return satisfies;
|
||||
}
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package org.apache.maven.archiva.model.jpox;
|
||||
|
||||
/*
|
||||
* 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.AbstractVersionedKey;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ArchivaProjectModelKey - unique classid-key for JPOX.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ArchivaProjectModelKey
|
||||
extends AbstractVersionedKey
|
||||
implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 7789859208617327581L;
|
||||
|
||||
public ArchivaProjectModelKey()
|
||||
{
|
||||
}
|
||||
|
||||
public ArchivaProjectModelKey( String key )
|
||||
{
|
||||
super( key );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,46 +0,0 @@
|
|||
package org.apache.maven.archiva.model.jpox;
|
||||
|
||||
/*
|
||||
* 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.AbstractProjectKey;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* ProjectReferenceKey - unique classid-key for JPOX.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectReferenceKey
|
||||
extends AbstractProjectKey
|
||||
implements Serializable
|
||||
{
|
||||
private static final long serialVersionUID = 7803774484166902823L;
|
||||
|
||||
public ProjectReferenceKey()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public ProjectReferenceKey( String key )
|
||||
{
|
||||
super( key );
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,59 +0,0 @@
|
|||
package org.apache.maven.archiva.model;
|
||||
|
||||
/*
|
||||
* 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.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
/**
|
||||
* ArchivaModelClonerTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ArchivaModelClonerTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
public void testCloneProjectModelWithParent()
|
||||
{
|
||||
ArchivaProjectModel actualModel = new ArchivaProjectModel();
|
||||
actualModel.setGroupId( null );
|
||||
actualModel.setArtifactId( "archiva-common" );
|
||||
actualModel.setVersion( null );
|
||||
actualModel.setParentProject( new VersionedReference() );
|
||||
actualModel.getParentProject().setGroupId( "org.apache.maven.archiva" );
|
||||
actualModel.getParentProject().setArtifactId( "archiva-parent" );
|
||||
actualModel.getParentProject().setVersion( "1.0" );
|
||||
|
||||
ArchivaProjectModel clonedModel = ArchivaModelCloner.clone( actualModel );
|
||||
|
||||
// Should not be the same object (in memory)
|
||||
assertNotSame( clonedModel, actualModel );
|
||||
|
||||
// Should be equal in value.
|
||||
assertEquals( clonedModel, actualModel );
|
||||
|
||||
// Test specific fields.
|
||||
assertNull( "Group Id", clonedModel.getGroupId() );
|
||||
assertNull( "Version", clonedModel.getVersion() );
|
||||
assertNotNull( "Parent Reference", clonedModel.getParentProject() );
|
||||
assertEquals( "Parent Group Id", "org.apache.maven.archiva", clonedModel.getParentProject().getGroupId() );
|
||||
assertEquals( "Parent Artifact Id", "archiva-parent", clonedModel.getParentProject().getArtifactId() );
|
||||
assertEquals( "Parent Version", "1.0", clonedModel.getParentProject().getVersion() );
|
||||
}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
package org.apache.maven.archiva.model;
|
||||
|
||||
/*
|
||||
* 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 junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
* DependencyScopeTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DependencyScopeTest
|
||||
extends TestCase
|
||||
{
|
||||
public void testIsWithinScope()
|
||||
{
|
||||
// Test on blank / empty desired scopes.
|
||||
assertFalse( DependencyScope.isWithinScope( "compile", null ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "test", null ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "runtime", null ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "provided", null ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "compile", "" ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "test", "" ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "runtime", "" ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "provided", "" ) );
|
||||
|
||||
// Tests on blank / empty actual scopes.
|
||||
assertTrue( DependencyScope.isWithinScope( "", DependencyScope.COMPILE ) );
|
||||
assertTrue( DependencyScope.isWithinScope( null, DependencyScope.COMPILE ) );
|
||||
assertTrue( DependencyScope.isWithinScope( "", DependencyScope.TEST ) );
|
||||
assertTrue( DependencyScope.isWithinScope( null, DependencyScope.TEST ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "", DependencyScope.PROVIDED ) );
|
||||
assertFalse( DependencyScope.isWithinScope( null, DependencyScope.PROVIDED ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "", DependencyScope.RUNTIME ) );
|
||||
assertFalse( DependencyScope.isWithinScope( null, DependencyScope.RUNTIME ) );
|
||||
|
||||
// Tests on compile desired scopes.
|
||||
assertTrue( DependencyScope.isWithinScope( "compile", DependencyScope.COMPILE ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.COMPILE ) );
|
||||
|
||||
// Tests on test desired scopes.
|
||||
assertTrue( DependencyScope.isWithinScope( "compile", DependencyScope.TEST ) );
|
||||
assertTrue( DependencyScope.isWithinScope( "test", DependencyScope.TEST ) );
|
||||
|
||||
// Tests on oddball scopes.
|
||||
assertFalse( DependencyScope.isWithinScope( "compile", DependencyScope.PROVIDED ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.PROVIDED ) );
|
||||
assertTrue( DependencyScope.isWithinScope( "provided", DependencyScope.PROVIDED ) );
|
||||
|
||||
assertFalse( DependencyScope.isWithinScope( "compile", DependencyScope.RUNTIME ) );
|
||||
assertFalse( DependencyScope.isWithinScope( "test", DependencyScope.RUNTIME ) );
|
||||
assertTrue( DependencyScope.isWithinScope( "provided", DependencyScope.RUNTIME ) );
|
||||
assertTrue( DependencyScope.isWithinScope( "runtime", DependencyScope.RUNTIME ) );
|
||||
}
|
||||
}
|
|
@ -24,7 +24,6 @@ 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;
|
||||
|
@ -42,12 +41,6 @@ public class ArchivaDAOStub
|
|||
return null;
|
||||
}
|
||||
|
||||
public ProjectModelDAO getProjectModelDAO()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
|
||||
public RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO()
|
||||
{
|
||||
// TODO Auto-generated method stub
|
||||
|
|
|
@ -80,18 +80,6 @@
|
|||
<goal>generate-metadata</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>merge</id>
|
||||
<goals>
|
||||
<goal>merge-metadata</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>${basedir}/src/main/resources/META-INF/plexus/components-fragment.xml</descriptor>
|
||||
<descriptor>${project.build.outputDirectory}/META-INF/plexus/components.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.common.ArchivaException;
|
||||
|
||||
/**
|
||||
* ProjectModelException
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModelException extends ArchivaException
|
||||
{
|
||||
public ProjectModelException( String message, Throwable cause )
|
||||
{
|
||||
super( message, cause );
|
||||
}
|
||||
|
||||
public ProjectModelException( String message )
|
||||
{
|
||||
super( message );
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.model.ArchivaProjectModel;
|
||||
|
||||
/**
|
||||
* Generic Filtering interface for {@link ArchivaProjectModel} objects.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ProjectModelFilter
|
||||
{
|
||||
/**
|
||||
* Filter a model and return the results of the filtering.
|
||||
*
|
||||
* @param model the model to filter.
|
||||
* @return a new model representing the filtered state of the model.
|
||||
* @throws ProjectModelException if there was a problem executing the filter.
|
||||
*/
|
||||
public ArchivaProjectModel filter( final ArchivaProjectModel model ) throws ProjectModelException;
|
||||
}
|
|
@ -1,688 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.ArrayList;
|
||||
import java.util.Enumeration;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaModelCloner;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.CiManagement;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.Exclusion;
|
||||
import org.apache.maven.archiva.model.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
|
||||
/**
|
||||
* ProjectModelMerge
|
||||
*
|
||||
* TODO: Should call this ProjectModelAncestry as it deals with the current project and its parent.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModelMerge
|
||||
{
|
||||
/**
|
||||
* Merge the contents of a project with it's parent project.
|
||||
*
|
||||
* @param mainProject the main project.
|
||||
* @param parentProject the parent project to merge.
|
||||
* @throws ProjectModelException if there was a problem merging the model.
|
||||
*/
|
||||
public static ArchivaProjectModel merge( ArchivaProjectModel mainProject, ArchivaProjectModel parentProject )
|
||||
throws ProjectModelException
|
||||
{
|
||||
if ( mainProject == null )
|
||||
{
|
||||
throw new ProjectModelException( "Cannot merge with a null main project." );
|
||||
}
|
||||
|
||||
if ( parentProject == null )
|
||||
{
|
||||
throw new ProjectModelException( "Cannot merge with a null parent project." );
|
||||
}
|
||||
|
||||
ArchivaProjectModel merged = new ArchivaProjectModel();
|
||||
|
||||
// Unmerged.
|
||||
merged.setParentProject(mainProject.getParentProject());
|
||||
merged.setArtifactId( mainProject.getArtifactId() );
|
||||
merged.setPackaging( StringUtils.defaultIfEmpty( mainProject.getPackaging(), "jar" ) );
|
||||
merged.setRelocation( mainProject.getRelocation() );
|
||||
|
||||
// Merged
|
||||
merged.setGroupId( merge( mainProject.getGroupId(), parentProject.getGroupId() ) );
|
||||
merged.setVersion( merge( mainProject.getVersion(), parentProject.getVersion() ) );
|
||||
merged.setName( merge( mainProject.getName(), parentProject.getName() ) );
|
||||
merged.setUrl( merge( mainProject.getUrl(), parentProject.getUrl() ) );
|
||||
merged.setDescription( merge( mainProject.getDescription(), parentProject.getDescription() ) );
|
||||
|
||||
merged.setOrigin( "merged" );
|
||||
|
||||
merged.setCiManagement( merge( mainProject.getCiManagement(), parentProject.getCiManagement() ) );
|
||||
merged.setIndividuals( mergeIndividuals( mainProject.getIndividuals(), parentProject.getIndividuals() ) );
|
||||
merged.setIssueManagement( merge( mainProject.getIssueManagement(), parentProject.getIssueManagement() ) );
|
||||
merged.setLicenses( mergeLicenses( mainProject.getLicenses(), parentProject.getLicenses() ) );
|
||||
merged.setOrganization( merge( mainProject.getOrganization(), parentProject.getOrganization() ) );
|
||||
merged.setScm( merge( mainProject.getScm(), parentProject.getScm() ) );
|
||||
merged.setRepositories( mergeRepositories( mainProject.getRepositories(), parentProject.getRepositories() ) );
|
||||
merged.setDependencies( mergeDependencies( mainProject.getDependencies(), parentProject.getDependencies() ) );
|
||||
merged.setDependencyManagement( mergeDependencyManagement( mainProject.getDependencyManagement(), parentProject
|
||||
.getDependencyManagement() ) );
|
||||
merged.setPlugins( mergePlugins( mainProject.getPlugins(), parentProject.getPlugins() ) );
|
||||
merged.setReports( mergeReports( mainProject.getReports(), parentProject.getReports() ) );
|
||||
merged.setProperties( merge( mainProject.getProperties(), parentProject.getProperties() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static Map<String, ArtifactReference> createArtifactReferenceMap( List<ArtifactReference> artifactReferences )
|
||||
{
|
||||
Map<String, ArtifactReference> ret = new HashMap<String, ArtifactReference>();
|
||||
|
||||
for ( ArtifactReference artifactReference : artifactReferences )
|
||||
{
|
||||
String key = toVersionlessArtifactKey( artifactReference );
|
||||
ret.put( key, artifactReference );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static Map<String, Dependency> createDependencyMap( List<Dependency> dependencies )
|
||||
{
|
||||
Map<String, Dependency> ret = new HashMap<String, Dependency>();
|
||||
|
||||
Iterator<Dependency> it = dependencies.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
String key = toVersionlessDependencyKey( dep );
|
||||
ret.put( key, dep );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static Map<String, Exclusion> createExclusionMap( List<Exclusion> exclusions )
|
||||
{
|
||||
Map<String, Exclusion> ret = new HashMap<String, Exclusion>();
|
||||
|
||||
Iterator<Exclusion> it = exclusions.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Exclusion exclusion = it.next();
|
||||
String key = exclusion.getGroupId() + ":" + exclusion.getArtifactId();
|
||||
ret.put( key, exclusion );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static Map<String, License> createLicensesMap( List<License> licenses )
|
||||
{
|
||||
Map<String, License> ret = new HashMap<String, License>();
|
||||
|
||||
for ( License license : licenses )
|
||||
{
|
||||
// TODO: Change to 'id' when LicenseTypeMapper is created.
|
||||
String key = license.getName();
|
||||
ret.put( key, license );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static Map<String, ProjectRepository> createRepositoriesMap( List<ProjectRepository> repositories )
|
||||
{
|
||||
Map<String, ProjectRepository> ret = new HashMap<String, ProjectRepository>();
|
||||
|
||||
for ( ProjectRepository repo : repositories )
|
||||
{
|
||||
// Should this really be using repo.id ?
|
||||
String key = repo.getUrl();
|
||||
ret.put( key, repo );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static boolean empty( String val )
|
||||
{
|
||||
if ( val == null )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return ( val.trim().length() <= 0 );
|
||||
}
|
||||
|
||||
private static ArtifactReference merge( ArtifactReference mainArtifactReference,
|
||||
ArtifactReference parentArtifactReference )
|
||||
{
|
||||
if ( parentArtifactReference == null )
|
||||
{
|
||||
return mainArtifactReference;
|
||||
}
|
||||
|
||||
if ( mainArtifactReference == null )
|
||||
{
|
||||
return ArchivaModelCloner.clone( parentArtifactReference );
|
||||
}
|
||||
|
||||
ArtifactReference merged = new ArtifactReference();
|
||||
|
||||
// Unmerged.
|
||||
merged.setGroupId( mainArtifactReference.getGroupId() );
|
||||
merged.setArtifactId( mainArtifactReference.getArtifactId() );
|
||||
|
||||
// Merged.
|
||||
merged.setVersion( merge( mainArtifactReference.getVersion(), parentArtifactReference.getVersion() ) );
|
||||
merged.setClassifier( merge( mainArtifactReference.getClassifier(), parentArtifactReference.getClassifier() ) );
|
||||
merged.setType( merge( mainArtifactReference.getType(), parentArtifactReference.getType() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static CiManagement merge( CiManagement mainCim, CiManagement parentCim )
|
||||
{
|
||||
if ( parentCim == null )
|
||||
{
|
||||
return mainCim;
|
||||
}
|
||||
|
||||
if ( mainCim == null )
|
||||
{
|
||||
return ArchivaModelCloner.clone( parentCim );
|
||||
}
|
||||
|
||||
CiManagement merged = new CiManagement();
|
||||
|
||||
merged.setSystem( merge( mainCim.getSystem(), parentCim.getSystem() ) );
|
||||
merged.setUrl( merge( mainCim.getUrl(), parentCim.getUrl() ) );
|
||||
merged.setCiUrl( merge( mainCim.getCiUrl(), parentCim.getCiUrl() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static Dependency merge( Dependency mainDep, Dependency parentDep )
|
||||
{
|
||||
if ( parentDep == null )
|
||||
{
|
||||
return mainDep;
|
||||
}
|
||||
|
||||
if ( mainDep == null )
|
||||
{
|
||||
Dependency dep = ArchivaModelCloner.clone( parentDep );
|
||||
dep.setFromParent( true );
|
||||
return dep;
|
||||
}
|
||||
|
||||
Dependency merged = new Dependency();
|
||||
|
||||
merged.setFromParent( true );
|
||||
|
||||
// Unmerged.
|
||||
merged.setGroupId( mainDep.getGroupId() );
|
||||
merged.setArtifactId( mainDep.getArtifactId() );
|
||||
|
||||
// Merged.
|
||||
merged.setVersion( merge( mainDep.getVersion(), parentDep.getVersion() ) );
|
||||
merged.setClassifier( merge( mainDep.getClassifier(), parentDep.getClassifier() ) );
|
||||
merged.setType( merge( mainDep.getType(), parentDep.getType() ) );
|
||||
merged.setScope( merge( mainDep.getScope(), parentDep.getScope() ) );
|
||||
if ( parentDep.isOptional() )
|
||||
{
|
||||
merged.setOptional( true );
|
||||
}
|
||||
|
||||
merged.setSystemPath( merge( mainDep.getSystemPath(), parentDep.getSystemPath() ) );
|
||||
merged.setUrl( merge( mainDep.getUrl(), parentDep.getUrl() ) );
|
||||
merged.setExclusions( mergeExclusions( mainDep.getExclusions(), parentDep.getExclusions() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static IssueManagement merge( IssueManagement mainIssueManagement, IssueManagement parentIssueManagement )
|
||||
{
|
||||
if ( parentIssueManagement == null )
|
||||
{
|
||||
return mainIssueManagement;
|
||||
}
|
||||
|
||||
if ( mainIssueManagement == null )
|
||||
{
|
||||
return ArchivaModelCloner.clone( parentIssueManagement );
|
||||
}
|
||||
|
||||
IssueManagement merged = new IssueManagement();
|
||||
|
||||
merged.setSystem( merge( mainIssueManagement.getSystem(), parentIssueManagement.getSystem() ) );
|
||||
merged.setUrl( merge( mainIssueManagement.getUrl(), parentIssueManagement.getUrl() ) );
|
||||
merged.setIssueManagementUrl( merge( mainIssueManagement.getIssueManagementUrl(), parentIssueManagement.getIssueManagementUrl() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static Organization merge( Organization mainOrganization, Organization parentOrganization )
|
||||
{
|
||||
if ( parentOrganization == null )
|
||||
{
|
||||
return mainOrganization;
|
||||
}
|
||||
|
||||
if ( mainOrganization == null )
|
||||
{
|
||||
return ArchivaModelCloner.clone( parentOrganization );
|
||||
}
|
||||
|
||||
Organization merged = new Organization();
|
||||
|
||||
merged.setFavicon( merge( mainOrganization.getFavicon(), parentOrganization.getFavicon() ) );
|
||||
merged.setOrganizationName( merge( mainOrganization.getOrganizationName(), parentOrganization.getOrganizationName() ) );
|
||||
merged.setName( merge( mainOrganization.getName(), parentOrganization.getName() ) );
|
||||
merged.setUrl( merge( mainOrganization.getUrl(), parentOrganization.getUrl() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Properties merge( Properties mainProperties, Properties parentProperties )
|
||||
{
|
||||
if ( parentProperties == null )
|
||||
{
|
||||
return mainProperties;
|
||||
}
|
||||
|
||||
if ( mainProperties == null )
|
||||
{
|
||||
return ArchivaModelCloner.clone( parentProperties );
|
||||
}
|
||||
|
||||
Properties merged = new Properties();
|
||||
merged.putAll(mainProperties);
|
||||
|
||||
Enumeration<String> keys = (Enumeration<String>) parentProperties.propertyNames();
|
||||
while ( keys.hasMoreElements() )
|
||||
{
|
||||
String key = (String) keys.nextElement();
|
||||
String value = merge( mainProperties.getProperty( key ), parentProperties.getProperty( key ) );
|
||||
|
||||
if ( value != null )
|
||||
{
|
||||
merged.put( key, value );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static Scm merge( Scm mainScm, Scm parentScm )
|
||||
{
|
||||
if ( parentScm == null )
|
||||
{
|
||||
return mainScm;
|
||||
}
|
||||
|
||||
if ( mainScm == null )
|
||||
{
|
||||
return ArchivaModelCloner.clone( parentScm );
|
||||
}
|
||||
|
||||
Scm merged = new Scm();
|
||||
|
||||
merged.setConnection( merge( mainScm.getConnection(), parentScm.getConnection() ) );
|
||||
merged.setDeveloperConnection( merge( mainScm.getDeveloperConnection(), parentScm.getDeveloperConnection() ) );
|
||||
merged.setUrl( merge( mainScm.getUrl(), parentScm.getUrl() ) );
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static String merge( String main, String parent )
|
||||
{
|
||||
if ( empty( main ) && !empty( parent ) )
|
||||
{
|
||||
return parent;
|
||||
}
|
||||
|
||||
return main;
|
||||
}
|
||||
|
||||
private static List<ArtifactReference> mergeArtifactReferences( List<ArtifactReference> mainArtifactReferences, List<ArtifactReference> parentArtifactReferences )
|
||||
{
|
||||
if ( parentArtifactReferences == null )
|
||||
{
|
||||
return mainArtifactReferences;
|
||||
}
|
||||
|
||||
if ( mainArtifactReferences == null )
|
||||
{
|
||||
return ArchivaModelCloner.cloneArtifactReferences( parentArtifactReferences );
|
||||
}
|
||||
|
||||
List<ArtifactReference> merged = new ArrayList<ArtifactReference>();
|
||||
|
||||
Map<String, ArtifactReference> mainArtifactReferenceMap = createArtifactReferenceMap( mainArtifactReferences );
|
||||
Map<String, ArtifactReference> parentArtifactReferenceMap = createArtifactReferenceMap( parentArtifactReferences );
|
||||
|
||||
for ( Map.Entry<String,ArtifactReference> entry : mainArtifactReferenceMap.entrySet() )
|
||||
{
|
||||
String key = entry.getKey();
|
||||
ArtifactReference mainArtifactReference = (ArtifactReference) entry.getValue();
|
||||
ArtifactReference parentArtifactReference = parentArtifactReferenceMap.get( key );
|
||||
|
||||
if ( parentArtifactReference == null )
|
||||
{
|
||||
merged.add( mainArtifactReference );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not merging. Local wins.
|
||||
merged.add( merge( mainArtifactReference, parentArtifactReference ) );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static List<Dependency> mergeDependencies( List<Dependency> mainDependencies, List<Dependency> parentDependencies )
|
||||
{
|
||||
if ( parentDependencies == null )
|
||||
{
|
||||
return mainDependencies;
|
||||
}
|
||||
|
||||
if ( mainDependencies == null )
|
||||
{
|
||||
List<Dependency> merged = ArchivaModelCloner.cloneDependencies( parentDependencies );
|
||||
Iterator<Dependency> it = merged.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
dep.setFromParent( true );
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
List<Dependency> merged = new ArrayList<Dependency>();
|
||||
|
||||
Map<String, Dependency> mainDepMap = createDependencyMap( mainDependencies );
|
||||
Map<String, Dependency> parentDepMap = createDependencyMap( parentDependencies );
|
||||
Set<String> uniqueKeys = new HashSet<String>();
|
||||
uniqueKeys.addAll( mainDepMap.keySet() );
|
||||
uniqueKeys.addAll( parentDepMap.keySet() );
|
||||
|
||||
Iterator<String> it = uniqueKeys.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
String key = it.next();
|
||||
Dependency parentDep = parentDepMap.get( key );
|
||||
Dependency mainDep = mainDepMap.get( key );
|
||||
|
||||
if ( parentDep == null )
|
||||
{
|
||||
// Means there is no parent dep to override main dep.
|
||||
merged.add( mainDep );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parent dep exists (main doesn't have to).
|
||||
// Merge the parent over the main dep.
|
||||
merged.add( merge( mainDep, parentDep ) );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static List<Dependency> mergeDependencyManagement( List<Dependency> mainDepMgmt, List<Dependency> parentDepMgmt )
|
||||
{
|
||||
if ( parentDepMgmt == null )
|
||||
{
|
||||
return mainDepMgmt;
|
||||
}
|
||||
|
||||
if ( mainDepMgmt == null )
|
||||
{
|
||||
List<Dependency> merged = ArchivaModelCloner.cloneDependencies( parentDepMgmt );
|
||||
Iterator<Dependency> it = merged.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
dep.setFromParent( true );
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
List<Dependency> merged = new ArrayList<Dependency>();
|
||||
|
||||
Map<String, Dependency> mainDepMap = createDependencyMap( mainDepMgmt );
|
||||
Map<String, Dependency> parentDepMap = createDependencyMap( parentDepMgmt );
|
||||
Set<String> uniqueKeys = new HashSet<String>();
|
||||
uniqueKeys.addAll( mainDepMap.keySet() );
|
||||
uniqueKeys.addAll( parentDepMap.keySet() );
|
||||
|
||||
Iterator<String> it = uniqueKeys.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
String key = it.next();
|
||||
Dependency parentDep = parentDepMap.get( key );
|
||||
Dependency mainDep = mainDepMap.get( key );
|
||||
|
||||
if ( parentDep == null )
|
||||
{
|
||||
// Means there is no parent depMan entry to override main depMan.
|
||||
merged.add( mainDep );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Parent depMan entry exists (main doesn't have to).
|
||||
// Merge the parent over the main depMan entry.
|
||||
merged.add( merge( mainDep, parentDep ) );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
public static List<Exclusion> mergeExclusions( List<Exclusion> mainExclusions, List<Exclusion> parentExclusions )
|
||||
{
|
||||
if ( parentExclusions == null )
|
||||
{
|
||||
return mainExclusions;
|
||||
}
|
||||
|
||||
if ( mainExclusions == null )
|
||||
{
|
||||
return ArchivaModelCloner.cloneExclusions( parentExclusions );
|
||||
}
|
||||
|
||||
List<Exclusion> merged = new ArrayList<Exclusion>();
|
||||
|
||||
Map<String, Exclusion> mainExclusionMap = createExclusionMap( mainExclusions );
|
||||
Map<String, Exclusion> parentExclusionMap = createExclusionMap( parentExclusions );
|
||||
|
||||
for ( Map.Entry<String, Exclusion> entry : mainExclusionMap.entrySet() )
|
||||
{
|
||||
String key = entry.getKey();
|
||||
Exclusion mainExclusion = entry.getValue();
|
||||
Exclusion parentExclusion = parentExclusionMap.get( key );
|
||||
|
||||
if ( parentExclusion == null )
|
||||
{
|
||||
merged.add( mainExclusion );
|
||||
}
|
||||
else
|
||||
{
|
||||
merged.add( parentExclusion );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static List<Individual> mergeIndividuals( List<Individual> mainIndividuals, List<Individual> parentIndividuals )
|
||||
{
|
||||
if ( parentIndividuals == null )
|
||||
{
|
||||
return mainIndividuals;
|
||||
}
|
||||
|
||||
if ( mainIndividuals == null )
|
||||
{
|
||||
return ArchivaModelCloner.cloneIndividuals( parentIndividuals );
|
||||
}
|
||||
|
||||
List<Individual> merged = ArchivaModelCloner.cloneIndividuals( mainIndividuals );
|
||||
|
||||
Iterator<Individual> it = parentIndividuals.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Individual parentIndividual = it.next();
|
||||
|
||||
if ( !mainIndividuals.contains( parentIndividual ) )
|
||||
{
|
||||
merged.add( parentIndividual );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static List<License> mergeLicenses( List<License> mainLicenses, List<License> parentLicenses )
|
||||
{
|
||||
if ( parentLicenses == null )
|
||||
{
|
||||
return mainLicenses;
|
||||
}
|
||||
|
||||
if ( mainLicenses == null )
|
||||
{
|
||||
return ArchivaModelCloner.cloneLicenses( parentLicenses );
|
||||
}
|
||||
|
||||
List<License> merged = new ArrayList<License>();
|
||||
|
||||
Map<String, License> mainLicensesMap = createLicensesMap( mainLicenses );
|
||||
Map<String, License> parentLicensesMap = createLicensesMap( parentLicenses );
|
||||
|
||||
for ( Map.Entry<String, License> entry : mainLicensesMap.entrySet() )
|
||||
{
|
||||
String key = entry.getKey();
|
||||
License mainLicense = entry.getValue();
|
||||
License parentLicense = parentLicensesMap.get( key );
|
||||
|
||||
if ( parentLicense == null )
|
||||
{
|
||||
merged.add( mainLicense );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not merging. Local wins.
|
||||
merged.add( parentLicense );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static List<ArtifactReference> mergePlugins( List<ArtifactReference> mainPlugins, List<ArtifactReference> parentPlugins )
|
||||
{
|
||||
return mergeArtifactReferences( mainPlugins, parentPlugins );
|
||||
}
|
||||
|
||||
private static List<ArtifactReference> mergeReports( List<ArtifactReference> mainReports, List<ArtifactReference> parentReports )
|
||||
{
|
||||
return mergeArtifactReferences( mainReports, parentReports );
|
||||
}
|
||||
|
||||
private static List<ProjectRepository> mergeRepositories( List<ProjectRepository> mainRepositories, List<ProjectRepository> parentRepositories )
|
||||
{
|
||||
if ( parentRepositories == null )
|
||||
{
|
||||
return mainRepositories;
|
||||
}
|
||||
|
||||
if ( mainRepositories == null )
|
||||
{
|
||||
return ArchivaModelCloner.cloneRepositories( parentRepositories );
|
||||
}
|
||||
|
||||
List<ProjectRepository> merged = new ArrayList<ProjectRepository>();
|
||||
|
||||
Map<String, ProjectRepository> mainRepositoriesMap = createRepositoriesMap( mainRepositories );
|
||||
Map<String, ProjectRepository> parentRepositoriesMap = createRepositoriesMap( parentRepositories );
|
||||
|
||||
for ( Map.Entry<String, ProjectRepository> entry : mainRepositoriesMap.entrySet() )
|
||||
{
|
||||
String key = entry.getKey();
|
||||
ProjectRepository mainProjectRepository = entry.getValue();
|
||||
ProjectRepository parentProjectRepository = parentRepositoriesMap.get( key );
|
||||
|
||||
if ( parentProjectRepository == null )
|
||||
{
|
||||
merged.add( mainProjectRepository );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Not merging. Local wins.
|
||||
merged.add( parentProjectRepository );
|
||||
}
|
||||
}
|
||||
|
||||
return merged;
|
||||
}
|
||||
|
||||
private static String toVersionlessArtifactKey( ArtifactReference artifactReference )
|
||||
{
|
||||
StringBuffer key = new StringBuffer();
|
||||
|
||||
key.append( artifactReference.getGroupId() ).append( ":" ).append( artifactReference.getArtifactId() );
|
||||
key.append( StringUtils.defaultString( artifactReference.getClassifier() ) ).append( ":" );
|
||||
key.append( artifactReference.getType() );
|
||||
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
private static String toVersionlessDependencyKey( Dependency dep )
|
||||
{
|
||||
StringBuffer key = new StringBuffer();
|
||||
|
||||
key.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() );
|
||||
key.append( StringUtils.defaultString( dep.getClassifier() ) ).append( ":" );
|
||||
key.append( dep.getType() );
|
||||
|
||||
return key.toString();
|
||||
}
|
||||
}
|
|
@ -1,39 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.model.ArchivaProjectModel;
|
||||
|
||||
/**
|
||||
* ProjectModelMonitor
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ProjectModelMonitor
|
||||
{
|
||||
/**
|
||||
* Report a problem encountered with a model.
|
||||
*
|
||||
* @param model the model that caused the problem.
|
||||
* @param type the type of problem.
|
||||
* @param problem the problem description.
|
||||
*/
|
||||
public void modelProblem( ArchivaProjectModel model, String type, String problem );
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* ProjectModelReader
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ProjectModelReader
|
||||
{
|
||||
public ArchivaProjectModel read( File pomFile )
|
||||
throws XMLException;
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
|
||||
/**
|
||||
* Interface for ProjectModel resolution.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ProjectModelResolver
|
||||
{
|
||||
/**
|
||||
* Get the ProjectModel given a specific {@link RepositoryContent} key.
|
||||
*
|
||||
* @param reference the reference to the other project.
|
||||
* @return the ArchivaProjectModel representing the provided {@link RepositoryContent} key.
|
||||
* @throws ProjectModelException if the project model cannot be resolved.
|
||||
*/
|
||||
public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
|
||||
throws ProjectModelException;
|
||||
}
|
|
@ -1,136 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationNames;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.RepositoryContentFactory;
|
||||
import org.apache.maven.archiva.repository.RepositoryException;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel300Reader;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
|
||||
import org.apache.maven.archiva.repository.project.resolvers.NopProjectResolver;
|
||||
import org.apache.maven.archiva.repository.project.resolvers.ProjectModelResolverStack;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
import org.codehaus.plexus.registry.Registry;
|
||||
import org.codehaus.plexus.registry.RegistryListener;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Factory for ProjectModelResolver objects
|
||||
*
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelResolverFactory"
|
||||
*/
|
||||
public class ProjectModelResolverFactory
|
||||
implements RegistryListener, Initializable
|
||||
{
|
||||
private Logger log = LoggerFactory.getLogger( ProjectModelResolverFactory.class );
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private RepositoryContentFactory repositoryFactory;
|
||||
|
||||
private ProjectModelResolverStack currentResolverStack = new ProjectModelResolverStack();
|
||||
|
||||
public void afterConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
if ( ConfigurationNames.isManagedRepositories( propertyName ) )
|
||||
{
|
||||
update();
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeConfigurationChange( Registry registry, String propertyName, Object propertyValue )
|
||||
{
|
||||
/* do nothing */
|
||||
}
|
||||
|
||||
public ProjectModelResolverStack getCurrentResolverStack()
|
||||
{
|
||||
return currentResolverStack;
|
||||
}
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
update();
|
||||
archivaConfiguration.addChangeListener( this );
|
||||
}
|
||||
|
||||
private ManagedRepositoryProjectResolver toResolver( ManagedRepositoryConfiguration repo )
|
||||
throws RepositoryException
|
||||
{
|
||||
ManagedRepositoryContent repoContent = repositoryFactory.getManagedRepositoryContent( repo.getId() );
|
||||
|
||||
ProjectModelReader reader;
|
||||
if ( StringUtils.equals( "legacy", repo.getLayout() ) )
|
||||
{
|
||||
reader = new ProjectModel300Reader();
|
||||
}
|
||||
else
|
||||
{
|
||||
reader = new ProjectModel400Reader();
|
||||
}
|
||||
|
||||
return new ManagedRepositoryProjectResolver( repoContent, reader );
|
||||
}
|
||||
|
||||
private void update()
|
||||
{
|
||||
synchronized ( currentResolverStack )
|
||||
{
|
||||
this.currentResolverStack.clearResolvers();
|
||||
|
||||
List<ManagedRepositoryConfiguration> list =
|
||||
archivaConfiguration.getConfiguration().getManagedRepositories();
|
||||
for ( ManagedRepositoryConfiguration repo : list )
|
||||
{
|
||||
try
|
||||
{
|
||||
ManagedRepositoryProjectResolver resolver = toResolver( repo );
|
||||
|
||||
// Add filesystem based resolver.
|
||||
this.currentResolverStack.addProjectModelResolver( resolver );
|
||||
}
|
||||
catch ( RepositoryException e )
|
||||
{
|
||||
log.warn( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
// Add no-op resolver.
|
||||
this.currentResolverStack.addProjectModelResolver( NopProjectResolver.getInstance() );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.model.ArchivaProjectModel;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
|
||||
/**
|
||||
* ProjectModelWriter
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ProjectModelWriter
|
||||
{
|
||||
/**
|
||||
* Write a project model out to disk.
|
||||
*
|
||||
* @param model the model to write.
|
||||
* @param pomFile the (pom) file on disk to write to.
|
||||
* @throws ProjectModelException if there was a problem with the model itself.
|
||||
* @throws IOException if there was a problem writing the pom file.
|
||||
*/
|
||||
public void write( ArchivaProjectModel model, File pomFile )
|
||||
throws ProjectModelException, IOException;
|
||||
|
||||
/**
|
||||
* Write a project model out to a {@link Writer}.
|
||||
*
|
||||
* @param model the model to write.
|
||||
* @param writer the writer (stream) to write to.
|
||||
* @throws ProjectModelException if there was a problem with the model itself.
|
||||
* @throws IOException if there was a problem writing the pom file.
|
||||
*/
|
||||
public void write( ArchivaProjectModel model, Writer writer )
|
||||
throws ProjectModelException, IOException;
|
||||
}
|
|
@ -1,312 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.filters;
|
||||
|
||||
/*
|
||||
* 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 org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaModelCloner;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelMerge;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory;
|
||||
import org.codehaus.plexus.cache.Cache;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Builder for the Effective Project Model.
|
||||
*
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelFilter"
|
||||
* role-hint="effective"
|
||||
*/
|
||||
public class EffectiveProjectModelFilter
|
||||
implements ProjectModelFilter
|
||||
{
|
||||
private ProjectModelFilter expressionFilter = new ProjectModelExpressionFilter();
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ProjectModelResolverFactory resolverFactory;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="effective-project-cache"
|
||||
*/
|
||||
private Cache effectiveProjectCache;
|
||||
|
||||
/**
|
||||
* Take the provided {@link ArchivaProjectModel} and build the effective {@link ArchivaProjectModel}.
|
||||
*
|
||||
* Steps:
|
||||
* 1) Expand any expressions / properties.
|
||||
* 2) Walk the parent project references and merge.
|
||||
* 3) Apply dependency management settings.
|
||||
*
|
||||
* @param project the project to create the effective {@link ArchivaProjectModel} from.
|
||||
* @return a the effective {@link ArchivaProjectModel}.
|
||||
* @throws ProjectModelException if there was a problem building the effective pom.
|
||||
*/
|
||||
public ArchivaProjectModel filter( final ArchivaProjectModel project )
|
||||
throws ProjectModelException
|
||||
{
|
||||
if ( project == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if ( resolverFactory.getCurrentResolverStack().isEmpty() )
|
||||
{
|
||||
throw new IllegalStateException( "Unable to build effective pom with no project model resolvers defined." );
|
||||
}
|
||||
|
||||
ArchivaProjectModel effectiveProject;
|
||||
String projectKey = toProjectKey( project );
|
||||
|
||||
synchronized ( effectiveProjectCache )
|
||||
{
|
||||
if ( effectiveProjectCache.hasKey( projectKey ) )
|
||||
{
|
||||
DEBUG( "Fetching (from cache/projectKey): " + projectKey );
|
||||
effectiveProject = (ArchivaProjectModel) effectiveProjectCache.get( projectKey );
|
||||
return effectiveProject;
|
||||
}
|
||||
}
|
||||
|
||||
// Clone submitted project (so that we don't mess with it)
|
||||
effectiveProject = ArchivaModelCloner.clone( project );
|
||||
|
||||
DEBUG( "Starting build of effective with: " + effectiveProject );
|
||||
|
||||
// Merge in all the parent poms.
|
||||
effectiveProject = mergeParent( effectiveProject );
|
||||
|
||||
// Setup Expression Evaluation pieces.
|
||||
effectiveProject = expressionFilter.filter( effectiveProject );
|
||||
|
||||
// Resolve dependency versions from dependency management.
|
||||
applyDependencyManagement( effectiveProject );
|
||||
|
||||
// groupId or version could be updated by parent or expressions
|
||||
projectKey = toProjectKey( effectiveProject );
|
||||
|
||||
// Do not add project into cache if it contains no groupId and
|
||||
// version information
|
||||
if ( effectiveProject.getGroupId() != null && effectiveProject.getVersion() != null )
|
||||
{
|
||||
synchronized ( effectiveProjectCache )
|
||||
{
|
||||
DEBUG( "Putting (to cache/projectKey): " + projectKey );
|
||||
effectiveProjectCache.put( projectKey, effectiveProject );
|
||||
}
|
||||
}
|
||||
|
||||
// Return what we got.
|
||||
return effectiveProject;
|
||||
}
|
||||
|
||||
private void applyDependencyManagement( ArchivaProjectModel pom )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( pom.getDependencyManagement() )
|
||||
|| CollectionUtils.isEmpty( pom.getDependencies() ) )
|
||||
{
|
||||
// Nothing to do. All done!
|
||||
return;
|
||||
}
|
||||
|
||||
Map<String, Dependency> managedDependencies = createDependencyMap( pom.getDependencyManagement() );
|
||||
Iterator<Dependency> it = pom.getDependencies().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
String key = toVersionlessDependencyKey( dep );
|
||||
|
||||
// Do we need to do anything?
|
||||
if ( managedDependencies.containsKey( key ) )
|
||||
{
|
||||
Dependency mgmtDep = (Dependency) managedDependencies.get( key );
|
||||
|
||||
dep.setVersion( mgmtDep.getVersion() );
|
||||
dep.setScope( mgmtDep.getScope() );
|
||||
dep.setExclusions( ProjectModelMerge.mergeExclusions( dep.getExclusions(), mgmtDep.getExclusions() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private ArchivaProjectModel mergeParent( ArchivaProjectModel pom )
|
||||
throws ProjectModelException
|
||||
{
|
||||
ArchivaProjectModel mixedProject;
|
||||
|
||||
DEBUG( "Project: " + toProjectKey( pom ) );
|
||||
|
||||
if ( pom.getParentProject() != null )
|
||||
{
|
||||
// Use parent reference.
|
||||
VersionedReference parentRef = pom.getParentProject();
|
||||
|
||||
String parentKey = VersionedReference.toKey( parentRef );
|
||||
|
||||
DEBUG( "Has parent: " + parentKey );
|
||||
|
||||
ArchivaProjectModel parentProject;
|
||||
|
||||
synchronized ( effectiveProjectCache )
|
||||
{
|
||||
// is the pre-merged parent in the cache?
|
||||
if ( effectiveProjectCache.hasKey( parentKey ) )
|
||||
{
|
||||
DEBUG( "Fetching (from cache/parentKey): " + parentKey );
|
||||
// Use the one from the cache.
|
||||
parentProject = (ArchivaProjectModel) effectiveProjectCache.get( parentKey );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Look it up, using resolvers.
|
||||
parentProject = this.resolverFactory.getCurrentResolverStack().findProject( parentRef );
|
||||
}
|
||||
}
|
||||
|
||||
if ( parentProject != null )
|
||||
{
|
||||
// Merge the pom with the parent pom.
|
||||
parentProject = mergeParent( parentProject );
|
||||
parentProject = expressionFilter.filter( parentProject );
|
||||
|
||||
// Cache the pre-merged parent.
|
||||
synchronized ( effectiveProjectCache )
|
||||
{
|
||||
DEBUG( "Putting (to cache/parentKey/merged): " + parentKey );
|
||||
// Add the merged parent pom to the cache.
|
||||
effectiveProjectCache.put( parentKey, parentProject );
|
||||
}
|
||||
|
||||
// Now merge the parent with the current
|
||||
mixedProject = ProjectModelMerge.merge( pom, parentProject );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Shortcircuit due to missing parent pom.
|
||||
// TODO: Document this via a monitor.
|
||||
mixedProject = mixinSuperPom( pom );
|
||||
|
||||
// Cache the non-existant parent.
|
||||
synchronized ( effectiveProjectCache )
|
||||
{
|
||||
DEBUG( "Putting (to cache/parentKey/basicPom): " + parentKey );
|
||||
// Add the basic pom to cache.
|
||||
effectiveProjectCache.put( parentKey, createBasicPom( parentRef ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
DEBUG( "No parent found" );
|
||||
|
||||
/* Mix in the super-pom.
|
||||
*
|
||||
* Super POM from maven/components contains many things.
|
||||
* However, for purposes of archiva, only the <repositories>
|
||||
* and <pluginRepositories> sections are of any value.
|
||||
*/
|
||||
|
||||
mixedProject = mixinSuperPom( pom );
|
||||
}
|
||||
|
||||
return mixedProject;
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createBasicPom( VersionedReference ref )
|
||||
{
|
||||
ArchivaProjectModel model = new ArchivaProjectModel();
|
||||
model.setGroupId( ref.getGroupId() );
|
||||
model.setArtifactId( ref.getArtifactId() );
|
||||
model.setVersion( ref.getVersion() );
|
||||
model.setPackaging( "jar" );
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
/**
|
||||
* Super POM from maven/components contains many things.
|
||||
* However, for purposes of archiva, only the <repositories>
|
||||
* and <pluginRepositories> sections are of any value.
|
||||
*
|
||||
* @param pom
|
||||
* @return
|
||||
*/
|
||||
private ArchivaProjectModel mixinSuperPom( ArchivaProjectModel pom )
|
||||
{
|
||||
// TODO: add super pom repositories.
|
||||
DEBUG( "Mix in Super POM: " + pom );
|
||||
|
||||
return pom;
|
||||
}
|
||||
|
||||
private static Map<String, Dependency> createDependencyMap( List<Dependency> dependencies )
|
||||
{
|
||||
Map<String, Dependency> ret = new HashMap<String, Dependency>();
|
||||
|
||||
Iterator<Dependency> it = dependencies.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
String key = toVersionlessDependencyKey( dep );
|
||||
ret.put( key, dep );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static String toVersionlessDependencyKey( Dependency dep )
|
||||
{
|
||||
StringBuffer key = new StringBuffer();
|
||||
|
||||
key.append( dep.getGroupId() ).append( ":" ).append( dep.getArtifactId() );
|
||||
key.append( StringUtils.defaultString( dep.getClassifier() ) ).append( ":" );
|
||||
key.append( dep.getType() );
|
||||
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
private String toProjectKey( ArchivaProjectModel project )
|
||||
{
|
||||
StringBuffer key = new StringBuffer();
|
||||
|
||||
key.append( project.getGroupId() ).append( ":" );
|
||||
key.append( project.getArtifactId() ).append( ":" );
|
||||
key.append( project.getVersion() );
|
||||
|
||||
return key.toString();
|
||||
}
|
||||
|
||||
private void DEBUG( String msg )
|
||||
{
|
||||
// Used in debugging of this object.
|
||||
// System.out.println( "[EffectiveProjectModelFilter] " + msg );
|
||||
}
|
||||
}
|
|
@ -1,458 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.filters;
|
||||
|
||||
/*
|
||||
* 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 org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaModelCloner;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.CiManagement;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.Exclusion;
|
||||
import org.apache.maven.archiva.model.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.MailingList;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.codehaus.plexus.evaluator.DefaultExpressionEvaluator;
|
||||
import org.codehaus.plexus.evaluator.EvaluatorException;
|
||||
import org.codehaus.plexus.evaluator.ExpressionEvaluator;
|
||||
import org.codehaus.plexus.evaluator.ExpressionSource;
|
||||
import org.codehaus.plexus.evaluator.sources.PropertiesExpressionSource;
|
||||
import org.codehaus.plexus.evaluator.sources.SystemPropertyExpressionSource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* ProjectModelExpressionFilter
|
||||
*
|
||||
* @version $Id$
|
||||
* @plexus.component role="org.apache.maven.archiva.repository.project.ProjectModelFilter"
|
||||
* role-hint="expression"
|
||||
* instantiation-strategy="per-lookup"
|
||||
*/
|
||||
public class ProjectModelExpressionFilter
|
||||
implements ProjectModelFilter
|
||||
{
|
||||
private ExpressionEvaluator evaluator = new DefaultExpressionEvaluator();
|
||||
|
||||
/**
|
||||
* Find and Evaluate the Expressions present in the model.
|
||||
*
|
||||
* @param model the model to correct.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public ArchivaProjectModel filter( final ArchivaProjectModel model )
|
||||
throws ProjectModelException
|
||||
{
|
||||
Properties props = new Properties();
|
||||
|
||||
if ( model.getProperties() != null )
|
||||
{
|
||||
props.putAll( model.getProperties() );
|
||||
}
|
||||
|
||||
ArchivaProjectModel ret = ArchivaModelCloner.clone( model );
|
||||
|
||||
// TODO: should probably clone evaluator to prevent threading issues.
|
||||
synchronized ( evaluator )
|
||||
{
|
||||
// TODO: create .resetSources() method in ExpressionEvaluator project on plexus side.
|
||||
// Remove previous expression sources.
|
||||
List<ExpressionSource> oldSources = new ArrayList<ExpressionSource>();
|
||||
oldSources.addAll( evaluator.getExpressionSourceList() );
|
||||
for ( ExpressionSource exprSrc : oldSources )
|
||||
{
|
||||
evaluator.removeExpressionSource( exprSrc );
|
||||
}
|
||||
|
||||
// Setup new sources (based on current model)
|
||||
PropertiesExpressionSource propsSource = new PropertiesExpressionSource();
|
||||
propsSource.setProperties( props );
|
||||
evaluator.addExpressionSource( propsSource );
|
||||
|
||||
// Add system properties to the mix.
|
||||
evaluator.addExpressionSource( new SystemPropertyExpressionSource() );
|
||||
|
||||
try
|
||||
{
|
||||
// Setup some common properties.
|
||||
VersionedReference parent = model.getParentProject();
|
||||
if ( parent != null )
|
||||
{
|
||||
String parentGroupId = StringUtils.defaultString( evaluator.expand( parent.getGroupId() ) );
|
||||
String parentArtifactId = StringUtils.defaultString( evaluator.expand( parent.getArtifactId() ) );
|
||||
String parentVersion = StringUtils.defaultString( evaluator.expand( parent.getVersion() ) );
|
||||
|
||||
props.setProperty( "parent.groupId", parentGroupId );
|
||||
props.setProperty( "parent.artifactId", parentArtifactId );
|
||||
props.setProperty( "parent.version", parentVersion );
|
||||
}
|
||||
|
||||
String groupId = StringUtils.defaultString( evaluator.expand( model.getGroupId() ) );
|
||||
String artifactId = StringUtils.defaultString( evaluator.expand( model.getArtifactId() ) );
|
||||
String version = StringUtils.defaultString( evaluator.expand( model.getVersion() ) );
|
||||
String name = StringUtils.defaultString( evaluator.expand( model.getName() ) );
|
||||
|
||||
|
||||
/* Archiva doesn't need to handle a full expression language with object tree walking
|
||||
* as the requirements within Archiva are much smaller, a quick replacement of the
|
||||
* important fields (groupId, artifactId, version, name) are handled specifically.
|
||||
*/
|
||||
props.setProperty( "pom.groupId", groupId );
|
||||
props.setProperty( "pom.artifactId", artifactId );
|
||||
props.setProperty( "pom.version", version );
|
||||
props.setProperty( "pom.name", name );
|
||||
props.setProperty( "project.groupId", groupId );
|
||||
props.setProperty( "project.artifactId", artifactId );
|
||||
props.setProperty( "project.version", version );
|
||||
props.setProperty( "project.name", name );
|
||||
|
||||
// Evaluate everything.
|
||||
ret.setVersion( evaluator.expand( ret.getVersion() ) );
|
||||
ret.setGroupId( evaluator.expand( ret.getGroupId() ) );
|
||||
ret.setName( evaluator.expand( ret.getName() ) );
|
||||
ret.setDescription( evaluator.expand( ret.getDescription() ) );
|
||||
ret.setPackaging( evaluator.expand( ret.getPackaging() ) );
|
||||
ret.setUrl( evaluator.expand( ret.getUrl() ) );
|
||||
|
||||
evaluateParentProject( evaluator, ret.getParentProject() );
|
||||
|
||||
evaluateBuildExtensions( evaluator, ret.getBuildExtensions() );
|
||||
evaluateCiManagement( evaluator, ret.getCiManagement() );
|
||||
evaluateDependencyList( evaluator, ret.getDependencies() );
|
||||
evaluateDependencyList( evaluator, ret.getDependencyManagement() );
|
||||
evaluateIndividuals( evaluator, ret.getIndividuals() );
|
||||
evaluateIssueManagement( evaluator, ret.getIssueManagement() );
|
||||
evaluateLicenses( evaluator, ret.getLicenses() );
|
||||
evaluateMailingLists( evaluator, ret.getMailingLists() );
|
||||
evaluateOrganization( evaluator, ret.getOrganization() );
|
||||
evaluatePlugins( evaluator, ret.getPlugins() );
|
||||
evaluateRelocation( evaluator, ret.getRelocation() );
|
||||
evaluateReports( evaluator, ret.getReports() );
|
||||
evaluateRepositories( evaluator, ret.getRepositories() );
|
||||
evaluateScm( evaluator, ret.getScm() );
|
||||
}
|
||||
catch ( EvaluatorException e )
|
||||
{
|
||||
throw new ProjectModelException( "Unable to evaluate expression in model: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private void evaluateArtifactReferenceList( ExpressionEvaluator eval, List<ArtifactReference> refs )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( refs ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ArtifactReference ref : refs )
|
||||
{
|
||||
ref.setGroupId( eval.expand( ref.getGroupId() ) );
|
||||
ref.setArtifactId( eval.expand( ref.getArtifactId() ) );
|
||||
ref.setVersion( eval.expand( ref.getVersion() ) );
|
||||
ref.setClassifier( eval.expand( ref.getClassifier() ) );
|
||||
ref.setType( eval.expand( ref.getType() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateBuildExtensions( ExpressionEvaluator eval, List<ArtifactReference> buildExtensions )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( buildExtensions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ArtifactReference ref : buildExtensions )
|
||||
{
|
||||
ref.setGroupId( eval.expand( ref.getGroupId() ) );
|
||||
ref.setArtifactId( eval.expand( ref.getArtifactId() ) );
|
||||
ref.setVersion( eval.expand( ref.getVersion() ) );
|
||||
ref.setClassifier( eval.expand( ref.getClassifier() ) );
|
||||
ref.setType( eval.expand( ref.getType() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateCiManagement( ExpressionEvaluator eval, CiManagement ciManagement )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( ciManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ciManagement.setSystem( eval.expand( ciManagement.getSystem() ) );
|
||||
ciManagement.setUrl( eval.expand( ciManagement.getUrl() ) );
|
||||
ciManagement.setCiUrl( eval.expand( ciManagement.getCiUrl() ) );
|
||||
}
|
||||
|
||||
private void evaluateDependencyList( ExpressionEvaluator eval, List<Dependency> dependencies )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencies ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Dependency dependency : dependencies )
|
||||
{
|
||||
dependency.setGroupId( eval.expand( dependency.getGroupId() ) );
|
||||
dependency.setArtifactId( eval.expand( dependency.getArtifactId() ) );
|
||||
dependency.setVersion( eval.expand( dependency.getVersion() ) );
|
||||
dependency.setScope( eval.expand( dependency.getScope() ) );
|
||||
dependency.setType( eval.expand( dependency.getType() ) );
|
||||
dependency.setUrl( eval.expand( dependency.getUrl() ) );
|
||||
|
||||
evaluateExclusions( eval, dependency.getExclusions() );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateExclusions( ExpressionEvaluator eval, List<Exclusion> exclusions )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( exclusions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Exclusion exclusion : exclusions )
|
||||
{
|
||||
exclusion.setGroupId( eval.expand( exclusion.getGroupId() ) );
|
||||
exclusion.setArtifactId( eval.expand( exclusion.getArtifactId() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateIndividuals( ExpressionEvaluator eval, List<Individual> individuals )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( individuals ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( Individual individual : individuals )
|
||||
{
|
||||
individual.setPrincipal( eval.expand( individual.getPrincipal() ) );
|
||||
individual.setName( eval.expand( individual.getName() ) );
|
||||
individual.setEmail( eval.expand( individual.getEmail() ) );
|
||||
individual.setTimezone( eval.expand( individual.getTimezone() ) );
|
||||
individual.setOrganization( eval.expand( individual.getOrganization() ) );
|
||||
individual.setOrganizationUrl( eval.expand( individual.getOrganizationUrl() ) );
|
||||
individual.setUrl( eval.expand( individual.getUrl() ) );
|
||||
individual.setIndividualEmail( eval.expand( individual.getIndividualEmail() ) );
|
||||
|
||||
evaluateProperties( eval, individual.getProperties() );
|
||||
evaluateStringList( eval, individual.getRoles() );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateIssueManagement( ExpressionEvaluator eval, IssueManagement issueManagement )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( issueManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
issueManagement.setSystem( eval.expand( issueManagement.getSystem() ) );
|
||||
issueManagement.setUrl( eval.expand( issueManagement.getUrl() ) );
|
||||
issueManagement.setIssueManagementUrl( eval.expand( issueManagement.getIssueManagementUrl() ) );
|
||||
}
|
||||
|
||||
private void evaluateLicenses( ExpressionEvaluator eval, List<License> licenses )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( licenses ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( License license : licenses )
|
||||
{
|
||||
license.setName( eval.expand( license.getName() ) );
|
||||
license.setUrl( eval.expand( license.getUrl() ) );
|
||||
license.setComments( eval.expand( license.getComments() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateMailingLists( ExpressionEvaluator eval, List<MailingList> mailingLists )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( mailingLists ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( MailingList mlist : mailingLists )
|
||||
{
|
||||
mlist.setName( eval.expand( mlist.getName() ) );
|
||||
mlist.setSubscribeAddress( eval.expand( mlist.getSubscribeAddress() ) );
|
||||
mlist.setUnsubscribeAddress( eval.expand( mlist.getUnsubscribeAddress() ) );
|
||||
mlist.setPostAddress( eval.expand( mlist.getPostAddress() ) );
|
||||
mlist.setMainArchiveUrl( eval.expand( mlist.getMainArchiveUrl() ) );
|
||||
|
||||
evaluateStringList( eval, mlist.getOtherArchives() );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateOrganization( ExpressionEvaluator eval, Organization organization )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( organization == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
organization.setOrganizationName( eval.expand( organization.getOrganizationName() ) );
|
||||
organization.setName( eval.expand( organization.getName() ) );
|
||||
organization.setUrl( eval.expand( organization.getUrl() ) );
|
||||
organization.setFavicon( eval.expand( organization.getFavicon() ) );
|
||||
}
|
||||
|
||||
private void evaluateParentProject( ExpressionEvaluator eval, VersionedReference parentProject )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( parentProject == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
parentProject.setGroupId( eval.expand( parentProject.getGroupId() ) );
|
||||
parentProject.setArtifactId( eval.expand( parentProject.getArtifactId() ) );
|
||||
parentProject.setVersion( eval.expand( parentProject.getVersion() ) );
|
||||
}
|
||||
|
||||
private void evaluatePlugins( ExpressionEvaluator eval, List<ArtifactReference> plugins )
|
||||
throws EvaluatorException
|
||||
{
|
||||
evaluateArtifactReferenceList( eval, plugins );
|
||||
}
|
||||
|
||||
private void evaluateProperties( ExpressionEvaluator eval, Properties props )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( props == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Only evaluate the values, not the keys.
|
||||
|
||||
// Collect the key names. (Done ahead of time to prevent iteration / concurrent modification exceptions)
|
||||
Set<String> keys = new HashSet<String>();
|
||||
for ( Object obj : props.keySet() )
|
||||
{
|
||||
keys.add( (String) obj );
|
||||
}
|
||||
|
||||
// Evaluate all of the values.
|
||||
for ( String key : keys )
|
||||
{
|
||||
String value = props.getProperty( key );
|
||||
props.setProperty( key, eval.expand( value ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateRelocation( ExpressionEvaluator eval, VersionedReference relocation )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( relocation == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
relocation.setGroupId( eval.expand( relocation.getGroupId() ) );
|
||||
relocation.setArtifactId( eval.expand( relocation.getArtifactId() ) );
|
||||
relocation.setVersion( eval.expand( relocation.getVersion() ) );
|
||||
}
|
||||
|
||||
private void evaluateReports( ExpressionEvaluator eval, List<ArtifactReference> reports )
|
||||
throws EvaluatorException
|
||||
{
|
||||
evaluateArtifactReferenceList( eval, reports );
|
||||
}
|
||||
|
||||
private void evaluateRepositories( ExpressionEvaluator eval, List<ProjectRepository> repositories )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( repositories ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ProjectRepository repository : repositories )
|
||||
{
|
||||
repository.setId( eval.expand( repository.getId() ) );
|
||||
repository.setLayout( eval.expand( repository.getLayout() ) );
|
||||
repository.setName( eval.expand( repository.getName() ) );
|
||||
repository.setUrl( eval.expand( repository.getUrl() ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void evaluateScm( ExpressionEvaluator eval, Scm scm )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( scm == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
scm.setConnection( eval.expand( scm.getConnection() ) );
|
||||
scm.setDeveloperConnection( eval.expand( scm.getDeveloperConnection() ) );
|
||||
scm.setUrl( eval.expand( scm.getUrl() ) );
|
||||
}
|
||||
|
||||
private void evaluateStringList( ExpressionEvaluator eval, List<String> strings )
|
||||
throws EvaluatorException
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( strings ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Create new list to hold post-evaluated strings.
|
||||
List<String> evaluated = new ArrayList<String>();
|
||||
|
||||
// Evaluate them all
|
||||
for ( String str : strings )
|
||||
{
|
||||
evaluated.add( eval.expand( str ) );
|
||||
}
|
||||
|
||||
// Populate the original list with the post-evaluated list.
|
||||
strings.clear();
|
||||
strings.addAll( evaluated );
|
||||
}
|
||||
}
|
|
@ -1,415 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.readers;
|
||||
|
||||
/*
|
||||
* 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.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
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.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.MailingList;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.apache.maven.archiva.xml.XMLReader;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
* ProjectModel300Reader
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModel300Reader
|
||||
implements ProjectModelReader
|
||||
{
|
||||
|
||||
public ArchivaProjectModel read( File pomFile )
|
||||
throws XMLException
|
||||
{
|
||||
XMLReader xml = new XMLReader( "project", pomFile );
|
||||
|
||||
ArchivaProjectModel model = new ArchivaProjectModel();
|
||||
|
||||
xml.removeNamespaces();
|
||||
|
||||
Element project = xml.getElement( "//project" );
|
||||
|
||||
// TODO: Handle <extend /> ?? (is this even possible?)
|
||||
|
||||
model.setGroupId( project.elementTextTrim( "groupId" ) );
|
||||
model.setArtifactId( project.elementTextTrim( "artifactId" ) );
|
||||
// TODO: Handle <id />
|
||||
model.setVersion( project.elementTextTrim( "currentVersion" ) );
|
||||
model.setName( project.elementTextTrim( "name" ) );
|
||||
model.setDescription( project.elementTextTrim( "description" ) );
|
||||
// TODO: what to do with <shortDescription /> ?
|
||||
model.setUrl( project.elementTextTrim( "url" ) );
|
||||
// TODO: Handle <logo />
|
||||
// TODO: Handle <inceptionYear />
|
||||
|
||||
model.setIssueManagement( getIssueManagement( xml ) );
|
||||
// TODO: What to do with <gumpRepositoryId /> ?
|
||||
// TODO: Handle <siteAddress />
|
||||
// TODO: Handle <siteDirectory /> ?
|
||||
// TODO: Handle <distributionSite />
|
||||
// TODO: Handle <distributionDirectory />
|
||||
model.setMailingLists( getMailingLists( xml ) );
|
||||
model.setIndividuals( getIndividuals( xml ) );
|
||||
model.setLicenses( getLicenses( xml ) );
|
||||
model.setReports( getReports( xml ) );
|
||||
model.setRepositories( getRepositories( xml ) );
|
||||
model.setScm( getSCM( xml ) );
|
||||
model.setOrganization( getOrganization( xml ) );
|
||||
model.setProperties( getProperties( xml.getElement( "//project/properties" ) ) );
|
||||
model.setDependencies( getDependencies( xml ) );
|
||||
|
||||
model.setOrigin( "filesystem" );
|
||||
|
||||
/*
|
||||
* Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files. model.setDependencyManagement()
|
||||
* model.setPlugins() model.setParentProject() model.setPackaging() model.setCiManagement()
|
||||
* model.setBuildExtensions() model.setRelocation()
|
||||
*/
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType )
|
||||
{
|
||||
ArtifactReference reference = new ArtifactReference();
|
||||
|
||||
reference.setGroupId( StringUtils.defaultString( elemPlugin.elementTextTrim( "groupId" ) ) );
|
||||
reference.setArtifactId( elemPlugin.elementTextTrim( "artifactId" ) );
|
||||
reference.setVersion( StringUtils.defaultString( elemPlugin.elementTextTrim( "version" ) ) );
|
||||
reference.setClassifier( StringUtils.defaultString( elemPlugin.elementTextTrim( "classifier" ) ) );
|
||||
reference.setType( StringUtils.defaultIfEmpty( elemPlugin.elementTextTrim( "type" ), defaultType ) );
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get List of {@link ArtifactReference} objects from xpath expr.
|
||||
*/
|
||||
private List<ArtifactReference> getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType )
|
||||
throws XMLException
|
||||
{
|
||||
List<ArtifactReference> refs = new ArrayList<ArtifactReference>();
|
||||
|
||||
Iterator<Element> it = xml.getElementList( xpathExpr ).iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemPlugin = it.next();
|
||||
|
||||
refs.add( getArtifactReference( elemPlugin, defaultType ) );
|
||||
}
|
||||
|
||||
return refs;
|
||||
}
|
||||
|
||||
private List<Dependency> getDependencies( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getDependencyList( xml, new String[] { "dependencies" } );
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Dependency> getDependencyList( XMLReader xml, String parts[] )
|
||||
throws XMLException
|
||||
{
|
||||
List<Dependency> dependencyList = new ArrayList<Dependency>();
|
||||
|
||||
Element project = xml.getElement( "//project" );
|
||||
|
||||
Element depsParent = project;
|
||||
|
||||
for ( String part : parts )
|
||||
{
|
||||
depsParent = depsParent.element( part );
|
||||
if ( depsParent == null )
|
||||
{
|
||||
return dependencyList;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Element> it = depsParent.elementIterator( "dependency" );
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemDependency = it.next();
|
||||
Dependency dependency = new Dependency();
|
||||
|
||||
dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) );
|
||||
dependency.setArtifactId( elemDependency.elementTextTrim( "artifactId" ) );
|
||||
dependency.setVersion( elemDependency.elementTextTrim( "version" ) );
|
||||
|
||||
dependency.setType( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "type" ), "jar" ) );
|
||||
dependency.setUrl( elemDependency.elementTextTrim( "url" ) );
|
||||
/* Following are not valid for <pomVersion>3</pomVersion> / Maven 1 pom files.
|
||||
*
|
||||
* dependency.setClassifier( StringUtils.defaultString( elemDependency.elementTextTrim( "classifier" ) ) );
|
||||
* dependency.setScope( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "scope" ), "compile" ) );
|
||||
* dependency.setOptional( toBoolean( elemDependency.elementTextTrim( "optional" ), false ) );
|
||||
*/
|
||||
|
||||
dependency.setSystemPath( elemDependency.elementTextTrim( "jar" ) );
|
||||
|
||||
if ( dependencyList.contains( dependency ) )
|
||||
{
|
||||
// TODO: throw into monitor as "duplicate dependency" issue.
|
||||
}
|
||||
|
||||
dependencyList.add( dependency );
|
||||
}
|
||||
|
||||
return dependencyList;
|
||||
}
|
||||
|
||||
private List<Individual> getIndividuals( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<Individual> individuals = new ArrayList<Individual>();
|
||||
|
||||
individuals.addAll( getIndividuals( xml, true, "//project/developers/developer" ) );
|
||||
individuals.addAll( getIndividuals( xml, false, "//project/contributors/contributor" ) );
|
||||
|
||||
return individuals;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<Individual> getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr )
|
||||
throws XMLException
|
||||
{
|
||||
List<Individual> ret = new ArrayList<Individual>();
|
||||
|
||||
List<Element> modelPersonList = xml.getElementList( xpathExpr );
|
||||
|
||||
Iterator<Element> iter = modelPersonList.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
Element elemPerson = iter.next();
|
||||
Individual individual = new Individual();
|
||||
|
||||
if ( isCommitor )
|
||||
{
|
||||
individual.setPrincipal( elemPerson.elementTextTrim( "id" ) );
|
||||
}
|
||||
|
||||
individual.setCommitor( isCommitor );
|
||||
individual.setEmail( elemPerson.elementTextTrim( "email" ) );
|
||||
individual.setName( elemPerson.elementTextTrim( "name" ) );
|
||||
individual.setOrganization( elemPerson.elementTextTrim( "organization" ) );
|
||||
individual.setOrganizationUrl( elemPerson.elementTextTrim( "organizationUrl" ) );
|
||||
individual.setUrl( elemPerson.elementTextTrim( "url" ) );
|
||||
individual.setTimezone( elemPerson.elementTextTrim( "timezone" ) );
|
||||
individual.setIndividualEmail( elemPerson.elementTextTrim( "email" ) );
|
||||
|
||||
// Roles
|
||||
Element elemRoles = elemPerson.element( "roles" );
|
||||
if ( elemRoles != null )
|
||||
{
|
||||
List<Element> roleNames = elemRoles.elements( "role" );
|
||||
Iterator<Element> itRole = roleNames.iterator();
|
||||
while ( itRole.hasNext() )
|
||||
{
|
||||
Element role = itRole.next();
|
||||
individual.addRole( role.getTextTrim() );
|
||||
}
|
||||
}
|
||||
|
||||
// Properties
|
||||
individual.setProperties( getProperties( elemPerson.element( "properties" ) ) );
|
||||
|
||||
ret.add( individual );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private IssueManagement getIssueManagement( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element issueTrackingUrlElem = xml.getElement( "//project/issueTrackingUrl" );
|
||||
|
||||
if ( issueTrackingUrlElem == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
String issueTrackingUrl = issueTrackingUrlElem.getTextTrim();
|
||||
if ( StringUtils.isBlank( issueTrackingUrl ) )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
IssueManagement issueMgmt = new IssueManagement();
|
||||
issueMgmt.setUrl( issueTrackingUrl );
|
||||
issueMgmt.setIssueManagementUrl( issueTrackingUrl );
|
||||
|
||||
return issueMgmt;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<License> getLicenses( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<License> licenses = new ArrayList<License>();
|
||||
|
||||
Element elemLicenses = xml.getElement( "//project/licenses" );
|
||||
|
||||
if ( elemLicenses != null )
|
||||
{
|
||||
List<Element> licenseList = elemLicenses.elements( "license" );
|
||||
for ( Element elemLicense : licenseList )
|
||||
{
|
||||
License license = new License();
|
||||
|
||||
// TODO: Create LicenseIdentity class to managed license ids.
|
||||
// license.setId( elemLicense.elementTextTrim("id") );
|
||||
license.setName( elemLicense.elementTextTrim( "name" ) );
|
||||
license.setUrl( elemLicense.elementTextTrim( "url" ) );
|
||||
license.setComments( elemLicense.elementTextTrim( "comments" ) );
|
||||
|
||||
licenses.add( license );
|
||||
}
|
||||
}
|
||||
|
||||
return licenses;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private List<MailingList> getMailingLists( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<MailingList> mailingLists = new ArrayList<MailingList>();
|
||||
|
||||
List<Element> mailingListElems = xml.getElementList( "//project/mailingLists/mailingList" );
|
||||
for ( Element elemMailingList : mailingListElems )
|
||||
{
|
||||
MailingList mlist = new MailingList();
|
||||
|
||||
mlist.setName( elemMailingList.elementTextTrim( "name" ) );
|
||||
mlist.setSubscribeAddress( elemMailingList.elementTextTrim( "subscribe" ) );
|
||||
mlist.setUnsubscribeAddress( elemMailingList.elementTextTrim( "unsubscribe" ) );
|
||||
mlist.setPostAddress( elemMailingList.elementTextTrim( "post" ) );
|
||||
mlist.setMainArchiveUrl( elemMailingList.elementTextTrim( "archive" ) );
|
||||
|
||||
Element elemOtherArchives = elemMailingList.element( "otherArchives" );
|
||||
if ( elemOtherArchives != null )
|
||||
{
|
||||
List<String> otherArchives = new ArrayList<String>();
|
||||
List<Element> others = elemOtherArchives.elements( "otherArchive" );
|
||||
for ( Element other : others )
|
||||
{
|
||||
String otherArchive = other.getTextTrim();
|
||||
otherArchives.add( otherArchive );
|
||||
}
|
||||
|
||||
mlist.setOtherArchives( otherArchives );
|
||||
}
|
||||
|
||||
mailingLists.add( mlist );
|
||||
}
|
||||
|
||||
return mailingLists;
|
||||
}
|
||||
|
||||
private Organization getOrganization( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemOrg = xml.getElement( "//project/organization" );
|
||||
if ( elemOrg != null )
|
||||
{
|
||||
Organization org = new Organization();
|
||||
|
||||
org.setOrganizationName( elemOrg.elementTextTrim( "name" ) );
|
||||
org.setName( elemOrg.elementTextTrim( "name" ) );
|
||||
org.setUrl( elemOrg.elementTextTrim( "url" ) );
|
||||
// TODO: Handle <logo />
|
||||
|
||||
return org;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Properties getProperties( Element elemProperties )
|
||||
{
|
||||
if ( elemProperties == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Properties ret = new Properties();
|
||||
|
||||
Iterator<Element> itProps = elemProperties.elements().iterator();
|
||||
while ( itProps.hasNext() )
|
||||
{
|
||||
Element elemProp = (Element) itProps.next();
|
||||
ret.setProperty( elemProp.getName(), elemProp.getText() );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private List<ArtifactReference> getReports( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/reports/plugins/plugin", "maven-plugin" );
|
||||
}
|
||||
|
||||
private List<ProjectRepository> getRepositories( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<ProjectRepository> repos = new ArrayList<ProjectRepository>();
|
||||
|
||||
// Repositories are not stored within the maven 1 pom.
|
||||
|
||||
return repos;
|
||||
}
|
||||
|
||||
private Scm getSCM( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemScm = xml.getElement( "//project/repository" );
|
||||
|
||||
if ( elemScm != null )
|
||||
{
|
||||
Scm scm = new Scm();
|
||||
|
||||
scm.setConnection( elemScm.elementTextTrim( "connection" ) );
|
||||
scm.setDeveloperConnection( elemScm.elementTextTrim( "developerConnection" ) );
|
||||
scm.setUrl( elemScm.elementTextTrim( "url" ) );
|
||||
|
||||
return scm;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,549 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.readers;
|
||||
|
||||
/*
|
||||
* 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.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.CiManagement;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.DependencyScope;
|
||||
import org.apache.maven.archiva.model.Exclusion;
|
||||
import org.apache.maven.archiva.model.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.MailingList;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.apache.maven.archiva.xml.XMLReader;
|
||||
import org.dom4j.Element;
|
||||
|
||||
/**
|
||||
* ProjectModel400Reader - read in modelVersion 4.0.0 pom files into archiva-model structures.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public class ProjectModel400Reader
|
||||
implements ProjectModelReader
|
||||
{
|
||||
public ArchivaProjectModel read( File pomFile )
|
||||
throws XMLException
|
||||
{
|
||||
XMLReader xml = new XMLReader( "project", pomFile );
|
||||
|
||||
ArchivaProjectModel model = new ArchivaProjectModel();
|
||||
|
||||
if ( !"http://maven.apache.org/POM/4.0.0".equals( xml.getDefaultNamespaceURI() ) )
|
||||
{
|
||||
// No namespace defined
|
||||
// TODO: Output to monitor the problem with the Namespace.
|
||||
}
|
||||
|
||||
xml.removeNamespaces();
|
||||
|
||||
Element project = xml.getElement( "//project" );
|
||||
|
||||
model.setGroupId( project.elementTextTrim( "groupId" ) );
|
||||
model.setArtifactId( project.elementTextTrim( "artifactId" ) );
|
||||
model.setVersion( project.elementTextTrim( "version" ) );
|
||||
model.setName( project.elementTextTrim( "name" ) );
|
||||
model.setDescription( project.elementTextTrim( "description" ) );
|
||||
model.setUrl( project.elementTextTrim( "url" ) );
|
||||
|
||||
model.setPackaging( StringUtils.defaultIfEmpty( project.elementTextTrim( "packaging" ), "jar" ) );
|
||||
|
||||
model.setParentProject( getParentProject( xml ) );
|
||||
|
||||
model.setMailingLists( getMailingLists( xml ) );
|
||||
model.setCiManagement( getCiManagement( xml ) );
|
||||
model.setIndividuals( getIndividuals( xml ) );
|
||||
model.setIssueManagement( getIssueManagement( xml ) );
|
||||
model.setLicenses( getLicenses( xml ) );
|
||||
model.setOrganization( getOrganization( xml ) );
|
||||
model.setScm( getSCM( xml ) );
|
||||
model.setRepositories( getRepositories( xml ) );
|
||||
|
||||
model.setDependencies( getDependencies( xml ) );
|
||||
model.setDependencyManagement( getDependencyManagement( xml ) );
|
||||
model.setPlugins( getPlugins( xml ) );
|
||||
model.setReports( getReports( xml ) );
|
||||
model.setProperties( getProperties( xml.getElement( "//project/properties" ) ) );
|
||||
|
||||
model.setBuildExtensions( getBuildExtensions( xml ) );
|
||||
|
||||
model.setRelocation( getRelocation( xml ) );
|
||||
|
||||
model.setOrigin( "filesystem" );
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
private ArtifactReference getArtifactReference( Element elemPlugin, String defaultType )
|
||||
{
|
||||
ArtifactReference reference = new ArtifactReference();
|
||||
|
||||
reference.setGroupId( StringUtils.defaultString( elemPlugin.elementTextTrim( "groupId" ) ) );
|
||||
reference.setArtifactId( elemPlugin.elementTextTrim( "artifactId" ) );
|
||||
reference.setVersion( StringUtils.defaultString( elemPlugin.elementTextTrim( "version" ) ) );
|
||||
reference.setClassifier( StringUtils.defaultString( elemPlugin.elementTextTrim( "classifier" ) ) );
|
||||
reference.setType( StringUtils.defaultIfEmpty( elemPlugin.elementTextTrim( "type" ), defaultType ) );
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get List of {@link ArtifactReference} objects from xpath expr.
|
||||
*/
|
||||
private List<ArtifactReference> getArtifactReferenceList( XMLReader xml, String xpathExpr, String defaultType )
|
||||
throws XMLException
|
||||
{
|
||||
List<ArtifactReference> refs = new ArrayList<ArtifactReference>();
|
||||
|
||||
Iterator<Element> it = xml.getElementList( xpathExpr ).iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemPlugin = it.next();
|
||||
|
||||
refs.add( getArtifactReference( elemPlugin, defaultType ) );
|
||||
}
|
||||
|
||||
return refs;
|
||||
}
|
||||
|
||||
private List<ArtifactReference> getBuildExtensions( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/build/extensions/extension", "jar" );
|
||||
}
|
||||
|
||||
private CiManagement getCiManagement( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemCiMgmt = xml.getElement( "//project/ciManagement" );
|
||||
if ( elemCiMgmt != null )
|
||||
{
|
||||
CiManagement ciManagement = new CiManagement();
|
||||
ciManagement.setSystem( elemCiMgmt.elementTextTrim( "system" ) );
|
||||
ciManagement.setUrl( elemCiMgmt.elementTextTrim( "url" ) );
|
||||
ciManagement.setCiUrl( elemCiMgmt.elementTextTrim( "url" ) );
|
||||
return ciManagement;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<Dependency> getDependencies( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getDependencyList( xml, new String[] { "dependencies" } );
|
||||
}
|
||||
|
||||
private List<Dependency> getDependencyList( XMLReader xml, String parts[] )
|
||||
throws XMLException
|
||||
{
|
||||
List<Dependency> dependencyList = new ArrayList<Dependency>();
|
||||
|
||||
Element project = xml.getElement( "//project" );
|
||||
|
||||
Element depsParent = project;
|
||||
|
||||
for ( String part : parts )
|
||||
{
|
||||
depsParent = depsParent.element( part );
|
||||
if ( depsParent == null )
|
||||
{
|
||||
return dependencyList;
|
||||
}
|
||||
}
|
||||
|
||||
Iterator<Element> it = depsParent.elementIterator( "dependency" );
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemDependency = it.next();
|
||||
Dependency dependency = new Dependency();
|
||||
|
||||
dependency.setGroupId( elemDependency.elementTextTrim( "groupId" ) );
|
||||
dependency.setArtifactId( elemDependency.elementTextTrim( "artifactId" ) );
|
||||
dependency.setVersion( elemDependency.elementTextTrim( "version" ) );
|
||||
|
||||
dependency.setClassifier( StringUtils.defaultString( elemDependency.elementTextTrim( "classifier" ) ) );
|
||||
dependency.setType( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "type" ), "jar" ) );
|
||||
dependency.setScope( StringUtils.defaultIfEmpty( elemDependency.elementTextTrim( "scope" ), "compile" ) );
|
||||
// Not for v4.0.0 -> dependency.setUrl( elemDependency.elementTextTrim("url") );
|
||||
dependency.setOptional( toBoolean( elemDependency.elementTextTrim( "optional" ), false ) );
|
||||
if ( DependencyScope.isSystemScoped( dependency ) )
|
||||
{
|
||||
dependency.setSystemPath( elemDependency.elementTextTrim( "systemPath" ) );
|
||||
}
|
||||
|
||||
dependency.setExclusions( getExclusions( elemDependency ) );
|
||||
|
||||
if ( dependencyList.contains( dependency ) )
|
||||
{
|
||||
// TODO: throw into monitor as "duplicate dependency" issue.
|
||||
}
|
||||
|
||||
dependencyList.add( dependency );
|
||||
}
|
||||
|
||||
return dependencyList;
|
||||
}
|
||||
|
||||
private List<Dependency> getDependencyManagement( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getDependencyList( xml, new String[] { "dependencyManagement", "dependencies" } );
|
||||
}
|
||||
|
||||
private List<Exclusion> getExclusions( Element elemDependency )
|
||||
{
|
||||
List<Exclusion> exclusions = new ArrayList<Exclusion>();
|
||||
|
||||
Element elemExclusions = elemDependency.element( "exclusions" );
|
||||
|
||||
if ( elemExclusions != null )
|
||||
{
|
||||
Iterator<Element> it = elemExclusions.elementIterator( "exclusion" );
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Element elemExclusion = it.next();
|
||||
Exclusion exclusion = new Exclusion();
|
||||
|
||||
exclusion.setGroupId( elemExclusion.elementTextTrim( "groupId" ) );
|
||||
exclusion.setArtifactId( elemExclusion.elementTextTrim( "artifactId" ) );
|
||||
|
||||
exclusions.add( exclusion );
|
||||
}
|
||||
}
|
||||
|
||||
return exclusions;
|
||||
}
|
||||
|
||||
private List<Individual> getIndividuals( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<Individual> individuals = new ArrayList<Individual>();
|
||||
|
||||
individuals.addAll( getIndividuals( xml, true, "//project/developers/developer" ) );
|
||||
individuals.addAll( getIndividuals( xml, false, "//project/contributors/contributor" ) );
|
||||
|
||||
return individuals;
|
||||
}
|
||||
|
||||
private List<Individual> getIndividuals( XMLReader xml, boolean isCommitor, String xpathExpr )
|
||||
throws XMLException
|
||||
{
|
||||
List<Individual> ret = new ArrayList<Individual>();
|
||||
|
||||
List<Element> modelPersonList = xml.getElementList( xpathExpr );
|
||||
|
||||
Iterator<Element> iter = modelPersonList.iterator();
|
||||
while ( iter.hasNext() )
|
||||
{
|
||||
Element elemPerson = iter.next();
|
||||
Individual individual = new Individual();
|
||||
|
||||
if ( isCommitor )
|
||||
{
|
||||
individual.setPrincipal( elemPerson.elementTextTrim( "id" ) );
|
||||
}
|
||||
|
||||
individual.setCommitor( isCommitor );
|
||||
individual.setEmail( elemPerson.elementTextTrim( "email" ) );
|
||||
individual.setName( elemPerson.elementTextTrim( "name" ) );
|
||||
individual.setOrganization( elemPerson.elementTextTrim( "organization" ) );
|
||||
individual.setOrganizationUrl( elemPerson.elementTextTrim( "organizationUrl" ) );
|
||||
individual.setUrl( elemPerson.elementTextTrim( "url" ) );
|
||||
individual.setTimezone( elemPerson.elementTextTrim( "timezone" ) );
|
||||
individual.setIndividualEmail( elemPerson.elementTextTrim( "email" ) );
|
||||
|
||||
// Roles
|
||||
Element elemRoles = elemPerson.element( "roles" );
|
||||
if ( elemRoles != null )
|
||||
{
|
||||
List<Element> roleNames = elemRoles.elements( "role" );
|
||||
Iterator<Element> itRole = roleNames.iterator();
|
||||
while ( itRole.hasNext() )
|
||||
{
|
||||
Element role = itRole.next();
|
||||
individual.addRole( role.getTextTrim() );
|
||||
}
|
||||
}
|
||||
|
||||
// Properties
|
||||
individual.setProperties( getProperties( elemPerson.element( "properties" ) ) );
|
||||
|
||||
ret.add( individual );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private IssueManagement getIssueManagement( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemIssueMgmt = xml.getElement( "//project/issueManagement" );
|
||||
if ( elemIssueMgmt != null )
|
||||
{
|
||||
IssueManagement issueMgmt = new IssueManagement();
|
||||
|
||||
issueMgmt.setSystem( elemIssueMgmt.elementTextTrim( "system" ) );
|
||||
issueMgmt.setUrl( elemIssueMgmt.elementTextTrim( "url" ) );
|
||||
issueMgmt.setIssueManagementUrl( elemIssueMgmt.elementTextTrim( "url" ) );
|
||||
|
||||
return issueMgmt;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<License> getLicenses( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<License> licenses = new ArrayList<License>();
|
||||
|
||||
Element elemLicenses = xml.getElement( "//project/licenses" );
|
||||
|
||||
if ( elemLicenses != null )
|
||||
{
|
||||
List<Element> licenseList = elemLicenses.elements( "license" );
|
||||
for ( Element elemLicense : licenseList )
|
||||
{
|
||||
License license = new License();
|
||||
|
||||
// TODO: Create LicenseIdentity class to managed license ids.
|
||||
// license.setId( elemLicense.elementTextTrim("id") );
|
||||
license.setName( elemLicense.elementTextTrim( "name" ) );
|
||||
license.setUrl( elemLicense.elementTextTrim( "url" ) );
|
||||
license.setComments( elemLicense.elementTextTrim( "comments" ) );
|
||||
|
||||
licenses.add( license );
|
||||
}
|
||||
}
|
||||
|
||||
return licenses;
|
||||
}
|
||||
|
||||
private List<MailingList> getMailingLists( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<MailingList> mailingLists = new ArrayList<MailingList>();
|
||||
|
||||
List<Element> mailingListElems = xml.getElementList( "//project/mailingLists/mailingList" );
|
||||
for ( Element elemMailingList : mailingListElems )
|
||||
{
|
||||
MailingList mlist = new MailingList();
|
||||
|
||||
mlist.setName( elemMailingList.elementTextTrim( "name" ) );
|
||||
mlist.setSubscribeAddress( elemMailingList.elementTextTrim( "subscribe" ) );
|
||||
mlist.setUnsubscribeAddress( elemMailingList.elementTextTrim( "unsubscribe" ) );
|
||||
mlist.setPostAddress( elemMailingList.elementTextTrim( "post" ) );
|
||||
mlist.setMainArchiveUrl( elemMailingList.elementTextTrim( "archive" ) );
|
||||
|
||||
Element elemOtherArchives = elemMailingList.element( "otherArchives" );
|
||||
if ( elemOtherArchives != null )
|
||||
{
|
||||
List<String> otherArchives = new ArrayList<String>();
|
||||
List<Element> others = elemOtherArchives.elements( "otherArchive" );
|
||||
for ( Element other : others )
|
||||
{
|
||||
String otherArchive = other.getTextTrim();
|
||||
otherArchives.add( otherArchive );
|
||||
}
|
||||
|
||||
mlist.setOtherArchives( otherArchives );
|
||||
}
|
||||
|
||||
mailingLists.add( mlist );
|
||||
}
|
||||
|
||||
return mailingLists;
|
||||
}
|
||||
|
||||
private Organization getOrganization( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemOrg = xml.getElement( "//project/organization" );
|
||||
if ( elemOrg != null )
|
||||
{
|
||||
Organization org = new Organization();
|
||||
|
||||
org.setOrganizationName( elemOrg.elementTextTrim( "name" ) );
|
||||
org.setName( elemOrg.elementTextTrim( "name" ) );
|
||||
org.setUrl( elemOrg.elementTextTrim( "url" ) );
|
||||
|
||||
return org;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private VersionedReference getParentProject( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemParent = xml.getElement( "//project/parent" );
|
||||
|
||||
if ( elemParent != null )
|
||||
{
|
||||
return getVersionedReference( elemParent );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<ArtifactReference> getPlugins( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/build/plugins/plugin", "maven-plugin" );
|
||||
}
|
||||
|
||||
private Properties getProperties( Element elemProperties )
|
||||
{
|
||||
if ( elemProperties == null )
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
Properties ret = new Properties();
|
||||
|
||||
Iterator<Element> itProps = elemProperties.elements().iterator();
|
||||
while ( itProps.hasNext() )
|
||||
{
|
||||
Element elemProp = (Element) itProps.next();
|
||||
ret.setProperty( elemProp.getName(), elemProp.getText() );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private VersionedReference getRelocation( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemRelocation = xml.getElement( "//project/distributionManagement/relocation" );
|
||||
|
||||
if ( elemRelocation != null )
|
||||
{
|
||||
return getVersionedReference( elemRelocation );
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<ArtifactReference> getReports( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
return getArtifactReferenceList( xml, "//project/reporting/plugins/plugin", "maven-plugin" );
|
||||
}
|
||||
|
||||
private List<ProjectRepository> getRepositories( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
List<ProjectRepository> repos = new ArrayList<ProjectRepository>();
|
||||
|
||||
repos.addAll( getRepositories( xml, false, "//project/repositories/repository" ) );
|
||||
repos.addAll( getRepositories( xml, true, "//project/pluginRepositories/pluginRepository" ) );
|
||||
|
||||
return repos;
|
||||
}
|
||||
|
||||
private List<ProjectRepository> getRepositories( XMLReader xml, boolean isPluginRepo, String xpathExpr )
|
||||
throws XMLException
|
||||
{
|
||||
List<ProjectRepository> ret = new ArrayList<ProjectRepository>();
|
||||
|
||||
List<Element> repositoriesList = xml.getElementList( xpathExpr );
|
||||
|
||||
for ( Element elemRepo : repositoriesList )
|
||||
{
|
||||
ProjectRepository repo = new ProjectRepository();
|
||||
|
||||
repo.setId( elemRepo.elementTextTrim( "id" ) );
|
||||
repo.setName( elemRepo.elementTextTrim( "name" ) );
|
||||
repo.setUrl( elemRepo.elementTextTrim( "url" ) );
|
||||
repo.setLayout( StringUtils.defaultIfEmpty( elemRepo.elementTextTrim( "layout" ), "default" ) );
|
||||
repo.setPlugins( isPluginRepo );
|
||||
|
||||
repo.setReleases( toBoolean( xml.getElementText( elemRepo, "releases/enabled" ), true ) );
|
||||
repo.setSnapshots( toBoolean( xml.getElementText( elemRepo, "snapshots/enabled" ), false ) );
|
||||
|
||||
ret.add( repo );
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private Scm getSCM( XMLReader xml )
|
||||
throws XMLException
|
||||
{
|
||||
Element elemScm = xml.getElement( "//project/scm" );
|
||||
|
||||
if ( elemScm != null )
|
||||
{
|
||||
Scm scm = new Scm();
|
||||
|
||||
scm.setConnection( elemScm.elementTextTrim( "connection" ) );
|
||||
scm.setDeveloperConnection( elemScm.elementTextTrim( "developerConnection" ) );
|
||||
scm.setUrl( elemScm.elementTextTrim( "url" ) );
|
||||
|
||||
return scm;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private VersionedReference getVersionedReference( Element elem )
|
||||
{
|
||||
VersionedReference reference = new VersionedReference();
|
||||
|
||||
reference.setGroupId( elem.elementTextTrim( "groupId" ) );
|
||||
reference.setArtifactId( elem.elementTextTrim( "artifactId" ) );
|
||||
reference.setVersion( elem.elementTextTrim( "version" ) );
|
||||
|
||||
return reference;
|
||||
}
|
||||
|
||||
private boolean toBoolean( String value, boolean defaultValue )
|
||||
{
|
||||
if ( StringUtils.equalsIgnoreCase( value, "true" ) )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else if ( StringUtils.equalsIgnoreCase( value, "false" ) )
|
||||
{
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
// If unset, or not "true" or "false".
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
||||
|
||||
/**
|
||||
* FalseProjectResolver will never resolver a model.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class FalseProjectResolver
|
||||
implements ProjectModelResolver
|
||||
{
|
||||
public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
|
||||
throws ProjectModelException
|
||||
{
|
||||
throw new ProjectModelException( "Cannot resolve model in FalseProjectResolver." );
|
||||
}
|
||||
}
|
|
@ -1,31 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Tag for RepositoryProjectResolver's to indicate that it is basing
|
||||
* it's resolution from the Filesystem.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface FilesystemBasedResolver
|
||||
{
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.archiva.common.utils.VersionComparator;
|
||||
import org.apache.maven.archiva.common.utils.VersionUtil;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.ContentNotFoundException;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
|
||||
/**
|
||||
* Resolve Project from managed repository.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ManagedRepositoryProjectResolver
|
||||
implements ProjectModelResolver, FilesystemBasedResolver
|
||||
{
|
||||
private ManagedRepositoryContent repository;
|
||||
|
||||
private ProjectModelReader reader;
|
||||
|
||||
public ManagedRepositoryProjectResolver( ManagedRepositoryContent repository, ProjectModelReader reader )
|
||||
{
|
||||
this.repository = repository;
|
||||
this.reader = reader;
|
||||
}
|
||||
|
||||
public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
|
||||
throws ProjectModelException
|
||||
{
|
||||
ArchivaArtifact artifact = new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), reference
|
||||
.getVersion(), "", "pom", repository.getId() );
|
||||
|
||||
File repoFile = repository.toFile( artifact );
|
||||
|
||||
// MRM-1194
|
||||
if( !repoFile.exists() && VersionUtil.isGenericSnapshot( reference.getVersion() ) )
|
||||
{
|
||||
// check if a timestamped version exists, get the latest if true
|
||||
try
|
||||
{
|
||||
List<String> versions = new ArrayList<String>( repository.getVersions( reference ) );
|
||||
Collections.sort( versions, VersionComparator.getInstance() );
|
||||
String latestSnapshot = versions.get( versions.size() - 1 );
|
||||
artifact =
|
||||
new ArchivaArtifact( reference.getGroupId(), reference.getArtifactId(), latestSnapshot, "", "pom",
|
||||
repository.getId() );
|
||||
|
||||
repoFile = repository.toFile( artifact );
|
||||
}
|
||||
catch( ContentNotFoundException e )
|
||||
{
|
||||
throw new ProjectModelException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return reader.read( repoFile );
|
||||
}
|
||||
catch ( XMLException e )
|
||||
{
|
||||
throw new ProjectModelException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
||||
|
||||
/**
|
||||
* A No-op Project Resolver, perform no lookup, just returns the requested
|
||||
* information in the form of a simple ArchviaProjectModel.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class NopProjectResolver
|
||||
implements ProjectModelResolver
|
||||
{
|
||||
private static NopProjectResolver INSTANCE = new NopProjectResolver();
|
||||
|
||||
public static NopProjectResolver getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
public ArchivaProjectModel resolveProjectModel( VersionedReference reference )
|
||||
throws ProjectModelException
|
||||
{
|
||||
ArchivaProjectModel model = new ArchivaProjectModel();
|
||||
|
||||
model.setGroupId( reference.getGroupId() );
|
||||
model.setArtifactId( reference.getArtifactId() );
|
||||
model.setVersion( reference.getVersion() );
|
||||
model.setPackaging( "pom" );
|
||||
|
||||
model.setOrigin( "nop" );
|
||||
|
||||
return model;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProjectModelResolutionListener
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public interface ProjectModelResolutionListener
|
||||
{
|
||||
/**
|
||||
* Indicates that the resolution process has started for a specific project.
|
||||
*
|
||||
* @param projectRef the project reference.
|
||||
* @param resolverList the {@link List} of {@link ProjectModelResolver}'s that will be searched.
|
||||
* @see #resolutionSuccess(VersionedReference, ProjectModelResolver, ArchivaProjectModel)
|
||||
* @see #resolutionNotFound(VersionedReference, List)
|
||||
*/
|
||||
public void resolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolverList );
|
||||
|
||||
/**
|
||||
* Indicates that a resolution against a specific resolver is about
|
||||
* to occur.
|
||||
*
|
||||
* @param projectRef the project reference.
|
||||
* @param resolver the resolver to attempt resolution on.
|
||||
*/
|
||||
public void resolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver );
|
||||
|
||||
/**
|
||||
* Indicates that a resolution against a specific resolver resulted
|
||||
* in in a missed resolution.
|
||||
*
|
||||
* "Miss" in this case refers to an attempt against a resolver, and that
|
||||
* resolver essentially responds with a "not found here" response.
|
||||
*
|
||||
* @param projectRef the project reference.
|
||||
* @param resolver the resolver the attempt was made on.
|
||||
*/
|
||||
public void resolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver );
|
||||
|
||||
/**
|
||||
* Indicates that a resolution against the specific resolver has
|
||||
* caused an error.
|
||||
*
|
||||
* @param projectRef the project reference.
|
||||
* @param resolver the (optional) resolver on which the error occured.
|
||||
* @param cause the cause of the error.
|
||||
*/
|
||||
public void resolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause );
|
||||
|
||||
/**
|
||||
* Indicates that a resolution process has finished, and the requested
|
||||
* projectRef has been found.
|
||||
*
|
||||
* @param projectRef the project reference.
|
||||
* @param resolver the resolver on which success occured.
|
||||
* @param model the resolved model.
|
||||
* @see #resolutionStart(VersionedReference, List)
|
||||
*/
|
||||
public void resolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver, ArchivaProjectModel model );
|
||||
|
||||
/**
|
||||
* Indicates that the resolution process has finished, and the requested
|
||||
* projectRef could not be found.
|
||||
*
|
||||
* @param projectRef the project reference.
|
||||
* @param resolverList the {@link List} of {@link ProjectModelResolver}'s that was be searched.
|
||||
* @see #resolutionStart(VersionedReference, List)
|
||||
*/
|
||||
public void resolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolverList );
|
||||
}
|
|
@ -1,258 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
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;
|
||||
|
||||
/**
|
||||
* Represents a stack of {@link ProjectModelResolver} resolvers for
|
||||
* finding/resolving an ArchivaProjectModel from multiple sources.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModelResolverStack
|
||||
{
|
||||
private List<ProjectModelResolver> resolvers;
|
||||
|
||||
private List<ProjectModelResolutionListener> listeners;
|
||||
|
||||
public ProjectModelResolverStack()
|
||||
{
|
||||
this.resolvers = new ArrayList<ProjectModelResolver>();
|
||||
this.listeners = new ArrayList<ProjectModelResolutionListener>();
|
||||
}
|
||||
|
||||
public void addListener( ProjectModelResolutionListener listener )
|
||||
{
|
||||
if ( listener == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.listeners.add( listener );
|
||||
}
|
||||
|
||||
public void addProjectModelResolver( ProjectModelResolver resolver )
|
||||
{
|
||||
if ( resolver == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.resolvers.add( resolver );
|
||||
}
|
||||
|
||||
public void clearResolvers()
|
||||
{
|
||||
this.resolvers.clear();
|
||||
}
|
||||
|
||||
public ArchivaProjectModel findProject( VersionedReference projectRef )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( this.resolvers ) )
|
||||
{
|
||||
throw new IllegalStateException( "No resolvers have been defined." );
|
||||
}
|
||||
|
||||
triggerResolutionStart( projectRef, this.resolvers );
|
||||
|
||||
Iterator<ProjectModelResolver> it = this.resolvers.iterator();
|
||||
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolver resolver = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
triggerResolutionAttempting( projectRef, resolver );
|
||||
ArchivaProjectModel model = resolver.resolveProjectModel( projectRef );
|
||||
|
||||
if ( model != null )
|
||||
{
|
||||
// Project was found.
|
||||
triggerResolutionSuccess( projectRef, resolver, model );
|
||||
return model;
|
||||
}
|
||||
triggerResolutionMiss( projectRef, resolver );
|
||||
}
|
||||
catch ( ProjectModelException e )
|
||||
{
|
||||
triggerResolutionError( projectRef, resolver, e );
|
||||
}
|
||||
}
|
||||
|
||||
// Project was not found in entire resolver list.
|
||||
triggerResolutionNotFound( projectRef, this.resolvers );
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean hasResolver( ProjectModelResolver resolver )
|
||||
{
|
||||
return this.resolvers.contains( resolver );
|
||||
}
|
||||
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return this.resolvers.isEmpty();
|
||||
}
|
||||
|
||||
public void prependProjectModelResolver( ProjectModelResolver resolver )
|
||||
{
|
||||
if ( resolver == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.resolvers.add( 0, resolver );
|
||||
}
|
||||
|
||||
public void removeListener( ProjectModelResolutionListener listener )
|
||||
{
|
||||
if ( listener == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
this.listeners.add( listener );
|
||||
}
|
||||
|
||||
public void removeResolver( ProjectModelResolver resolver )
|
||||
{
|
||||
this.resolvers.remove( resolver );
|
||||
}
|
||||
|
||||
private void triggerResolutionAttempting( VersionedReference projectRef, ProjectModelResolver resolver )
|
||||
{
|
||||
Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolutionListener listener = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
listener.resolutionAttempting( projectRef, resolver );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// do nothing with exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerResolutionError( VersionedReference projectRef, ProjectModelResolver resolver, Exception cause )
|
||||
{
|
||||
Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolutionListener listener = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
listener.resolutionError( projectRef, resolver, cause );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// do nothing with exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerResolutionMiss( VersionedReference projectRef, ProjectModelResolver resolver )
|
||||
{
|
||||
Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolutionListener listener = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
listener.resolutionMiss( projectRef, resolver );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// do nothing with exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerResolutionNotFound( VersionedReference projectRef, List<ProjectModelResolver> resolvers )
|
||||
{
|
||||
Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolutionListener listener = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
listener.resolutionNotFound( projectRef, resolvers );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// do nothing with exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerResolutionStart( VersionedReference projectRef, List<ProjectModelResolver> resolvers )
|
||||
{
|
||||
Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolutionListener listener = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
listener.resolutionStart( projectRef, resolvers );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// do nothing with exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void triggerResolutionSuccess( VersionedReference projectRef, ProjectModelResolver resolver,
|
||||
ArchivaProjectModel model )
|
||||
{
|
||||
Iterator<ProjectModelResolutionListener> it = this.listeners.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
ProjectModelResolutionListener listener = it.next();
|
||||
|
||||
try
|
||||
{
|
||||
listener.resolutionSuccess( projectRef, resolver, model );
|
||||
}
|
||||
catch ( Exception e )
|
||||
{
|
||||
// do nothing with exception.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,540 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.writers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.ArtifactReference;
|
||||
import org.apache.maven.archiva.model.CiManagement;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.model.Exclusion;
|
||||
import org.apache.maven.archiva.model.Individual;
|
||||
import org.apache.maven.archiva.model.IssueManagement;
|
||||
import org.apache.maven.archiva.model.License;
|
||||
import org.apache.maven.archiva.model.MailingList;
|
||||
import org.apache.maven.archiva.model.Organization;
|
||||
import org.apache.maven.archiva.model.ProjectRepository;
|
||||
import org.apache.maven.archiva.model.Scm;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelWriter;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.apache.maven.archiva.xml.XMLWriter;
|
||||
import org.dom4j.Document;
|
||||
import org.dom4j.DocumentHelper;
|
||||
import org.dom4j.Element;
|
||||
import org.dom4j.Namespace;
|
||||
import org.dom4j.Node;
|
||||
import org.dom4j.QName;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.Writer;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProjectModel400Writer for Maven 2 project model v4.0.0 pom files.
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModel400Writer
|
||||
implements ProjectModelWriter
|
||||
{
|
||||
private static final Namespace DEFAULT_NAMESPACE = Namespace.get( "", "http://maven.apache.org/POM/4.0.0" );
|
||||
|
||||
public void write( ArchivaProjectModel model, File pomFile )
|
||||
throws ProjectModelException, IOException
|
||||
{
|
||||
FileWriter writer = null;
|
||||
try
|
||||
{
|
||||
writer = new FileWriter( pomFile );
|
||||
write( model, writer );
|
||||
writer.flush();
|
||||
}
|
||||
finally
|
||||
{
|
||||
IOUtils.closeQuietly( writer );
|
||||
}
|
||||
}
|
||||
|
||||
public void write( ArchivaProjectModel model, Writer writer )
|
||||
throws ProjectModelException, IOException
|
||||
{
|
||||
Document doc = DocumentHelper.createDocument();
|
||||
|
||||
Element root = DocumentHelper.createElement( "project" );
|
||||
|
||||
root.add( DEFAULT_NAMESPACE );
|
||||
root.addNamespace( "xsi", "http://www.w3.org/2001/XMLSchema-instance" );
|
||||
root.addAttribute( "xsi:schemaLocation",
|
||||
"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" );
|
||||
|
||||
doc.setRootElement( root );
|
||||
|
||||
root.addElement( "modelVersion" ).setText( "4.0.0" );
|
||||
|
||||
addParent( root, model.getParentProject() );
|
||||
|
||||
addChildElement( root, "groupId", model.getGroupId() );
|
||||
root.addElement( "artifactId" ).setText( model.getArtifactId() );
|
||||
|
||||
addChildElement( root, "version", model.getVersion() );
|
||||
|
||||
addChildElement( root, "packaging", model.getPackaging() );
|
||||
addChildElement( root, "name", model.getName() );
|
||||
addChildElement( root, "description", model.getDescription() );
|
||||
addChildElement( root, "url", model.getUrl() );
|
||||
// TODO: add inceptionYear to ArchivaProjectModel
|
||||
|
||||
addOrganization( root, model.getOrganization() );
|
||||
|
||||
addIssueManagement( root, model.getIssueManagement() );
|
||||
addCiManagement( root, model.getCiManagement() );
|
||||
addMailingLists( root, model.getMailingLists() );
|
||||
addDevelopersAndContributors( root, model.getIndividuals() );
|
||||
// TODO: add distribution management to ArchivaProjectModel
|
||||
|
||||
addLicenses( root, model.getLicenses() );
|
||||
addRepositories( root, model.getRepositories() );
|
||||
addDependencyManagement( root, model.getDependencyManagement() );
|
||||
addDependencies( root, model.getDependencies() );
|
||||
|
||||
addReporting( root, model.getReports() );
|
||||
addScm( root, model.getScm() );
|
||||
|
||||
// <build> element
|
||||
addPlugins( root, model.getPlugins() );
|
||||
addBuildExtensions( root, model.getBuildExtensions() );
|
||||
|
||||
// <distributionManagement>
|
||||
addRelocation( root, model.getRelocation() );
|
||||
|
||||
fixDefaultNamespace( root );
|
||||
|
||||
try
|
||||
{
|
||||
XMLWriter.write( doc, writer );
|
||||
}
|
||||
catch ( XMLException e )
|
||||
{
|
||||
throw new ProjectModelException( "Unable to write xml contents to writer: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
private void addArtifactReference( Element elem, ArtifactReference ref, String defaultType )
|
||||
{
|
||||
addChildElement( elem, "groupId", ref.getGroupId() );
|
||||
addChildElement( elem, "artifactId", ref.getArtifactId() );
|
||||
addChildElement( elem, "version", ref.getVersion() );
|
||||
addChildElement( elem, "classifier", ref.getClassifier() );
|
||||
|
||||
if ( !StringUtils.equals( defaultType, ref.getType() ) )
|
||||
{
|
||||
addChildElement( elem, "type", ref.getType() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addBuildExtensions( Element root, List<ArtifactReference> buildExtensions )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( buildExtensions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element build = root.element( "build" );
|
||||
if ( build == null )
|
||||
{
|
||||
build = root.addElement( "build" );
|
||||
}
|
||||
|
||||
Element elemExtensions = build.addElement( "extensions" );
|
||||
|
||||
for ( ArtifactReference extension : buildExtensions )
|
||||
{
|
||||
Element elem = elemExtensions.addElement( "extension" );
|
||||
|
||||
addArtifactReference( elem, extension, "jar" );
|
||||
}
|
||||
}
|
||||
|
||||
private void addCiManagement( Element root, CiManagement ciManagement )
|
||||
{
|
||||
if ( ciManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "ciManagement" );
|
||||
addChildElement( elem, "system", ciManagement.getSystem() );
|
||||
addChildElement( elem, "url", ciManagement.getUrl() );
|
||||
// TODO: Add notifiers into ArchivaProjectModel
|
||||
}
|
||||
|
||||
private void addDependencies( Element root, List<Dependency> dependencies )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencies ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
addDependencyList( root, dependencies );
|
||||
}
|
||||
|
||||
private void addDependencyList( Element elemParent, List<Dependency> dependencies )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencies ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemDeps = elemParent.addElement( "dependencies" );
|
||||
|
||||
for ( Dependency dep : dependencies )
|
||||
{
|
||||
Element elem = elemDeps.addElement( "dependency" );
|
||||
|
||||
addChildElement( elem, "groupId", dep.getGroupId() );
|
||||
addChildElement( elem, "artifactId", dep.getArtifactId() );
|
||||
addChildElement( elem, "version", dep.getVersion() );
|
||||
addChildElement( elem, "classifier", dep.getClassifier() );
|
||||
addChildElement( elem, "type", dep.getType() );
|
||||
addChildElement( elem, "scope", dep.getScope() );
|
||||
addChildElement( elem, "systemPath", dep.getSystemPath() );
|
||||
|
||||
addExclusions( elem, dep.getExclusions() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addDependencyManagement( Element root, List<Dependency> dependencyManagement )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( dependencyManagement ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemDepMgmt = root.addElement( "dependencyManagement" );
|
||||
addDependencyList( elemDepMgmt, dependencyManagement );
|
||||
}
|
||||
|
||||
private void addDevelopersAndContributors( Element root, List<Individual> individuals )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( individuals ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element developers = null;
|
||||
Element contributors = null;
|
||||
|
||||
for ( Individual individual : individuals )
|
||||
{
|
||||
if ( individual.isCommitor() )
|
||||
{
|
||||
if ( developers == null )
|
||||
{
|
||||
developers = root.addElement( "developers" );
|
||||
}
|
||||
|
||||
Element developer = developers.addElement( "developer" );
|
||||
addChildElement( developer, "id", individual.getPrincipal() );
|
||||
addIndividual( developer, individual );
|
||||
}
|
||||
else
|
||||
{
|
||||
if ( contributors == null )
|
||||
{
|
||||
contributors = root.addElement( "contributors" );
|
||||
}
|
||||
|
||||
Element contributor = contributors.addElement( "contributor" );
|
||||
addIndividual( contributor, individual );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addExclusions( Element elemParent, List<Exclusion> exclusions )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( exclusions ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemExclusions = elemParent.addElement( "exclusions" );
|
||||
|
||||
for ( Exclusion exclusion : exclusions )
|
||||
{
|
||||
Element elem = elemExclusions.addElement( "exclusion" );
|
||||
|
||||
addChildElement( elem, "groupId", exclusion.getGroupId() );
|
||||
addChildElement( elem, "artifactId", exclusion.getArtifactId() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addIndividual( Element elem, Individual individual )
|
||||
{
|
||||
addChildElement( elem, "name", individual.getName() );
|
||||
addChildElement( elem, "email", individual.getEmail() );
|
||||
addChildElement( elem, "organization", individual.getOrganization() );
|
||||
addChildElement( elem, "organizationUrl", individual.getOrganizationUrl() );
|
||||
addChildElement( elem, "timezone", individual.getTimezone() );
|
||||
|
||||
if ( CollectionUtils.isNotEmpty( individual.getRoles() ) )
|
||||
{
|
||||
Element roles = elem.addElement( "roles" );
|
||||
List<String> roleList = individual.getRoles();
|
||||
for ( String roleName : roleList )
|
||||
{
|
||||
addChildElement( roles, "role", roleName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addIssueManagement( Element root, IssueManagement issueManagement )
|
||||
{
|
||||
if ( issueManagement == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "issueManagement" );
|
||||
addChildElement( elem, "system", issueManagement.getSystem() );
|
||||
addChildElement( elem, "url", issueManagement.getUrl() );
|
||||
}
|
||||
|
||||
private void addLicenses( Element root, List<License> licenses )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( licenses ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemLicenses = root.addElement( "licenses" );
|
||||
|
||||
for ( License license : licenses )
|
||||
{
|
||||
Element elem = elemLicenses.addElement( "license" );
|
||||
addChildElement( elem, "name", license.getName() );
|
||||
addChildElement( elem, "url", license.getUrl() );
|
||||
// TODO: research if we need <distribution> subelement.
|
||||
}
|
||||
}
|
||||
|
||||
private void addMailingLists( Element root, List<MailingList> mailingLists )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( mailingLists ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element mlists = root.addElement( "mailingLists" );
|
||||
|
||||
for ( MailingList mailingList : mailingLists )
|
||||
{
|
||||
Element mlist = mlists.addElement( "mailingList" );
|
||||
addChildElement( mlist, "name", mailingList.getName() );
|
||||
addChildElement( mlist, "post", mailingList.getPostAddress() );
|
||||
addChildElement( mlist, "subscribe", mailingList.getSubscribeAddress() );
|
||||
addChildElement( mlist, "unsubscribe", mailingList.getUnsubscribeAddress() );
|
||||
addChildElement( mlist, "archive", mailingList.getMainArchiveUrl() );
|
||||
|
||||
addOtherArchives( mlist, mailingList.getOtherArchives() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addOtherArchives( Element mlist, List<String> otherArchives )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( otherArchives ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemOtherArchives = mlist.addElement( "otherArchives" );
|
||||
|
||||
for ( String archive : otherArchives )
|
||||
{
|
||||
addChildElement( elemOtherArchives, "otherArchive", archive );
|
||||
}
|
||||
}
|
||||
|
||||
private void addOrganization( Element root, Organization organization )
|
||||
{
|
||||
if ( organization == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "organization" );
|
||||
|
||||
//addChildElement( elem, "name", organization.getOrganizationName() );
|
||||
addChildElement( elem, "name", organization.getName() );
|
||||
addChildElement( elem, "url", organization.getUrl() );
|
||||
}
|
||||
|
||||
private void addParent( Element root, VersionedReference parentProject )
|
||||
{
|
||||
if ( parentProject == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element parent = root.addElement( "parent" );
|
||||
parent.addElement( "groupId" ).setText( parentProject.getGroupId() );
|
||||
parent.addElement( "artifactId" ).setText( parentProject.getArtifactId() );
|
||||
parent.addElement( "version" ).setText( parentProject.getVersion() );
|
||||
}
|
||||
|
||||
private void addPlugins( Element root, List<ArtifactReference> plugins )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( plugins ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element build = root.element( "build" );
|
||||
if ( build == null )
|
||||
{
|
||||
build = root.addElement( "build" );
|
||||
}
|
||||
|
||||
Element elemPlugins = build.addElement( "plugins" );
|
||||
|
||||
for ( ArtifactReference plugin : plugins )
|
||||
{
|
||||
Element elem = elemPlugins.addElement( "plugin" );
|
||||
|
||||
addArtifactReference( elem, plugin, "maven-plugin" );
|
||||
}
|
||||
}
|
||||
|
||||
private void addRelocation( Element root, VersionedReference relocation )
|
||||
{
|
||||
if ( relocation == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element distribManagement = root.element( "distributionManagement" );
|
||||
|
||||
if ( distribManagement == null )
|
||||
{
|
||||
distribManagement = root.addElement( "distributionManagement" );
|
||||
}
|
||||
|
||||
Element elem = distribManagement.addElement( "relocation" );
|
||||
addChildElement( elem, "groupId", relocation.getGroupId() );
|
||||
addChildElement( elem, "artifactId", relocation.getArtifactId() );
|
||||
addChildElement( elem, "version", relocation.getVersion() );
|
||||
}
|
||||
|
||||
private void addReporting( Element root, List<ArtifactReference> reports )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( reports ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element reporting = root.addElement( "reporting" );
|
||||
Element plugins = reporting.addElement( "plugins" );
|
||||
|
||||
for ( ArtifactReference reference : reports )
|
||||
{
|
||||
Element plugin = plugins.addElement( "plugin" );
|
||||
addChildElement( plugin, "groupId", reference.getGroupId() );
|
||||
addChildElement( plugin, "artifactId", reference.getArtifactId() );
|
||||
addChildElement( plugin, "version", reference.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
private void addRepositories( Element root, List<ProjectRepository> repositories )
|
||||
{
|
||||
if ( CollectionUtils.isEmpty( repositories ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elemRepos = root.addElement( "repositories" );
|
||||
for ( ProjectRepository repository : repositories )
|
||||
{
|
||||
Element elem = elemRepos.addElement( "repository" );
|
||||
addChildElement( elem, "id", repository.getId() );
|
||||
addChildElement( elem, "name", repository.getName() );
|
||||
addChildElement( elem, "url", repository.getUrl() );
|
||||
|
||||
if ( !StringUtils.equals( "default", repository.getLayout() ) )
|
||||
{
|
||||
addChildElement( elem, "layout", repository.getLayout() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addScm( Element root, Scm scm )
|
||||
{
|
||||
if ( scm == null )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Element elem = root.addElement( "scm" );
|
||||
|
||||
addChildElement( elem, "connection", scm.getConnection() );
|
||||
addChildElement( elem, "developerConnection", scm.getDeveloperConnection() );
|
||||
addChildElement( elem, "url", scm.getUrl() );
|
||||
}
|
||||
|
||||
/**
|
||||
* Fix the default namespace on all elements recursively.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
private void fixDefaultNamespace( Element elem )
|
||||
{
|
||||
elem.remove( elem.getNamespace() );
|
||||
elem.setQName( QName.get( elem.getName(), DEFAULT_NAMESPACE, elem.getQualifiedName() ) );
|
||||
|
||||
Node n;
|
||||
|
||||
Iterator<Node> it = elem.elementIterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
n = it.next();
|
||||
|
||||
switch ( n.getNodeType() )
|
||||
{
|
||||
case Node.ELEMENT_NODE:
|
||||
fixDefaultNamespace( (Element) n );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void addChildElement( Element elem, String elemName, String text )
|
||||
{
|
||||
if ( StringUtils.isBlank( text ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
elem.addElement( elemName ).setText( text );
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.cache.Cache</role>
|
||||
<role-hint>effective-project-cache</role-hint>
|
||||
<implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
|
||||
<description>Effective Project Cache</description>
|
||||
<configuration>
|
||||
<disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
|
||||
<disk-persistent>true</disk-persistent>
|
||||
<disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path>
|
||||
<eternal>true</eternal>
|
||||
<max-elements-in-memory>1000</max-elements-in-memory>
|
||||
<memory-eviction-policy>LRU</memory-eviction-policy>
|
||||
<name>effective-project-cache</name>
|
||||
<overflow-to-disk>false</overflow-to-disk>
|
||||
<!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) -->
|
||||
<!-- 45 minutes = 2700 seconds -->
|
||||
<time-to-idle-seconds>2700</time-to-idle-seconds>
|
||||
<!-- 30 minutes = 1800 seconds -->
|
||||
<time-to-live-seconds>1800</time-to-live-seconds>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -1,106 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.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.Enumeration;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelMerge;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
/**
|
||||
* ProjectModelMergeTest
|
||||
*
|
||||
* @author jzurbano
|
||||
*/
|
||||
public class ProjectModelMergeTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
private ProjectModelMerge modelMerge;
|
||||
|
||||
private Enumeration<String> keys;
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
modelMerge = new ProjectModelMerge();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testPropertiesMerge()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel mainProject = createMainProject();
|
||||
ArchivaProjectModel parentProject = createParentProject();
|
||||
|
||||
assertNotNull( mainProject.getProperties() );
|
||||
|
||||
Properties prop = parentProject.getProperties();
|
||||
assertNotNull( prop );
|
||||
|
||||
keys = (Enumeration<String>) prop.propertyNames();
|
||||
assertTrue( keys.hasMoreElements() );
|
||||
|
||||
modelMerge.merge( mainProject, parentProject );
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createMainProject()
|
||||
{
|
||||
ArchivaProjectModel mainProject = new ArchivaProjectModel();
|
||||
|
||||
VersionedReference parent = new VersionedReference();
|
||||
parent.setGroupId( "org.apache" );
|
||||
parent.setArtifactId( "apache" );
|
||||
parent.setVersion( "4" );
|
||||
|
||||
mainProject.setParentProject( parent );
|
||||
mainProject.setGroupId( "org.apache.servicemix" );
|
||||
mainProject.setArtifactId( "servicemix-pom" );
|
||||
mainProject.setVersion( "2" );
|
||||
mainProject.setPackaging( "pom" );
|
||||
mainProject.setName( "ServiceMix POM" );
|
||||
mainProject.setUrl( "http://servicemix.apache.org/" );
|
||||
mainProject.setDescription( "This pom provides project information that is common to all ServiceMix branches." );
|
||||
mainProject.setProperties( new Properties() );
|
||||
|
||||
return mainProject;
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createParentProject()
|
||||
{
|
||||
ArchivaProjectModel parentProject = new ArchivaProjectModel();
|
||||
|
||||
parentProject.setGroupId( "org.apache" );
|
||||
parentProject.setArtifactId( "apache" );
|
||||
parentProject.setVersion( "4" );
|
||||
parentProject.setPackaging( "pom" );
|
||||
|
||||
Properties prop = new Properties();
|
||||
prop.setProperty( "test.key", "" );
|
||||
parentProject.setProperties( prop );
|
||||
|
||||
return parentProject;
|
||||
}
|
||||
}
|
|
@ -1,395 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.filters;
|
||||
|
||||
/*
|
||||
* 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.common.utils.VersionUtil;
|
||||
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.Individual;
|
||||
import org.apache.maven.archiva.repository.AbstractRepositoryLayerTestCase;
|
||||
import org.apache.maven.archiva.repository.ManagedRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolver;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelResolverFactory;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.repository.project.resolvers.ManagedRepositoryProjectResolver;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* EffectiveProjectModelFilterTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class EffectiveProjectModelFilterTest
|
||||
extends AbstractRepositoryLayerTestCase
|
||||
{
|
||||
private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository";
|
||||
|
||||
private EffectiveProjectModelFilter lookupEffective()
|
||||
throws Exception
|
||||
{
|
||||
return (EffectiveProjectModelFilter) lookup( ProjectModelFilter.class, "effective" );
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws XMLException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
File pomFile = new File( getBasedir(), path );
|
||||
|
||||
return reader.read( pomFile );
|
||||
}
|
||||
|
||||
private ProjectModelResolver createDefaultRepositoryResolver() throws Exception
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), DEFAULT_REPOSITORY );
|
||||
|
||||
ManagedRepositoryContent repo = createManagedRepositoryContent( "defaultTestRepo", "Default Test Repo", defaultRepoDir, "default" );
|
||||
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
ManagedRepositoryProjectResolver resolver = new ManagedRepositoryProjectResolver( repo, reader );
|
||||
|
||||
return resolver;
|
||||
}
|
||||
|
||||
public void testBuildEffectiveProject()
|
||||
throws Exception
|
||||
{
|
||||
assertEffectiveProject(
|
||||
"/org/apache/maven/archiva/archiva-model/1.0-SNAPSHOT/archiva-model-1.0-SNAPSHOT.pom",
|
||||
"/archiva-model-effective.pom");
|
||||
|
||||
assertEffectiveProject(
|
||||
"/test-project/test-project-endpoint-ejb/2.4.4/test-project-endpoint-ejb-2.4.4.pom",
|
||||
"/test-project-model-effective.pom");
|
||||
}
|
||||
|
||||
private void assertEffectiveProject(String pomFile, String effectivePomFile) throws Exception,
|
||||
ProjectModelException {
|
||||
initTestResolverFactory();
|
||||
EffectiveProjectModelFilter filter = lookupEffective();
|
||||
|
||||
ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile );
|
||||
|
||||
ArchivaProjectModel effectiveModel = filter.filter( startModel );
|
||||
|
||||
ArchivaProjectModel expectedModel = createArchivaProjectModel( "src/test/expected-poms/" + effectivePomFile);
|
||||
|
||||
assertModel( expectedModel, effectiveModel );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* [MRM-510] In Repository Browse, the first unique snapshot version clicked is getting persisted in the
|
||||
* request resulting to 'version does not match' error
|
||||
*
|
||||
* The purpose of this test is ensure that timestamped SNAPSHOTS do not cache improperly, and each timestamped
|
||||
* pom can be loaded through the effective project filter correctly.
|
||||
*/
|
||||
public void testBuildEffectiveSnapshotProject()
|
||||
throws Exception
|
||||
{
|
||||
initTestResolverFactory();
|
||||
EffectiveProjectModelFilter filter = lookupEffective();
|
||||
|
||||
String axisVersions[] = new String[] {
|
||||
"1.3-20070725.210059-1",
|
||||
"1.3-20070725.232304-2",
|
||||
"1.3-20070726.053327-3",
|
||||
"1.3-20070726.173653-5",
|
||||
"1.3-20070727.113106-7",
|
||||
"1.3-20070728.053229-10",
|
||||
"1.3-20070728.112043-11",
|
||||
"1.3-20070729.171937-16",
|
||||
"1.3-20070730.232112-20",
|
||||
"1.3-20070731.113304-21",
|
||||
"1.3-20070731.172936-22",
|
||||
"1.3-20070802.113139-29" };
|
||||
|
||||
for ( int i = 0; i < axisVersions.length; i++ )
|
||||
{
|
||||
assertTrue( "Version should be a unique snapshot.", VersionUtil.isUniqueSnapshot( axisVersions[i] ) );
|
||||
|
||||
ArchivaProjectModel initialModel = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
+ "/org/apache/axis2/axis2/1.3-SNAPSHOT/axis2-" + axisVersions[i] + ".pom" );
|
||||
|
||||
// This is the process that ProjectModelToDatabaseConsumer uses, so we mimic it here.
|
||||
// This logic is related to the MRM-510 jira.
|
||||
String baseVersion = VersionUtil.getBaseVersion( axisVersions[i] );
|
||||
|
||||
assertEquals( "Base Version <" + baseVersion + "> of filename <" + axisVersions[i]
|
||||
+ "> should be equal to what is in model.", initialModel.getVersion(), baseVersion );
|
||||
|
||||
initialModel.setVersion( axisVersions[i] );
|
||||
|
||||
assertEquals( "Unique snapshot versions of initial model should be equal.", axisVersions[i], initialModel
|
||||
.getVersion() );
|
||||
|
||||
ArchivaProjectModel effectiveModel = filter.filter( initialModel );
|
||||
|
||||
assertEquals( "Unique snapshot versions of initial model should be equal.", axisVersions[i], initialModel
|
||||
.getVersion() );
|
||||
assertEquals( "Unique snapshot versions of filtered/effective model should be equal.", axisVersions[i],
|
||||
effectiveModel.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Test before and after the properties are evaluated. pom snippet: <maven.version>2.0.5</maven.version>
|
||||
* <wagon.version>1.0-beta-2</wagon.version> <plexus-security.version>1.0-alpha-10-SNAPSHOT</plexus-security.version>
|
||||
*/
|
||||
public void testEffectiveProjectProperty()
|
||||
throws Exception
|
||||
{
|
||||
initTestResolverFactory();
|
||||
EffectiveProjectModelFilter filter = lookupEffective();
|
||||
|
||||
String pomFile = "/org/apache/maven/archiva/archiva/1.0-SNAPSHOT/archiva-1.0-SNAPSHOT.pom";
|
||||
ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile );
|
||||
|
||||
String plexusSecurityVersion = "1.0-alpha-10-SNAPSHOT";
|
||||
String wagonVersion = "1.0-beta-2";
|
||||
|
||||
boolean passedPlexusVersionChecking = false;
|
||||
boolean passedWagonVersionChecking = false;
|
||||
|
||||
List<Dependency> startDeps = startModel.getDependencyManagement();
|
||||
for ( Dependency startDep : startDeps )
|
||||
{
|
||||
if ( "org.codehaus.plexus.security".equals( startDep.getGroupId() ) )
|
||||
{
|
||||
assertEquals( startDep.getVersion(), "${plexus-security.version}" );
|
||||
}
|
||||
else if ( "org.apache.maven.wagon".equals( startDep.getGroupId() ) )
|
||||
{
|
||||
assertEquals( startDep.getVersion(), "${wagon.version}" );
|
||||
}
|
||||
}
|
||||
|
||||
ArchivaProjectModel effectiveModel = filter.filter( startModel );
|
||||
|
||||
List<Dependency> effectiveDeps = effectiveModel.getDependencyManagement();
|
||||
for ( Dependency dependency : effectiveDeps )
|
||||
{
|
||||
if ( "org.codehaus.plexus.security".equals( dependency.getGroupId() ) )
|
||||
{
|
||||
assertEquals( dependency.getVersion(), plexusSecurityVersion );
|
||||
|
||||
if ( !passedPlexusVersionChecking )
|
||||
{
|
||||
passedPlexusVersionChecking = true;
|
||||
}
|
||||
}
|
||||
else if ( "org.apache.maven.wagon".equals( dependency.getGroupId() ) )
|
||||
{
|
||||
assertEquals( dependency.getVersion(), wagonVersion );
|
||||
|
||||
if ( !passedWagonVersionChecking )
|
||||
{
|
||||
passedWagonVersionChecking = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
assertTrue( passedPlexusVersionChecking );
|
||||
assertTrue( passedWagonVersionChecking );
|
||||
}
|
||||
|
||||
// MRM-1194
|
||||
public void testEffectiveProjectPropertyExistingParentHasUniqueSnapshotVersion()
|
||||
throws Exception
|
||||
{
|
||||
initTestResolverFactory();
|
||||
EffectiveProjectModelFilter filter = lookupEffective();
|
||||
|
||||
String pomFile = "/org/apache/archiva/sample-project/2.1-SNAPSHOT/sample-project-2.1-SNAPSHOT.pom";
|
||||
ArchivaProjectModel startModel = createArchivaProjectModel( DEFAULT_REPOSITORY + pomFile );
|
||||
|
||||
String buildHelperPluginVersion = "1.0";
|
||||
|
||||
boolean passedBuildHelperVersionChecking = false;
|
||||
|
||||
List<ArtifactReference> startPlugins = startModel.getPlugins();
|
||||
for( ArtifactReference plugin : startPlugins )
|
||||
{
|
||||
if( "build-helper-maven-plugin".equals( plugin.getArtifactId() ) )
|
||||
{
|
||||
assertEquals( "${build-helper-maven-plugin.version}", plugin.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
ArchivaProjectModel effectiveModel = filter.filter( startModel );
|
||||
|
||||
List<ArtifactReference> effectivePlugins = effectiveModel.getPlugins();
|
||||
for( ArtifactReference plugin : effectivePlugins )
|
||||
{
|
||||
if( "build-helper-maven-plugin".equals( plugin.getArtifactId() ) )
|
||||
{
|
||||
assertEquals( buildHelperPluginVersion, plugin.getVersion() );
|
||||
|
||||
if ( !passedBuildHelperVersionChecking )
|
||||
{
|
||||
passedBuildHelperVersionChecking = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
assertTrue( passedBuildHelperVersionChecking );
|
||||
}
|
||||
|
||||
|
||||
private ProjectModelResolverFactory initTestResolverFactory()
|
||||
throws Exception
|
||||
{
|
||||
ProjectModelResolverFactory resolverFactory = (ProjectModelResolverFactory) lookup( ProjectModelResolverFactory.class );
|
||||
|
||||
resolverFactory.getCurrentResolverStack().clearResolvers();
|
||||
resolverFactory.getCurrentResolverStack().addProjectModelResolver( createDefaultRepositoryResolver() );
|
||||
|
||||
return resolverFactory;
|
||||
}
|
||||
|
||||
private void assertModel( ArchivaProjectModel expectedModel, ArchivaProjectModel effectiveModel )
|
||||
{
|
||||
assertEquals( "Equivalent Models", expectedModel, effectiveModel );
|
||||
|
||||
assertContainsSameIndividuals( "Individuals", expectedModel.getIndividuals(), effectiveModel.getIndividuals() );
|
||||
dumpDependencyList( "Expected", expectedModel.getDependencies() );
|
||||
dumpDependencyList( "Effective", effectiveModel.getDependencies() );
|
||||
assertContainsSameDependencies( "Dependencies", expectedModel.getDependencies(), effectiveModel
|
||||
.getDependencies() );
|
||||
assertContainsSameDependencies( "DependencyManagement", expectedModel.getDependencyManagement(), effectiveModel
|
||||
.getDependencyManagement() );
|
||||
}
|
||||
|
||||
private void dumpDependencyList( String type, List<Dependency> deps )
|
||||
{
|
||||
if ( deps == null )
|
||||
{
|
||||
System.out.println( " Dependencies [" + type + "] is null." );
|
||||
return;
|
||||
}
|
||||
|
||||
if ( deps.isEmpty() )
|
||||
{
|
||||
System.out.println( " Dependencies [" + type + "] dependency list is empty." );
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println( ".\\ [" + type + "] Dependency List (size:" + deps.size() + ") \\.________________" );
|
||||
Iterator<Dependency> it = deps.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
System.out.println( " " + Dependency.toKey( dep ) );
|
||||
}
|
||||
System.out.println( "" );
|
||||
}
|
||||
|
||||
private void assertEquivalentLists( String listId, List<?> expectedList, List<?> effectiveList )
|
||||
{
|
||||
if ( ( expectedList == null ) && ( effectiveList == null ) )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( expectedList == null ) && ( effectiveList != null ) )
|
||||
{
|
||||
fail( "Effective [" + listId + "] List is instantiated, while expected List is null." );
|
||||
}
|
||||
|
||||
if ( ( expectedList != null ) && ( effectiveList == null ) )
|
||||
{
|
||||
fail( "Effective [" + listId + "] List is null, while expected List is instantiated." );
|
||||
}
|
||||
|
||||
assertEquals( "[" + listId + "] List Size", expectedList.size(), expectedList.size() );
|
||||
}
|
||||
|
||||
private void assertContainsSameIndividuals( String listId, List<Individual> expectedList,
|
||||
List<Individual> effectiveList )
|
||||
{
|
||||
assertEquivalentLists( listId, expectedList, effectiveList );
|
||||
|
||||
Map<String, Individual> expectedMap = getIndividualsMap( expectedList );
|
||||
Map<String, Individual> effectiveMap = getIndividualsMap( effectiveList );
|
||||
|
||||
Iterator<String> it = expectedMap.keySet().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
String key = (String) it.next();
|
||||
|
||||
assertTrue( "Should exist in Effective [" + listId + "] list: " + key, effectiveMap.containsKey( key ) );
|
||||
}
|
||||
}
|
||||
|
||||
private void assertContainsSameDependencies( String listId, List<Dependency> expectedList,
|
||||
List<Dependency> effectiveList )
|
||||
{
|
||||
assertEquivalentLists( listId, expectedList, effectiveList );
|
||||
|
||||
Map<String, Dependency> expectedMap = getDependencyMap( expectedList );
|
||||
Map<String, Dependency> effectiveMap = getDependencyMap( effectiveList );
|
||||
|
||||
Iterator<String> it = expectedMap.keySet().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
String key = it.next();
|
||||
|
||||
assertTrue( "Should exist in Effective [" + listId + "] list: " + key, effectiveMap.containsKey( key ) );
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Individual> getIndividualsMap( List<Individual> individuals )
|
||||
{
|
||||
Map<String, Individual> map = new HashMap<String, Individual>();
|
||||
Iterator<Individual> it = individuals.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Individual individual = it.next();
|
||||
String key = individual.getEmail();
|
||||
map.put( key, individual );
|
||||
}
|
||||
return map;
|
||||
}
|
||||
|
||||
private Map<String, Dependency> getDependencyMap( List<Dependency> deps )
|
||||
{
|
||||
Map<String, Dependency> map = new HashMap<String, Dependency>();
|
||||
Iterator<Dependency> it = deps.iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
String key = Dependency.toKey( dep );
|
||||
map.put( key, dep );
|
||||
}
|
||||
return map;
|
||||
}
|
||||
}
|
|
@ -1,161 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.filters;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelFilter;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelWriter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.repository.project.writers.ProjectModel400Writer;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ProjectModelExpressionExpanderTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModelExpressionExpanderTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository";
|
||||
|
||||
private ProjectModelExpressionFilter lookupExpression()
|
||||
throws Exception
|
||||
{
|
||||
return (ProjectModelExpressionFilter) lookup( ProjectModelFilter.class, "expression" );
|
||||
}
|
||||
|
||||
public void testExpressionEvaluation()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = new ArchivaProjectModel();
|
||||
model.setGroupId( "org.apache.maven.archiva" );
|
||||
model.setArtifactId( "archiva-test-project" );
|
||||
model.setVersion( "1.0-SNAPSHOT" );
|
||||
|
||||
List<Dependency> deps = new ArrayList<Dependency>();
|
||||
|
||||
deps.add( createDependency( "org.apache.maven.archiva", "archiva-model", "${archiva.version}" ) );
|
||||
deps.add( createDependency( "org.apache.maven.archiva", "archiva-common", "${archiva.version}" ) );
|
||||
deps.add( createDependency( "org.apache.maven.archiva", "archiva-indexer", "${archiva.version}" ) );
|
||||
|
||||
model.setDependencies( deps );
|
||||
|
||||
model.addProperty( "archiva.version", "1.0-SNAPSHOT" );
|
||||
|
||||
ProjectModelExpressionFilter filter = lookupExpression();
|
||||
|
||||
model = filter.filter( model );
|
||||
|
||||
assertNotNull( model );
|
||||
assertEquals( "Group ID", "org.apache.maven.archiva", model.getGroupId() );
|
||||
assertEquals( "Artifact ID", "archiva-test-project", model.getArtifactId() );
|
||||
assertEquals( "Version", "1.0-SNAPSHOT", model.getVersion() );
|
||||
assertNotNull( "Dependencies", model.getDependencies() );
|
||||
assertEquals( "Dependencies Size", 3, model.getDependencies().size() );
|
||||
|
||||
Iterator<Dependency> it = model.getDependencies().iterator();
|
||||
while ( it.hasNext() )
|
||||
{
|
||||
Dependency dep = it.next();
|
||||
assertEquals( "Dependency [" + dep.getArtifactId() + "] Group ID", "org.apache.maven.archiva", dep
|
||||
.getGroupId() );
|
||||
assertEquals( "Dependency [" + dep.getArtifactId() + "] Version", "1.0-SNAPSHOT", dep.getVersion() );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* [MRM-487] pom version is not resolved
|
||||
* [MRM-488] properties in pom are not resolved (at least while browsing)
|
||||
*
|
||||
* This is to ensure that any expression within the pom is evaluated properly.
|
||||
*/
|
||||
public void testExpressionHell()
|
||||
throws Exception
|
||||
{
|
||||
ProjectModelExpressionFilter filter = lookupExpression();
|
||||
|
||||
ArchivaProjectModel initialModel = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
+ "/org/apache/maven/test/2.0.4-SNAPSHOT/test-2.0.4-SNAPSHOT.pom" );
|
||||
|
||||
ArchivaProjectModel filteredModel = filter.filter( initialModel );
|
||||
|
||||
// Dump the evaluated model to xml
|
||||
String evaluatedModelText = toModelText( filteredModel );
|
||||
|
||||
// Test xml buffer for the existance of an unevaluated expression.
|
||||
boolean foundUnevaluated = false;
|
||||
if ( evaluatedModelText.indexOf( "${" ) != ( -1 ) )
|
||||
{
|
||||
System.err.println( "Found Expression:\n" + evaluatedModelText );
|
||||
foundUnevaluated = true;
|
||||
}
|
||||
|
||||
if ( foundUnevaluated )
|
||||
{
|
||||
fail( "Found Unevaluated Expression. (see System.err for details)" );
|
||||
}
|
||||
}
|
||||
|
||||
private String toModelText( ArchivaProjectModel model )
|
||||
throws ProjectModelException, IOException
|
||||
{
|
||||
StringWriter strWriter = new StringWriter();
|
||||
|
||||
ProjectModelWriter modelWriter = new ProjectModel400Writer();
|
||||
modelWriter.write( model, strWriter );
|
||||
|
||||
return strWriter.toString();
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws XMLException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
File pomFile = new File( getBasedir(), path );
|
||||
|
||||
return reader.read( pomFile );
|
||||
}
|
||||
|
||||
private Dependency createDependency( String groupId, String artifactId, String version )
|
||||
{
|
||||
Dependency dep = new Dependency();
|
||||
|
||||
dep.setGroupId( groupId );
|
||||
dep.setArtifactId( artifactId );
|
||||
dep.setVersion( version );
|
||||
dep.setTransitive( false );
|
||||
|
||||
return dep;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.readers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.Dependency;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
/**
|
||||
* ProjectModel300ReaderTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModel300ReaderTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
public void testLoadSimple()
|
||||
throws XMLException
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), "src/test/repositories/legacy-repository" );
|
||||
File pomFile = new File( defaultRepoDir, "org.apache.maven/poms/maven-model-v3-2.0.pom" );
|
||||
|
||||
ProjectModelReader reader = new ProjectModel300Reader();
|
||||
|
||||
ArchivaProjectModel project = reader.read( pomFile );
|
||||
|
||||
assertNotNull( project );
|
||||
assertEquals( "Group Id", "org.apache.maven", project.getGroupId() );
|
||||
assertEquals( "Artifact Id", "maven-model-v3", project.getArtifactId() );
|
||||
assertEquals( "Version", "2.0", project.getVersion() );
|
||||
assertEquals( "Name", "Maven Model v3", project.getName() );
|
||||
assertEquals( "Description", "Maven Model v3", project.getDescription() );
|
||||
|
||||
assertNull( "Has no parent project.", project.getParentProject() );
|
||||
|
||||
assertNotNull( "Dependencies", project.getDependencies() );
|
||||
assertEquals( "Dependencies.size", 1, project.getDependencies().size() );
|
||||
|
||||
Dependency dep = (Dependency) project.getDependencies().get( 0 );
|
||||
assertNotNull( dep );
|
||||
assertEquals( "dep.groupId", "org.codehaus.plexus", dep.getGroupId() );
|
||||
assertEquals( "dep.artifactId", "plexus-utils", dep.getArtifactId() );
|
||||
assertEquals( "dep.version", "1.0.4", dep.getVersion() );
|
||||
}
|
||||
}
|
|
@ -1,96 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.readers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
/**
|
||||
* ProjectModel400ReaderTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModel400ReaderTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
public void testLoadSimple()
|
||||
throws XMLException
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
|
||||
File pomFile = new File( defaultRepoDir,
|
||||
"org/apache/maven/shared/maven-downloader/1.0/maven-downloader-1.0.pom" );
|
||||
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
ArchivaProjectModel project = reader.read( pomFile );
|
||||
|
||||
assertNotNull( project );
|
||||
assertEquals( "Group Id", "org.apache.maven.shared", project.getGroupId() );
|
||||
assertEquals( "Artifact Id", "maven-downloader", project.getArtifactId() );
|
||||
assertEquals( "Version", "1.0", project.getVersion() );
|
||||
assertEquals( "Name", "Maven Downloader", project.getName() );
|
||||
assertEquals( "Description", "Provide a super simple interface for downloading a single artifact.", project
|
||||
.getDescription() );
|
||||
|
||||
// Test for parent
|
||||
VersionedReference parentRef = project.getParentProject();
|
||||
assertNotNull( "Parent Reference", parentRef );
|
||||
assertEquals( "Parent Group ID", "org.apache.maven.shared", parentRef.getGroupId() );
|
||||
assertEquals( "Parent Artifact ID", "maven-shared-components", parentRef.getArtifactId() );
|
||||
assertEquals( "Parent Version", "4", parentRef.getVersion() );
|
||||
|
||||
assertNotNull( "Dependencies", project.getDependencies() );
|
||||
assertEquals( "Dependencies.size", 3, project.getDependencies().size() );
|
||||
}
|
||||
|
||||
public void testLoadWithNamespace()
|
||||
throws XMLException
|
||||
{
|
||||
File defaultRepoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
|
||||
File pomFile = new File( defaultRepoDir,
|
||||
"org/apache/maven/archiva/archiva-model/1.0-SNAPSHOT/archiva-model-1.0-SNAPSHOT.pom" );
|
||||
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
ArchivaProjectModel project = reader.read( pomFile );
|
||||
|
||||
assertNotNull( project );
|
||||
assertEquals( "Group Id", null, project.getGroupId() );
|
||||
assertEquals( "Artifact Id", "archiva-model", project.getArtifactId() );
|
||||
assertEquals( "Version", null, project.getVersion() );
|
||||
assertEquals( "Name", "Archiva Base :: Model", project.getName() );
|
||||
assertEquals( "Description", null, project.getDescription() );
|
||||
|
||||
// Test for parent
|
||||
VersionedReference parentRef = project.getParentProject();
|
||||
assertNotNull( "Parent Reference", parentRef );
|
||||
assertEquals( "Parent Group ID", "org.apache.maven.archiva", parentRef.getGroupId() );
|
||||
assertEquals( "Parent Artifact ID", "archiva-base", parentRef.getArtifactId() );
|
||||
assertEquals( "Parent Version", "1.0-SNAPSHOT", parentRef.getVersion() );
|
||||
|
||||
assertNotNull( "Dependencies", project.getDependencies() );
|
||||
assertEquals( "Dependencies.size", 8, project.getDependencies().size() );
|
||||
}
|
||||
}
|
|
@ -1,139 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.resolvers;
|
||||
|
||||
/*
|
||||
* 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 org.apache.maven.archiva.configuration.FileTypes;
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
import org.apache.maven.archiva.repository.content.ManagedDefaultRepositoryContent;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
|
||||
public class ManagedRepositoryProjectResolverTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
private ManagedRepositoryProjectResolver resolver;
|
||||
|
||||
public void setUp() throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
FileTypes fileTypes = new MockFileTypes();
|
||||
|
||||
ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
|
||||
repoConfig.setId( "test-repo" );
|
||||
repoConfig.setLocation( new File( getBasedir(), "target/test-classes/test-repo" ).getPath() );
|
||||
repoConfig.setName( "Test Repository" );
|
||||
|
||||
ManagedDefaultRepositoryContent repository = new ManagedDefaultRepositoryContent();
|
||||
repository.setRepository( repoConfig );
|
||||
repository.setFiletypes( fileTypes );
|
||||
|
||||
resolver = new ManagedRepositoryProjectResolver( repository, new ProjectModel400Reader() );
|
||||
}
|
||||
|
||||
public void testResolveSnapshotUniqueVersionPresent()
|
||||
throws Exception
|
||||
{
|
||||
VersionedReference ref = new VersionedReference();
|
||||
ref.setGroupId( "org.apache.archiva" );
|
||||
ref.setArtifactId( "unique-version" );
|
||||
ref.setVersion( "1.0-SNAPSHOT" );
|
||||
|
||||
try
|
||||
{
|
||||
ArchivaProjectModel model = resolver.resolveProjectModel( ref );
|
||||
|
||||
assertNotNull( model );
|
||||
assertEquals( "org.apache.archiva", model.getGroupId() );
|
||||
assertEquals( "unique-version", model.getArtifactId() );
|
||||
assertEquals( "1.0-SNAPSHOT", model.getVersion() );
|
||||
assertEquals( "Unique Version Snapshot - Build 3", model.getName() );
|
||||
}
|
||||
catch ( ProjectModelException e )
|
||||
{
|
||||
fail( "A ProjectModelException should not have occurred. Instead, the latest timestamp should have been found!" );
|
||||
}
|
||||
}
|
||||
|
||||
public void testResolveSnapshotGenericVersionPresent()
|
||||
throws Exception
|
||||
{
|
||||
VersionedReference ref = new VersionedReference();
|
||||
ref.setGroupId( "org.apache.archiva" );
|
||||
ref.setArtifactId( "generic-version" );
|
||||
ref.setVersion( "1.0-SNAPSHOT" );
|
||||
|
||||
ArchivaProjectModel model = resolver.resolveProjectModel( ref );
|
||||
|
||||
assertNotNull( model );
|
||||
assertEquals( "org.apache.archiva", model.getGroupId() );
|
||||
assertEquals( "generic-version", model.getArtifactId() );
|
||||
assertEquals( "1.0-SNAPSHOT", model.getVersion() );
|
||||
}
|
||||
|
||||
public void testResolveSuccessful()
|
||||
throws Exception
|
||||
{
|
||||
VersionedReference ref = new VersionedReference();
|
||||
ref.setGroupId( "org.apache.archiva" );
|
||||
ref.setArtifactId( "released-version" );
|
||||
ref.setVersion( "1.0" );
|
||||
|
||||
ArchivaProjectModel model = resolver.resolveProjectModel( ref );
|
||||
|
||||
assertNotNull( model );
|
||||
assertEquals( "org.apache.archiva", model.getGroupId() );
|
||||
assertEquals( "released-version", model.getArtifactId() );
|
||||
assertEquals( "1.0", model.getVersion() );
|
||||
}
|
||||
|
||||
public void testResolveNotFound()
|
||||
throws Exception
|
||||
{
|
||||
VersionedReference ref = new VersionedReference();
|
||||
ref.setGroupId( "org.apache.archiva" );
|
||||
ref.setArtifactId( "non-existant" );
|
||||
ref.setVersion( "2.0" );
|
||||
|
||||
try
|
||||
{
|
||||
resolver.resolveProjectModel( ref );
|
||||
fail( "A ProjectModelException should have been thrown." );
|
||||
}
|
||||
catch( ProjectModelException e )
|
||||
{
|
||||
assertTrue( true );
|
||||
}
|
||||
}
|
||||
|
||||
class MockFileTypes
|
||||
extends FileTypes
|
||||
{
|
||||
public boolean matchesArtifactPattern( String relativePath )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,150 +0,0 @@
|
|||
package org.apache.maven.archiva.repository.project.writers;
|
||||
|
||||
/*
|
||||
* 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.io.FileUtils;
|
||||
import org.apache.maven.archiva.model.ArchivaProjectModel;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelException;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelReader;
|
||||
import org.apache.maven.archiva.repository.project.ProjectModelWriter;
|
||||
import org.apache.maven.archiva.repository.project.readers.ProjectModel400Reader;
|
||||
import org.apache.maven.archiva.xml.XMLException;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.custommonkey.xmlunit.DetailedDiff;
|
||||
import org.custommonkey.xmlunit.Diff;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
|
||||
/**
|
||||
* ProjectModel400WriterTest
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class ProjectModel400WriterTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
private static final String DEFAULT_REPOSITORY = "src/test/repositories/default-repository";
|
||||
|
||||
private ProjectModelWriter modelWriter;
|
||||
|
||||
@Override
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
modelWriter = new ProjectModel400Writer();
|
||||
}
|
||||
|
||||
public void testSimpleWrite()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = new ArchivaProjectModel();
|
||||
model.setGroupId( "org.apache.archiva.test" );
|
||||
model.setArtifactId( "simple-model-write" );
|
||||
model.setVersion( "1.0" );
|
||||
|
||||
String actualModel = writeToString( model );
|
||||
String expectedModel = getExpectedModelString( "model-write-400-simple.pom" );
|
||||
|
||||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
public void testReadWriteSimple()
|
||||
throws Exception
|
||||
{
|
||||
String pathToModel = DEFAULT_REPOSITORY + "/org/apache/maven/A/1.0/A-1.0.pom";
|
||||
ArchivaProjectModel model = createArchivaProjectModel( pathToModel );
|
||||
|
||||
String actualModel = writeToString( model );
|
||||
String expectedModel = FileUtils.readFileToString( new File( pathToModel ), null );
|
||||
|
||||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
public void testReadWriteMavenParent()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
+ "/org/apache/maven/maven-parent/4/maven-parent-4.pom" );
|
||||
|
||||
String actualModel = writeToString( model );
|
||||
String expectedModel = getExpectedModelString( "maven-parent-4.pom" );
|
||||
|
||||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
public void testReadWriteCocoon()
|
||||
throws Exception
|
||||
{
|
||||
ArchivaProjectModel model = createArchivaProjectModel( DEFAULT_REPOSITORY
|
||||
+ "/org/apache/cocoon/cocoon/1/cocoon-1.pom" );
|
||||
|
||||
String actualModel = writeToString( model );
|
||||
String expectedModel = getExpectedModelString( "cocoon-1.pom" );
|
||||
|
||||
assertModelSimilar( expectedModel, actualModel );
|
||||
}
|
||||
|
||||
private void assertModelSimilar( String expectedModel, String actualModel )
|
||||
throws Exception
|
||||
{
|
||||
Diff diff = new Diff( expectedModel, actualModel );
|
||||
DetailedDiff detailedDiff = new DetailedDiff( diff );
|
||||
if ( !detailedDiff.similar() )
|
||||
{
|
||||
// If it isn't similar, dump the difference.
|
||||
System.out.println( detailedDiff.toString() );
|
||||
System.out.println( "-- Actual Model --\n" + actualModel + "\n---------------\n\n" );
|
||||
System.out.println( "-- Expected Model --\n" + expectedModel + "\n---------------\n\n" );
|
||||
|
||||
assertEquals( expectedModel, actualModel );
|
||||
}
|
||||
}
|
||||
|
||||
private String getExpectedModelString( String pomfilename )
|
||||
throws IOException
|
||||
{
|
||||
File pomFile = getTestFile( "src/test/expected-poms/" + pomfilename );
|
||||
return FileUtils.readFileToString( pomFile, null );
|
||||
}
|
||||
|
||||
private ArchivaProjectModel createArchivaProjectModel( String path )
|
||||
throws XMLException
|
||||
{
|
||||
ProjectModelReader reader = new ProjectModel400Reader();
|
||||
|
||||
File pomFile = new File( getBasedir(), path );
|
||||
|
||||
return reader.read( pomFile );
|
||||
}
|
||||
|
||||
private String writeToString( ArchivaProjectModel model )
|
||||
throws ProjectModelException, IOException
|
||||
{
|
||||
StringWriter writer = new StringWriter();
|
||||
|
||||
modelWriter.write( model, writer );
|
||||
|
||||
return writer.toString();
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.apache.maven.archiva.configuration.ArchivaConfiguration</role>
|
||||
<role-hint>mock</role-hint>
|
||||
<implementation>org.apache.maven.archiva.repository.MockConfiguration</implementation>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.codehaus.plexus.cache.Cache</role>
|
||||
<role-hint>effective-project-cache</role-hint>
|
||||
<implementation>org.codehaus.plexus.cache.ehcache.EhcacheCache</implementation>
|
||||
<description>Effective Project Cache</description>
|
||||
<configuration>
|
||||
<disk-expiry-thread-interval-seconds>600</disk-expiry-thread-interval-seconds>
|
||||
<disk-persistent>true</disk-persistent>
|
||||
<disk-store-path>${java.io.tmpdir}/archiva/effectiveproject</disk-store-path>
|
||||
<eternal>true</eternal>
|
||||
<max-elements-in-memory>1000</max-elements-in-memory>
|
||||
<memory-eviction-policy>LRU</memory-eviction-policy>
|
||||
<name>effective-project-cache</name>
|
||||
<overflow-to-disk>false</overflow-to-disk>
|
||||
<!-- TODO: Adjust the time to live to be more sane (ie: huge 4+ hours) -->
|
||||
<!-- 45 minutes = 2700 seconds -->
|
||||
<time-to-idle-seconds>2700</time-to-idle-seconds>
|
||||
<!-- 30 minutes = 1800 seconds -->
|
||||
<time-to-live-seconds>1800</time-to-live-seconds>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -49,8 +49,6 @@ public interface ArchivaDAO
|
|||
|
||||
ArtifactDAO getArtifactDAO();
|
||||
|
||||
ProjectModelDAO getProjectModelDAO();
|
||||
|
||||
RepositoryProblemDAO getRepositoryProblemDAO();
|
||||
|
||||
RepositoryContentStatisticsDAO getRepositoryContentStatisticsDAO();
|
||||
|
|
|
@ -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;
|
||||
}
|
|
@ -23,11 +23,9 @@ 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.
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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
|
||||
*
|
||||
|
@ -49,11 +48,6 @@ public class JdoArchivaDAO
|
|||
*/
|
||||
private ArtifactDAO artifactDAO;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
private ProjectModelDAO projectModelDAO;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
|
@ -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;
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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
|
||||
{
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
|
@ -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 );
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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>
|
|
@ -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
|
||||
{
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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() );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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 ) );
|
||||
}
|
||||
|
||||
}
|
|
@ -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() );
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -1,71 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<artifactId>archiva-scheduler</artifactId>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<version>1.3-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>archiva-scheduler-database</artifactId>
|
||||
<name>Archiva Base :: Scheduled Tasks :: Database</name>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-scheduler-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-configuration</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-database</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-quartz</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-simple</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>hsqldb</groupId>
|
||||
<artifactId>hsqldb</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-spring</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.plexus</groupId>
|
||||
<artifactId>plexus-component-metadata</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>merge</id>
|
||||
<goals>
|
||||
<goal>merge-metadata</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<descriptors>
|
||||
<descriptor>${basedir}/src/main/resources/META-INF/plexus/components.xml</descriptor>
|
||||
<descriptor>${project.build.outputDirectory}/META-INF/plexus/components.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
|
@ -1,79 +0,0 @@
|
|||
package org.apache.archiva.scheduler.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.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.database.updater.DatabaseUpdater;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.InitializationException;
|
||||
import org.codehaus.plexus.taskqueue.Task;
|
||||
import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
|
||||
import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* ArchivaDatabaseTaskExecutor
|
||||
*
|
||||
* @version $Id$
|
||||
*
|
||||
* @plexus.component
|
||||
* role="org.codehaus.plexus.taskqueue.execution.TaskExecutor"
|
||||
* role-hint="database-update"
|
||||
*/
|
||||
public class ArchivaDatabaseUpdateTaskExecutor
|
||||
implements TaskExecutor, Initializable
|
||||
{
|
||||
private Logger log = LoggerFactory.getLogger( ArchivaDatabaseUpdateTaskExecutor.class );
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="jdo"
|
||||
*/
|
||||
private DatabaseUpdater databaseUpdater;
|
||||
|
||||
public void initialize()
|
||||
throws InitializationException
|
||||
{
|
||||
log.info( "Initialized " + this.getClass().getName() );
|
||||
}
|
||||
|
||||
public void executeTask( Task task )
|
||||
throws TaskExecutionException
|
||||
{
|
||||
DatabaseTask dbtask = (DatabaseTask) task;
|
||||
|
||||
log.info( "Executing task from queue with job name: " + dbtask );
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
try
|
||||
{
|
||||
log.info( "Task: Updating unprocessed artifacts" );
|
||||
databaseUpdater.updateAllUnprocessed();
|
||||
}
|
||||
catch ( ArchivaDatabaseException e )
|
||||
{
|
||||
throw new TaskExecutionException( "Error running unprocessed updater", e );
|
||||
}
|
||||
|
||||
time = System.currentTimeMillis() - time;
|
||||
|
||||
log.info( "Finished database task in " + time + "ms." );
|
||||
}
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
package org.apache.archiva.scheduler.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 java.text.ParseException;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.archiva.scheduler.ArchivaTaskScheduler;
|
||||
import org.apache.maven.archiva.common.ArchivaException;
|
||||
import org.apache.maven.archiva.configuration.ArchivaConfiguration;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationEvent;
|
||||
import org.apache.maven.archiva.configuration.ConfigurationListener;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.Startable;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.StartingException;
|
||||
import org.codehaus.plexus.personality.plexus.lifecycle.phase.StoppingException;
|
||||
import org.codehaus.plexus.scheduler.CronExpressionValidator;
|
||||
import org.codehaus.plexus.scheduler.Scheduler;
|
||||
import org.codehaus.plexus.taskqueue.Task;
|
||||
import org.codehaus.plexus.taskqueue.TaskQueue;
|
||||
import org.codehaus.plexus.taskqueue.TaskQueueException;
|
||||
import org.codehaus.plexus.taskqueue.execution.TaskExecutionException;
|
||||
import org.quartz.CronTrigger;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobDetail;
|
||||
import org.quartz.SchedulerException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Default implementation of a scheduling component for archiva.
|
||||
*
|
||||
* @plexus.component role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="database"
|
||||
*/
|
||||
public class DatabaseArchivaTaskScheduler
|
||||
implements ArchivaTaskScheduler<DatabaseTask>, Startable, ConfigurationListener
|
||||
{
|
||||
private Logger log = LoggerFactory.getLogger( DatabaseArchivaTaskScheduler.class );
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private Scheduler scheduler;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role-hint="database-update"
|
||||
*/
|
||||
private TaskQueue databaseUpdateQueue;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private ArchivaConfiguration archivaConfiguration;
|
||||
|
||||
private static final String DATABASE_SCAN_GROUP = "dbg";
|
||||
|
||||
private static final String DATABASE_JOB = "dbj";
|
||||
|
||||
private static final String DATABASE_JOB_TRIGGER = "dbt";
|
||||
|
||||
static final String TASK_QUEUE = "TASK_QUEUE";
|
||||
|
||||
public static final String CRON_HOURLY = "0 0 * * * ?";
|
||||
|
||||
public void startup()
|
||||
throws ArchivaException
|
||||
{
|
||||
archivaConfiguration.addListener( this );
|
||||
|
||||
try
|
||||
{
|
||||
start();
|
||||
}
|
||||
catch ( StartingException e )
|
||||
{
|
||||
throw new ArchivaException( e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public void start()
|
||||
throws StartingException
|
||||
{
|
||||
try
|
||||
{
|
||||
scheduleDatabaseJobs();
|
||||
}
|
||||
catch ( SchedulerException e )
|
||||
{
|
||||
throw new StartingException( "Unable to start scheduler: " + e.getMessage(), e );
|
||||
}
|
||||
}
|
||||
|
||||
public void stop()
|
||||
throws StoppingException
|
||||
{
|
||||
try
|
||||
{
|
||||
scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP );
|
||||
}
|
||||
catch ( SchedulerException e )
|
||||
{
|
||||
throw new StoppingException( "Unable to unschedule tasks", e );
|
||||
}
|
||||
}
|
||||
|
||||
public void scheduleDatabaseTasks()
|
||||
throws TaskExecutionException
|
||||
{
|
||||
try
|
||||
{
|
||||
scheduleDatabaseJobs();
|
||||
}
|
||||
catch ( SchedulerException e )
|
||||
{
|
||||
throw new TaskExecutionException( "Unable to schedule repository jobs: " + e.getMessage(), e );
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public boolean isProcessingDatabaseTask()
|
||||
{
|
||||
List<? extends Task> queue = null;
|
||||
|
||||
try
|
||||
{
|
||||
queue = databaseUpdateQueue.getQueueSnapshot();
|
||||
}
|
||||
catch ( TaskQueueException e )
|
||||
{
|
||||
// not possible with plexus-taskqueue implementation, ignore
|
||||
}
|
||||
|
||||
return !queue.isEmpty();
|
||||
}
|
||||
|
||||
public void queueTask( DatabaseTask task )
|
||||
throws TaskQueueException
|
||||
{
|
||||
databaseUpdateQueue.put( task );
|
||||
}
|
||||
|
||||
public void configurationEvent( ConfigurationEvent event )
|
||||
{
|
||||
if ( event.getType() == ConfigurationEvent.SAVED )
|
||||
{
|
||||
try
|
||||
{
|
||||
scheduler.unscheduleJob( DATABASE_JOB, DATABASE_SCAN_GROUP );
|
||||
|
||||
scheduleDatabaseJobs();
|
||||
}
|
||||
catch ( SchedulerException e )
|
||||
{
|
||||
log.error( "Error restarting the database scanning job after property change." );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private synchronized void scheduleDatabaseJobs()
|
||||
throws SchedulerException
|
||||
{
|
||||
String cronString = archivaConfiguration.getConfiguration().getDatabaseScanning().getCronExpression();
|
||||
|
||||
// setup the unprocessed artifact job
|
||||
JobDetail databaseJob = new JobDetail( DATABASE_JOB, DATABASE_SCAN_GROUP, DatabaseTaskJob.class );
|
||||
|
||||
JobDataMap dataMap = new JobDataMap();
|
||||
dataMap.put( TASK_QUEUE, databaseUpdateQueue );
|
||||
databaseJob.setJobDataMap( dataMap );
|
||||
|
||||
CronExpressionValidator cronValidator = new CronExpressionValidator();
|
||||
if ( !cronValidator.validate( cronString ) )
|
||||
{
|
||||
log.warn(
|
||||
"Cron expression [" + cronString + "] for database update is invalid. Defaulting to hourly." );
|
||||
cronString = CRON_HOURLY;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
CronTrigger trigger = new CronTrigger( DATABASE_JOB_TRIGGER, DATABASE_SCAN_GROUP, cronString );
|
||||
|
||||
scheduler.scheduleJob( databaseJob, trigger );
|
||||
}
|
||||
catch ( ParseException e )
|
||||
{
|
||||
log.error(
|
||||
"ParseException in database scanning cron expression, disabling database scanning: " + e.getMessage() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
package org.apache.archiva.scheduler.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.codehaus.plexus.taskqueue.Task;
|
||||
|
||||
/**
|
||||
* DataRefreshTask - task for discovering changes in the repository
|
||||
* and updating all associated data.
|
||||
*
|
||||
* @version $Id: DataRefreshTask.java 525176 2007-04-03 15:21:33Z joakime $
|
||||
*/
|
||||
public class DatabaseTask
|
||||
implements Task
|
||||
{
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
return "DatabaseTask";
|
||||
}
|
||||
|
||||
public long getMaxExecutionTime()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
package org.apache.archiva.scheduler.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.codehaus.plexus.scheduler.AbstractJob;
|
||||
import org.codehaus.plexus.taskqueue.Task;
|
||||
import org.codehaus.plexus.taskqueue.TaskQueue;
|
||||
import org.codehaus.plexus.taskqueue.TaskQueueException;
|
||||
import org.quartz.JobDataMap;
|
||||
import org.quartz.JobExecutionContext;
|
||||
import org.quartz.JobExecutionException;
|
||||
|
||||
/**
|
||||
* This class is the database job that is executed by the scheduler.
|
||||
*/
|
||||
public class DatabaseTaskJob
|
||||
extends AbstractJob
|
||||
{
|
||||
/**
|
||||
* Execute the discoverer and the indexer.
|
||||
*
|
||||
* @param context
|
||||
* @throws org.quartz.JobExecutionException
|
||||
*
|
||||
*/
|
||||
public void execute( JobExecutionContext context )
|
||||
throws JobExecutionException
|
||||
{
|
||||
JobDataMap dataMap = context.getJobDetail().getJobDataMap();
|
||||
setJobDataMap( dataMap );
|
||||
|
||||
TaskQueue taskQueue = (TaskQueue) dataMap.get( DatabaseArchivaTaskScheduler.TASK_QUEUE );
|
||||
|
||||
Task task = new DatabaseTask();
|
||||
|
||||
try
|
||||
{
|
||||
// The database job only needs to run one at a time
|
||||
if ( taskQueue.getQueueSnapshot().isEmpty() )
|
||||
{
|
||||
taskQueue.put( task );
|
||||
}
|
||||
}
|
||||
catch ( TaskQueueException e )
|
||||
{
|
||||
throw new JobExecutionException( e );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0" ?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<!--
|
||||
|
|
||||
| Database Update Task Queue / Executor
|
||||
|
|
||||
-->
|
||||
<component>
|
||||
<role>org.codehaus.plexus.taskqueue.TaskQueue</role>
|
||||
<role-hint>database-update</role-hint>
|
||||
<implementation>org.codehaus.plexus.taskqueue.DefaultTaskQueue</implementation>
|
||||
<lifecycle-handler>plexus-configurable</lifecycle-handler>
|
||||
<configuration>
|
||||
<task-entry-evaluators>
|
||||
</task-entry-evaluators>
|
||||
<task-exit-evaluators>
|
||||
</task-exit-evaluators>
|
||||
<task-viability-evaluators>
|
||||
</task-viability-evaluators>
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
<component>
|
||||
<role>org.codehaus.plexus.taskqueue.execution.TaskQueueExecutor</role>
|
||||
<role-hint>database-update</role-hint>
|
||||
<implementation>org.codehaus.plexus.taskqueue.execution.ThreadedTaskQueueExecutor</implementation>
|
||||
<instantiation-strategy>singleton</instantiation-strategy>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
|
||||
<role-hint>database-update</role-hint>
|
||||
</requirement>
|
||||
<requirement>
|
||||
<role>org.codehaus.plexus.taskqueue.TaskQueue</role>
|
||||
<role-hint>database-update</role-hint>
|
||||
</requirement>
|
||||
</requirements>
|
||||
<configuration>
|
||||
<name>database-update</name>
|
||||
</configuration>
|
||||
</component>
|
||||
</components>
|
||||
</component-set>
|
|
@ -1,190 +0,0 @@
|
|||
package org.apache.archiva.scheduler.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 java.io.File;
|
||||
import java.net.URL;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import javax.jdo.PersistenceManager;
|
||||
import javax.jdo.PersistenceManagerFactory;
|
||||
|
||||
import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
||||
import org.apache.maven.archiva.database.ArchivaDAO;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.database.constraints.ArtifactsProcessedConstraint;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory;
|
||||
import org.codehaus.plexus.jdo.JdoFactory;
|
||||
import org.codehaus.plexus.spring.PlexusInSpringTestCase;
|
||||
import org.codehaus.plexus.taskqueue.execution.TaskExecutor;
|
||||
import org.jpox.SchemaTool;
|
||||
|
||||
/**
|
||||
* ArchivaDatabaseUpdateTaskExecutorTest
|
||||
*
|
||||
* @version $Id:$
|
||||
*/
|
||||
public class ArchivaDatabaseUpdateTaskExecutorTest
|
||||
extends PlexusInSpringTestCase
|
||||
{
|
||||
private TaskExecutor taskExecutor;
|
||||
|
||||
protected ArchivaDAO dao;
|
||||
|
||||
protected void setUp()
|
||||
throws Exception
|
||||
{
|
||||
super.setUp();
|
||||
|
||||
DefaultConfigurableJdoFactory jdoFactory = (DefaultConfigurableJdoFactory) lookup( JdoFactory.ROLE, "archiva" );
|
||||
assertEquals( DefaultConfigurableJdoFactory.class.getName(), jdoFactory.getClass().getName() );
|
||||
|
||||
jdoFactory.setPersistenceManagerFactoryClass( "org.jpox.PersistenceManagerFactoryImpl" );
|
||||
|
||||
/* derby version
|
||||
File derbyDbDir = new File( "target/plexus-home/testdb" );
|
||||
if ( derbyDbDir.exists() )
|
||||
{
|
||||
FileUtils.deleteDirectory( derbyDbDir );
|
||||
}
|
||||
|
||||
jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.apache.derby.jdbc.EmbeddedDriver" ) );
|
||||
jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:derby:" + derbyDbDir.getAbsolutePath() + ";create=true" ) );
|
||||
*/
|
||||
|
||||
jdoFactory.setDriverName( System.getProperty( "jdo.test.driver", "org.hsqldb.jdbcDriver" ) );
|
||||
jdoFactory.setUrl( System.getProperty( "jdo.test.url", "jdbc:hsqldb:mem:" + getName() ) );
|
||||
|
||||
jdoFactory.setUserName( System.getProperty( "jdo.test.user", "sa" ) );
|
||||
|
||||
jdoFactory.setPassword( System.getProperty( "jdo.test.pass", "" ) );
|
||||
|
||||
jdoFactory.setProperty( "org.jpox.transactionIsolation", "READ_COMMITTED" );
|
||||
|
||||
jdoFactory.setProperty( "org.jpox.poid.transactionIsolation", "READ_COMMITTED" );
|
||||
|
||||
jdoFactory.setProperty( "org.jpox.autoCreateSchema", "true" );
|
||||
|
||||
jdoFactory.setProperty( "javax.jdo.option.RetainValues", "true" );
|
||||
|
||||
jdoFactory.setProperty( "javax.jdo.option.RestoreValues", "true" );
|
||||
|
||||
// jdoFactory.setProperty( "org.jpox.autoCreateColumns", "true" );
|
||||
|
||||
jdoFactory.setProperty( "org.jpox.validateTables", "true" );
|
||||
|
||||
jdoFactory.setProperty( "org.jpox.validateColumns", "true" );
|
||||
|
||||
jdoFactory.setProperty( "org.jpox.validateConstraints", "true" );
|
||||
|
||||
Properties properties = jdoFactory.getProperties();
|
||||
|
||||
for ( Map.Entry<Object, Object> entry : properties.entrySet() )
|
||||
{
|
||||
System.setProperty( (String) entry.getKey(), (String) entry.getValue() );
|
||||
}
|
||||
|
||||
URL jdoFileUrls[] = new URL[] { getClass().getResource( "/org/apache/maven/archiva/model/package.jdo" ) };
|
||||
|
||||
if ( ( jdoFileUrls == null ) || ( jdoFileUrls[0] == null ) )
|
||||
{
|
||||
fail( "Unable to process test " + getName() + " - missing package.jdo." );
|
||||
}
|
||||
|
||||
File propsFile = null; // intentional
|
||||
boolean verbose = true;
|
||||
|
||||
SchemaTool.deleteSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose );
|
||||
SchemaTool.createSchemaTables( jdoFileUrls, new URL[] {}, propsFile, verbose, null );
|
||||
|
||||
PersistenceManagerFactory pmf = jdoFactory.getPersistenceManagerFactory();
|
||||
|
||||
assertNotNull( pmf );
|
||||
|
||||
PersistenceManager pm = pmf.getPersistenceManager();
|
||||
|
||||
pm.close();
|
||||
|
||||
this.dao = (ArchivaDAO) lookup( ArchivaDAO.class.getName(), "jdo" );
|
||||
|
||||
taskExecutor = (TaskExecutor) lookup( TaskExecutor.class, "test-database-update" );
|
||||
}
|
||||
|
||||
public void testExecutor()
|
||||
throws Exception
|
||||
{
|
||||
File repoDir = new File( getBasedir(), "src/test/repositories/default-repository" );
|
||||
|
||||
assertTrue( "Default Test Repository should exist.", repoDir.exists() && repoDir.isDirectory() );
|
||||
|
||||
ManagedRepositoryConfiguration repo = createRepository( "testRepo", "Test Repository", repoDir );
|
||||
assertNotNull( repo );
|
||||
|
||||
ArtifactDAO adao = dao.getArtifactDAO();
|
||||
|
||||
ArchivaArtifact sqlArtifact = adao.createArtifact( "javax.sql", "jdbc", "2.0", "", "jar", repo.getId() );
|
||||
sqlArtifact.getModel().setLastModified( new Date() );
|
||||
sqlArtifact.getModel().setSize( 1234 );
|
||||
sqlArtifact.getModel().setOrigin( "testcase" );
|
||||
sqlArtifact.getModel().setWhenProcessed( null );
|
||||
|
||||
adao.saveArtifact( sqlArtifact );
|
||||
|
||||
ArchivaArtifact artifact = adao.getArtifact( "javax.sql", "jdbc", "2.0", null, "jar", repo.getId() );
|
||||
|
||||
assertNotNull( artifact );
|
||||
|
||||
// Test for artifact existance.
|
||||
List<ArchivaArtifact> artifactList = adao.queryArtifacts( null );
|
||||
assertNotNull( "Artifact list should not be null.", artifactList );
|
||||
assertEquals( "Artifact list size", 1, artifactList.size() );
|
||||
|
||||
// Test for unprocessed artifacts.
|
||||
List<ArchivaArtifact> unprocessedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( false ) );
|
||||
assertNotNull( "Unprocessed Results should not be null.", unprocessedResultList );
|
||||
assertEquals( "Incorrect number of unprocessed artifacts detected.", 1, unprocessedResultList.size() );
|
||||
|
||||
// Execute the database task.
|
||||
DatabaseTask dataTask = new DatabaseTask();
|
||||
taskExecutor.executeTask( dataTask );
|
||||
|
||||
// Test for artifact existance.
|
||||
artifactList = adao.queryArtifacts( null );
|
||||
assertNotNull( "Artifact list should not be null.", artifactList );
|
||||
assertEquals( "Artifact list size", 1, artifactList.size() );
|
||||
|
||||
// Test for processed artifacts.
|
||||
List<ArchivaArtifact> processedResultList = adao.queryArtifacts( new ArtifactsProcessedConstraint( true ) );
|
||||
assertNotNull( "Processed Results should not be null.", processedResultList );
|
||||
assertEquals( "Incorrect number of processed artifacts detected.", 1, processedResultList.size() );
|
||||
}
|
||||
|
||||
protected ManagedRepositoryConfiguration createRepository( String id, String name, File location )
|
||||
{
|
||||
ManagedRepositoryConfiguration repo = new ManagedRepositoryConfiguration();
|
||||
repo.setId( id );
|
||||
repo.setName( name );
|
||||
repo.setLocation( location.getAbsolutePath() );
|
||||
return repo;
|
||||
}
|
||||
}
|
|
@ -1,110 +0,0 @@
|
|||
package org.apache.archiva.scheduler.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 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.database.updater.DatabaseUnprocessedArtifactConsumer;
|
||||
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;
|
||||
}
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<!-- This metdata is intentionally wrong. -->
|
||||
<metadata>
|
||||
<groupId>javax.sql</groupId>
|
||||
<artifactId>jdbc</artifactId>
|
||||
<version>2.0</version>
|
||||
</metadata>
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<metadata>
|
||||
<groupId>javax.sql</groupId>
|
||||
<artifactId>jdbc</artifactId>
|
||||
<version>2.0</version>
|
||||
</metadata>
|
|
@ -1,30 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<metadata>
|
||||
<groupId>javax.sql</groupId>
|
||||
<artifactId>jdbc</artifactId>
|
||||
<version>2.0</version>
|
||||
<versioning>
|
||||
<versions>
|
||||
<version>2.0</version>
|
||||
</versions>
|
||||
</versioning>
|
||||
</metadata>
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<metadata>
|
||||
<groupId>javax.sql</groupId>
|
||||
<artifactId>jdbc</artifactId>
|
||||
<version>2.0</version>
|
||||
</metadata>
|
|
@ -1,28 +0,0 @@
|
|||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>A</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>Maven Test Repository Artifact Discovery</name>
|
||||
<packaging>war</packaging>
|
||||
</project>
|
|
@ -1,28 +0,0 @@
|
|||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>B</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>Maven Test Repository Artifact Discovery</name>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
|
@ -1,28 +0,0 @@
|
|||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>B</artifactId>
|
||||
<version>2.0</version>
|
||||
<name>Maven Test Repository Artifact Discovery</name>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
|
@ -1,28 +0,0 @@
|
|||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
<artifactId>C</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>Maven Test Repository Artifact Discovery</name>
|
||||
<packaging>war</packaging>
|
||||
</project>
|
|
@ -1,23 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<metadata>
|
||||
<groupId>org.apache.maven</groupId>
|
||||
</metadata>
|
|
@ -1,28 +0,0 @@
|
|||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.apache.testgroup</groupId>
|
||||
<artifactId>discovery</artifactId>
|
||||
<version>1.0</version>
|
||||
<name>Maven Test Repository Artifact Discovery</name>
|
||||
<packaging>pom</packaging>
|
||||
</project>
|
|
@ -1,25 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<metadata>
|
||||
<groupId>org.apache.testgroup</groupId>
|
||||
<artifactId>discovery</artifactId>
|
||||
<version>1.0</version>
|
||||
</metadata>
|
|
@ -1,24 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<metadata>
|
||||
<groupId>org.apache.testgroup</groupId>
|
||||
<artifactId>discovery</artifactId>
|
||||
</metadata>
|
|
@ -1,119 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<configuration>
|
||||
<managedRepositories>
|
||||
<managedRepository>
|
||||
<id>testRepo</id>
|
||||
<name>Archiva Test Repository</name>
|
||||
<location>${basedir}/src/test/repositories/default-repository</location>
|
||||
<layout>default</layout>
|
||||
<releases>true</releases>
|
||||
<snapshots>false</snapshots>
|
||||
<indexed>true</indexed>
|
||||
<refreshCronExpression>0 0 * * * ?</refreshCronExpression>
|
||||
</managedRepository>
|
||||
</managedRepositories>
|
||||
|
||||
<proxyConnectors />
|
||||
|
||||
<networkProxies />
|
||||
|
||||
<repositoryScanning>
|
||||
<fileTypes>
|
||||
<fileType>
|
||||
<id>artifacts</id>
|
||||
<patterns>
|
||||
<pattern>**/*.pom</pattern>
|
||||
<pattern>**/*.jar</pattern>
|
||||
<pattern>**/*.ear</pattern>
|
||||
<pattern>**/*.war</pattern>
|
||||
<pattern>**/*.car</pattern>
|
||||
<pattern>**/*.sar</pattern>
|
||||
<pattern>**/*.mar</pattern>
|
||||
<pattern>**/*.rar</pattern>
|
||||
<pattern>**/*.dtd</pattern>
|
||||
<pattern>**/*.tld</pattern>
|
||||
<pattern>**/*.tar.gz</pattern>
|
||||
<pattern>**/*.tar.bz2</pattern>
|
||||
<pattern>**/*.zip</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
<fileType>
|
||||
<id>indexable-content</id>
|
||||
<patterns>
|
||||
<pattern>**/*.txt</pattern>
|
||||
<pattern>**/*.TXT</pattern>
|
||||
<pattern>**/*.block</pattern>
|
||||
<pattern>**/*.config</pattern>
|
||||
<pattern>**/*.pom</pattern>
|
||||
<pattern>**/*.xml</pattern>
|
||||
<pattern>**/*.xsd</pattern>
|
||||
<pattern>**/*.dtd</pattern>
|
||||
<pattern>**/*.tld</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
<fileType>
|
||||
<id>auto-remove</id>
|
||||
<patterns>
|
||||
<pattern>**/*.bak</pattern>
|
||||
<pattern>**/*~</pattern>
|
||||
<pattern>**/*-</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
<fileType>
|
||||
<id>ignored</id>
|
||||
<patterns>
|
||||
<pattern>**/.htaccess</pattern>
|
||||
<pattern>**/KEYS</pattern>
|
||||
<pattern>**/*.rb</pattern>
|
||||
<pattern>**/*.sh</pattern>
|
||||
<pattern>**/.svn/**</pattern>
|
||||
<pattern>**/.DAV/**</pattern>
|
||||
</patterns>
|
||||
</fileType>
|
||||
</fileTypes>
|
||||
<knownContentConsumers>
|
||||
<knownContentConsumer>update-db-artifact</knownContentConsumer>
|
||||
<knownContentConsumer>create-missing-checksums</knownContentConsumer>
|
||||
<knownContentConsumer>update-db-repository-metadata</knownContentConsumer>
|
||||
<knownContentConsumer>validate-checksum</knownContentConsumer>
|
||||
<knownContentConsumer>validate-signature</knownContentConsumer>
|
||||
<knownContentConsumer>index-content</knownContentConsumer>
|
||||
<knownContentConsumer>auto-remove</knownContentConsumer>
|
||||
<knownContentConsumer>auto-rename</knownContentConsumer>
|
||||
</knownContentConsumers>
|
||||
<invalidContentConsumers>
|
||||
<invalidContentConsumer>update-db-bad-content</invalidContentConsumer>
|
||||
</invalidContentConsumers>
|
||||
</repositoryScanning>
|
||||
|
||||
<databaseScanning>
|
||||
<cronExpression>0 0 * * * ?</cronExpression>
|
||||
<unprocessedConsumers>
|
||||
<unprocessedConsumer>test-db-unprocessed</unprocessedConsumer>
|
||||
<unprocessedConsumer>update-db-artifact</unprocessedConsumer>
|
||||
</unprocessedConsumers>
|
||||
<cleanupConsumers>
|
||||
<cleanupConsumer>test-db-cleanup</cleanupConsumer>
|
||||
</cleanupConsumers>
|
||||
</databaseScanning>
|
||||
|
||||
</configuration>
|
|
@ -1,92 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<component-set>
|
||||
<components>
|
||||
<component>
|
||||
<role>org.codehaus.plexus.taskqueue.execution.TaskExecutor</role>
|
||||
<role-hint>test-database-update</role-hint>
|
||||
<implementation>org.apache.archiva.scheduler.database.ArchivaDatabaseUpdateTaskExecutor</implementation>
|
||||
<description></description>
|
||||
<requirements>
|
||||
<requirement>
|
||||
<role>org.apache.maven.archiva.database.updater.DatabaseUpdater</role>
|
||||
<role-hint>jdo</role-hint>
|
||||
<field-name>databaseUpdater</field-name>
|
||||
</requirement>
|
||||
</requirements>
|
||||
</component>
|
||||
|
||||
<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>
|
||||
|
||||
<component>
|
||||
<role>org.apache.maven.archiva.database.updater.DatabaseUnprocessedArtifactConsumer</role>
|
||||
<role-hint>test-db-unprocessed</role-hint>
|
||||
<implementation>org.apache.archiva.scheduler.database.TestDatabaseUnprocessedConsumer</implementation>
|
||||
</component>
|
||||
|
||||
|
||||
<component>
|
||||
<role>org.codehaus.plexus.jdo.JdoFactory</role>
|
||||
<role-hint>archiva</role-hint>
|
||||
<implementation>org.codehaus.plexus.jdo.DefaultConfigurableJdoFactory</implementation>
|
||||
<configuration>
|
||||
<persistenceManagerFactoryClass>org.jpox.PersistenceManagerFactoryImpl</persistenceManagerFactoryClass>
|
||||
<otherProperties>
|
||||
<property>
|
||||
<name>javax.jdo.PersistenceManagerFactoryClass</name>
|
||||
<value>org.jpox.PersistenceManagerFactoryImpl</value>
|
||||
</property>
|
||||
</otherProperties>
|
||||
</configuration>
|
||||
</component>
|
||||
|
||||
</components>
|
||||
</component-set>
|
|
@ -31,7 +31,6 @@
|
|||
<modules>
|
||||
<module>archiva-scheduler-api</module>
|
||||
<module>archiva-scheduler-indexing</module>
|
||||
<module>archiva-scheduler-database</module>
|
||||
<module>archiva-scheduler-repository</module>
|
||||
</modules>
|
||||
</project>
|
|
@ -37,10 +37,6 @@
|
|||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-scheduler-repository</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-scheduler-database</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.archiva</groupId>
|
||||
<artifactId>archiva-indexer</artifactId>
|
||||
|
|
|
@ -40,7 +40,6 @@ import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
|
|||
import org.apache.maven.archiva.database.ArchivaDatabaseException;
|
||||
import org.apache.maven.archiva.database.ArtifactDAO;
|
||||
import org.apache.maven.archiva.database.constraints.ArtifactVersionsConstraint;
|
||||
import org.apache.maven.archiva.database.updater.DatabaseConsumers;
|
||||
import org.apache.maven.archiva.model.ArchivaArtifact;
|
||||
import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
|
||||
import org.apache.maven.archiva.model.VersionedReference;
|
||||
|
@ -115,11 +114,6 @@ public class DeleteArtifactAction
|
|||
*/
|
||||
private ArtifactDAO artifactDAO;
|
||||
|
||||
/**
|
||||
* @plexus.requirement
|
||||
*/
|
||||
private DatabaseConsumers databaseConsumers;
|
||||
|
||||
/** @plexus.requirement role="org.apache.maven.archiva.repository.events.RepositoryListener" */
|
||||
private List<RepositoryListener> listeners;
|
||||
|
||||
|
|
|
@ -19,8 +19,6 @@ package org.apache.maven.archiva.web.action.admin;
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import org.apache.archiva.scheduler.database.DatabaseArchivaTaskScheduler;
|
||||
import org.apache.archiva.scheduler.database.DatabaseTask;
|
||||
import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
|
||||
import org.apache.archiva.scheduler.repository.RepositoryTask;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
@ -46,11 +44,6 @@ public class SchedulerAction
|
|||
*/
|
||||
private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
|
||||
|
||||
/**
|
||||
* @plexus.requirement role="org.apache.archiva.scheduler.ArchivaTaskScheduler" role-hint="database"
|
||||
*/
|
||||
private DatabaseArchivaTaskScheduler databaseTaskScheduler;
|
||||
|
||||
private String repoid;
|
||||
|
||||
private boolean scanAll;
|
||||
|
@ -89,32 +82,6 @@ public class SchedulerAction
|
|||
return SUCCESS;
|
||||
}
|
||||
|
||||
public String updateDatabase()
|
||||
{
|
||||
log.info( "Queueing database task on request from user interface" );
|
||||
DatabaseTask task = new DatabaseTask();
|
||||
|
||||
if ( databaseTaskScheduler.isProcessingDatabaseTask() )
|
||||
{
|
||||
addActionError( "Database task was already queued." );
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
databaseTaskScheduler.queueTask( task );
|
||||
addActionMessage( "Your request to update the database has been queued." );
|
||||
}
|
||||
catch ( TaskQueueException e )
|
||||
{
|
||||
addActionError( "Unable to queue your request to update the database: " + e.getMessage() );
|
||||
}
|
||||
}
|
||||
|
||||
// Return to the database screen.
|
||||
return SUCCESS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addActionMessage( String aMessage )
|
||||
{
|
||||
|
|
|
@ -1,66 +0,0 @@
|
|||
package org.apache.maven.archiva.web.action.admin.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.commons.collections.Closure;
|
||||
import org.apache.maven.archiva.database.updater.ArchivaArtifactConsumer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* AddAdminDatabaseConsumerClosure
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AddAdminDatabaseConsumerClosure
|
||||
implements Closure
|
||||
{
|
||||
private List<AdminDatabaseConsumer> list = new ArrayList<AdminDatabaseConsumer>();
|
||||
|
||||
private List<String> selectedIds;
|
||||
|
||||
public AddAdminDatabaseConsumerClosure( List<String> selectedIds )
|
||||
{
|
||||
this.selectedIds = selectedIds;
|
||||
}
|
||||
|
||||
public void execute( Object input )
|
||||
{
|
||||
if ( input instanceof ArchivaArtifactConsumer )
|
||||
{
|
||||
ArchivaArtifactConsumer consumer = (ArchivaArtifactConsumer) input;
|
||||
|
||||
boolean enabled = this.selectedIds.contains( consumer.getId() );
|
||||
|
||||
AdminDatabaseConsumer adminconsumer = new AdminDatabaseConsumer();
|
||||
adminconsumer.setEnabled( enabled );
|
||||
adminconsumer.setId( consumer.getId() );
|
||||
adminconsumer.setDescription( consumer.getDescription() );
|
||||
|
||||
list.add( adminconsumer );
|
||||
}
|
||||
}
|
||||
|
||||
public List<AdminDatabaseConsumer> getList()
|
||||
{
|
||||
return list;
|
||||
}
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
package org.apache.maven.archiva.web.action.admin.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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* AdminDatabaseConsumer
|
||||
*
|
||||
* @version $Id$
|
||||
*/
|
||||
public class AdminDatabaseConsumer
|
||||
{
|
||||
private boolean enabled = false;
|
||||
|
||||
private String id;
|
||||
|
||||
private String description;
|
||||
|
||||
public String getDescription()
|
||||
{
|
||||
return description;
|
||||
}
|
||||
|
||||
public String getId()
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
||||
public boolean isEnabled()
|
||||
{
|
||||
return enabled;
|
||||
}
|
||||
|
||||
public void setDescription( String description )
|
||||
{
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
public void setEnabled( boolean enabled )
|
||||
{
|
||||
this.enabled = enabled;
|
||||
}
|
||||
|
||||
public void setId( String id )
|
||||
{
|
||||
this.id = id;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue